Merge branch 'dev'
This commit is contained in:
commit
0b1a143419
19 changed files with 73 additions and 171 deletions
|
@ -2,7 +2,7 @@ class Admin::ProceduresController < AdminController
|
|||
include SmartListing::Helper::ControllerExtensions
|
||||
helper SmartListing::Helper
|
||||
|
||||
before_action :retrieve_procedure, only: [:show, :edit]
|
||||
before_action :retrieve_procedure, only: [:show, :edit, :delete_logo, :delete_deliberation, :delete_notice]
|
||||
|
||||
def index
|
||||
@procedures = smart_listing_create :procedures,
|
||||
|
@ -252,31 +252,25 @@ class Admin::ProceduresController < AdminController
|
|||
end
|
||||
|
||||
def delete_logo
|
||||
procedure = Procedure.find(params[:id])
|
||||
|
||||
procedure.remove_logo!
|
||||
procedure.save
|
||||
@procedure.remove_logo!
|
||||
@procedure.save
|
||||
|
||||
flash.notice = 'le logo a bien été supprimé'
|
||||
redirect_to edit_admin_procedure_path(procedure)
|
||||
redirect_to edit_admin_procedure_path(@procedure)
|
||||
end
|
||||
|
||||
def delete_deliberation
|
||||
procedure = Procedure.find(params[:id])
|
||||
|
||||
procedure.deliberation.purge_later
|
||||
@procedure.deliberation.purge_later
|
||||
|
||||
flash.notice = 'la délibération a bien été supprimée'
|
||||
redirect_to edit_admin_procedure_path(procedure)
|
||||
redirect_to edit_admin_procedure_path(@procedure)
|
||||
end
|
||||
|
||||
def delete_notice
|
||||
procedure = Procedure.find(params[:id])
|
||||
|
||||
procedure.notice.purge_later
|
||||
@procedure.notice.purge_later
|
||||
|
||||
flash.notice = 'la notice a bien été supprimée'
|
||||
redirect_to edit_admin_procedure_path(procedure)
|
||||
redirect_to edit_admin_procedure_path(@procedure)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -28,9 +28,6 @@ module NewUser
|
|||
def show
|
||||
if dossier.brouillon?
|
||||
redirect_to brouillon_dossier_path(dossier)
|
||||
|
||||
elsif !Flipflop.new_dossier_details?
|
||||
redirect_to users_dossier_recapitulatif_path(dossier)
|
||||
end
|
||||
|
||||
@dossier = dossier
|
||||
|
@ -125,15 +122,7 @@ module NewUser
|
|||
flash.now.alert = errors
|
||||
render :modifier
|
||||
else
|
||||
if Flipflop.new_dossier_details?
|
||||
redirect_to demande_dossier_path(@dossier)
|
||||
else
|
||||
if current_user.owns?(dossier)
|
||||
redirect_to users_dossier_recapitulatif_path(@dossier)
|
||||
else
|
||||
redirect_to users_dossiers_invite_path(@dossier.invite_for_user(current_user))
|
||||
end
|
||||
end
|
||||
redirect_to demande_dossier_path(@dossier)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -14,10 +14,8 @@ class Users::Dossiers::InvitesController < UsersController
|
|||
|
||||
if @facade.dossier.brouillon?
|
||||
redirect_to brouillon_dossier_path(@facade.dossier)
|
||||
elsif Flipflop.new_dossier_details?
|
||||
return redirect_to dossier_path(@facade.dossier)
|
||||
else
|
||||
render 'users/recapitulatif/show'
|
||||
return redirect_to dossier_path(@facade.dossier)
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
flash.alert = t('errors.messages.dossier_not_found')
|
||||
|
|
|
@ -4,11 +4,7 @@ class Users::RecapitulatifController < UsersController
|
|||
end
|
||||
|
||||
def show
|
||||
if Flipflop.new_dossier_details?
|
||||
redirect_to dossier_url(current_user_dossier)
|
||||
else
|
||||
create_dossier_facade
|
||||
end
|
||||
redirect_to dossier_url(current_user_dossier)
|
||||
end
|
||||
|
||||
def initiate
|
||||
|
|
|
@ -18,10 +18,8 @@ module DossierHelper
|
|||
def url_for_dossier(dossier)
|
||||
if dossier.brouillon?
|
||||
brouillon_dossier_path(dossier)
|
||||
elsif Flipflop.new_dossier_details?
|
||||
dossier_path(dossier)
|
||||
else
|
||||
users_dossier_recapitulatif_path(dossier)
|
||||
dossier_path(dossier)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
%br
|
||||
%br
|
||||
= f.submit 'Valider', class: 'btn btn-info', style: 'float: left;', id: 'add-gestionnaire-email'
|
||||
%br
|
||||
.alert.alert-info
|
||||
Astuce : ajoutez votre adresse email pour tester la partie instructeur.
|
||||
.col-xs-6
|
||||
%h3.text-success Affectés
|
||||
= smart_listing_render :instructeurs_assign
|
||||
|
|
|
@ -20,10 +20,7 @@
|
|||
= link_to service.email, "mailto:#{service.email}"
|
||||
- else
|
||||
Directement
|
||||
- if Flipflop.new_dossier_details?
|
||||
= link_to "par la messagerie", messagerie_dossier_path(dossier)
|
||||
- else
|
||||
= link_to "par la messagerie", users_dossier_recapitulatif_path(dossier)
|
||||
= link_to "par la messagerie", messagerie_dossier_path(dossier)
|
||||
|
||||
%p
|
||||
Par téléphone :
|
||||
|
|
|
@ -18,7 +18,4 @@
|
|||
%b échanger avec un instructeur
|
||||
lors de sa construction et de son instruction
|
||||
|
||||
- if Flipflop.new_dossier_details?
|
||||
= link_to 'Accéder à votre dossier', dossier_path(@dossier), class: 'button large primary'
|
||||
- else
|
||||
= link_to 'Accéder à votre dossier', users_dossier_recapitulatif_path(@dossier), class: 'button large primary'
|
||||
= link_to 'Accéder à votre dossier', dossier_path(@dossier), class: 'button large primary'
|
||||
|
|
|
@ -19,9 +19,6 @@ Flipflop.configure do
|
|||
feature :publish_draft
|
||||
feature :support_form
|
||||
|
||||
feature :new_dossier_details,
|
||||
title: "Nouvelle page « Dossier »"
|
||||
|
||||
group :production do
|
||||
feature :remote_storage,
|
||||
default: ENV['FOG_ENABLED'] == 'enabled'
|
||||
|
|
|
@ -713,15 +713,53 @@ describe Admin::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
describe "DELETE #delete_deliberation" do
|
||||
let(:procedure) { create(:procedure, :with_deliberation) }
|
||||
context "with a demarche the admin owns" do
|
||||
let(:procedure) { create(:procedure, :with_deliberation, administrateur: admin) }
|
||||
|
||||
before do
|
||||
delete :delete_deliberation, params: { id: procedure.id }
|
||||
procedure.reload
|
||||
before do
|
||||
delete :delete_deliberation, params: { id: procedure.id }
|
||||
procedure.reload
|
||||
end
|
||||
|
||||
it { expect(procedure.deliberation.attached?).to eq(false) }
|
||||
it { expect(response).to redirect_to(edit_admin_procedure_path(procedure)) }
|
||||
end
|
||||
|
||||
it { expect(procedure.deliberation.attached?).to eq(false) }
|
||||
it { expect(response).to redirect_to(edit_admin_procedure_path(procedure)) }
|
||||
context "with a demarche the admin does not own" do
|
||||
let(:procedure) { create(:procedure, :with_deliberation) }
|
||||
|
||||
before do
|
||||
delete :delete_deliberation, params: { id: procedure.id }
|
||||
procedure.reload
|
||||
end
|
||||
|
||||
it { expect(response.status).to eq(404) }
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE #delete_notice" do
|
||||
context "with a demarche the admin owns" do
|
||||
let(:procedure) { create(:procedure, :with_notice, administrateur: admin) }
|
||||
|
||||
before do
|
||||
delete :delete_notice, params: { id: procedure.id }
|
||||
procedure.reload
|
||||
end
|
||||
|
||||
it { expect(procedure.notice.attached?).to eq(false) }
|
||||
it { expect(response).to redirect_to(edit_admin_procedure_path(procedure)) }
|
||||
end
|
||||
|
||||
context "with a demarche the admin does not own" do
|
||||
let(:procedure) { create(:procedure, :with_notice) }
|
||||
|
||||
before do
|
||||
delete :delete_notice, params: { id: procedure.id }
|
||||
procedure.reload
|
||||
end
|
||||
|
||||
it { expect(response.status).to eq(404) }
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #check_availability" do
|
||||
|
|
|
@ -434,7 +434,7 @@ describe NewUser::DossiersController, type: :controller do
|
|||
it 'updates the champs' do
|
||||
subject
|
||||
|
||||
expect(response).to redirect_to(users_dossier_recapitulatif_path(dossier))
|
||||
expect(response).to redirect_to(demande_dossier_path(dossier))
|
||||
expect(first_champ.reload.value).to eq('beautiful value')
|
||||
expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_construction))
|
||||
end
|
||||
|
@ -490,7 +490,7 @@ describe NewUser::DossiersController, type: :controller do
|
|||
it 'does not raise any errors' do
|
||||
subject
|
||||
|
||||
expect(response).to redirect_to(users_dossier_recapitulatif_path(dossier))
|
||||
expect(response).to redirect_to(demande_dossier_path(dossier))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -505,7 +505,7 @@ describe NewUser::DossiersController, type: :controller do
|
|||
|
||||
it { expect(first_champ.reload.value).to eq('beautiful value') }
|
||||
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_construction)) }
|
||||
it { expect(response).to redirect_to(users_dossiers_invite_path(invite)) }
|
||||
it { expect(response).to redirect_to(demande_dossier_path(dossier)) }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -578,10 +578,7 @@ describe NewUser::DossiersController, type: :controller do
|
|||
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
|
||||
|
||||
|
@ -594,17 +591,8 @@ describe NewUser::DossiersController, type: :controller do
|
|||
|
||||
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
|
||||
it { expect(assigns(:dossier)).to eq(dossier) }
|
||||
it { is_expected.to render_template(:show) }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -612,7 +600,6 @@ describe NewUser::DossiersController, type: :controller do
|
|||
let(:dossier) { create(:dossier, :en_construction, user: user) }
|
||||
|
||||
before do
|
||||
Flipflop::FeatureSet.current.test!.switch!(:new_dossier_details, true)
|
||||
sign_in(user)
|
||||
end
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ describe Users::Dossiers::InvitesController, type: :controller do
|
|||
context 'and user is connected' do
|
||||
let(:invite) { create :invite, dossier: dossier, user: user }
|
||||
before { sign_in invite.user }
|
||||
it { is_expected.to have_http_status(:ok) }
|
||||
it { is_expected.to redirect_to(dossier_path(dossier)) }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -54,23 +54,17 @@ describe Users::Dossiers::InvitesController, type: :controller do
|
|||
|
||||
context 'and dossier is a brouillon' do
|
||||
let(:dossier) { create :dossier, state: Dossier.states.fetch(:brouillon) }
|
||||
|
||||
it { is_expected.to have_http_status(302) }
|
||||
it { is_expected.to redirect_to brouillon_dossier_path(dossier) }
|
||||
end
|
||||
|
||||
context 'and dossier is not a brouillon' do
|
||||
let(:dossier) { create :dossier, :en_construction }
|
||||
|
||||
it { is_expected.to have_http_status(:ok) }
|
||||
it { is_expected.to render_template('users/recapitulatif/show') }
|
||||
it { is_expected.to redirect_to(dossier_path(dossier)) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when invitation ID is not attached at the user email account' do
|
||||
let(:email) { 'fake@email.com' }
|
||||
|
||||
it { is_expected.to have_http_status(302) }
|
||||
it { is_expected.to redirect_to dossiers_path }
|
||||
it { expect(flash[:alert]).to be_present }
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ describe Users::RecapitulatifController, type: :controller do
|
|||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
get :show, params: { dossier_id: dossier.id }
|
||||
expect(response).to have_http_status(:success)
|
||||
expect(response).to redirect_to(dossier_path(dossier))
|
||||
end
|
||||
|
||||
it 'redirection vers siret si mauvais dossier ID' do
|
||||
|
|
|
@ -6,7 +6,6 @@ describe 'Dossier details:' do
|
|||
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)
|
||||
visit_dossier dossier
|
||||
end
|
||||
|
||||
|
|
|
@ -75,10 +75,6 @@ feature 'Invitations' do
|
|||
context 'when the dossier is en_construction' do
|
||||
let!(:dossier) { create(:dossier, :for_individual, :en_construction, user: owner, procedure: procedure) }
|
||||
|
||||
before do
|
||||
Flipflop::FeatureSet.current.test!.switch!(:new_dossier_details, true)
|
||||
end
|
||||
|
||||
scenario 'on dossier details, the owner of a dossier can invite another user to collaborate on the dossier', js: true do
|
||||
log_in(owner)
|
||||
navigate_to_dossier(dossier)
|
||||
|
@ -101,43 +97,6 @@ feature 'Invitations' do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when the dossier is en_construction (legacy UI)' do
|
||||
let!(:dossier) { create(:dossier, :for_individual, :en_construction, user: owner, procedure: procedure) }
|
||||
|
||||
scenario 'on dossier details, a user can invite another user to collaborate on the dossier', js: true do
|
||||
log_in(owner)
|
||||
navigate_to_recapitulatif(dossier)
|
||||
|
||||
legacy_send_invite_to "user_invite@exemple.fr"
|
||||
|
||||
expect(page).to have_current_path(users_dossier_recapitulatif_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")
|
||||
end
|
||||
|
||||
scenario 'an invited user can see and edit the dossier', js: true do
|
||||
visit users_dossiers_invite_path(invite)
|
||||
expect(page).to have_current_path(new_user_session_path)
|
||||
|
||||
submit_login_form(invited_user.email, invited_user.password)
|
||||
expect(page).to have_current_path(users_dossiers_invite_path(invite))
|
||||
expect(page).to have_no_selector('.button.invite-user-action')
|
||||
expect(page).to have_text("Dossier nº #{dossier.id}")
|
||||
|
||||
# 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: brouillon_dossier_path(dossier))
|
||||
visit brouillon_dossier_path(dossier)
|
||||
|
||||
expect(page).to have_current_path(brouillon_dossier_path(dossier))
|
||||
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))
|
||||
expect(page).to have_text("Some edited value")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def log_in(user)
|
||||
|
@ -171,12 +130,6 @@ feature 'Invitations' do
|
|||
submit_login_form(invited_user.email, invited_user.password)
|
||||
end
|
||||
|
||||
def navigate_to_recapitulatif(dossier)
|
||||
expect(page).to have_current_path(dossiers_path)
|
||||
click_on(dossier.id)
|
||||
expect(page).to have_current_path(users_dossier_recapitulatif_path(dossier))
|
||||
end
|
||||
|
||||
def send_invite_to(invited_email)
|
||||
click_on "Inviter une personne à modifier ce dossier"
|
||||
expect(page).to have_button("Envoyer une invitation", visible: true)
|
||||
|
@ -184,15 +137,4 @@ feature 'Invitations' do
|
|||
fill_in 'invite_email', with: invited_email
|
||||
click_on "Envoyer une invitation"
|
||||
end
|
||||
|
||||
def legacy_send_invite_to(invited_email)
|
||||
find('.dropdown-toggle', text: "Voir les personnes impliquées").click()
|
||||
expect(page).to have_button("Ajouter", visible: true)
|
||||
|
||||
fill_in 'invite_email', with: invited_email
|
||||
|
||||
page.accept_alert "Envoyer l'invitation ?" do
|
||||
click_on "Ajouter"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -48,7 +48,7 @@ describe 'user access to the list of his dossier' do
|
|||
page.click_on(dossier1.procedure.libelle)
|
||||
end
|
||||
scenario 'user is redirected to dossier page' do
|
||||
expect(page).to have_css('#users-recapitulatif-dossier-show')
|
||||
expect(page).to have_current_path(dossier_path(dossier1))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -93,7 +93,7 @@ describe 'user access to the list of his dossier' do
|
|||
end
|
||||
|
||||
it "redirects to the dossier page" do
|
||||
expect(current_path).to eq(users_dossier_recapitulatif_path(dossier1))
|
||||
expect(current_path).to eq(dossier_path(dossier1))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'users: flux de commentaires' do
|
||||
let(:user) { create(:user) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user, state: Dossier.states.fetch(:en_construction)) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
|
||||
let(:champ1) { dossier.champs.first }
|
||||
let(:champ2) { create(:champ, dossier: dossier, type_de_champ: create(:type_de_champ, libelle: "subtitle")) }
|
||||
|
||||
let!(:commentaire1) { create(:commentaire, dossier: dossier, champ: champ1) }
|
||||
let!(:commentaire2) { create(:commentaire, dossier: dossier, email: 'paul.chavard@beta.gouv.fr') }
|
||||
let!(:commentaire3) { create(:commentaire, dossier: dossier, champ: champ2) }
|
||||
let!(:commentaire4) { create(:commentaire, dossier: dossier, champ: champ1) }
|
||||
|
||||
before do
|
||||
login_as user, scope: :user
|
||||
visit users_dossier_recapitulatif_path(dossier)
|
||||
end
|
||||
|
||||
scenario "seuls les commentaires généraux sont affichés" do
|
||||
comments = find(".commentaires")
|
||||
expect(comments).to have_selector(".content", count: 1)
|
||||
expect(comments).to have_content('paul.chavard')
|
||||
expect(comments).not_to have_content('paul.chavard@beta.gouv.fr')
|
||||
end
|
||||
end
|
|
@ -36,7 +36,7 @@ RSpec.describe DossierHelper, type: :helper do
|
|||
|
||||
context "when the dossier is any other state" do
|
||||
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:en_construction)) }
|
||||
it { is_expected.to eq "/users/dossiers/#{dossier.id}/recapitulatif" }
|
||||
it { is_expected.to eq "/dossiers/#{dossier.id}" }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ describe 'new_user/dossiers/index.html.haml', type: :view do
|
|||
|
||||
expect(rendered).to have_text(dossier_en_construction.id)
|
||||
expect(rendered).to have_text(dossier_en_construction.procedure.libelle)
|
||||
expect(rendered).to have_link(dossier_en_construction.id, href: users_dossier_recapitulatif_path(dossier_en_construction))
|
||||
expect(rendered).to have_link(dossier_en_construction.id, href: dossier_path(dossier_en_construction))
|
||||
end
|
||||
|
||||
context 'quand il n’y a aucun dossier' do
|
||||
|
|
Loading…
Reference in a new issue