Remove an unused Gestionnaire method and its tests

The tests would fail with rails 5.1
This commit is contained in:
gregoirenovel 2018-01-30 16:03:52 +01:00
parent 7ccae2c4f1
commit 2da724d681
2 changed files with 0 additions and 53 deletions

View file

@ -51,17 +51,6 @@ class Gestionnaire < ActiveRecord::Base
Notification.where(already_read: false, dossier_id: follows.pluck(:dossier_id)).order("updated_at DESC") Notification.where(already_read: false, dossier_id: follows.pluck(:dossier_id)).order("updated_at DESC")
end end
def notifications_for procedure
procedure_ids = followed_dossiers.pluck(:procedure_id)
if procedure_ids.include?(procedure.id)
return followed_dossiers.where(procedure_id: procedure.id).sum do |dossier|
dossier.notifications.where(already_read: false).count
end
end
0
end
def dossiers_with_notifications_count_for_procedure(procedure) def dossiers_with_notifications_count_for_procedure(procedure)
followed_dossiers_id = followed_dossiers.where(procedure: procedure).pluck(:id) followed_dossiers_id = followed_dossiers.where(procedure: procedure).pluck(:id)
Notification.unread.where(dossier_id: followed_dossiers_id).select(:dossier_id).distinct(:dossier_id).count Notification.unread.where(dossier_id: followed_dossiers_id).select(:dossier_id).distinct(:dossier_id).count

View file

@ -88,48 +88,6 @@ describe Gestionnaire, type: :model do
end end
end end
describe '#notifications_for' do
subject { gestionnaire.notifications_for procedure }
context 'when gestionnaire follow any dossier' do
it { is_expected.to eq 0 }
it { expect(gestionnaire.follows.count).to eq 0 }
it do
expect_any_instance_of(Dossier::ActiveRecord_AssociationRelation).not_to receive(:sum)
subject
end
end
context 'when gestionnaire follow any dossier into the procedure past in params' do
before do
create :follow, gestionnaire: gestionnaire, dossier: create(:dossier, procedure: procedure_2)
end
it { is_expected.to eq 0 }
it { expect(gestionnaire.follows.count).to eq 1 }
it do
expect_any_instance_of(Dossier::ActiveRecord_AssociationRelation).not_to receive(:sum)
subject
end
end
context 'when gestionnaire follow a dossier with a notification into the procedure past in params' do
let(:dossier) { create(:dossier, procedure: procedure, state: 'en_construction') }
before do
create :follow, gestionnaire: gestionnaire, dossier: dossier
create :notification, dossier: dossier
end
it { is_expected.to eq 1 }
it { expect(gestionnaire.follows.count).to eq 1 }
it do
expect_any_instance_of(Dossier::ActiveRecord_AssociationRelation).to receive(:sum)
subject
end
end
end
describe '#procedure_filter' do describe '#procedure_filter' do
subject { gestionnaire.procedure_filter } subject { gestionnaire.procedure_filter }