2015-11-17 18:21:03 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-04-12 17:13:31 +02:00
|
|
|
feature 'search file on gestionnaire backoffice' do
|
|
|
|
let(:administrateur) { create(:administrateur) }
|
|
|
|
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
|
2015-11-17 18:21:03 +01:00
|
|
|
|
2017-04-12 17:13:31 +02:00
|
|
|
before do
|
|
|
|
login_as gestionnaire, scope: :gestionnaire
|
|
|
|
end
|
2015-11-17 18:21:03 +01:00
|
|
|
|
2017-04-12 17:13:31 +02:00
|
|
|
context 'when gestionnaire is logged in' do
|
|
|
|
context 'when he click on search button' do
|
|
|
|
let(:terms) { '' }
|
|
|
|
let!(:procedure) { create(:procedure, administrateur: administrateur) }
|
2015-11-17 18:21:03 +01:00
|
|
|
|
2017-04-12 17:13:31 +02:00
|
|
|
before do
|
|
|
|
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
|
2016-05-20 15:39:17 +02:00
|
|
|
|
2017-04-12 17:13:31 +02:00
|
|
|
visit backoffice_dossiers_url
|
|
|
|
page.find_by_id(:q).set terms
|
2017-04-12 11:12:05 +02:00
|
|
|
page.find_by_id("search-button").click
|
2017-04-12 17:13:31 +02:00
|
|
|
end
|
2015-11-17 18:21:03 +01:00
|
|
|
|
2017-04-12 11:12:05 +02:00
|
|
|
it { expect(page).to have_css('#backoffice-search') }
|
2015-11-17 18:21:03 +01:00
|
|
|
|
2017-04-12 17:13:31 +02:00
|
|
|
context 'when terms input is empty' do
|
|
|
|
it { expect(page).to have_content('Aucun dossier') }
|
|
|
|
end
|
2015-11-17 18:21:03 +01:00
|
|
|
|
2017-04-12 17:13:31 +02:00
|
|
|
context 'when terms input is informed' do
|
|
|
|
let(:terms) { 'test' }
|
2015-11-17 18:21:03 +01:00
|
|
|
|
2017-04-12 17:13:31 +02:00
|
|
|
it 'terms stay in input after search' do
|
|
|
|
expect(page.find_by_id('q').value).to eq(terms)
|
|
|
|
end
|
2015-11-17 18:21:03 +01:00
|
|
|
|
2017-04-12 17:13:31 +02:00
|
|
|
context 'when terms input does not return result' do
|
|
|
|
it { expect(page).to have_content('Aucun dossier') }
|
|
|
|
end
|
2015-11-17 18:21:03 +01:00
|
|
|
|
2017-04-12 17:13:31 +02:00
|
|
|
context 'when terms input does return result' do
|
2017-06-12 16:12:03 +02:00
|
|
|
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') }
|
|
|
|
let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'initiated') }
|
2015-11-17 18:21:03 +01:00
|
|
|
|
2017-04-12 17:13:31 +02:00
|
|
|
let(:terms) { dossier.entreprise.raison_sociale }
|
2015-11-17 18:21:03 +01:00
|
|
|
|
2017-04-12 17:13:31 +02:00
|
|
|
it { expect(page).to have_content(dossier.entreprise.raison_sociale) }
|
2015-11-17 18:21:03 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-02-21 16:47:59 +01:00
|
|
|
end
|