2015-11-17 18:21:03 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
feature 'search file on gestionnaire backoffice' do
|
|
|
|
let(:administrateur) { create(:administrateur) }
|
2016-05-20 15:39:17 +02:00
|
|
|
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
|
2015-11-17 18:21:03 +01:00
|
|
|
|
|
|
|
before do
|
|
|
|
login_as gestionnaire, scope: :gestionnaire
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when gestionnaire is logged in' do
|
|
|
|
context 'when he click on search button' do
|
|
|
|
let(:terms) { '' }
|
2016-05-20 15:39:17 +02:00
|
|
|
let!(:procedure) { create(:procedure, administrateur: administrateur) }
|
2015-11-17 18:21:03 +01:00
|
|
|
|
|
|
|
before do
|
2016-05-20 15:39:17 +02:00
|
|
|
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
|
|
|
|
|
2015-12-02 18:03:52 +01:00
|
|
|
visit backoffice_dossiers_url
|
2015-11-26 15:47:31 +01:00
|
|
|
page.find_by_id(:q).set terms
|
2015-11-17 18:21:03 +01:00
|
|
|
page.find_by_id(:search_button).click
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(page).to have_css('#backoffice_search') }
|
|
|
|
|
|
|
|
context 'when terms input is empty' do
|
|
|
|
it { expect(page).to have_content('Aucun dossier trouvé') }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when terms input is informed' do
|
|
|
|
let(:terms) { 'test' }
|
|
|
|
|
|
|
|
it 'terms stay in input after search' do
|
2015-11-26 15:47:31 +01:00
|
|
|
expect(page.find_by_id('q').value).to eq(terms)
|
2015-11-17 18:21:03 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when terms input does not return result' do
|
|
|
|
it { expect(page).to have_content('Aucun dossier trouvé') }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when terms input does return result' do
|
2016-01-18 17:18:04 +01:00
|
|
|
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') }
|
|
|
|
let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'initiated', nom_projet: 'Projet de test') }
|
2015-11-17 18:21:03 +01:00
|
|
|
|
|
|
|
let(:terms) { dossier.nom_projet }
|
|
|
|
|
|
|
|
it { expect(page).not_to have_content('Projet de test') }
|
|
|
|
|
|
|
|
it { expect(page).to have_content(dossier.nom_projet) }
|
|
|
|
|
|
|
|
context "when terms is a file's id" do
|
|
|
|
let(:terms) { dossier.id }
|
|
|
|
|
|
|
|
it { expect(page).to have_content("Dossier N°#{dossier.id}") }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|