diff --git a/app/services/notifications/create_from_model_service.rb b/app/services/notifications/create_from_model_service.rb index 4a02890b3c..ecd0b78aa0 100644 --- a/app/services/notifications/create_from_model_service.rb +++ b/app/services/notifications/create_from_model_service.rb @@ -87,7 +87,7 @@ class Notifications::CreateFromModelService resource:, journal:, actor: user_with_fallback, - reason: reason, + reason:, read_ian: strategy.supports_ian? ? false : nil, mail_reminder_sent: strategy.supports_mail_digest? ? false : nil, mail_alert_sent: strategy.supports_mail? ? false : nil @@ -111,7 +111,7 @@ class Notifications::CreateFromModelService def delete_outdated_notifications(current_recipient_ids) Notification - .where(journal: journal) + .where(journal:) .where.not(recipient_id: current_recipient_ids) .destroy_all end diff --git a/spec/services/notifications/create_from_model_service_work_package_spec.rb b/spec/services/notifications/create_from_model_service_work_package_spec.rb index 51255b9dd2..8c35743e42 100644 --- a/spec/services/notifications/create_from_model_service_work_package_spec.rb +++ b/spec/services/notifications/create_from_model_service_work_package_spec.rb @@ -137,7 +137,7 @@ describe Notifications::CreateFromModelService, end end - context 'assignee has all notifications disabled' do + context 'when assignee has all notifications disabled' do let(:recipient_notification_settings) do [ build(:notification_setting, **notification_settings_all_false) @@ -147,7 +147,7 @@ describe Notifications::CreateFromModelService, it_behaves_like 'creates no notification' end - context 'assignee has all in app notifications enabled but only involved for mail' do + context 'when assignee has all in app notifications enabled but only involved for mail' do let(:recipient_notification_settings) do [ build(:notification_setting, **notification_settings_all_false.merge(involved: true)) @@ -166,13 +166,13 @@ describe Notifications::CreateFromModelService, end end - context 'assignee is not allowed to view work packages' do + context 'when assignee is not allowed to view work packages' do let(:permissions) { [] } it_behaves_like 'creates no notification' end - context 'assignee is placeholder user' do + context 'when assignee is placeholder user' do let(:recipient) { create :placeholder_user } it_behaves_like 'creates no notification' @@ -721,8 +721,8 @@ describe Notifications::CreateFromModelService, end shared_examples_for 'group mention' do - context 'group member is allowed to view the work package' do - context 'user wants to receive notifications' do + context 'with a group member allowed to view the work package' do + context 'when the user wants to receive notifications' do it_behaves_like 'creates notification' do let(:notification_channel_reasons) do { @@ -735,7 +735,7 @@ describe Notifications::CreateFromModelService, end end - context 'user disabled mention notifications' do + context 'when the user disabled mention notifications' do let(:recipient_notification_settings) do [ build(:notification_setting, **notification_settings_all_false.merge(mentioned: false)) @@ -746,13 +746,13 @@ describe Notifications::CreateFromModelService, end end - context 'group is not allowed to view the work package' do + context 'with the group not allowed to view the work package' do let(:group_role) { create(:role, permissions: []) } let(:permissions) { [] } it_behaves_like 'creates no notification' - context 'but group member is allowed individually' do + context 'with the group member allowed individually' do let(:permissions) { [:view_work_packages] } it_behaves_like 'creates notification' do @@ -914,8 +914,8 @@ describe Notifications::CreateFromModelService, it 'removes the existing notification' do call - expect(Notification.exists?(id: existing_notification.id)) - .to be_falsey + expect(Notification) + .not_to exist(id: existing_notification.id) end end end @@ -930,7 +930,7 @@ describe Notifications::CreateFromModelService, end end - context 'on a hash/id based mention' do + context 'with a hash/id based mention' do let(:note) do "Hello group##{group.id}" end @@ -938,7 +938,7 @@ describe Notifications::CreateFromModelService, it_behaves_like 'group mention' end - context 'on a tag based mention with the type after' do + context 'with a tag based mention with the type after' do let(:note) do <<~NOTE Hello @#{group.name} @@ -948,7 +948,7 @@ describe Notifications::CreateFromModelService, it_behaves_like 'group mention' end - context 'on a tag based mention with the type before' do + context 'with a tag based mention with the type before' do let(:note) do <<~NOTE Hello @#{group.name} @@ -1027,8 +1027,8 @@ describe Notifications::CreateFromModelService, it 'removes the existing notifications' do call - expect(Notification.exists?(id: existing_notification.id)) - .to be_falsey + expect(Notification) + .not_to exist(id: existing_notification.id) end end