2016-12-19 17:15:59 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-01-03 12:53:27 +01:00
|
|
|
feature 'As a User I want to edit a dossier I own' do
|
2016-12-19 17:15:59 +01:00
|
|
|
|
2016-12-20 11:58:17 +01:00
|
|
|
let(:user) { create(:user) }
|
2017-01-03 12:53:27 +01:00
|
|
|
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') }
|
2016-12-19 17:15:59 +01:00
|
|
|
|
2017-01-03 12:11:29 +01:00
|
|
|
before "Create dossier and visit root path" do
|
2016-12-20 11:58:17 +01:00
|
|
|
login_as user, scope: :user
|
|
|
|
visit root_path
|
2016-12-19 17:15:59 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'After sign_in, I can navigate through dossiers indexes and edit a dossier' do
|
|
|
|
|
|
|
|
scenario 'After sign_in, I can see dossiers "à traiter" (default), and other indexes' do
|
2017-04-12 11:12:05 +02:00
|
|
|
expect(page.find('#a_traiter')['class'] ).to eq('active procedure-list-element')
|
2017-01-03 12:53:27 +01:00
|
|
|
page.find_by_id('brouillon').click
|
|
|
|
page.find_by_id('a_traiter').click
|
|
|
|
page.find_by_id('en_instruction').click
|
|
|
|
page.find_by_id('termine').click
|
|
|
|
page.find_by_id('invite').click
|
2016-12-19 17:15:59 +01:00
|
|
|
end
|
|
|
|
|
2017-01-03 12:53:27 +01:00
|
|
|
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
|
2016-12-19 17:15:59 +01:00
|
|
|
expect(page).to have_current_path(users_dossier_recapitulatif_path(Dossier.first.id.to_s), only_path: true)
|
2017-01-03 12:53:27 +01:00
|
|
|
page.find_by_id('open-message').click
|
2016-12-19 17:15:59 +01:00
|
|
|
page.execute_script("$('#texte_commentaire').data('wysihtml5').editor.setValue('Contenu du nouveau message')")
|
2017-01-03 12:53:27 +01:00
|
|
|
page.find_by_id('save-message').click
|
2016-12-19 17:15:59 +01:00
|
|
|
expect(page.find('.last-commentaire .content').text).to eq('Contenu du nouveau message')
|
|
|
|
end
|
|
|
|
|
2017-01-03 12:53:27 +01:00
|
|
|
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)
|
2017-01-03 14:08:44 +01:00
|
|
|
fill_in "champs_#{dossier.champs.first.id.to_s}", with: 'Contenu du champ 1'
|
2017-01-03 12:53:27 +01:00
|
|
|
page.find_by_id('modification_terminee').click
|
|
|
|
expect(page).to have_current_path(users_dossier_recapitulatif_path(dossier.id.to_s), only_path: true)
|
2017-02-13 11:57:35 +01:00
|
|
|
expect(page.find("#champ-#{dossier.champs.first.id}-value").text).to eq('Contenu du champ 1')
|
2016-12-19 17:15:59 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|