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
include reminder feature spec at proper location
ulferts1aae2385662b
diff --git a/spec/features/notifications/digest_mail_spec.rb b/spec/features/notifications/digest_mail_spec.rbdeleted file mode 100644index 03b7b431ec5..00000000000--- a/spec/features/notifications/digest_mail_spec.rb+++ /dev/null@@ -1,140 +0,0 @@-require 'spec_helper'-require 'support/pages/my/notifications'--# TODO: This feature spec is to be replaced by the reminder_mail_spec.rb in the same directory.-describe "Digest email", type: :feature, js: true do- let!(:project) { FactoryBot.create :project, members: { current_user => role } }- let!(:mute_project) { FactoryBot.create :project, members: { current_user => role } }- let(:notification_settings_page) { Pages::My::Notifications.new(current_user) }- 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) }-- current_user do- FactoryBot.create :user,- notification_settings: [- FactoryBot.build(:mail_notification_setting,- involved: false,- watched: false,- mentioned: false,- work_package_commented: false,- work_package_created: false,- work_package_processed: false,- work_package_prioritized: false,- work_package_scheduled: false,- all: false),- FactoryBot.build(:in_app_notification_setting,- involved: false,- watched: false,- mentioned: false,- work_package_commented: false,- work_package_created: false,- work_package_processed: false,- work_package_prioritized: false,- work_package_scheduled: false,- all: false),- 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(Setting).to receive(:notification_email_digest_time)- .and_return(hitting_reminder_slot_for(current_user))-- watched_work_package- work_package- involved_work_package-- allow(CustomStyle.current)- .to receive(:logo).and_return(nil)-- ActiveJob::Base.queue_adapter.enqueued_jobs.clear- end-- it 'sends a digest mail based on the configuration', with_settings: { journal_aggregation_time_minutes: 0 } do- # Configure the digest- notification_settings_page.visit!-- notification_settings_page.expect_setting channel: :mail_digest,- project: nil,- involved: true,- mentioned: true,- watched: true,- work_package_commented: true,- work_package_created: true,- work_package_processed: true,- work_package_prioritized: true,- work_package_scheduled: true,- all: false-- notification_settings_page.configure_channel :mail_digest,- project: nil,- involved: false,- mentioned: true,- watched: true,- work_package_commented: false,- work_package_created: false,- work_package_processed: false,- work_package_prioritized: false,- work_package_scheduled: false,- all: false-- notification_settings_page.add_row(mute_project)-- notification_settings_page.configure_channel :mail_digest,- project: mute_project,- involved: false,- mentioned: false,- watched: false,- work_package_commented: false,- work_package_created: false,- work_package_processed: false,- work_package_prioritized: false,- work_package_scheduled: false,- all: false-- notification_settings_page.save-- # 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-- Cron::ScheduleReminderMailsJob.perform_later- perform_enqueued_jobs- 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-enddiff --git a/spec/features/notifications/reminder_mail_spec.rb b/spec/features/notifications/reminder_mail_spec.rbindex 9e653616969..50ac70664c0 100644--- a/spec/features/notifications/reminder_mail_spec.rb+++ b/spec/features/notifications/reminder_mail_spec.rb@@ -41,7 +41,7 @@ describe "Reminder email", type: :feature, js: true doendend- context 'with the my page' do+ context 'configuring via the my page' dolet(:reminders_settings_page) { Pages::My::Reminders.new(current_user) }current_user do@@ -51,7 +51,7 @@ describe "Reminder email", type: :feature, js: true doit_behaves_like 'reminder settings'end- context 'with the user administration page' do+ context 'configuring via the user administration page' dolet(:reminders_settings_page) { Pages::Reminders::Settings.new(other_user) }let(:other_user) { FactoryBot.create :user }@@ -62,4 +62,78 @@ describe "Reminder email", type: :feature, js: true doit_behaves_like 'reminder settings'end++ context '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) }++ current_user do+ FactoryBot.create :user,+ 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(Setting).to receive(:notification_email_digest_time)+ .and_return(hitting_reminder_slot_for(current_user))++ watched_work_package+ work_package+ involved_work_package++ allow(CustomStyle.current)+ .to receive(:logo).and_return(nil)++ ActiveJob::Base.queue_adapter.enqueued_jobs.clear+ 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