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 remote-tracking branch 'origin/dev' into implementation/38707-reminder-emails-scheduling
ulfertsa2380345d88f
diff --cc app/views/admin/settings/mail_notifications_settings/show.html.erbindex 4be305d8f13,31a6797a491..1e716b1703b--- a/app/views/admin/settings/mail_notifications_settings/show.html.erb+++ b/app/views/admin/settings/mail_notifications_settings/show.html.erb@@@ -37,15 -37,14 +37,6 @@@ See COPYRIGHT and LICENSE files for mor<div class="form--field"><%= setting_text_field :mail_from, size: 60, container_class: '-middle' %></div><div class="form--field"><%= setting_check_box :bcc_recipients %></div><div class="form--field"><%= setting_check_box :plain_text_mail %></div>-- <div class="form--field">- <%= setting_number_field :notification_email_delay_minutes,- container_class: '-xslim',- min: 0,- unit: t(:label_minute_plural) %>- <%= setting_time_field :notification_email_digest_time,- container_class: '-xslim',- unit: 'UTC' %>-- <div class="form--field-instructions">- <%= t(:'settings.notifications.delay_minutes_explanation') %>- <%= t(:'settings.notifications.email_digest_explanation') %>-- </div>-- </div></section><fieldset id="emails_decorators" class="form--fieldset"><legend class="form--fieldset-legend"><%= t(:setting_emails_header) %> & <%= t(:setting_emails_footer) %></legend>diff --cc config/locales/en.ymlindex 4452ea75203,8a284a67b56..6328467fc2e--- a/config/locales/en.yml+++ b/config/locales/en.yml@@@ -2451,7 -2452,7 +2451,6 @@@ ensetting_enabled_scm: "Enabled SCM"setting_enabled_projects_columns: "Visible in project list"setting_notification_retention_period_days: "Notification retention period"- setting_notification_email_delay_minutes: "Email sending delay"- setting_notification_email_digest_time: "Email digest time"setting_feeds_enabled: "Enable Feeds"setting_feeds_limit: "Feed content limit"setting_file_max_size_displayed: "Max size of text files displayed inline"@@@ -2533,7 -2534,7 +2532,6 @@@retention_text: >Set the number of days notification events for users (the source for in-app notifications)will be kept in the system. Any events older than this time will be deleted.- delay_minutes_explanation: "Email sending can be delayed to allow users with configured in app notification to confirm the notification within the application before a mail is sent out. Users who read a notification within the application will not receive an email for the already read notification."- email_digest_explanation: "Once a day, an email digest can be sent out containing a collection of all the notification users subscribed to. The setting is relative to each users configured time zone, so e.g. 8:00 will be executed at 7:00 UTC for users in UTC+1 and 9:00 UTC for those in UTC-1."events_explanation: 'Governs for which event an email is sent out. Work packages are excluded from this list as the notifications for them can be configured specifically for every user.'display:first_date_of_week_and_year_set: >diff --cc config/settings.ymlindex eeb05506f30,29dab8222e5..970c83080f5--- a/config/settings.yml+++ b/config/settings.yml@@@ -382,6 -382,5 +382,3 @@@ apiv3_docs_enablednotification_retention_period_days:default: 30format: int- notification_email_delay_minutes:- default: 15- format: int-notification_email_digest_time:- default: '08:00'diff --cc spec/features/notifications/reminder_mail_spec.rbindex 74e0625d5bd,9e653616969..51e9e38d7f3--- a/spec/features/notifications/reminder_mail_spec.rb+++ b/spec/features/notifications/reminder_mail_spec.rb@@@ -62,89 -62,4 +62,90 @@@ describe "Reminder email", type: :featuit_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) }+ let(:current_utc_time) { ActiveSupport::TimeZone['Hawaii'].parse("08:43").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: Time.current.utc))+ 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