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

[#43158] Impossible to deselect all days when choosing days to receiv… (#11133)

Batracov Dmitrii1a23483fc3b9
diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb
index 6de8d783505..3c0f78a36a2 100644
--- a/app/models/user_preference.rb
+++ b/app/models/user_preference.rb
@@ -132,10 +132,6 @@ class UserPreference < ApplicationRecord
super.presence || { enabled: false }.with_indifferent_access
end
- def workdays
- super.presence || [1, 2, 3, 4, 5]
- end
-
def supported_settings_method?(method_name)
UserPreferences::Schema.properties.include?(method_name.to_s.gsub(/\?|=\z/, ''))
end
diff --git a/frontend/src/app/features/user-preferences/state/user-preferences.store.ts b/frontend/src/app/features/user-preferences/state/user-preferences.store.ts
index a5321308df5..4479bd38493 100644
--- a/frontend/src/app/features/user-preferences/state/user-preferences.store.ts
+++ b/frontend/src/app/features/user-preferences/state/user-preferences.store.ts
@@ -26,7 +26,6 @@
// See COPYRIGHT and LICENSE files for more details.
//++
-import { Injectable } from '@angular/core';
import {
Store,
StoreConfig,
@@ -45,7 +44,7 @@ function createInitialState():IUserPreference {
enabled: true,
times: ['08:00'],
},
- workdays: [1, 2, 3, 4, 5],
+ workdays: [],
immediateReminders: {
mentioned: false,
},
diff --git a/spec/features/notifications/settings/workdays_settings_spec.rb b/spec/features/notifications/settings/workdays_settings_spec.rb
index a865e909ac4..a1557de4ef7 100644
--- a/spec/features/notifications/settings/workdays_settings_spec.rb
+++ b/spec/features/notifications/settings/workdays_settings_spec.rb
@@ -14,9 +14,7 @@ describe "Workday notification settings", type: :feature, js: true do
# Configure the reminders
settings_page.visit!
- # Expect Mo-Fr to be checked
- settings_page.expect_workdays %w[Monday Tuesday Wednesday Thursday Friday]
- settings_page.expect_non_workdays %w[Saturday Sunday]
+ settings_page.expect_non_workdays %w[Sunday Monday Tuesday Wednesday Thursday Friday Saturday]
settings_page.set_workdays Monday: true,
Tuesday: true,
@@ -37,6 +35,31 @@ describe "Workday notification settings", type: :feature, js: true do
expect(pref.reload.workdays).to eq [1, 2, 5, 6, 7]
end
+
+ it 'updates properly working days' do
+ # Configure the reminders
+ settings_page.visit!
+
+ settings_page.expect_non_workdays %w[Sunday Monday Tuesday Wednesday Thursday Friday Saturday]
+
+ settings_page.set_workdays Monday: false,
+ Tuesday: false,
+ Wednesday: false,
+ Thursday: false,
+ Friday: false,
+ Saturday: false,
+ Sunday: false
+
+ settings_page.save
+
+ settings_page.expect_and_dismiss_toaster(message: I18n.t('js.notice_successful_update'))
+
+ settings_page.reload!
+
+ settings_page.expect_non_workdays %w[Monday Tuesday Wednesday Thursday Friday Saturday Sunday]
+
+ expect(pref.reload.workdays).to eq []
+ end
end
context 'with german locale' do
@@ -49,8 +72,7 @@ describe "Workday notification settings", type: :feature, js: true do
settings_page.visit!
# Expect Mo-Fr to be checked
- settings_page.expect_workdays %w[Montag Dienstag Mittwoch Donnerstag Freitag]
- settings_page.expect_non_workdays %w[Samstag Sonntag]
+ settings_page.expect_non_workdays %w[Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag]
settings_page.set_workdays Montag: true,
Dienstag: true,