dossier spec: create a simple_procedure
factory
This commit is contained in:
parent
2b2dbcb112
commit
df2bbba201
3 changed files with 19 additions and 14 deletions
|
@ -22,6 +22,14 @@ FactoryBot.define do
|
|||
end
|
||||
end
|
||||
|
||||
factory :simple_procedure do
|
||||
after(:build) do |procedure, _evaluator|
|
||||
procedure.for_individual = true
|
||||
procedure.types_de_champ << create(:type_de_champ, libelle: 'Texte obligatoire', mandatory: true)
|
||||
procedure.publish!(generate(:published_path))
|
||||
end
|
||||
end
|
||||
|
||||
after(:build) do |procedure, _evaluator|
|
||||
if procedure.module_api_carto.nil?
|
||||
module_api_carto = create(:module_api_carto)
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
describe 'Dossier details:' do
|
||||
let(:user) { create(:user) }
|
||||
let(:simple_procedure) do
|
||||
tdcs = [create(:type_de_champ, libelle: 'texte obligatoire')]
|
||||
create(:procedure, :published, :for_individual, types_de_champ: tdcs)
|
||||
end
|
||||
let(:dossier) { create(:dossier, :en_construction, :for_individual, :with_commentaires, user: user, procedure: simple_procedure) }
|
||||
let(:procedure) { create(:simple_procedure) }
|
||||
let(:dossier) { create(:dossier, :en_construction, :for_individual, :with_commentaires, user: user, procedure: procedure) }
|
||||
|
||||
before do
|
||||
Flipflop::FeatureSet.current.test!.switch!(:new_dossier_details, true)
|
||||
|
@ -21,7 +18,7 @@ describe 'Dossier details:' do
|
|||
describe "the user can see the mean time they are expected to wait" do
|
||||
context "when the dossier is in construction" do
|
||||
before do
|
||||
other_dossier = create(:dossier, :accepte, :for_individual, procedure: simple_procedure, en_construction_at: 10.days.ago, en_instruction_at: Time.now)
|
||||
other_dossier = create(:dossier, :accepte, :for_individual, procedure: procedure, en_construction_at: 10.days.ago, en_instruction_at: Time.now)
|
||||
visit dossier_path(dossier)
|
||||
end
|
||||
|
||||
|
@ -29,10 +26,10 @@ describe 'Dossier details:' do
|
|||
end
|
||||
|
||||
context "when the dossier is in instruction" do
|
||||
let(:dossier) { create(:dossier, :en_instruction, :for_individual, :with_commentaires, user: user, procedure: simple_procedure) }
|
||||
let(:dossier) { create(:dossier, :en_instruction, :for_individual, :with_commentaires, user: user, procedure: procedure) }
|
||||
|
||||
before do
|
||||
other_dossier = create(:dossier, :accepte, :for_individual, procedure: simple_procedure, en_instruction_at: 2.months.ago, processed_at: Time.now)
|
||||
other_dossier = create(:dossier, :accepte, :for_individual, procedure: procedure, en_instruction_at: 2.months.ago, processed_at: Time.now)
|
||||
visit dossier_path(dossier)
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||
feature 'Invitations' do
|
||||
let(:user) { create(:user) }
|
||||
let(:invited_user) { create(:user, email: 'user_invite@exemple.fr') }
|
||||
let(:procedure) { create(:procedure, :published, :with_type_de_champ) }
|
||||
let(:procedure) { create(:simple_procedure) }
|
||||
let(:invite) { create(:invite_user, user: invited_user, dossier: dossier) }
|
||||
|
||||
context 'when the dossier is a brouillon' do
|
||||
|
@ -13,7 +13,7 @@ feature 'Invitations' do
|
|||
log_in(user)
|
||||
navigate_to_brouillon(dossier)
|
||||
|
||||
fill_in 'Libelle du champ', with: 'Some edited value'
|
||||
fill_in 'Texte obligatoire', with: 'Some edited value'
|
||||
send_invite_to "user_invite@exemple.fr"
|
||||
|
||||
expect(page).to have_current_path(brouillon_dossier_path(dossier))
|
||||
|
@ -21,7 +21,7 @@ feature 'Invitations' do
|
|||
expect(page).to have_text("user_invite@exemple.fr")
|
||||
|
||||
# Ensure unsaved edits to the form are not lost
|
||||
expect(page).to have_field('Libelle du champ', with: 'Some edited value')
|
||||
expect(page).to have_field('Texte obligatoire', with: 'Some edited value')
|
||||
end
|
||||
|
||||
context 'when inviting someone without an existing account' do
|
||||
|
@ -58,10 +58,10 @@ feature 'Invitations' do
|
|||
expect(page).to have_current_path(brouillon_dossier_path(dossier))
|
||||
expect(page).to have_no_selector('.button.invite-user-action')
|
||||
|
||||
fill_in 'Libelle du champ', with: 'Some edited value'
|
||||
fill_in 'Texte obligatoire', with: 'Some edited value'
|
||||
click_button 'Enregistrer le brouillon'
|
||||
expect(page).to have_text('Votre brouillon a bien été sauvegardé')
|
||||
expect(page).to have_field('Libelle du champ', with: 'Some edited value')
|
||||
expect(page).to have_field('Texte obligatoire', with: 'Some edited value')
|
||||
end
|
||||
|
||||
scenario 'an invited user cannot submit the draft' do
|
||||
|
@ -105,7 +105,7 @@ feature 'Invitations' do
|
|||
visit brouillon_dossier_path(dossier)
|
||||
|
||||
expect(page).to have_current_path(brouillon_dossier_path(dossier))
|
||||
fill_in "Libelle du champ", with: "Some edited value"
|
||||
fill_in "Texte obligatoire", with: "Some edited value"
|
||||
click_button "Enregistrer les modifications du dossier"
|
||||
|
||||
expect(page).to have_current_path(users_dossiers_invite_path(invite))
|
||||
|
|
Loading…
Reference in a new issue