This commit is contained in:
Kara Diaby 2023-03-02 22:07:44 +01:00
parent cb0417aad4
commit 4ea7bb2f1c

View file

@ -176,11 +176,21 @@ describe Administrateurs::ProceduresController, type: :controller do
end end
context 'with specific tag' do context 'with specific tag' do
let!(:tag_procedure) { create(:procedure, :published, tags: ['environnement']) } let!(:tags_procedure) { create(:procedure, :published, tags: ['environnement', 'diplomatie']) }
it 'returns procedures with specific tag' do it 'returns procedure who contains at least one tag included in params' do
get :all, params: { tag: 'environnement' } get :all, params: { tags: ['environnement'] }
expect(assigns(:procedures).any? { |p| p.id == tag_procedure.id }).to be_truthy expect(assigns(:procedures).any? { |p| p.id == tags_procedure.id }).to be_truthy
end
it 'returns procedures who contains all tags included in params' do
get :all, params: { tags: ['environnement', 'diplomatie'] }
expect(assigns(:procedures).any? { |p| p.id == tags_procedure.id }).to be_truthy
end
it 'does not returns the procedure' do
get :all, params: { tags: ['environnement', 'diplomatie', 'football'] }
expect(assigns(:procedures).any? { |p| p.id == tags_procedure.id }).to be_falsey
end end
end end