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
Merge pull request #11341 from opf/implementation/43640-journalling-updates-for-work-packages-when-non-working-days-settings-change
ulfertsdfb93b5fc185
diff --cc spec/features/admin/working_days_spec.rbindex b4bf1afd454,82227304e81..a7b5c8bf124--- a/spec/features/admin/working_days_spec.rb+++ b/spec/features/admin/working_days_spec.rb@@@ -131,28 -147,11 +147,29 @@@ describe 'Working Days', type: :featureexpect(page).to have_unchecked_field 'Sunday'expect(working_days_setting).to eq([1, 2, 3, 4, 5])- expect(work_package.reload.start_date)- .to eql(Date.parse('2022-09-19'))-- expect(work_package.due_date)- .to eql(Date.parse('2022-09-23'))+ expect_schedule(WorkPackage.all, <<~CHART)+ days | MTWTFSSmtwtfss |+ earliest_work_package | XXXXX |+ second_work_package | XX..XX |+ follower | XXX |+ CHARTend++ it 'shows an error when a previous change to the working days configuration isn\'t processed yet' do+ # Have a job already scheduled+ # Attempting to set the job via simply using the UI would require to change the test setup of how+ # delayed jobs are handled.+ ActiveJob::QueueAdapters::DelayedJobAdapter+ .new+ .enqueue(WorkPackages::ApplyWorkingDaysChangeJob.new(user_id: 5, previous_working_days: []))++ uncheck 'Tuesday'+ click_on 'Save'++ # Not executing the background jobs+ dialog.confirm++ expect(page).to have_selector('.flash.error',+ text: 'The previous changes to the working days configuration have not been applied yet.')+ endenddiff --cc spec/workers/work_packages/apply_working_days_change_job_spec.rbindex 35eab0348f9,1cdfb54a391..6822e692f81--- a/spec/workers/work_packages/apply_working_days_change_job_spec.rb+++ b/spec/workers/work_packages/apply_working_days_change_job_spec.rb@@@ -376,27 -516,60 +516,82 @@@ RSpec.describe WorkPackages::ApplyWorkiwp3 | ░░]░░░ ░░ ░░░ ░░ ░░░ |CHARTend++ it_behaves_like 'journal updates with note' do+ let(:changed_work_packages) do+ [wp1, wp2, wp3]+ end+ let(:journal_notice) do+ "**Working days** changed (Tuesday is now non-working, Wednesday is now non-working, Friday is now non-working)."+ end+ end+ end++ context 'when having a non english default language', with_settings: { default_language: :fr } do+ let_schedule(<<~CHART)+ days | fssMTWTFSS |+ work_package | X▓▓XX ░░ |+ CHART++ before do+ set_working_week_days('saturday')+ end++ # Not interested in the scheduling changes in this spec+ it_behaves_like 'journal updates with note' do+ let(:changed_work_packages) do+ [work_package]+ end+ let(:journal_notice) do+ I18n.with_locale(:fr) do+ I18n.t(:'working_days.journal_note.changed',+ changes: I18n.t(:'working_days.journal_note.days.working',+ day: I18n.t('date.day_names')[6]))+ end+ end+ end+ end++ context 'when turning Sunday into a working day' do+ let_schedule(<<~CHART)+ days | MTWTFSSm |+ work_package | X▓▓X |+ CHART++ before do+ set_working_week_days('Sunday')+ end++ # Not interested in the scheduling changes in this spec+ it_behaves_like 'journal updates with note' do+ let(:changed_work_packages) do+ [work_package]+ end+ let(:journal_notice) do+ "**Working days** changed (Sunday is now working)."+ end+ endend++ describe '.scheduled?' do+ context 'with a job already scheduled in the DB' do+ before do+ ActiveJob::QueueAdapters::DelayedJobAdapter+ .new+ .enqueue(described_class.new(user_id: 5, previous_working_days: [1, 2]))+ end++ it 'is true' do+ expect(described_class)+ .to be_scheduled+ end+ end++ context 'without a job already scheduled in the DB' do+ it 'is false' do+ expect(described_class)+ .not_to be_scheduled+ end+ end+ endend