Merge pull request #1488 from betagouv/remove_procedure_filter

Remove unused procedure_filter
This commit is contained in:
gregoirenovel 2018-02-26 17:41:46 +01:00 committed by GitHub
commit 7d5231b756
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 49 deletions

View file

@ -18,16 +18,6 @@ class Gestionnaire < ActiveRecord::Base
procedures.publiees_ou_archivees procedures.publiees_ou_archivees
end 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) def can_view_dossier?(dossier_id)
avis.where(dossier_id: dossier_id).any? || avis.where(dossier_id: dossier_id).any? ||
dossiers.where(id: dossier_id).any? dossiers.where(id: dossier_id).any?

View file

@ -0,0 +1,5 @@
class RemoveProcedureFilterFromGestionnaires < ActiveRecord::Migration[5.2]
def change
remove_column :gestionnaires, :procedure_filter, :integer, default: nil
end
end

View file

@ -5,8 +5,7 @@ describe Gestionnaire, type: :model do
let!(:procedure) { create :procedure, :published, administrateur: admin } let!(:procedure) { create :procedure, :published, administrateur: admin }
let!(:procedure_2) { create :procedure, :published, administrateur: admin } let!(:procedure_2) { create :procedure, :published, administrateur: admin }
let!(:procedure_3) { create :procedure, :published, administrateur: admin } let!(:procedure_3) { create :procedure, :published, administrateur: admin }
let(:gestionnaire) { create :gestionnaire, procedure_filter: procedure_filter, administrateurs: [admin] } let(:gestionnaire) { create :gestionnaire, administrateurs: [admin] }
let(:procedure_filter) { nil }
let!(:procedure_assign) { create :assign_to, gestionnaire: gestionnaire, procedure: procedure } let!(:procedure_assign) { create :assign_to, gestionnaire: gestionnaire, procedure: procedure }
before do before do
@ -136,43 +135,6 @@ describe Gestionnaire, type: :model do
end end
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 describe 'last_week_overview' do
let!(:gestionnaire2) { create(:gestionnaire) } let!(:gestionnaire2) { create(:gestionnaire) }
subject { gestionnaire2.last_week_overview } subject { gestionnaire2.last_week_overview }