Merge pull request #2354 from betagouv/new-dossier-details-route
Nouvelle route pour les nouveaux détails d'un dossier
This commit is contained in:
commit
66598edfb9
7 changed files with 95 additions and 3 deletions
|
@ -4,8 +4,8 @@ module NewUser
|
|||
|
||||
helper_method :new_demarche_url
|
||||
|
||||
before_action :ensure_ownership!, except: [:index, :modifier, :update, :recherche]
|
||||
before_action :ensure_ownership_or_invitation!, only: [:modifier, :update]
|
||||
before_action :ensure_ownership!, except: [:index, :show, :modifier, :update, :recherche]
|
||||
before_action :ensure_ownership_or_invitation!, only: [:show, :modifier, :update]
|
||||
before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update]
|
||||
before_action :forbid_invite_submission!, only: [:update]
|
||||
|
||||
|
@ -23,6 +23,17 @@ module NewUser
|
|||
end
|
||||
end
|
||||
|
||||
def show
|
||||
if dossier.brouillon?
|
||||
redirect_to modifier_dossier_path(dossier)
|
||||
|
||||
elsif !Flipflop.new_dossier_details?
|
||||
redirect_to users_dossier_recapitulatif_path(dossier)
|
||||
end
|
||||
|
||||
@dossier = dossier
|
||||
end
|
||||
|
||||
def attestation
|
||||
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
|
||||
end
|
||||
|
|
3
app/views/new_user/dossiers/show.html.haml
Normal file
3
app/views/new_user/dossiers/show.html.haml
Normal file
|
@ -0,0 +1,3 @@
|
|||
%h1
|
||||
Dossier
|
||||
= @dossier.id
|
|
@ -17,6 +17,9 @@ Flipflop.configure do
|
|||
|
||||
feature :web_hook
|
||||
|
||||
feature :new_dossier_details,
|
||||
title: "Nouvelle page « Dossier »"
|
||||
|
||||
group :production do
|
||||
feature :remote_storage,
|
||||
default: Rails.env.production? || Rails.env.staging?
|
||||
|
|
|
@ -267,7 +267,7 @@ Rails.application.routes.draw do
|
|||
#
|
||||
|
||||
scope module: 'new_user' do
|
||||
resources :dossiers, only: [:index, :update] do
|
||||
resources :dossiers, only: [:index, :show, :update] do
|
||||
member do
|
||||
get 'identite'
|
||||
patch 'update_identite'
|
||||
|
|
|
@ -478,6 +478,37 @@ describe NewUser::DossiersController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#show' do
|
||||
let(:new_dossier_details_enabled) { false }
|
||||
|
||||
before do
|
||||
Flipflop::FeatureSet.current.test!.switch!(:new_dossier_details, new_dossier_details_enabled)
|
||||
sign_in(user)
|
||||
end
|
||||
|
||||
subject! { get(:show, params: { id: dossier.id }) }
|
||||
|
||||
context 'when the dossier is a brouillon' do
|
||||
let(:dossier) { create(:dossier, user: user) }
|
||||
it { is_expected.to redirect_to(modifier_dossier_path(dossier)) }
|
||||
end
|
||||
|
||||
context 'when the dossier has been submitted' do
|
||||
let(:dossier) { create(:dossier, :en_construction, user: user) }
|
||||
|
||||
context 'and the new dossier details page is disabled' do
|
||||
let(:new_dossier_details_enabled) { false }
|
||||
it { is_expected.to redirect_to(users_dossier_recapitulatif_path(dossier)) }
|
||||
end
|
||||
|
||||
context 'and the new dossier details page is enabled' do
|
||||
let(:new_dossier_details_enabled) { true }
|
||||
it { expect(assigns(:dossier)).to eq(dossier) }
|
||||
it { is_expected.to render_template(:show) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#ask_deletion' do
|
||||
before { sign_in(user) }
|
||||
|
||||
|
|
28
spec/features/new_user/dossier_details_spec.rb
Normal file
28
spec/features/new_user/dossier_details_spec.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
describe 'Dossier details:' do
|
||||
let(:user) { create(:user) }
|
||||
let(:dossier) { create(:dossier, :en_construction, user: user) }
|
||||
|
||||
before do
|
||||
Flipflop::FeatureSet.current.test!.switch!(:new_dossier_details, true)
|
||||
end
|
||||
|
||||
scenario 'the user can see the details of their dossier' do
|
||||
visit_dossier dossier
|
||||
|
||||
expect(page).to have_current_path(dossier_path(dossier))
|
||||
expect(page).to have_content(dossier.id)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def visit_dossier(dossier)
|
||||
visit dossier_path(dossier)
|
||||
|
||||
expect(page).to have_current_path(new_user_session_path)
|
||||
fill_in 'user_email', with: user.email
|
||||
fill_in 'user_password', with: user.password
|
||||
click_on 'Se connecter'
|
||||
|
||||
expect(page).to have_current_path(dossier_path(dossier))
|
||||
end
|
||||
end
|
16
spec/views/new_user/dossiers/show.html.haml_spec.rb
Normal file
16
spec/views/new_user/dossiers/show.html.haml_spec.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'new_user/dossiers/show.html.haml', type: :view do
|
||||
let(:dossier) { create(:dossier, :with_service, state: 'brouillon', procedure: create(:procedure)) }
|
||||
|
||||
before do
|
||||
sign_in dossier.user
|
||||
assign(:dossier, dossier)
|
||||
end
|
||||
|
||||
subject! { render }
|
||||
|
||||
it 'affiche les informations du dossier' do
|
||||
expect(rendered).to have_text("Dossier #{dossier.id}")
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue