Remove unused procedure_filter
This commit is contained in:
parent
8dfa8ebbbe
commit
2b6edc0fa4
3 changed files with 6 additions and 49 deletions
|
@ -18,16 +18,6 @@ class Gestionnaire < ActiveRecord::Base
|
|||
procedures.publiees_ou_archivees
|
||||
end
|
||||
|
||||
def procedure_filter
|
||||
procedure_id = self[:procedure_filter]
|
||||
if procedures.find_by(id: procedure_id).present?
|
||||
procedure_id
|
||||
else
|
||||
self.update_column(:procedure_filter, nil)
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def can_view_dossier?(dossier_id)
|
||||
avis.where(dossier_id: dossier_id).any? ||
|
||||
dossiers.where(id: dossier_id).any?
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class RemoveProcedureFilterFromGestionnaires < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
remove_column :gestionnaires, :procedure_filter, :integer, default: nil
|
||||
end
|
||||
end
|
|
@ -5,8 +5,7 @@ describe Gestionnaire, type: :model do
|
|||
let!(:procedure) { create :procedure, :published, administrateur: admin }
|
||||
let!(:procedure_2) { create :procedure, :published, administrateur: admin }
|
||||
let!(:procedure_3) { create :procedure, :published, administrateur: admin }
|
||||
let(:gestionnaire) { create :gestionnaire, procedure_filter: procedure_filter, administrateurs: [admin] }
|
||||
let(:procedure_filter) { nil }
|
||||
let(:gestionnaire) { create :gestionnaire, administrateurs: [admin] }
|
||||
let!(:procedure_assign) { create :assign_to, gestionnaire: gestionnaire, procedure: procedure }
|
||||
|
||||
before do
|
||||
|
@ -136,43 +135,6 @@ describe Gestionnaire, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#procedure_filter' do
|
||||
subject { gestionnaire.procedure_filter }
|
||||
|
||||
context 'when procedure_filter_id is nil' do
|
||||
it { is_expected.to eq nil }
|
||||
end
|
||||
|
||||
context 'when procedure_filter is not nil' do
|
||||
context 'when gestionnaire is assign_to the procedure filter id' do
|
||||
before do
|
||||
gestionnaire.update_column :procedure_filter, procedure.id
|
||||
end
|
||||
|
||||
it { expect(AssignTo.where(gestionnaire: gestionnaire, procedure: procedure).count).to eq 1 }
|
||||
it { is_expected.to eq procedure_assign.procedure.id }
|
||||
end
|
||||
|
||||
context 'when gestionnaire is not any more assign to the procedure filter id' do
|
||||
before do
|
||||
gestionnaire.update_column :procedure_filter, procedure_3.id
|
||||
end
|
||||
|
||||
it { expect(AssignTo.where(gestionnaire: gestionnaire, procedure: procedure_3).count).to eq 0 }
|
||||
it { is_expected.to be_nil }
|
||||
end
|
||||
|
||||
context "when procedure is hidden clear procedure_filter" do
|
||||
before do
|
||||
gestionnaire.update_column :procedure_filter, procedure_3.id
|
||||
procedure_3.hide!
|
||||
end
|
||||
|
||||
it { is_expected.to be_nil }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'last_week_overview' do
|
||||
let!(:gestionnaire2) { create(:gestionnaire) }
|
||||
subject { gestionnaire2.last_week_overview }
|
||||
|
|
Loading…
Reference in a new issue