chore: Get all notification API improvments (#8549)
Co-authored-by: Sojan Jose <sojan@chatwoot.com>
This commit is contained in:
@@ -11,6 +11,7 @@ describe NotificationBuilder do
|
||||
before do
|
||||
notification_setting = user.notification_settings.find_by(account_id: account.id)
|
||||
notification_setting.selected_email_flags = [:email_conversation_creation]
|
||||
notification_setting.selected_push_flags = [:push_conversation_creation]
|
||||
notification_setting.save!
|
||||
end
|
||||
|
||||
@@ -38,5 +39,37 @@ describe NotificationBuilder do
|
||||
).perform
|
||||
).to be_nil
|
||||
end
|
||||
|
||||
it 'will not create a conversation_creation notification if user is not subscribed to it' do
|
||||
notification_setting = user.notification_settings.find_by(account_id: account.id)
|
||||
notification_setting.selected_email_flags = []
|
||||
notification_setting.selected_push_flags = []
|
||||
notification_setting.save!
|
||||
|
||||
expect(
|
||||
described_class.new(
|
||||
notification_type: 'conversation_creation',
|
||||
user: user,
|
||||
account: account,
|
||||
primary_actor: primary_actor
|
||||
).perform
|
||||
).to be_nil
|
||||
end
|
||||
|
||||
it 'will create a conversation_mention notification eventhough user is not subscribed to it' do
|
||||
notification_setting = user.notification_settings.find_by(account_id: account.id)
|
||||
notification_setting.selected_email_flags = []
|
||||
notification_setting.selected_push_flags = []
|
||||
notification_setting.save!
|
||||
|
||||
expect do
|
||||
described_class.new(
|
||||
notification_type: 'conversation_mention',
|
||||
user: user,
|
||||
account: account,
|
||||
primary_actor: primary_actor
|
||||
).perform
|
||||
end.to change { user.notifications.count }.by(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user