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
test correct reloading of mailer config in jobs
Markus Kahl72e755d87f06
diff --git a/spec/workers/application_job_spec.rb b/spec/workers/application_job_spec.rbindex 8e28ab5a2d9..20b990257ee 100644--- a/spec/workers/application_job_spec.rb+++ b/spec/workers/application_job_spec.rb@@ -55,4 +55,36 @@ describe ApplicationJob doexpect(RequestStore[:test_value]).to eq 'my value2'endend++ describe 'email configuration' do #, with_settings: { email_delivery_method: :smtp } do+ # the email delivery method has to be smtp for the settings to be reloaded++ let(:ports) { [] }++ before do+ allow_any_instance_of(Principals::DeleteJob).to receive(:perform) do+ ports << ActionMailer::Base.smtp_settings[:port]+ end+ end++ it "is reloaded for each job" do+ Setting.email_delivery_method = :smtp++ Principals::DeleteJob.perform_now nil++ expect(ports).not_to be_empty+ expect(ports.last).not_to be 42++ # We have to change the time here for Setting.settings_updated_at to actually be different from before+ # since this is of course all running within the same second.+ Timecop.travel(1.second.from_now) do+ # While we're in the worker here, this simulates another process changing the setting.+ Setting.create!(name: "smtp_port", value: 42)++ Principals::DeleteJob.perform_now nil++ expect(ports.last).to eq 42+ end+ end+ endend