OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
ensure all enqueued jobs are run
ulferts5e33c4b637f9
diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rbindex 6c3e262fe05..b831170a55e 100644--- a/spec/controllers/users_controller_spec.rb+++ b/spec/controllers/users_controller_spec.rb@@ -188,7 +188,9 @@ describe UsersController, type: :controller doexpect(ActionMailer::Base.deliveries).to be_emptyas_logged_in_user admin do- post :resend_invitation, params: { id: invited_user.id }+ perform_enqueued_jobs do+ post :resend_invitation, params: { id: invited_user.id }+ endendend@@ -197,7 +199,6 @@ describe UsersController, type: :controller doendit 'sends another activation email' do- perform_enqueued_jobsmail = ActionMailer::Base.deliveries.first.body.parts.first.body.to_stoken = Token::Invitation.find_by user_id: invited_user.iddiff --git a/spec/features/users/create_spec.rb b/spec/features/users/create_spec.rbindex 846ba5e3218..dbd610ee6b3 100644--- a/spec/features/users/create_spec.rb+++ b/spec/features/users/create_spec.rb@@ -35,12 +35,11 @@ describe 'create users', type: :feature, selenium: true dolet(:new_user_page) { Pages::NewUser.new }before do- allow(User).to receive(:current).and_return current_user+ login_as current_userendshared_examples_for 'successful user creation' dolet(:mail) do- perform_enqueued_jobsActionMailer::Base.deliveries.lastendlet(:mail_body) { mail.body.parts.first.body.to_s }@@ -68,7 +67,9 @@ describe 'create users', type: :feature, selenium: true dolast_name: 'boblast',email: '[email protected]'- new_user_page.submit!+ perform_enqueued_jobs do+ new_user_page.submit!+ endendit_behaves_like 'successful user creation' do@@ -109,7 +110,9 @@ describe 'create users', type: :feature, selenium: true doauth_source: auth_source.name- new_user_page.submit!+ perform_enqueued_jobs do+ new_user_page.submit!+ endendafter dodiff --git a/spec/models/mail_handler_spec.rb b/spec/models/mail_handler_spec.rbindex 3c1b63d1f5c..937750c7147 100644--- a/spec/models/mail_handler_spec.rb+++ b/spec/models/mail_handler_spec.rb@@ -231,10 +231,11 @@ describe MailHandler, type: :model doendit 'sends a mail as a work package has been created' do- subject+ perform_enqueued_jobs do+ subject+ end# Email notification should be sent- perform_enqueued_jobsmail = ActionMailer::Base.deliveries.lastexpect(mail)diff --git a/spec/models/wiki_content_spec.rb b/spec/models/wiki_content_spec.rbindex 8eb06959cba..d1a1e72e21a 100644--- a/spec/models/wiki_content_spec.rb+++ b/spec/models/wiki_content_spec.rb@@ -71,8 +71,9 @@ describe WikiContent, type: :model doproject_watcherexpect {- content.save!- perform_enqueued_jobs+ perform_enqueued_jobs do+ content.save!+ end}.to change { ActionMailer::Base.deliveries.size }.by(2)@@ -86,14 +87,12 @@ describe WikiContent, type: :model dowiki_watcherproject_watcher- content- perform_enqueued_jobs-content.text = 'My new content'expect {- content.save!- perform_enqueued_jobs+ perform_enqueued_jobs do+ content.save!+ end}.to change { ActionMailer::Base.deliveries.size }.by(3)diff --git a/spec/models/work_package/work_package_action_mailer_spec.rb b/spec/models/work_package/work_package_action_mailer_spec.rbindex b909405d6cb..af6fd0853f1 100644--- a/spec/models/work_package/work_package_action_mailer_spec.rb+++ b/spec/models/work_package/work_package_action_mailer_spec.rb@@ -48,14 +48,15 @@ describe WorkPackage, type: :model doallow(work_package).to receive(:watcher_recipients).and_return([user_2])Journal::NotificationConfiguration.with true do- work_package.save+ perform_enqueued_jobs do+ work_package.save+ endendendsubject { ActionMailer::Base.deliveries.size }it do- perform_enqueued_jobsexpect(subject).to eq 2enddiff --git a/spec/models/work_package/work_package_notifications_spec.rb b/spec/models/work_package/work_package_notifications_spec.rbindex 919955393fb..082e74a8013 100644--- a/spec/models/work_package/work_package_notifications_spec.rb+++ b/spec/models/work_package/work_package_notifications_spec.rb@@ -37,7 +37,7 @@ describe WorkPackage, type: :model dolet(:user) { admin }let(:current_user) { FactoryBot.create :admin }let(:project) { FactoryBot.create :project }- let!(:work_package) do+ let(:work_package) doFactoryBot.create :work_package,author: user,subject: 'I can see you',@@ -46,7 +46,10 @@ describe WorkPackage, type: :model docontext 'after creation' doit "are sent to the work package's author" do- perform_enqueued_jobs+ perform_enqueued_jobs do+ work_package+ end+mail = ActionMailer::Base.deliveries.detect { |m| m.subject.include? 'I can see you' }expect(mail).to be_present@@ -65,6 +68,10 @@ describe WorkPackage, type: :model doendit "are not sent to the work package's author" do+ perform_enqueued_jobs do+ work_package+ end+mail = ActionMailer::Base.deliveries.detect { |m| m.subject.include? 'I can see you' }expect(mail).not_to be_present@@ -74,11 +81,12 @@ describe WorkPackage, type: :model dodescribe 'after update' dobefore do- work_package.update subject: 'the wind of change'+ perform_enqueued_jobs do+ work_package.update subject: 'the wind of change'+ endendit "are sent to the work package's author" do- perform_enqueued_jobsmail = ActionMailer::Base.deliveries.detect { |m| m.subject.include? 'the wind of change' }expect(mail).to be_presentdiff --git a/spec/rails_helper.rb b/spec/rails_helper.rbindex cdc56ee527a..8042f25f8f0 100644--- a/spec/rails_helper.rb+++ b/spec/rails_helper.rb@@ -73,6 +73,9 @@ RSpec.configure do |config|config.include JsonSpec::Helpers# Add job helper+ # Only the ActiveJob::TestHelper is actually used but it in turn requires+ # e.g. assert_nothing_raised+ config.include ::ActiveSupport::Testing::Assertionsconfig.include ::ActiveJob::TestHelperOpenProject::Configuration['attachments_storage_path'] = 'tmp/files'