diff --git a/app/controllers/new_user/dossiers_controller.rb b/app/controllers/new_user/dossiers_controller.rb index 478378867..6f53d7295 100644 --- a/app/controllers/new_user/dossiers_controller.rb +++ b/app/controllers/new_user/dossiers_controller.rb @@ -26,9 +26,12 @@ module NewUser def show if dossier.brouillon? redirect_to modifier_dossier_path(dossier) - else + + elsif !Flipflop.new_dossier_details? redirect_to users_dossier_recapitulatif_path(dossier) end + + @dossier = dossier end def attestation diff --git a/app/views/new_user/dossiers/show.html.haml b/app/views/new_user/dossiers/show.html.haml new file mode 100644 index 000000000..439052790 --- /dev/null +++ b/app/views/new_user/dossiers/show.html.haml @@ -0,0 +1,3 @@ +%h1 + Dossier + = @dossier.id diff --git a/config/features.rb b/config/features.rb index f5bcb649f..383c95364 100644 --- a/config/features.rb +++ b/config/features.rb @@ -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? diff --git a/spec/controllers/new_user/dossiers_controller_spec.rb b/spec/controllers/new_user/dossiers_controller_spec.rb index 17f18cc1f..c62e00de9 100644 --- a/spec/controllers/new_user/dossiers_controller_spec.rb +++ b/spec/controllers/new_user/dossiers_controller_spec.rb @@ -479,7 +479,13 @@ describe NewUser::DossiersController, type: :controller do end describe '#show' do - before { sign_in(user) } + 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 @@ -489,7 +495,17 @@ describe NewUser::DossiersController, type: :controller do context 'when the dossier has been submitted' do let(:dossier) { create(:dossier, :en_construction, user: user) } - it { is_expected.to redirect_to(users_dossier_recapitulatif_path(dossier)) } + + 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 diff --git a/spec/features/new_user/dossier_details_spec.rb b/spec/features/new_user/dossier_details_spec.rb new file mode 100644 index 000000000..a82cd881b --- /dev/null +++ b/spec/features/new_user/dossier_details_spec.rb @@ -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 diff --git a/spec/views/new_user/dossiers/show.html.haml_spec.rb b/spec/views/new_user/dossiers/show.html.haml_spec.rb new file mode 100644 index 000000000..278315692 --- /dev/null +++ b/spec/views/new_user/dossiers/show.html.haml_spec.rb @@ -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