Add a missing feature test for the linked dossier feature
This commit is contained in:
parent
b34bf4846c
commit
2b23d0d087
4 changed files with 35 additions and 5 deletions
|
@ -55,6 +55,17 @@ FactoryGirl.define do
|
|||
archived false
|
||||
end
|
||||
|
||||
trait :with_dossier_link do
|
||||
after(:create) do |dossier, _evaluator|
|
||||
linked_dossier = create(:dossier)
|
||||
type_de_champ = dossier.procedure.types_de_champ.find { |t| t.type_champ == 'dossier_link' }
|
||||
champ = dossier.champs.find { |c| c.type_de_champ == type_de_champ }
|
||||
|
||||
champ.value = linked_dossier.id
|
||||
champ.save!
|
||||
end
|
||||
end
|
||||
|
||||
trait :replied do
|
||||
state 'replied'
|
||||
end
|
||||
|
|
|
@ -61,6 +61,14 @@ FactoryGirl.define do
|
|||
end
|
||||
end
|
||||
|
||||
trait :with_dossier_link do
|
||||
after(:build) do |procedure, _evaluator|
|
||||
type_de_champ = create(:type_de_champ_public, :type_dossier_link)
|
||||
|
||||
procedure.types_de_champ << type_de_champ
|
||||
end
|
||||
end
|
||||
|
||||
trait :with_two_type_de_piece_justificative do
|
||||
after(:build) do |procedure, _evaluator|
|
||||
rib = create(:type_de_piece_justificative, :rib, order_place: 1)
|
||||
|
|
|
@ -9,5 +9,10 @@ FactoryGirl.define do
|
|||
trait :checkbox do
|
||||
type_champ 'checkbox'
|
||||
end
|
||||
|
||||
trait :type_dossier_link do
|
||||
libelle 'Référence autre dossier'
|
||||
type_champ 'dossier_link'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,8 +3,8 @@ require 'spec_helper'
|
|||
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_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') }
|
||||
let(:procedure_for_individual) { create(:procedure, :published, :for_individual, :with_type_de_champ, :with_two_type_de_piece_justificative, :with_dossier_link) }
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, :for_individual, :with_dossier_link, procedure: procedure_for_individual, user: user, autorisation_donnees: true, state: 'initiated') }
|
||||
|
||||
before "Create dossier and visit root path" do
|
||||
login_as user, scope: :user
|
||||
|
@ -23,7 +23,7 @@ feature 'As a User I want to edit a dossier I own' do
|
|||
end
|
||||
|
||||
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
|
||||
page.find_by_id('tr_dossier_' + dossier.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').click
|
||||
page.execute_script("$('#texte_commentaire').data('wysihtml5').editor.setValue('Contenu du nouveau message')")
|
||||
|
@ -34,12 +34,18 @@ feature 'As a User I want to edit a dossier I own' do
|
|||
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)
|
||||
|
||||
# Linked Dossier
|
||||
linked_dossier_id = dossier.champs.find { |c| c.type_de_champ.type_champ == 'dossier_link' }.value
|
||||
linked_dossier = Dossier.find(linked_dossier_id)
|
||||
expect(page).to have_content(linked_dossier.procedure.libelle)
|
||||
|
||||
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_#{dossier.champs.first.id.to_s}", with: 'Contenu du champ 1'
|
||||
fill_in "champs_#{dossier.champs.order(:id).first.id.to_s}", with: 'Contenu du champ 1'
|
||||
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-#{dossier.champs.first.id}-value").text).to eq('Contenu du champ 1')
|
||||
expect(page.find("#champ-#{dossier.champs.order(:id).first.id}-value").text).to eq('Contenu du champ 1')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue