Remove read_mail, reason_mail, reason_mail_digest

pull/9665/head
Oliver Günther 3 years ago
parent 41df9a4c54
commit e3913e61e4
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 5
      app/contracts/notifications/create_contract.rb
  2. 2
      app/helpers/mail_digest_helper.rb
  3. 2
      app/helpers/mail_notification_helper.rb
  4. 2
      app/mailers/digest_mailer.rb
  5. 5
      app/models/notification.rb
  6. 42
      app/models/notifications/scopes/unread_mail.rb
  7. 23
      app/services/notifications/create_from_model_service.rb
  8. 2
      app/workers/notifications/workflow_job.rb
  9. 6
      config/locales/en.yml
  10. 17
      db/migrate/20210914065555_cleanup_notifications.rb
  11. 3
      lib/api/v3/notifications/notification_representer.rb
  12. 2
      lib/api/v3/notifications/notifications_api.rb
  13. 14
      modules/documents/spec/services/notifications/create_from_model_service_document_spec.rb
  14. 52
      spec/contracts/notifications/create_contract_spec.rb
  15. 5
      spec/factories/notification_factory.rb
  16. 2
      spec/lib/api/v3/notifications/notification_representer_rendering_spec.rb
  17. 50
      spec/models/notifications/scopes/unread_mail_spec.rb
  18. 2
      spec/requests/api/v3/notifications/index_resource_spec.rb
  19. 7
      spec/services/notifications/create_from_journal_job_shared.rb
  20. 9
      spec/services/notifications/create_from_model_service_comment_spec.rb
  21. 42
      spec/services/notifications/create_from_model_service_message_spec.rb
  22. 7
      spec/services/notifications/create_from_model_service_news_spec.rb
  23. 33
      spec/services/notifications/create_from_model_service_wiki_spec.rb
  24. 190
      spec/services/notifications/create_from_model_service_work_package_spec.rb
  25. 22
      spec/services/notifications/set_attributes_service_spec.rb

@ -32,16 +32,13 @@ module Notifications
attribute :recipient
attribute :subject
attribute :reason_ian
attribute :reason_mail
attribute :reason_mail_digest
attribute :reason
attribute :project
attribute :actor
attribute :resource
attribute :journal
attribute :resource_type
attribute :read_ian
attribute :read_mail
attribute :read_mail_digest
validate :validate_recipient_present

@ -52,7 +52,7 @@ module MailDigestHelper
end
def digest_comment_text(notification)
if notification.reason_mail_digest === "mentioned"
if notification.reason == "mentioned"
sanitize I18n.t(:'mail.digests.work_packages.mentioned')
else
sanitize I18n.t(:'mail.digests.work_packages.comment_added')

@ -55,7 +55,7 @@ module MailNotificationHelper
def unique_reasons_of_notifications(notifications)
notifications
.map(&:reason_mail_digest)
.map(&:reason)
.uniq
end

@ -68,7 +68,7 @@ class DigestMailer < ApplicationMailer
@mentioned_count = @aggregated_notifications
.values
.flatten
.map(&:reason_mail_digest)
.map(&:reason)
.compact
.count("mentioned")

@ -12,9 +12,7 @@ class Notification < ApplicationRecord
responsible: 9
}.freeze
enum reason_ian: REASONS, _prefix: :ian
enum reason_mail: REASONS, _prefix: :mail
enum reason_mail_digest: REASONS, _prefix: :mail_digest
enum reason: REASONS
belongs_to :recipient, class_name: 'User'
belongs_to :actor, class_name: 'User'
@ -24,7 +22,6 @@ class Notification < ApplicationRecord
include Scopes::Scoped
scopes :unsent_reminders_before,
:unread_mail,
:unread_mail_digest,
:recipient
end

@ -1,42 +0,0 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See COPYRIGHT and LICENSE files for more details.
#++
# Return mail notifications that are unread (have read_mail: false)
module Notifications::Scopes
module UnreadMail
extend ActiveSupport::Concern
class_methods do
def unread_mail
where(read_mail: false)
end
end
end
end

@ -75,29 +75,10 @@ class Notifications::CreateFromModelService
end
def channel_attributes(channel_reasons)
channel_attributes_mail(channel_reasons)
.merge(channel_attributes_mail_digest(channel_reasons))
.merge(channel_attributes_ian(channel_reasons))
end
def channel_attributes_mail(channel_reasons)
{
read_mail: strategy.supports_mail? && channel_reasons.keys.include?('mail') ? false : nil,
reason_mail: strategy.supports_mail? && channel_reasons['mail']&.first
}
end
def channel_attributes_mail_digest(channel_reasons)
{
read_mail_digest: strategy.supports_mail_digest? && channel_reasons.keys.include?('mail_digest') ? false : nil,
reason_mail_digest: strategy.supports_mail_digest? && channel_reasons['mail_digest']&.first
}
end
def channel_attributes_ian(channel_reasons)
{
reason: strategy.supports_ian? && channel_reasons['in_app']&.first,
read_ian: strategy.supports_ian? && channel_reasons.keys.include?('in_app') ? false : nil,
reason_ian: strategy.supports_ian? && channel_reasons['in_app']&.first
read_mail_digest: strategy.supports_mail_digest? && channel_reasons.keys.include?('mail_digest') ? false : nil
}
end

@ -65,7 +65,7 @@ class Notifications::WorkflowJob < ApplicationJob
Notification
.where(id: notification_ids)
.unread_mail
.unread_mail # TODO
.each do |notification|
Notifications::MailService
.new(notification)

@ -686,14 +686,10 @@ en:
attributes:
read_ian:
read_on_creation: 'cannot be set to true on notification creation.'
read_mail:
read_on_creation: 'cannot be set to true on notification creation.'
read_mail_digest:
read_on_creation: 'cannot be set to true on notification creation.'
reason_ian:
reason:
no_notification_reason: 'cannot be blank as IAN is chosen as a channel.'
reason_mail:
no_notification_reason: 'cannot be blank as mail is chosen as a channel.'
reason_mail_digest:
no_notification_reason: 'cannot be blank as mail digest is chosen as a channel.'
notification_settings:

@ -0,0 +1,17 @@
class CleanupNotifications < ActiveRecord::Migration[6.1]
def up
change_table :notifications, bulk: true do |t|
t.remove :read_mail, :reason_mail, :reason_mail_digest
t.rename :reason_ian, :reason
end
end
def down
change_table :notifications, bulk: true do |t|
t.boolean :read_email, default: false, index: true
t.integer :reason_mail, limit: 1
t.integer :reason_mail_digest, limit: 1
t.rename :reason, :reason_ian
end
end
end

@ -46,8 +46,7 @@ module API
property :read_ian,
as: :readIAN
property :reason_ian,
as: :reason
property :reason
date_time_property :created_at

@ -47,7 +47,7 @@ module API
.recipient(current_user)
.includes(NotificationRepresenter.to_eager_load)
.where
.not(reason_ian: nil)
.not(reason: nil)
end
def bulk_update_status(attributes)

@ -62,11 +62,8 @@ describe Notifications::CreateFromModelService, 'document', with_settings: { jou
let(:notification_channel_reasons) do
{
read_ian: nil,
reason_ian: false,
read_mail: false,
reason_mail: :subscribed,
read_mail_digest: nil,
reason_mail_digest: false
reason: false,
read_mail_digest: nil
}
end
end
@ -116,11 +113,8 @@ describe Notifications::CreateFromModelService, 'document', with_settings: { jou
let(:notification_channel_reasons) do
{
read_ian: nil,
reason_ian: false,
read_mail: false,
reason_mail: :subscribed,
read_mail_digest: nil,
reason_mail_digest: false
reason: false,
read_mail_digest: nil
}
end
end

@ -41,23 +41,17 @@ describe Notifications::CreateContract do
let(:notification_resource) { FactoryBot.build_stubbed(:journal) }
let(:notification_recipient) { FactoryBot.build_stubbed(:user) }
let(:notification_subject) { 'Some text' }
let(:notification_reason_ian) { :mentioned }
let(:notification_reason_mail) { :assigned }
let(:notification_reason_mail_digest) { :watched }
let(:notification_reason) { :mentioned }
let(:notification_read_ian) { false }
let(:notification_read_mail) { false }
let(:notification_read_mail_digest) { false }
let(:notification) do
Notification.new(project: notification_context,
recipient: notification_recipient,
subject: notification_subject,
reason_ian: notification_reason_ian,
reason_mail: notification_reason_mail,
reason_mail_digest: notification_reason_mail_digest,
reason: notification_reason,
resource: notification_resource,
read_ian: notification_read_ian,
read_mail: notification_read_mail,
read_mail_digest: notification_read_mail_digest)
end
@ -73,48 +67,19 @@ describe Notifications::CreateContract do
end
context 'without a reason for IAN with read_ian false' do
let(:notification_reason_ian) { nil }
let(:notification_reason) { nil }
let(:notification_read_ian) { false }
it_behaves_like 'contract is invalid', reason_ian: :no_notification_reason
it_behaves_like 'contract is invalid', reason: :no_notification_reason
end
context 'without a reason for IAN with read_ian nil' do
let(:notification_reason_ian) { nil }
let(:notification_reason) { nil }
let(:notification_read_ian) { nil }
it_behaves_like 'contract is valid'
end
context 'without a reason for mail with read_mail false' do
let(:notification_reason_mail) { nil }
let(:notification_read_mail) { false }
it_behaves_like 'contract is invalid', reason_mail: :no_notification_reason
end
context 'without a reason for mail with read_mail nil' do
let(:notification_reason_mail) { nil }
let(:notification_read_mail) { nil }
it_behaves_like 'contract is valid'
end
context 'without a reason for mail_digest with read_mail_digest false' do
let(:notification_reason_mail_digest) { nil }
let(:notification_read_mail_digest) { false }
it_behaves_like 'contract is invalid', reason_mail_digest: :no_notification_reason
end
context 'without a reason for mail_digest with read_mail_digest nil' do
let(:notification_reason_mail_digest) { nil }
let(:notification_read_mail_digest) { nil }
it_behaves_like 'contract is valid'
end
context 'without a subject' do
let(:notification_subject) { nil }
@ -129,7 +94,6 @@ describe Notifications::CreateContract do
context 'with all channels nil' do
let(:notification_read_ian) { nil }
let(:notification_read_mail) { nil }
let(:notification_read_mail_digest) { nil }
it_behaves_like 'contract is invalid', base: :at_least_one_channel
@ -141,12 +105,6 @@ describe Notifications::CreateContract do
it_behaves_like 'contract is invalid', read_ian: :read_on_creation
end
context 'with read_mail true' do
let(:notification_read_mail) { true }
it_behaves_like 'contract is invalid', read_mail: :read_on_creation
end
context 'with read_mail_digest true' do
let(:notification_read_mail_digest) { true }

@ -2,11 +2,8 @@ FactoryBot.define do
factory :notification do
subject { "MyText" } # rubocop:disable RSpec/EmptyLineAfterSubject
read_ian { false }
read_mail { false }
read_mail_digest { false }
reason_ian { :mentioned }
reason_mail { :assigned }
reason_mail_digest { :watched }
reason { :mentioned }
recipient factory: :user
project { association :project }
resource { association :work_package, project: project }

@ -107,7 +107,7 @@ describe ::API::V3::Notifications::NotificationRepresenter, 'rendering' do
end
it_behaves_like 'property', :reason do
let(:value) { notification.reason_ian }
let(:value) { notification.reason }
end
it_behaves_like 'datetime property', :createdAt do

@ -1,50 +0,0 @@
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See COPYRIGHT and LICENSE files for more details.
#++
require 'spec_helper'
describe Notifications::Scopes::UnreadMail, type: :model do
describe '.unread_mail' do
subject(:scope) { ::Notification.unread_mail }
let(:no_mail_notification) { FactoryBot.create(:notification, read_mail: nil) }
let(:unread_mail_notification) { FactoryBot.create(:notification, read_mail: false) }
let(:read_mail_notification) { FactoryBot.create(:notification, read_mail: true) }
before do
no_mail_notification
unread_mail_notification
read_mail_notification
end
it 'contains the notifications with read_mail: false' do
expect(scope)
.to match_array([unread_mail_notification])
end
end
end

@ -82,7 +82,7 @@ describe ::API::V3::Notifications::NotificationsAPI,
it_behaves_like 'API V3 collection response', 2, 2, 'Notification'
context 'with a digest notification' do
let(:digest_notification) { FactoryBot.create :notification, recipient: recipient, reason_ian: nil }
let(:digest_notification) { FactoryBot.create :notification, recipient: recipient, reason: nil }
let(:notifications) { [notification1, notification2, digest_notification] }
it_behaves_like 'API V3 collection response', 2, 2, 'Notification' do

@ -76,11 +76,8 @@ shared_context 'with CreateFromJournalJob context' do
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :mentioned,
read_mail: false,
reason_mail: :mentioned,
read_mail_digest: false,
reason_mail_digest: :mentioned
reason: :mentioned,
read_mail_digest: false
}
end
let(:notification) { FactoryBot.build_stubbed(:notification) }

@ -67,11 +67,8 @@ describe Notifications::CreateFromModelService, 'comment', with_settings: { jour
let(:notification_channel_reasons) do
{
read_ian: nil,
reason_ian: false,
read_mail: false,
reason_mail: :subscribed,
reason: false,
read_mail_digest: nil,
reason_mail_digest: false
}
end
end
@ -118,11 +115,9 @@ describe Notifications::CreateFromModelService, 'comment', with_settings: { jour
let(:notification_channel_reasons) do
{
read_ian: nil,
reason_ian: false,
reason: false,
read_mail: false,
reason_mail: :watched,
read_mail_digest: nil,
reason_mail_digest: false
}
end
end

@ -68,11 +68,8 @@ describe Notifications::CreateFromModelService, 'message', with_settings: { jour
let(:notification_channel_reasons) do
{
read_ian: nil,
reason_ian: false,
read_mail: false,
reason_mail: :subscribed,
read_mail_digest: nil,
reason_mail_digest: false
reason: false,
read_mail_digest: nil
}
end
end
@ -119,11 +116,8 @@ describe Notifications::CreateFromModelService, 'message', with_settings: { jour
let(:notification_channel_reasons) do
{
read_ian: nil,
reason_ian: false,
read_mail: false,
reason_mail: :watched,
read_mail_digest: nil,
reason_mail_digest: false
reason: false,
read_mail_digest: nil
}
end
end
@ -174,11 +168,8 @@ describe Notifications::CreateFromModelService, 'message', with_settings: { jour
let(:notification_channel_reasons) do
{
read_ian: nil,
reason_ian: false,
read_mail: false,
reason_mail: :watched,
read_mail_digest: nil,
reason_mail_digest: false
reason: false,
read_mail_digest: nil
}
end
end
@ -220,11 +211,8 @@ describe Notifications::CreateFromModelService, 'message', with_settings: { jour
let(:notification_channel_reasons) do
{
read_ian: nil,
reason_ian: false,
read_mail: false,
reason_mail: :subscribed,
read_mail_digest: nil,
reason_mail_digest: false
reason: false,
read_mail_digest: nil
}
end
end
@ -271,11 +259,8 @@ describe Notifications::CreateFromModelService, 'message', with_settings: { jour
let(:notification_channel_reasons) do
{
read_ian: nil,
reason_ian: false,
read_mail: false,
reason_mail: :watched,
read_mail_digest: nil,
reason_mail_digest: false
reason: false,
read_mail_digest: nil
}
end
end
@ -326,11 +311,8 @@ describe Notifications::CreateFromModelService, 'message', with_settings: { jour
let(:notification_channel_reasons) do
{
read_ian: nil,
reason_ian: false,
read_mail: false,
reason_mail: :watched,
read_mail_digest: nil,
reason_mail_digest: false
reason: false,
read_mail_digest: nil
}
end
end

@ -60,11 +60,8 @@ describe Notifications::CreateFromModelService, 'news', with_settings: { journal
let(:notification_channel_reasons) do
{
read_ian: nil,
reason_ian: false,
read_mail: false,
reason_mail: :subscribed,
read_mail_digest: nil,
reason_mail_digest: false
reason: false,
read_mail_digest: nil
}
end
end

@ -66,11 +66,9 @@ describe Notifications::CreateFromModelService, 'wiki', with_settings: { journal
let(:notification_channel_reasons) do
{
read_ian: nil,
reason_ian: false,
reason: false,
read_mail: false,
reason_mail: :subscribed,
read_mail_digest: nil,
reason_mail_digest: false
read_mail_digest: nil
}
end
end
@ -117,11 +115,9 @@ describe Notifications::CreateFromModelService, 'wiki', with_settings: { journal
let(:notification_channel_reasons) do
{
read_ian: nil,
reason_ian: false,
reason: false,
read_mail: false,
reason_mail: :watched,
read_mail_digest: nil,
reason_mail_digest: false
read_mail_digest: nil
}
end
end
@ -173,11 +169,8 @@ describe Notifications::CreateFromModelService, 'wiki', with_settings: { journal
let(:notification_channel_reasons) do
{
read_ian: nil,
reason_ian: false,
read_mail: false,
reason_mail: :subscribed,
read_mail_digest: nil,
reason_mail_digest: false
reason: false,
read_mail_digest: nil
}
end
end
@ -224,11 +217,8 @@ describe Notifications::CreateFromModelService, 'wiki', with_settings: { journal
let(:notification_channel_reasons) do
{
read_ian: nil,
reason_ian: false,
read_mail: false,
reason_mail: :watched,
read_mail_digest: nil,
reason_mail_digest: false
reason: false,
read_mail_digest: nil
}
end
end
@ -279,11 +269,8 @@ describe Notifications::CreateFromModelService, 'wiki', with_settings: { journal
let(:notification_channel_reasons) do
{
read_ian: nil,
reason_ian: false,
read_mail: false,
reason_mail: :watched,
read_mail_digest: nil,
reason_mail_digest: false
reason: false,
read_mail_digest: nil
}
end
end

@ -115,11 +115,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :assigned,
read_mail: false,
reason_mail: :assigned,
read_mail_digest: false,
reason_mail_digest: :assigned
reason: :assigned,
read_mail_digest: false
}
end
end
@ -139,7 +136,7 @@ describe Notifications::CreateFromModelService,
read_ian: nil,
reason_ian: nil,
read_mail: false,
reason_mail: :assigned,
reason_mail: :involved,
read_mail_digest: false,
reason_mail_digest: :assigned
}
@ -160,11 +157,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :assigned,
read_mail: nil,
reason_mail: nil,
read_mail_digest: nil,
reason_mail_digest: nil
reason: :assigned,
read_mail_digest: nil
}
end
end
@ -195,11 +189,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :assigned,
read_mail: false,
reason_mail: :assigned,
read_mail_digest: false,
reason_mail_digest: :assigned
reason: :assigned,
read_mail_digest: false
}
end
end
@ -245,11 +236,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :responsible,
read_mail: false,
reason_mail: :responsible,
read_mail_digest: false,
reason_mail_digest: :responsible
reason: :responsible,
read_mail_digest: false
}
end
end
@ -267,11 +255,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: nil,
reason_ian: nil,
read_mail: nil,
reason_mail: nil,
read_mail_digest: false,
reason_mail_digest: :responsible
reason: nil,
read_mail_digest: false
}
end
end
@ -290,11 +275,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :responsible,
read_mail: nil,
reason_mail: nil,
read_mail_digest: nil,
reason_mail_digest: nil
reason: :responsible,
read_mail_digest: nil
}
end
end
@ -352,11 +334,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :watched,
read_mail: false,
reason_mail: :watched,
read_mail_digest: false,
reason_mail_digest: :watched
reason: :watched,
read_mail_digest: false
}
end
end
@ -374,11 +353,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: nil,
reason_ian: nil,
read_mail: false,
reason_mail: :watched,
read_mail_digest: false,
reason_mail_digest: :watched
reason: nil,
read_mail_digest: false
}
end
end
@ -397,11 +373,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :watched,
read_mail: nil,
reason_mail: nil,
read_mail_digest: nil,
reason_mail_digest: nil
reason: :watched,
read_mail_digest: nil
}
end
end
@ -454,11 +427,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :created,
read_mail: false,
reason_mail: :created,
read_mail_digest: false,
reason_mail_digest: :created
reason: :subscribed,
read_mail_digest: false
}
end
end
@ -476,11 +446,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: nil,
reason_ian: nil,
read_mail: false,
reason_mail: :created,
read_mail_digest: false,
reason_mail_digest: :created
reason: nil,
read_mail_digest: false
}
end
end
@ -499,11 +466,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :created,
read_mail: nil,
reason_mail: nil,
read_mail_digest: nil,
reason_mail_digest: nil
reason: :created,
read_mail_digest: nil
}
end
end
@ -537,11 +501,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :created,
read_mail: false,
reason_mail: :created,
read_mail_digest: false,
reason_mail_digest: :created
reason: :subscribed,
read_mail_digest: false
}
end
end
@ -599,11 +560,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :created,
read_mail: false,
reason_mail: :created,
read_mail_digest: false,
reason_mail_digest: :created
reason: :created,
read_mail_digest: false
}
end
end
@ -671,11 +629,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :commented,
read_mail: false,
reason_mail: :commented,
read_mail_digest: false,
reason_mail_digest: :commented
reason: :commented,
read_mail_digest: false
}
end
end
@ -732,11 +687,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :processed,
read_mail: false,
reason_mail: :processed,
read_mail_digest: false,
reason_mail_digest: :processed
reason: :processed,
read_mail_digest: false
}
end
end
@ -793,11 +745,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :prioritized,
read_mail: false,
reason_mail: :prioritized,
read_mail_digest: false,
reason_mail_digest: :prioritized
reason: :prioritized,
read_mail_digest: false
}
end
end
@ -854,11 +803,9 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :scheduled,
reason: :scheduled,
read_mail: false,
reason_mail: :scheduled,
read_mail_digest: false,
reason_mail_digest: :scheduled
read_mail_digest: false
}
end
end
@ -915,11 +862,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :scheduled,
read_mail: false,
reason_mail: :scheduled,
read_mail_digest: false,
reason_mail_digest: :scheduled
reason: :scheduled,
read_mail_digest: false
}
end
end
@ -952,11 +896,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :assigned,
read_mail: false,
reason_mail: :assigned,
read_mail_digest: false,
reason_mail_digest: :assigned
reason: :assigned,
read_mail_digest: false
}
end
end
@ -978,11 +919,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :mentioned,
read_mail: false,
reason_mail: :mentioned,
read_mail_digest: false,
reason_mail_digest: :mentioned
reason: :mentioned,
read_mail_digest: false
}
end
end
@ -1014,11 +952,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :mentioned,
read_mail: false,
reason_mail: :mentioned,
read_mail_digest: false,
reason_mail_digest: :mentioned
reason: :mentioned,
read_mail_digest: false
}
end
end
@ -1035,11 +970,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :mentioned,
read_mail: false,
reason_mail: :mentioned,
read_mail_digest: false,
reason_mail_digest: :mentioned
reason: :mentioned,
read_mail_digest: false
}
end
end
@ -1053,11 +985,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :mentioned,
read_mail: false,
reason_mail: :mentioned,
read_mail_digest: false,
reason_mail_digest: :mentioned
reason: :mentioned,
read_mail_digest: false
}
end
end
@ -1070,11 +999,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :mentioned,
read_mail: false,
reason_mail: :mentioned,
read_mail_digest: false,
reason_mail_digest: :mentioned
reason: :mentioned,
read_mail_digest: false
}
end
end
@ -1091,11 +1017,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :mentioned,
read_mail: false,
reason_mail: :mentioned,
read_mail_digest: false,
reason_mail_digest: :mentioned
reason: :mentioned,
read_mail_digest: false
}
end
end
@ -1112,11 +1035,8 @@ describe Notifications::CreateFromModelService,
let(:notification_channel_reasons) do
{
read_ian: false,
reason_ian: :mentioned,
read_mail: false,
reason_mail: :mentioned,
read_mail_digest: false,
reason_mail_digest: :mentioned
reason: :mentioned,
read_mail_digest: false
}
end
end

@ -58,9 +58,7 @@ describe Notifications::SetAttributesService, type: :model do
end
let(:call_attributes) { {} }
let(:project) { FactoryBot.build_stubbed(:project) }
let(:reason_ian) { :mentioned }
let(:reason_mail) { :assigned }
let(:reason_mail_digest) { :watched }
let(:reason) { :mentioned }
let(:journal) { FactoryBot.build_stubbed(:journal, journable: journable, data: journal_data) }
let(:journable) { nil }
let(:journal_data) { nil }
@ -71,9 +69,7 @@ describe Notifications::SetAttributesService, type: :model do
let(:call_attributes) do
{
recipient_id: recipient_id,
reason_ian: reason_ian,
reason_mail: reason_mail,
reason_mail_digest: reason_mail_digest,
reason: reason,
resource: journable,
journal: journal,
subject: event_subject,
@ -99,14 +95,11 @@ describe Notifications::SetAttributesService, type: :model do
expect(event.attributes.compact.symbolize_keys)
.to eql({
project_id: project.id,
reason_ian: 'mentioned',
reason_mail: 'assigned',
reason_mail_digest: 'watched',
reason: 'mentioned',
journal_id: journal.id,
recipient_id: 1,
subject: event_subject,
read_ian: false,
read_mail: false,
read_mail_digest: false
})
end
@ -125,9 +118,7 @@ describe Notifications::SetAttributesService, type: :model do
let(:call_attributes) do
{
recipient_id: recipient_id,
reason_ian: reason_ian,
reason_mail: reason_mail,
reason_mail_digest: reason_mail_digest,
reason: reason,
journal: journal,
resource: journable,
}
@ -139,15 +130,12 @@ describe Notifications::SetAttributesService, type: :model do
expect(event.attributes.compact.symbolize_keys)
.to eql({
project_id: project.id,
reason_ian: 'mentioned',
reason_mail: 'assigned',
reason_mail_digest: 'watched',
reason: 'mentioned',
resource_id: journable.id,
resource_type: 'WorkPackage',
journal_id: journal.id,
recipient_id: 1,
read_ian: false,
read_mail: false,
read_mail_digest: false
})
end

Loading…
Cancel
Save