refactor Dossier#with_notifications

This commit is contained in:
clemkeirua 2020-09-18 15:40:26 +02:00 committed by Keirua (Rebase PR Action)
parent d01a53eb72
commit f96377d878
6 changed files with 15 additions and 15 deletions

View file

@ -454,9 +454,9 @@ describe Instructeurs::DossiersController, type: :controller do
before { follower.follow(dossier) }
it 'the follower has a notification' do
expect(follower.followed_dossiers.with_notifications(follower)).to eq([])
expect(follower.followed_dossiers.with_notifications).to eq([])
subject
expect(follower.followed_dossiers.with_notifications(follower)).to eq([dossier.reload])
expect(follower.followed_dossiers.with_notifications).to eq([dossier.reload])
end
end
end
@ -671,8 +671,8 @@ describe Instructeurs::DossiersController, type: :controller do
it 'updates the annotations' do
Timecop.travel(now + 1.hour)
expect(instructeur.followed_dossiers.with_notifications(instructeur)).to eq([])
expect(another_instructeur.followed_dossiers.with_notifications(instructeur)).to eq([dossier.reload])
expect(instructeur.followed_dossiers.with_notifications).to eq([])
expect(another_instructeur.followed_dossiers.with_notifications).to eq([dossier.reload])
end
end

View file

@ -693,9 +693,9 @@ describe Users::DossiersController, type: :controller do
end
it 'the follower has a notification' do
expect(instructeur.reload.followed_dossiers.with_notifications(instructeur)).to eq([])
expect(instructeur.reload.followed_dossiers.with_notifications).to eq([])
subject
expect(instructeur.reload.followed_dossiers.with_notifications(instructeur)).to eq([dossier.reload])
expect(instructeur.reload.followed_dossiers.with_notifications).to eq([dossier.reload])
end
end
@ -911,15 +911,15 @@ describe Users::DossiersController, type: :controller do
context 'notification' do
before 'instructeurs have no notification before the message' do
expect(instructeur_with_instant_message.followed_dossiers.with_notifications(instructeur_with_instant_message)).to eq([])
expect(instructeur_without_instant_message.followed_dossiers.with_notifications(instructeur_without_instant_message)).to eq([])
expect(instructeur_with_instant_message.followed_dossiers.with_notifications).to eq([])
expect(instructeur_without_instant_message.followed_dossiers.with_notifications).to eq([])
Timecop.travel(now + 1.day)
subject
end
it 'adds them a notification' do
expect(instructeur_with_instant_message.reload.followed_dossiers.with_notifications(instructeur_with_instant_message)).to eq([dossier.reload])
expect(instructeur_without_instant_message.reload.followed_dossiers.with_notifications(instructeur_without_instant_message)).to eq([dossier.reload])
expect(instructeur_with_instant_message.reload.followed_dossiers.with_notifications).to eq([dossier.reload])
expect(instructeur_without_instant_message.reload.followed_dossiers.with_notifications).to eq([dossier.reload])
end
end
end

View file

@ -105,7 +105,7 @@ describe Dossier do
create(:follow, dossier: dossier, instructeur: instructeur, messagerie_seen_at: 2.hours.ago)
end
subject { instructeur.followed_dossiers.with_notifications(instructeur) }
subject { instructeur.followed_dossiers.with_notifications }
context('without changes') do
it { is_expected.to eq [] }