diff --git a/spec/controllers/work_packages/creation_spec.rb b/spec/controllers/work_packages/creation_spec.rb index 3f34563c65..a19048cec7 100644 --- a/spec/controllers/work_packages/creation_spec.rb +++ b/spec/controllers/work_packages/creation_spec.rb @@ -36,6 +36,8 @@ describe WorkPackagesController, type: :controller do before do allow(User).to receive(:current).and_return user expect(controller).to receive(:authorize).and_return(true) + expect(Setting).to receive(:notified_events).and_return ['work_package_added', + 'work_package_updated'] end around(:each) do |example| @@ -73,9 +75,7 @@ describe WorkPackagesController, type: :controller do # Find the enqueued job responsible for sending the notification # for the creation of the work package. Delayed::Job.all.map(&:payload_object).detect do |job| - if job.is_a? EnqueueWorkPackageNotificationJob - job.send(:work_package) == work_package - end + job.is_a?(EnqueueWorkPackageNotificationJob) && job.send(:work_package) == work_package end end diff --git a/spec/legacy/functional/messages_controller_spec.rb b/spec/legacy/functional/messages_controller_spec.rb index c96f31205e..695ebc234f 100644 --- a/spec/legacy/functional/messages_controller_spec.rb +++ b/spec/legacy/functional/messages_controller_spec.rb @@ -89,7 +89,7 @@ describe MessagesController, type: :controller do it 'should post create' do session[:user_id] = 2 ActionMailer::Base.deliveries.clear - Setting.notified_events = ['message_posted'] + allow(Setting).to receive(:notified_events).and_return ['message_posted'] post :create, board_id: 1, message: { subject: 'Test created message', diff --git a/spec/models/mail_handler_spec.rb b/spec/models/mail_handler_spec.rb index b791a0ab35..814463d1cd 100644 --- a/spec/models/mail_handler_spec.rb +++ b/spec/models/mail_handler_spec.rb @@ -67,7 +67,7 @@ describe MailHandler, type: :model do before do ActionMailer::Base.deliveries.clear - Setting.notified_events = Redmine::Notifiable.all.map(&:name) + allow(Setting).to receive(:notified_events).and_return(Redmine::Notifiable.all.map(&:name)) # we need both of these run first so the anonymous user is created and # there is a default work package priority to save any work packages priority_low diff --git a/spec/models/setting_spec.rb b/spec/models/setting_spec.rb index 5a660dc68c..df41ab1423 100644 --- a/spec/models/setting_spec.rb +++ b/spec/models/setting_spec.rb @@ -100,6 +100,9 @@ describe Setting, type: :model do after do Setting.find_by_name('notified_events').destroy + # have to clear the cache as well + # as settings are stored there + Rails.cache.clear end end @@ -166,6 +169,9 @@ describe Setting, type: :model do after do Setting.destroy_all + # have to clear the cache as well + # as settings are stored there + Rails.cache.clear end end