Update notification_finder_spec.rb

This commit is contained in:
Muhsin Keloth
2024-01-04 14:27:31 +05:30
parent 3474473e38
commit 4285fb20f3
+19 -2
View File
@@ -11,6 +11,8 @@ describe NotificationFinder do
create(:notification, account: account, user: user, snoozed_until: DateTime.now.utc + 3.days, updated_at: DateTime.now.utc,
last_activity_at: DateTime.now.utc)
create(:notification, account: account, user: user, updated_at: DateTime.now.utc + 2.days, last_activity_at: DateTime.now.utc + 2.days)
create(:notification, account: account, user: user, updated_at: DateTime.now.utc + 4.days, last_activity_at: DateTime.now.utc + 4.days,
notification_type: :conversation_creation)
end
describe '#perform' do
@@ -24,7 +26,7 @@ describe NotificationFinder do
end
context 'without snoozed status' do
let(:params) { { status: 'open' } }
let(:params) { {} }
it 'returns all notifications' do
result = notification_finder.perform
@@ -33,7 +35,7 @@ describe NotificationFinder do
end
context 'when order by last_activity_at' do
let(:params) { { status: 'open' } }
let(:params) { {} }
it 'returns all notifications' do
result = notification_finder.perform
@@ -41,5 +43,20 @@ describe NotificationFinder do
expect(result.first.last_activity_at).to be > result.last.last_activity_at
end
end
context 'when order by user notification settings' do
let(:params) { {} }
before do
notification_setting = user.notification_settings.find_by(account_id: account.id)
notification_setting.selected_email_flags = [:email_conversation_creation]
notification_setting.save!
end
it 'returns all notifications' do
result = notification_finder.perform
expect(result.length).to be 4
end
end
end
end