[fix #1411] user: link new screen to the rest of the application
This commit is contained in:
parent
d702a0c083
commit
a0667f5ad9
14 changed files with 21 additions and 77 deletions
|
@ -23,7 +23,7 @@ module NewUser
|
|||
if @dossier.procedure.module_api_carto.use_api_carto
|
||||
redirect_to users_dossier_carte_path(@dossier.id)
|
||||
else
|
||||
redirect_to users_dossier_description_path(@dossier) # Simon should replace this with dossier_path when done
|
||||
redirect_to modifier_dossier_path(@dossier)
|
||||
end
|
||||
else
|
||||
flash.now.alert = @dossier.errors.full_messages
|
||||
|
|
|
@ -24,10 +24,7 @@ class Users::CarteController < UsersController
|
|||
|
||||
dossier.update_attributes(json_latlngs: params[:json_latlngs])
|
||||
|
||||
controller = :recapitulatif
|
||||
controller = :description if dossier.brouillon?
|
||||
|
||||
redirect_to url_for(controller: controller, action: :show, dossier_id: params[:dossier_id])
|
||||
redirect_to modifier_dossier_path(dossier)
|
||||
end
|
||||
|
||||
def get_position
|
||||
|
|
|
@ -154,7 +154,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 url_for(controller: :description, action: :show, dossier_id: @facade.dossier.id)
|
||||
redirect_to modifier_dossier_path(@facade.dossier)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,14 +16,6 @@ class DossierDecorator < Draper::Decorator
|
|||
DossierDecorator.case_state_fr state
|
||||
end
|
||||
|
||||
def url(gestionnaire_signed_in)
|
||||
if brouillon?
|
||||
users_dossier_description_path(id)
|
||||
else
|
||||
users_dossier_recapitulatif_path(id)
|
||||
end
|
||||
end
|
||||
|
||||
def self.case_state_fr state = self.state
|
||||
h.t("activerecord.attributes.dossier.state.#{state}")
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
- if !@facade.dossier.read_only?
|
||||
- if user_signed_in? && (@facade.dossier.owner?(current_user.email) || @facade.dossier.invite_by_user?(current_user.email))
|
||||
%a#maj_infos.action{ href: "/users/dossiers/#{@facade.dossier.id}/description" }
|
||||
= link_to modifier_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
|
||||
= "éditer".upcase
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
- if champ.type_champ == 'dossier_link'
|
||||
- dossier = Dossier.includes(:procedure).find_by(id: champ.decorate.value)
|
||||
- if dossier
|
||||
= link_to("Dossier #{dossier.id}", dossier.decorate.url(gestionnaire_signed_in?), target: '_blank')
|
||||
= link_to("Dossier #{dossier.id}", modifier_dossier_path(dossier), target: '_blank')
|
||||
%br
|
||||
= sanitize(dossier.text_summary)
|
||||
- else
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
- dossier_url = users_dossiers_invite_path(id: invite.id) if invite.present?
|
||||
- if invite.nil?
|
||||
- dossier_url = users_dossier_recapitulatif_path(dossier) if !dossier.brouillon?
|
||||
- dossier_url = users_dossier_description_path(dossier) if dossier.brouillon?
|
||||
- dossier_url = modifier_dossier_path(dossier) if dossier.brouillon?
|
||||
|
||||
%tr{ id: "tr_dossier_#{dossier.id}", 'data-dossier_url' => dossier_url }
|
||||
%td.center
|
||||
|
|
|
@ -81,7 +81,7 @@ describe NewUser::DossiersController, type: :controller do
|
|||
let(:dossier_params) { { autorisation_donnees: true } }
|
||||
|
||||
it do
|
||||
expect(response).to redirect_to(users_dossier_description_path(dossier))
|
||||
expect(response).to redirect_to(modifier_dossier_path(dossier))
|
||||
end
|
||||
|
||||
context 'on a procedure with carto' do
|
||||
|
|
|
@ -59,21 +59,14 @@ shared_examples 'carte_controller_spec' do
|
|||
end
|
||||
|
||||
describe 'POST #save' do
|
||||
context 'Aucune localisation n\'a jamais été enregistrée' do
|
||||
it do
|
||||
post :save, params: { dossier_id: dossier.id, json_latlngs: '' }
|
||||
expect(response).to redirect_to("/users/dossiers/#{dossier.id}/description")
|
||||
end
|
||||
end
|
||||
|
||||
context 'En train de modifier la localisation' do
|
||||
let(:dossier) { create(:dossier, state: 'en_construction') }
|
||||
before do
|
||||
post :save, params: { dossier_id: dossier.id, json_latlngs: '' }
|
||||
end
|
||||
|
||||
it 'Redirection vers la page récapitulatif' do
|
||||
expect(response).to redirect_to("/users/dossiers/#{dossier.id}/recapitulatif")
|
||||
it 'Redirection vers le formulaire de la procedure' do
|
||||
expect(response).to redirect_to(modifier_dossier_path(dossier))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -398,7 +398,7 @@ describe Users::DossiersController, type: :controller do
|
|||
|
||||
context 'procedure not use api carto' do
|
||||
it 'redirects to demande' do
|
||||
expect(response).to redirect_to(controller: :description, action: :show, dossier_id: dossier.id)
|
||||
expect(response).to redirect_to(modifier_dossier_path(dossier))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -52,30 +52,4 @@ describe DossierDecorator do
|
|||
expect(subject).to eq('Refusé')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#url' do
|
||||
context "when a gestionnaire is not signed_in" do
|
||||
context "when the dossier is in brouillon state" do
|
||||
before do
|
||||
dossier.state = 'brouillon'
|
||||
dossier.save
|
||||
end
|
||||
|
||||
subject { super().url(false) }
|
||||
|
||||
it { is_expected.to eq("/users/dossiers/#{dossier.id}/description") }
|
||||
end
|
||||
|
||||
context "when the dossier is not in brouillon state" do
|
||||
before do
|
||||
dossier.state = 'en_construction'
|
||||
dossier.save
|
||||
end
|
||||
|
||||
subject { super().url(false) }
|
||||
|
||||
it { is_expected.to eq("/users/dossiers/#{dossier.id}/recapitulatif") }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -63,13 +63,13 @@ feature 'user path for dossier creation' do
|
|||
page.check('dossier_autorisation_donnees')
|
||||
page.find_by_id('etape_suivante').click
|
||||
end
|
||||
scenario 'user is on description page' do
|
||||
expect(page).to have_css('#description-page')
|
||||
scenario 'user is on edition page' do
|
||||
expect(page).to have_current_path(modifier_dossier_path(Dossier.last))
|
||||
end
|
||||
context 'user fill and validate description page' do
|
||||
before do
|
||||
page.find_by_id("champs_#{Dossier.last.champs.first.id}").set 'Mon super projet'
|
||||
page.find_by_id('suivant').click
|
||||
page.find_by_id("dossier_champs_attributes_0_value").set 'Mon super projet'
|
||||
click_on 'Soumettre le dossier'
|
||||
end
|
||||
scenario 'user is on recap page' do
|
||||
expect(page).to have_css('#users-recapitulatif-dossier-show')
|
||||
|
|
|
@ -28,13 +28,9 @@ 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(users_dossier_description_path(procedure_for_individual.dossiers.last.id))
|
||||
fill_in "champs_#{procedure_for_individual.dossiers.last.champs.first.id}", with: 'contenu du champ 1'
|
||||
find(:css, '[name=submit_action]').set('nouveaux')
|
||||
click_button('suivant')
|
||||
expect(page).to have_current_path(modifier_dossier_path(procedure_for_individual.dossiers.last))
|
||||
|
||||
expect(user.dossiers.first.individual.birthdate).to eq("1987-10-14")
|
||||
expect(page).to have_current_path(users_dossier_recapitulatif_path(procedure_for_individual.dossiers.last.id.to_s))
|
||||
end
|
||||
|
||||
scenario "with a basic text input field for birthdate (type='date' unsupported)" do
|
||||
|
@ -44,12 +40,9 @@ 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')
|
||||
|
||||
fill_in "champs_#{procedure_for_individual.dossiers.last.champs.first.id}", with: 'contenu du champ 1'
|
||||
find(:css, '[name=submit_action]').set('nouveaux')
|
||||
page.find_by_id('suivant').click
|
||||
expect(page).to have_current_path(modifier_dossier_path(procedure_for_individual.dossiers.last))
|
||||
|
||||
expect(user.dossiers.first.individual.birthdate).to eq("1987-10-14")
|
||||
expect(page).to have_current_path(users_dossier_recapitulatif_path(procedure_for_individual.dossiers.last.id.to_s))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -59,15 +52,12 @@ feature 'As a User I wanna create a dossier' do
|
|||
scenario "no need for birthday" do
|
||||
click_button('Continuer')
|
||||
|
||||
expect(page).to have_current_path(users_dossier_carte_path(procedure_for_individual.dossiers.last.id.to_s))
|
||||
expect(page).to have_current_path(users_dossier_carte_path(procedure_for_individual.dossiers.last))
|
||||
click_button('Etape suivante')
|
||||
|
||||
fill_in "champs_#{procedure_for_individual.dossiers.last.champs.first.id}", with: 'contenu du champ 1'
|
||||
find(:css, '[name=submit_action]').set('nouveaux')
|
||||
click_button('suivant')
|
||||
expect(page).to have_current_path(modifier_dossier_path(procedure_for_individual.dossiers.last))
|
||||
|
||||
expect(user.dossiers.first.individual.birthdate).to eq(nil)
|
||||
expect(page).to have_current_path(users_dossier_recapitulatif_path(procedure_for_individual.dossiers.last.id.to_s))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -92,9 +82,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
|
||||
fill_in "champs_#{procedure_with_siret.dossiers.last.champs.first.id}", with: 'contenu du champ 1'
|
||||
page.find_by_id('suivant').click
|
||||
expect(page).to have_current_path(users_dossier_recapitulatif_path(procedure_with_siret.dossiers.last.id.to_s))
|
||||
expect(page).to have_current_path(modifier_dossier_path(procedure_with_siret.dossiers.last))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,8 +30,8 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
|
|||
expect(rendered).to have_css('#maj_infos')
|
||||
end
|
||||
|
||||
it 'le lien vers description est correct' do
|
||||
expect(rendered).to have_selector("a[id=maj_infos][href='/users/dossiers/#{dossier_id}/description']")
|
||||
it 'le lien vers l édition est correct' do
|
||||
expect(rendered).to have_selector("a[id=maj_infos][href='/dossiers/#{dossier_id}/modifier']")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue