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
Review feedback
Oliver Günther11b6df76afbd
diff --git a/app/contracts/user_preferences/base_contract.rb b/app/contracts/user_preferences/base_contract.rbindex e5b0c6e4b6f..e9359249362 100644--- a/app/contracts/user_preferences/base_contract.rb+++ b/app/contracts/user_preferences/base_contract.rb@@ -48,7 +48,7 @@ module UserPreferencesvalidate :full_hour_reminder_time,if: -> { model.daily_reminders.present? }- validate :workdays_are_iso,+ validate :no_duplicate_workdays,if: -> { model.workdays.present? }protected@@ -72,11 +72,7 @@ module UserPreferencesendend- def workdays_are_iso- unless model.workdays.all? { |workday| workday.is_a?(Integer) && (1..7).include?(workday) }- errors.add :workdays, :iso_workday- end-+ def no_duplicate_workdaysunless model.workdays.uniq.length == model.workdays.lengtherrors.add :workdays, :no_duplicatesenddiff --git a/app/models/users/scopes/having_reminder_mail_to_send.rb b/app/models/users/scopes/having_reminder_mail_to_send.rbindex 83f04719130..ab1870d7f38 100644--- a/app/models/users/scopes/having_reminder_mail_to_send.rb+++ b/app/models/users/scopes/having_reminder_mail_to_send.rb@@ -112,7 +112,7 @@ module Users::Scopes# Get the iso weekday of the current time to check# which users have it enabled as a workday- workday = Time.now.in_time_zone(z).to_date.cwday+ workday = local_time.to_date.cwday# Since only full hours can be configured, we can disregard any local time that is not# a full hour.diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 50011883b2a..0c4680fb838 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -762,9 +762,6 @@ en:day_limit: "is too high as a maximum of 24 hours can be logged per date."user_preference:attributes:- workdays:- iso_workday: "can only contain numbers between 1-7."- no_duplicates: "must not contain any duplicates."daily_reminders:full_hour: "can only be configured to be delivered at a full hour."wiki_page:diff --git a/config/schemas/user_preferences.schema.json b/config/schemas/user_preferences.schema.jsonindex 1f82f2452ee..b6ed2d8f503 100644--- a/config/schemas/user_preferences.schema.json+++ b/config/schemas/user_preferences.schema.json@@ -23,7 +23,12 @@"type": "boolean"},"workdays": {- "type": "array"+ "type": "array",+ "items": {+ "type": "integer",+ "minimum": 1,+ "maximum": 7+ }},"daily_reminders": {"$ref": "#/definitions/DailyReminders"diff --git a/spec/contracts/user_preferences/update_contract_spec.rb b/spec/contracts/user_preferences/update_contract_spec.rbindex 91bc375bad1..d79b14a5447 100644--- a/spec/contracts/user_preferences/update_contract_spec.rb+++ b/spec/contracts/user_preferences/update_contract_spec.rb@@ -238,6 +238,16 @@ describe UserPreferences::UpdateContract doenddescribe 'workdays' do+ context 'with valid entries' do+ let(:settings) do+ {+ workdays: [1, 2, 4, 6]+ }+ end++ it_behaves_like 'contract is valid'+ end+context 'with duplicate entries' dolet(:settings) do{@@ -255,7 +265,8 @@ describe UserPreferences::UpdateContract do}end- it_behaves_like 'contract is invalid', workdays: :iso_workday+ it_behaves_like 'contract is invalid', workdays: %i[invalid type_mismatch_nested+ type_mismatch_nested type_mismatch_nested]endendenddiff --git a/spec/features/notifications/settings/reminder_email_settings_spec.rb b/spec/features/notifications/settings/reminder_email_settings_spec.rbindex c11b3a5fe25..50335ed89ac 100644--- a/spec/features/notifications/settings/reminder_email_settings_spec.rb+++ b/spec/features/notifications/settings/reminder_email_settings_spec.rb@@ -62,96 +62,4 @@ describe "Reminder email", type: :feature, js: true doit_behaves_like 'reminder settings'end-- describe 'sending' do- let!(:project) { FactoryBot.create :project, members: { current_user => role } }- let!(:mute_project) { FactoryBot.create :project, members: { current_user => role } }- let(:role) { FactoryBot.create(:role, permissions: %i[view_work_packages]) }- let(:other_user) { FactoryBot.create(:user) }- let(:work_package) { FactoryBot.create(:work_package, project: project) }- let(:watched_work_package) { FactoryBot.create(:work_package, project: project, watcher_users: [current_user]) }- let(:involved_work_package) { FactoryBot.create(:work_package, project: project, assigned_to: current_user) }- # The run_at time of the delayed job used for scheduling the reminder mails- # needs to be within a time frame eligible for sending out mails for the chose- # time zone. For the time zone Hawaii (UTC-10) this means between 8:00:00 and 8:14:59 UTC.- # The job is scheduled to run every 15 min so the run_at will in production always move between the quarters of an hour.- # The current time can be way behind that.- let(:current_utc_time) { ActiveSupport::TimeZone['Hawaii'].parse("08:34:10").utc }- let(:job_run_at) { ActiveSupport::TimeZone['Hawaii'].parse("08:00").utc }-- current_user do- FactoryBot.create(- :user,- preferences: {- time_zone: "Hawaii",- daily_reminders: {- enabled: true,- times: [hitting_reminder_slot_for("Hawaii", current_utc_time)]- }- },- notification_settings: [- FactoryBot.build(:mail_digest_notification_setting,- involved: true,- watched: true,- mentioned: true,- work_package_commented: true,- work_package_created: true,- work_package_processed: true,- work_package_prioritized: true,- work_package_scheduled: true,- all: false)- ]- )- end-- before do- allow(Time).to receive(:current).and_return(current_utc_time)- allow(Time).to receive(:now).and_return(current_utc_time)-- watched_work_package- work_package- involved_work_package-- ActiveJob::Base.queue_adapter.enqueued_jobs.clear-- # There is no delayed_job associated when using the testing backend of ActiveJob- # so we have to mock it.- allow(Notifications::ScheduleReminderMailsJob)- .to receive(:delayed_job)- .and_return(instance_double(Delayed::Backend::ActiveRecord::Job, run_at: job_run_at))- end-- it 'sends a digest mail based on the configuration', with_settings: { journal_aggregation_time_minutes: 0 } do- # Perform some actions the user listens to- User.execute_as other_user do- note = <<~NOTE- Hey <mention class=\"mention\"- data-id=\"#{current_user.id}\"- data-type=\"user\"- data-text=\"@#{current_user.name}\">- @#{current_user.name}- </mention>- NOTE-- work_package.add_journal(other_user, note)- work_package.save!-- watched_work_package.subject = 'New watched work package subject'- watched_work_package.save!-- involved_work_package.description = 'New involved work package description'- involved_work_package.save!- end-- # The Job is triggered by time so we mock it and the jobs started by it being triggered- Notifications::ScheduleReminderMailsJob.perform_later- 2.times { perform_enqueued_jobs }-- expect(ActionMailer::Base.deliveries.length)- .to be 1-- expect(ActionMailer::Base.deliveries.first.subject)- .to eql "OpenProject - 1 unread notification including a mention"- end- endend