demarches-normaliennes/spec/features/users/list_dossiers_spec.rb

43 lines
1.5 KiB
Ruby
Raw Normal View History

require 'spec_helper'
feature 'user access to the list of his dossier' do
let(:user) { create(:user) }
let!(:last_updated_dossier) { create(:dossier, :with_entreprise, user: user, state: 'replied')}
let!(:dossier1) { create(:dossier, :with_entreprise, user: user, state: 'replied') }
let!(:dossier2) { create(:dossier, :with_entreprise) }
2015-11-20 17:50:54 +01:00
before do
2016-08-22 16:10:48 +02:00
dossier1.update_column(:updated_at, "19/07/2052 15:35".to_time)
2016-08-30 11:18:43 +02:00
dossier1.procedure.update_column(:libelle, 'PLOP')
last_updated_dossier.procedure.update_column(:libelle, 'PLIP')
2016-02-01 17:16:00 +01:00
visit new_user_session_path
within('#new_user') do
page.find_by_id('user_email').set user.email
page.find_by_id('user_password').set user.password
page.click_on 'Se connecter'
end
end
scenario '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)
end
scenario '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)
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
2016-11-08 15:13:40 +01:00
context 'when user clicks on a projet in list', js: true do
before do
2016-11-08 15:13:40 +01:00
page.find("#tr_dossier_#{dossier1.id}").click
end
scenario 'user is redirected to dossier page' do
expect(page).to have_css('#recap_dossier')
end
end
end