2015-09-23 12:04:57 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-04-12 11:18:28 +02:00
|
|
|
describe 'user access to the list of his dossier' do
|
2015-09-23 12:04:57 +02:00
|
|
|
let(:user) { create(:user) }
|
2017-12-14 15:51:45 +01:00
|
|
|
let!(:last_updated_dossier) { create(:dossier, :with_entreprise, user: user, state: 'en_construction')}
|
|
|
|
let!(:dossier1) { create(:dossier, :with_entreprise, user: user, state: 'en_construction') }
|
2016-07-19 16:10:50 +02:00
|
|
|
let!(:dossier2) { create(:dossier, :with_entreprise) }
|
2017-12-14 15:51:45 +01:00
|
|
|
let!(:dossier_archived) { create(:dossier, :with_entreprise, user: user, state: 'en_construction') }
|
2015-11-20 17:50:54 +01:00
|
|
|
|
2015-09-23 12:04:57 +02:00
|
|
|
before do
|
2017-04-12 11:18:28 +02:00
|
|
|
last_updated_dossier.update_column(:updated_at, "19/07/2052 15:35".to_time)
|
2016-07-19 16:10:50 +02:00
|
|
|
|
2016-02-01 17:16:00 +01:00
|
|
|
visit new_user_session_path
|
2017-06-13 17:46:08 +02:00
|
|
|
within('#new_user') do
|
2015-10-07 12:01:05 +02:00
|
|
|
page.find_by_id('user_email').set user.email
|
|
|
|
page.find_by_id('user_password').set user.password
|
|
|
|
page.click_on 'Se connecter'
|
|
|
|
end
|
2015-09-23 12:04:57 +02:00
|
|
|
end
|
2017-04-12 11:18:28 +02:00
|
|
|
|
|
|
|
it 'the list of dossier is displayed' do
|
2016-08-30 11:18:43 +02:00
|
|
|
expect(page).to have_content(dossier1.procedure.libelle)
|
|
|
|
expect(page).not_to have_content(dossier2.procedure.libelle)
|
2015-09-23 12:04:57 +02:00
|
|
|
end
|
2015-09-25 10:26:50 +02:00
|
|
|
|
2017-04-12 11:18:28 +02:00
|
|
|
it 'the list must be order by last updated' do
|
2016-08-30 11:18:43 +02:00
|
|
|
expect(page.body).to match(/#{last_updated_dossier.procedure.libelle}.*#{dossier1.procedure.libelle}/m)
|
2015-09-25 10:26:50 +02:00
|
|
|
end
|
|
|
|
|
2017-04-12 11:18:28 +02:00
|
|
|
it 'should list archived dossier' do
|
|
|
|
expect(page).to have_content(dossier_archived.procedure.libelle)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'the state of dossier is displayed' do
|
2015-09-25 11:42:20 +02:00
|
|
|
expect(page).to have_css("#dossier_#{dossier1.id}_state")
|
|
|
|
end
|
|
|
|
|
2016-11-08 15:13:40 +01:00
|
|
|
context 'when user clicks on a projet in list', js: true do
|
2015-09-24 12:02:59 +02:00
|
|
|
before do
|
2016-11-08 15:13:40 +01:00
|
|
|
page.find("#tr_dossier_#{dossier1.id}").click
|
2015-09-24 12:02:59 +02:00
|
|
|
end
|
|
|
|
scenario 'user is redirected to dossier page' do
|
2017-04-12 11:12:05 +02:00
|
|
|
expect(page).to have_css('#users-recapitulatif-dossier-show')
|
2015-09-24 12:02:59 +02:00
|
|
|
end
|
|
|
|
end
|
2016-12-13 16:10:03 +01:00
|
|
|
end
|