2015-09-23 12:04:57 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
feature 'user access to the list of his dossier' do
|
|
|
|
|
|
|
|
let(:user) { create(:user) }
|
2015-09-25 10:26:50 +02:00
|
|
|
let!(:last_updated_dossier) { create(:dossier, :with_procedure, user: user)}
|
2015-09-24 12:02:59 +02:00
|
|
|
let!(:dossier1) { create(:dossier, :with_procedure, user: user, nom_projet: 'mon permier dossier') }
|
2015-09-24 11:45:28 +02:00
|
|
|
let!(:dossier2) { create(:dossier, :with_user, nom_projet: 'mon deuxième dossier') }
|
2015-09-23 12:04:57 +02:00
|
|
|
before do
|
2015-09-25 10:26:50 +02:00
|
|
|
last_updated_dossier.update_attributes(nom_projet: 'salut la compagnie')
|
2015-09-23 12:04:57 +02:00
|
|
|
visit root_path
|
|
|
|
page.find_by_id('user_email').set user.email
|
|
|
|
page.find_by_id('user_password').set user.password
|
|
|
|
page.click_on 'Se connecter'
|
|
|
|
end
|
|
|
|
scenario 'the list of dossier is displayed' do
|
|
|
|
expect(page).to have_content(dossier1.nom_projet)
|
2015-09-24 11:45:28 +02:00
|
|
|
expect(page).not_to have_content(dossier2.nom_projet)
|
2015-09-23 12:04:57 +02:00
|
|
|
end
|
2015-09-25 10:26:50 +02:00
|
|
|
|
|
|
|
scenario 'the list must be order by last updated' do
|
|
|
|
expect(page.body).to match(/#{last_updated_dossier.nom_projet}.*#{dossier1.nom_projet}/m)
|
|
|
|
end
|
|
|
|
|
2015-09-25 11:42:20 +02:00
|
|
|
scenario 'the state of dossier is displayed' do
|
|
|
|
expect(page).to have_css("#dossier_#{dossier1.id}_state")
|
|
|
|
end
|
|
|
|
|
2015-09-24 12:02:59 +02:00
|
|
|
context 'when user clicks on a projet in list' do
|
|
|
|
before do
|
|
|
|
page.click_on dossier1.nom_projet
|
|
|
|
end
|
|
|
|
scenario 'user is redirected to dossier page' do
|
|
|
|
expect(page).to have_css('#recap_dossier')
|
|
|
|
end
|
|
|
|
end
|
2015-09-23 12:04:57 +02:00
|
|
|
end
|