Fix features dossiers edition spec

This commit is contained in:
Xavier J 2017-01-03 12:53:27 +01:00
parent 49d539b136
commit 8d4656cf89
4 changed files with 35 additions and 20 deletions

View file

@ -122,7 +122,7 @@ class Users::DescriptionController < UsersController
private
def check_autorisation_donnees
@dossier ||= current_user_dossier
@dossier = current_user_dossier
redirect_to url_for(users_dossier_path(@dossier.id)) if @dossier.autorisation_donnees.nil? || !@dossier.autorisation_donnees
end

View file

@ -19,6 +19,13 @@ FactoryGirl.define do
end
end
trait :for_individual do
after(:build) do |dossier, _evaluator|
dossier.individual = create :individual
dossier.save
end
end
trait :with_two_quartier_prioritaires do
after(:build) do |dossier, _evaluator|
dossier.quartier_prioritaires << create(:quartier_prioritaire)

View file

@ -0,0 +1,7 @@
FactoryGirl.define do
factory :individual do
nom 'Julien'
prenom 'Xavier'
birthdate '20/01/1991'
end
end

View file

@ -1,10 +1,10 @@
require 'spec_helper'
feature 'As a User I want to edit a dossier I own', js: true do
feature 'As a User I want to edit a dossier I own' do
let(:user) { create(:user) }
let(:procedure_for_individual) { create(:procedure, :published, :for_individual, :with_api_carto, :with_type_de_champ, :with_two_type_de_piece_justificative) }
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure_for_individual, user: user, state: 'initiated') }
let(:procedure_for_individual) { create(:procedure, :published, :for_individual, :with_type_de_champ, :with_two_type_de_piece_justificative) }
let!(:dossier) { create(:dossier, :with_entreprise, :for_individual, procedure: procedure_for_individual, user: user, autorisation_donnees: true, state: 'initiated') }
before "Create dossier and visit root path" do
login_as user, scope: :user
@ -15,30 +15,31 @@ feature 'As a User I want to edit a dossier I own', js: true do
scenario 'After sign_in, I can see dossiers "à traiter" (default), and other indexes' do
expect(page.find('#a_traiter')['class'] ).to eq('active procedure_list_element')
page.find_by_id('brouillon').trigger('click')
page.find_by_id('a_traiter').trigger('click')
page.find_by_id('valides').trigger('click')
page.find_by_id('en_instruction').trigger('click')
page.find_by_id('termine').trigger('click')
page.find_by_id('invite').trigger('click')
page.find_by_id('brouillon').click
page.find_by_id('a_traiter').click
page.find_by_id('valides').click
page.find_by_id('en_instruction').click
page.find_by_id('termine').click
page.find_by_id('invite').click
end
scenario 'Getting a dossier, I want to create a new message on' do
page.find_by_id('tr_dossier_' + Dossier.last.id.to_s).trigger('click')
scenario 'Getting a dossier, I want to create a new message on', js: true do
page.find_by_id('tr_dossier_' + Dossier.last.id.to_s).click
expect(page).to have_current_path(users_dossier_recapitulatif_path(Dossier.first.id.to_s), only_path: true)
page.find_by_id('open-message').trigger('click')
page.find_by_id('open-message').click
page.execute_script("$('#texte_commentaire').data('wysihtml5').editor.setValue('Contenu du nouveau message')")
page.find_by_id('save-message').trigger('click')
page.find_by_id('save-message').click
expect(page.find('.last-commentaire .content').text).to eq('Contenu du nouveau message')
end
scenario 'On the same dossier, I want to edit informations' do
page.find_by_id('tr_dossier_' + Dossier.last.id.to_s).trigger('click')
page.find_by_id('edit-dossier').trigger('click')
expect(page).to have_current_path(users_dossier_description_path(Dossier.first.id.to_s), only_path: true)
scenario 'On the same dossier, I want to edit informations', js: true do
page.find_by_id('tr_dossier_' + dossier.id.to_s).click
expect(page).to have_current_path(users_dossier_recapitulatif_path(dossier.id.to_s), only_path: true)
page.find_by_id('maj_infos').trigger('click')
expect(page).to have_current_path(users_dossier_description_path(dossier.id.to_s), only_path: true)
fill_in 'champs_1', with: 'Contenu du champ 1'
page.find_by_id('modification_terminee').trigger('click')
expect(page).to have_current_path(users_dossier_recapitulatif_path(Dossier.first.id.to_s), only_path: true)
page.find_by_id('modification_terminee').click
expect(page).to have_current_path(users_dossier_recapitulatif_path(dossier.id.to_s), only_path: true)
expect(page.find('#champ-1-value').text).to eq('Contenu du champ 1')
end
end