Skip to content

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

Update date alerts specs with unsetting values

Dombi Attila45f7d57d75b6
diff --git a/spec/features/notifications/settings/date_alert_settings_spec.rb b/spec/features/notifications/settings/date_alert_settings_spec.rb
index 4b9c826d948..57636cfc292 100644
--- a/spec/features/notifications/settings/date_alert_settings_spec.rb
+++ b/spec/features/notifications/settings/date_alert_settings_spec.rb
@@ -12,12 +12,14 @@ describe "Date alert settings", js: true do
let!(:member_two) { create(:member, user:, project: project_alt, roles: [role]) }
it 'allows to configure the date alert settings' do
+ # Set date alert settings
settings_page.visit!
settings_page.set_time('op-reminder-settings-start-date-alerts', '3 days before')
settings_page.date_alert_option('overdue', true)
settings_page.set_time('op-reminder-settings-overdue-date-alerts', 'every week')
settings_page.save
+ settings_page.expect_and_dismiss_toaster(message: 'Successful update')
user.reload
notification_settings = user.notification_settings
@@ -26,9 +28,25 @@ describe "Date alert settings", js: true do
expect(notification_settings.first.start_date).to eq(3)
expect(notification_settings.first.due_date).to eq(1)
expect(notification_settings.first.overdue).to eq(7)
+
+ # Unset date alert settings
+ settings_page.date_alert_option('start', false)
+ settings_page.date_alert_option('overdue', false)
+ settings_page.date_alert_option('due', false)
+
+ settings_page.save
+
+ user.reload
+ notification_settings = user.notification_settings
+
+ expect(notification_settings.count).to eq(1)
+ expect(notification_settings.first.start_date).to be_nil
+ expect(notification_settings.first.due_date).to be_nil
+ expect(notification_settings.first.overdue).to be_nil
end
it 'allows to configure date alerts settings per project' do
+ # Set date alert settings
settings_page.visit!
settings_page.add_project project
@@ -36,6 +54,7 @@ describe "Date alert settings", js: true do
settings_page.set_time('op-reminder-settings-due-date-alerts-global', '3 days before')
settings_page.set_time('op-reminder-settings-overdue-date-alerts-global', 'every week')
settings_page.save
+ settings_page.expect_and_dismiss_toaster(message: 'Successful update')
user.reload
notification_settings = user.notification_settings
@@ -45,5 +64,21 @@ describe "Date alert settings", js: true do
expect(notification_settings.where(project:).first.start_date).to eq(3)
expect(notification_settings.where(project:).first.due_date).to eq(3)
expect(notification_settings.where(project:).first.overdue).to eq(7)
+
+ # Unset date alert settings
+ settings_page.set_time('op-reminder-settings-start-date-alerts-global', 'No notification')
+ settings_page.set_time('op-reminder-settings-due-date-alerts-global', 'No notification')
+ settings_page.set_time('op-reminder-settings-overdue-date-alerts-global', 'No notification')
+ settings_page.save
+ settings_page.expect_and_dismiss_toaster(message: 'Successful update')
+
+ user.reload
+ notification_settings = user.notification_settings
+
+ expect(notification_settings.count).to eq 2
+ expect(notification_settings.where(project:).count).to eq 1
+ expect(notification_settings.where(project:).first.start_date).to be_nil
+ expect(notification_settings.where(project:).first.due_date).to be_nil
+ expect(notification_settings.where(project:).first.overdue).to be_nil
end
end