DossierController#modifier → #brouillon
This commit is contained in:
parent
075a28d36a
commit
5ac8117c69
26 changed files with 52 additions and 52 deletions
|
@ -4,8 +4,8 @@ module NewUser
|
|||
|
||||
helper_method :new_demarche_url
|
||||
|
||||
before_action :ensure_ownership!, except: [:index, :show, :demande, :messagerie, :modifier, :update, :recherche]
|
||||
before_action :ensure_ownership_or_invitation!, only: [:show, :demande, :messagerie, :modifier, :update, :create_commentaire]
|
||||
before_action :ensure_ownership!, except: [:index, :show, :demande, :messagerie, :brouillon, :update, :recherche]
|
||||
before_action :ensure_ownership_or_invitation!, only: [:show, :demande, :messagerie, :brouillon, :update, :create_commentaire]
|
||||
before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update]
|
||||
before_action :forbid_invite_submission!, only: [:update]
|
||||
|
||||
|
@ -25,7 +25,7 @@ module NewUser
|
|||
|
||||
def show
|
||||
if dossier.brouillon?
|
||||
redirect_to modifier_dossier_path(dossier)
|
||||
redirect_to brouillon_dossier_path(dossier)
|
||||
|
||||
elsif !Flipflop.new_dossier_details?
|
||||
redirect_to users_dossier_recapitulatif_path(dossier)
|
||||
|
@ -64,7 +64,7 @@ module NewUser
|
|||
if @dossier.procedure.module_api_carto.use_api_carto
|
||||
redirect_to users_dossier_carte_path(@dossier.id)
|
||||
else
|
||||
redirect_to modifier_dossier_path(@dossier)
|
||||
redirect_to brouillon_dossier_path(@dossier)
|
||||
end
|
||||
else
|
||||
flash.now.alert = @dossier.errors.full_messages
|
||||
|
@ -72,7 +72,7 @@ module NewUser
|
|||
end
|
||||
end
|
||||
|
||||
def modifier
|
||||
def brouillon
|
||||
@dossier = dossier_with_champs
|
||||
|
||||
# TODO: remove when the champs are unifed
|
||||
|
@ -104,10 +104,10 @@ module NewUser
|
|||
|
||||
if errors.present?
|
||||
flash.now.alert = errors
|
||||
render :modifier
|
||||
render :brouillon
|
||||
elsif draft?
|
||||
flash.now.notice = 'Votre brouillon a bien été sauvegardé.'
|
||||
render :modifier
|
||||
render :brouillon
|
||||
elsif @dossier.can_transition_to_en_construction?
|
||||
@dossier.en_construction!
|
||||
NotificationMailer.send_initiated_notification(@dossier).deliver_later
|
||||
|
|
|
@ -25,7 +25,7 @@ class Users::CarteController < UsersController
|
|||
|
||||
dossier.update(json_latlngs: safe_json_latlngs)
|
||||
|
||||
redirect_to modifier_dossier_path(dossier)
|
||||
redirect_to brouillon_dossier_path(dossier)
|
||||
end
|
||||
|
||||
def get_position
|
||||
|
|
|
@ -10,7 +10,7 @@ class Users::Dossiers::InvitesController < UsersController
|
|||
@facade = InviteDossierFacades.new params[:id].to_i, current_user.email
|
||||
|
||||
if @facade.dossier.brouillon?
|
||||
redirect_to modifier_dossier_path(@facade.dossier)
|
||||
redirect_to brouillon_dossier_path(@facade.dossier)
|
||||
else
|
||||
render 'users/recapitulatif/show'
|
||||
end
|
||||
|
|
|
@ -142,7 +142,7 @@ class Users::DossiersController < UsersController
|
|||
if @facade.dossier.procedure.module_api_carto.use_api_carto
|
||||
redirect_to url_for(controller: :carte, action: :show, dossier_id: @facade.dossier.id)
|
||||
else
|
||||
redirect_to modifier_dossier_path(@facade.dossier)
|
||||
redirect_to brouillon_dossier_path(@facade.dossier)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ module DossierHelper
|
|||
|
||||
def url_for_dossier(dossier)
|
||||
if dossier.brouillon?
|
||||
modifier_dossier_path(dossier)
|
||||
brouillon_dossier_path(dossier)
|
||||
else
|
||||
users_dossier_recapitulatif_path(dossier)
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
- if !@facade.dossier.read_only?
|
||||
- if user_signed_in? && (current_user.owns_or_invite?(@facade.dossier))
|
||||
= link_to modifier_dossier_path(@facade.dossier), class: 'action', id: 'maj_infos' do
|
||||
= link_to brouillon_dossier_path(@facade.dossier), class: 'action', id: 'maj_infos' do
|
||||
#edit-dossier.col-lg-2.col-md-2.col-sm-2.col-xs-2.action
|
||||
= "MODIFIER"
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
- if champ.type_champ == TypeDeChamp.type_champs.fetch(:dossier_link)
|
||||
- dossier = Dossier.includes(:procedure).find_by(id: champ.decorate.value)
|
||||
- if dossier
|
||||
= link_to("Dossier #{dossier.id}", modifier_dossier_path(dossier), target: '_blank')
|
||||
= link_to("Dossier #{dossier.id}", brouillon_dossier_path(dossier), target: '_blank')
|
||||
%br
|
||||
= sanitize(dossier.text_summary)
|
||||
- else
|
||||
|
|
|
@ -7,4 +7,4 @@
|
|||
|
||||
.container
|
||||
- if !@dossier.read_only?
|
||||
= link_to "Modifier le dossier", modifier_dossier_path(@dossier), class: 'button primary edit-form'
|
||||
= link_to "Modifier le dossier", brouillon_dossier_path(@dossier), class: 'button primary edit-form'
|
||||
|
|
|
@ -275,8 +275,8 @@ Rails.application.routes.draw do
|
|||
member do
|
||||
get 'identite'
|
||||
patch 'update_identite'
|
||||
get 'modifier'
|
||||
patch 'modifier', to: 'dossiers#update'
|
||||
get 'brouillon'
|
||||
patch 'modifier', to: 'dossiers#update', as: 'modifier'
|
||||
get 'merci'
|
||||
get 'demande'
|
||||
get 'messagerie'
|
||||
|
|
|
@ -69,14 +69,14 @@ describe InvitesController, type: :controller do
|
|||
|
||||
context 'when user has access to dossier' do
|
||||
before do
|
||||
request.env["HTTP_REFERER"] = "/dossiers/#{dossier.id}/modifier"
|
||||
request.env["HTTP_REFERER"] = "/dossiers/#{dossier.id}/brouillon"
|
||||
dossier.update(user: signed_in_profile)
|
||||
end
|
||||
|
||||
it { expect { subject }.to change(InviteUser, :count).by(1) }
|
||||
|
||||
it "redirects to the previous URL" do
|
||||
expect(subject).to redirect_to("/dossiers/#{dossier.id}/modifier")
|
||||
expect(subject).to redirect_to("/dossiers/#{dossier.id}/brouillon")
|
||||
end
|
||||
|
||||
context 'when email is assign to an user' do
|
||||
|
|
|
@ -174,7 +174,7 @@ describe NewUser::DossiersController, type: :controller do
|
|||
let(:dossier_params) { { autorisation_donnees: true } }
|
||||
|
||||
it do
|
||||
expect(response).to redirect_to(modifier_dossier_path(dossier))
|
||||
expect(response).to redirect_to(brouillon_dossier_path(dossier))
|
||||
end
|
||||
|
||||
context 'on a procedure with carto' do
|
||||
|
@ -208,14 +208,14 @@ describe NewUser::DossiersController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#modifier' do
|
||||
describe '#brouillon' do
|
||||
before { sign_in(user) }
|
||||
let!(:dossier) { create(:dossier, user: user, autorisation_donnees: true) }
|
||||
|
||||
subject { get :modifier, params: { id: dossier.id } }
|
||||
subject { get :brouillon, params: { id: dossier.id } }
|
||||
|
||||
context 'when autorisation_donnees is checked' do
|
||||
it { is_expected.to render_template(:modifier) }
|
||||
it { is_expected.to render_template(:brouillon) }
|
||||
end
|
||||
|
||||
context 'when autorisation_donnees is not checked' do
|
||||
|
@ -238,7 +238,7 @@ describe NewUser::DossiersController, type: :controller do
|
|||
let!(:dossier) { create(:dossier, user: user) }
|
||||
|
||||
it 'returns the edit page' do
|
||||
get :modifier, params: { id: dossier.id }
|
||||
get :brouillon, params: { id: dossier.id }
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
@ -318,7 +318,7 @@ describe NewUser::DossiersController, type: :controller do
|
|||
subject
|
||||
end
|
||||
|
||||
it { expect(response).to render_template(:modifier) }
|
||||
it { expect(response).to render_template(:brouillon) }
|
||||
it { expect(flash.alert).to eq(['nop']) }
|
||||
|
||||
it 'does not send an email' do
|
||||
|
@ -335,7 +335,7 @@ describe NewUser::DossiersController, type: :controller do
|
|||
subject
|
||||
end
|
||||
|
||||
it { expect(response).to render_template(:modifier) }
|
||||
it { expect(response).to render_template(:brouillon) }
|
||||
it { expect(flash.alert).to eq(['nop']) }
|
||||
end
|
||||
|
||||
|
@ -349,13 +349,13 @@ describe NewUser::DossiersController, type: :controller do
|
|||
subject
|
||||
end
|
||||
|
||||
it { expect(response).to render_template(:modifier) }
|
||||
it { expect(response).to render_template(:brouillon) }
|
||||
it { expect(flash.alert).to eq(['Le champ l doit être rempli.', 'pj']) }
|
||||
|
||||
context 'and the user saves a draft' do
|
||||
let(:payload) { submit_payload.merge(save_draft: true) }
|
||||
|
||||
it { expect(response).to render_template(:modifier) }
|
||||
it { expect(response).to render_template(:brouillon) }
|
||||
it { expect(flash.notice).to eq('Votre brouillon a bien été sauvegardé.') }
|
||||
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:brouillon)) }
|
||||
end
|
||||
|
@ -385,7 +385,7 @@ describe NewUser::DossiersController, type: :controller do
|
|||
subject
|
||||
end
|
||||
|
||||
it { expect(response).to render_template(:modifier) }
|
||||
it { expect(response).to render_template(:brouillon) }
|
||||
it { expect(flash.notice).to eq('Votre brouillon a bien été sauvegardé.') }
|
||||
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:brouillon)) }
|
||||
end
|
||||
|
@ -490,7 +490,7 @@ describe NewUser::DossiersController, type: :controller do
|
|||
|
||||
context 'when the dossier is a brouillon' do
|
||||
let(:dossier) { create(:dossier, user: user) }
|
||||
it { is_expected.to redirect_to(modifier_dossier_path(dossier)) }
|
||||
it { is_expected.to redirect_to(brouillon_dossier_path(dossier)) }
|
||||
end
|
||||
|
||||
context 'when the dossier has been submitted' do
|
||||
|
|
|
@ -105,7 +105,7 @@ shared_examples 'carte_controller_spec' do
|
|||
end
|
||||
|
||||
it 'Redirection vers le formulaire de la procedure' do
|
||||
expect(response).to redirect_to(modifier_dossier_path(dossier))
|
||||
expect(response).to redirect_to(brouillon_dossier_path(dossier))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ describe Users::Dossiers::InvitesController, type: :controller do
|
|||
let(:dossier) { create :dossier, state: Dossier.states.fetch(:brouillon) }
|
||||
|
||||
it { is_expected.to have_http_status(302) }
|
||||
it { is_expected.to redirect_to modifier_dossier_path(dossier) }
|
||||
it { is_expected.to redirect_to brouillon_dossier_path(dossier) }
|
||||
end
|
||||
|
||||
context 'and dossier is not a brouillon' do
|
||||
|
|
|
@ -355,7 +355,7 @@ describe Users::DossiersController, type: :controller do
|
|||
|
||||
context 'procedure not use api carto' do
|
||||
it 'redirects to demande' do
|
||||
expect(response).to redirect_to(modifier_dossier_path(dossier))
|
||||
expect(response).to redirect_to(brouillon_dossier_path(dossier))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ describe 'Dossier details:' do
|
|||
expect(page).to have_current_path(demande_dossier_path(dossier))
|
||||
click_on 'Modifier le dossier'
|
||||
|
||||
expect(page).to have_current_path(modifier_dossier_path(dossier))
|
||||
expect(page).to have_current_path(brouillon_dossier_path(dossier))
|
||||
fill_in('texte obligatoire', with: 'Nouveau texte')
|
||||
click_on 'Enregistrer les modifications du dossier'
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ feature 'The user' do
|
|||
fill_in('individual_nom', with: 'nom')
|
||||
check 'dossier_autorisation_donnees'
|
||||
click_on 'Continuer'
|
||||
expect(page).to have_current_path(modifier_dossier_path(user_dossier))
|
||||
expect(page).to have_current_path(brouillon_dossier_path(user_dossier))
|
||||
end
|
||||
|
||||
def select_date_and_time(date, field)
|
||||
|
|
|
@ -16,7 +16,7 @@ feature 'Invitations' do
|
|||
fill_in 'Libelle du champ', with: 'Some edited value'
|
||||
send_invite_to "user_invite@exemple.fr"
|
||||
|
||||
expect(page).to have_current_path(modifier_dossier_path(dossier))
|
||||
expect(page).to have_current_path(brouillon_dossier_path(dossier))
|
||||
expect(page).to have_text("Une invitation a été envoyée à user_invite@exemple.fr.")
|
||||
expect(page).to have_text("user_invite@exemple.fr")
|
||||
|
||||
|
@ -29,7 +29,7 @@ feature 'Invitations' do
|
|||
expect(page).to have_current_path(new_user_session_path)
|
||||
|
||||
submit_login_form(invited_user)
|
||||
expect(page).to have_current_path(modifier_dossier_path(dossier))
|
||||
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'
|
||||
|
@ -43,7 +43,7 @@ feature 'Invitations' do
|
|||
expect(page).to have_current_path(new_user_session_path)
|
||||
|
||||
submit_login_form(invited_user)
|
||||
expect(page).to have_current_path(modifier_dossier_path(dossier))
|
||||
expect(page).to have_current_path(brouillon_dossier_path(dossier))
|
||||
|
||||
expect(page).to have_button('Soumettre le dossier', disabled: true)
|
||||
expect(page).to have_selector('.invite-cannot-submit')
|
||||
|
@ -75,10 +75,10 @@ feature 'Invitations' do
|
|||
|
||||
# We should be able to just click() the link, but Capybara detects that the
|
||||
# enclosing div would be clicked instead.
|
||||
expect(page).to have_link("MODIFIER", href: modifier_dossier_path(dossier))
|
||||
visit modifier_dossier_path(dossier)
|
||||
expect(page).to have_link("MODIFIER", href: brouillon_dossier_path(dossier))
|
||||
visit brouillon_dossier_path(dossier)
|
||||
|
||||
expect(page).to have_current_path(modifier_dossier_path(dossier))
|
||||
expect(page).to have_current_path(brouillon_dossier_path(dossier))
|
||||
fill_in "Libelle du champ", with: "Some edited value"
|
||||
click_button "Enregistrer les modifications du dossier"
|
||||
|
||||
|
@ -105,7 +105,7 @@ feature 'Invitations' do
|
|||
def navigate_to_brouillon(dossier)
|
||||
expect(page).to have_current_path(dossiers_path)
|
||||
click_on(dossier.id)
|
||||
expect(page).to have_current_path(modifier_dossier_path(dossier))
|
||||
expect(page).to have_current_path(brouillon_dossier_path(dossier))
|
||||
end
|
||||
|
||||
def navigate_to_recapitulatif(dossier)
|
||||
|
|
|
@ -61,7 +61,7 @@ feature 'linked dropdown lists' do
|
|||
fill_in('individual_nom', with: 'nom')
|
||||
check 'dossier_autorisation_donnees'
|
||||
click_on 'Continuer'
|
||||
expect(page).to have_current_path(modifier_dossier_path(user_dossier))
|
||||
expect(page).to have_current_path(brouillon_dossier_path(user_dossier))
|
||||
end
|
||||
|
||||
def primary_id_for(libelle)
|
||||
|
|
|
@ -64,7 +64,7 @@ feature 'user path for dossier creation' do
|
|||
page.find_by_id('etape_suivante').click
|
||||
end
|
||||
scenario 'user is on edition page' do
|
||||
expect(page).to have_current_path(modifier_dossier_path(Dossier.last))
|
||||
expect(page).to have_current_path(brouillon_dossier_path(Dossier.last))
|
||||
end
|
||||
context 'user fill and validate description page' do
|
||||
before do
|
||||
|
|
|
@ -28,7 +28,7 @@ feature 'As a User I wanna create a dossier' do
|
|||
expect(page).to have_current_path(users_dossier_carte_path(procedure_for_individual.dossiers.last.id))
|
||||
click_button('Etape suivante')
|
||||
|
||||
expect(page).to have_current_path(modifier_dossier_path(procedure_for_individual.dossiers.last))
|
||||
expect(page).to have_current_path(brouillon_dossier_path(procedure_for_individual.dossiers.last))
|
||||
|
||||
expect(user.dossiers.first.individual.birthdate).to eq(Date.new(1987, 10, 14))
|
||||
end
|
||||
|
@ -40,7 +40,7 @@ feature 'As a User I wanna create a dossier' do
|
|||
expect(page).to have_current_path(users_dossier_carte_path(procedure_for_individual.dossiers.last.id.to_s))
|
||||
click_button('Etape suivante')
|
||||
|
||||
expect(page).to have_current_path(modifier_dossier_path(procedure_for_individual.dossiers.last))
|
||||
expect(page).to have_current_path(brouillon_dossier_path(procedure_for_individual.dossiers.last))
|
||||
|
||||
expect(user.dossiers.first.individual.birthdate).to eq(Date.new(1987, 10, 14))
|
||||
end
|
||||
|
@ -55,7 +55,7 @@ feature 'As a User I wanna create a dossier' do
|
|||
expect(page).to have_current_path(users_dossier_carte_path(procedure_for_individual.dossiers.last))
|
||||
click_button('Etape suivante')
|
||||
|
||||
expect(page).to have_current_path(modifier_dossier_path(procedure_for_individual.dossiers.last))
|
||||
expect(page).to have_current_path(brouillon_dossier_path(procedure_for_individual.dossiers.last))
|
||||
|
||||
expect(user.dossiers.first.individual.birthdate).to eq(nil)
|
||||
end
|
||||
|
@ -85,7 +85,7 @@ feature 'As a User I wanna create a dossier' do
|
|||
page.find_by_id('etape_suivante').click
|
||||
expect(page).to have_current_path(users_dossier_carte_path(procedure_with_siret.dossiers.last.id.to_s))
|
||||
page.find_by_id('etape_suivante').click
|
||||
expect(page).to have_current_path(modifier_dossier_path(procedure_with_siret.dossiers.last))
|
||||
expect(page).to have_current_path(brouillon_dossier_path(procedure_with_siret.dossiers.last))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,7 +31,7 @@ RSpec.describe DossierHelper, type: :helper do
|
|||
|
||||
context "when the dossier is in the brouillon state" do
|
||||
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:brouillon)) }
|
||||
it { is_expected.to eq "/dossiers/#{dossier.id}/modifier" }
|
||||
it { is_expected.to eq "/dossiers/#{dossier.id}/brouillon" }
|
||||
end
|
||||
|
||||
context "when the dossier is any other state" do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'new_user/dossiers/modifier.html.haml', type: :view do
|
||||
describe 'new_user/dossiers/brouillon.html.haml', type: :view do
|
||||
let(:procedure) { create(:procedure, :with_api_carto, :with_two_type_de_piece_justificative, :with_notice, for_individual: true) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, :with_service, state: Dossier.states.fetch(:brouillon), procedure: procedure) }
|
||||
let(:footer) { view.content_for(:footer) }
|
|
@ -21,7 +21,7 @@ describe 'new_user/dossiers/demande.html.haml', type: :view do
|
|||
end
|
||||
|
||||
context 'when the dossier is editable' do
|
||||
it { is_expected.to have_link('Modifier le dossier', href: modifier_dossier_path(dossier)) }
|
||||
it { is_expected.to have_link('Modifier le dossier', href: brouillon_dossier_path(dossier)) }
|
||||
end
|
||||
|
||||
context 'when the dossier is read-only' do
|
||||
|
|
|
@ -26,7 +26,7 @@ describe 'new_user/dossiers/index.html.haml', type: :view do
|
|||
dossier = user_dossiers.first
|
||||
expect(rendered).to have_text(dossier_brouillon.id)
|
||||
expect(rendered).to have_text(dossier_brouillon.procedure.libelle)
|
||||
expect(rendered).to have_link(dossier_brouillon.id, href: modifier_dossier_path(dossier_brouillon))
|
||||
expect(rendered).to have_link(dossier_brouillon.id, href: brouillon_dossier_path(dossier_brouillon))
|
||||
|
||||
expect(rendered).to have_text(dossier_en_construction.id)
|
||||
expect(rendered).to have_text(dossier_en_construction.procedure.libelle)
|
||||
|
|
|
@ -31,7 +31,7 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
|
|||
end
|
||||
|
||||
it 'le lien vers l édition est correct' do
|
||||
expect(rendered).to have_selector("a[id=maj_infos][href='/dossiers/#{dossier_id}/modifier']")
|
||||
expect(rendered).to have_selector("a[id=maj_infos][href='/dossiers/#{dossier_id}/brouillon']")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue