Merge branch 'dev'

This commit is contained in:
gregoirenovel 2018-10-02 14:03:42 +02:00
commit 0b1a143419
19 changed files with 73 additions and 171 deletions

View file

@ -2,7 +2,7 @@ class Admin::ProceduresController < AdminController
include SmartListing::Helper::ControllerExtensions include SmartListing::Helper::ControllerExtensions
helper SmartListing::Helper 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 def index
@procedures = smart_listing_create :procedures, @procedures = smart_listing_create :procedures,
@ -252,31 +252,25 @@ class Admin::ProceduresController < AdminController
end end
def delete_logo 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é' flash.notice = 'le logo a bien été supprimé'
redirect_to edit_admin_procedure_path(procedure) redirect_to edit_admin_procedure_path(@procedure)
end end
def delete_deliberation 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' 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 end
def delete_notice 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' flash.notice = 'la notice a bien été supprimée'
redirect_to edit_admin_procedure_path(procedure) redirect_to edit_admin_procedure_path(@procedure)
end end
private private

View file

@ -28,9 +28,6 @@ module NewUser
def show def show
if dossier.brouillon? if dossier.brouillon?
redirect_to brouillon_dossier_path(dossier) redirect_to brouillon_dossier_path(dossier)
elsif !Flipflop.new_dossier_details?
redirect_to users_dossier_recapitulatif_path(dossier)
end end
@dossier = dossier @dossier = dossier
@ -125,15 +122,7 @@ module NewUser
flash.now.alert = errors flash.now.alert = errors
render :modifier render :modifier
else else
if Flipflop.new_dossier_details? redirect_to demande_dossier_path(@dossier)
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
end end
end end

View file

@ -14,10 +14,8 @@ class Users::Dossiers::InvitesController < UsersController
if @facade.dossier.brouillon? if @facade.dossier.brouillon?
redirect_to brouillon_dossier_path(@facade.dossier) redirect_to brouillon_dossier_path(@facade.dossier)
elsif Flipflop.new_dossier_details?
return redirect_to dossier_path(@facade.dossier)
else else
render 'users/recapitulatif/show' return redirect_to dossier_path(@facade.dossier)
end end
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
flash.alert = t('errors.messages.dossier_not_found') flash.alert = t('errors.messages.dossier_not_found')

View file

@ -4,11 +4,7 @@ class Users::RecapitulatifController < UsersController
end end
def show def show
if Flipflop.new_dossier_details? redirect_to dossier_url(current_user_dossier)
redirect_to dossier_url(current_user_dossier)
else
create_dossier_facade
end
end end
def initiate def initiate

View file

@ -18,10 +18,8 @@ module DossierHelper
def url_for_dossier(dossier) def url_for_dossier(dossier)
if dossier.brouillon? if dossier.brouillon?
brouillon_dossier_path(dossier) brouillon_dossier_path(dossier)
elsif Flipflop.new_dossier_details?
dossier_path(dossier)
else else
users_dossier_recapitulatif_path(dossier) dossier_path(dossier)
end end
end end

View file

@ -18,6 +18,9 @@
%br %br
%br %br
= f.submit 'Valider', class: 'btn btn-info', style: 'float: left;', id: 'add-gestionnaire-email' = 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 .col-xs-6
%h3.text-success Affectés %h3.text-success Affectés
= smart_listing_render :instructeurs_assign = smart_listing_render :instructeurs_assign

View file

@ -20,10 +20,7 @@
= link_to service.email, "mailto:#{service.email}" = link_to service.email, "mailto:#{service.email}"
- else - else
Directement Directement
- if Flipflop.new_dossier_details? = link_to "par la messagerie", messagerie_dossier_path(dossier)
= link_to "par la messagerie", messagerie_dossier_path(dossier)
- else
= link_to "par la messagerie", users_dossier_recapitulatif_path(dossier)
%p %p
Par téléphone : Par téléphone :

View file

@ -18,7 +18,4 @@
%b échanger avec un instructeur %b échanger avec un instructeur
lors de sa construction et de son instruction 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'
= 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'

View file

@ -19,9 +19,6 @@ Flipflop.configure do
feature :publish_draft feature :publish_draft
feature :support_form feature :support_form
feature :new_dossier_details,
title: "Nouvelle page « Dossier »"
group :production do group :production do
feature :remote_storage, feature :remote_storage,
default: ENV['FOG_ENABLED'] == 'enabled' default: ENV['FOG_ENABLED'] == 'enabled'

View file

@ -713,15 +713,53 @@ describe Admin::ProceduresController, type: :controller do
end end
describe "DELETE #delete_deliberation" do 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 before do
delete :delete_deliberation, params: { id: procedure.id } delete :delete_deliberation, params: { id: procedure.id }
procedure.reload procedure.reload
end
it { expect(procedure.deliberation.attached?).to eq(false) }
it { expect(response).to redirect_to(edit_admin_procedure_path(procedure)) }
end end
it { expect(procedure.deliberation.attached?).to eq(false) } context "with a demarche the admin does not own" do
it { expect(response).to redirect_to(edit_admin_procedure_path(procedure)) } 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 end
describe "GET #check_availability" do describe "GET #check_availability" do

View file

@ -434,7 +434,7 @@ describe NewUser::DossiersController, type: :controller do
it 'updates the champs' do it 'updates the champs' do
subject 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(first_champ.reload.value).to eq('beautiful value')
expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_construction)) expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_construction))
end end
@ -490,7 +490,7 @@ describe NewUser::DossiersController, type: :controller do
it 'does not raise any errors' do it 'does not raise any errors' do
subject subject
expect(response).to redirect_to(users_dossier_recapitulatif_path(dossier)) expect(response).to redirect_to(demande_dossier_path(dossier))
end end
end end
@ -505,7 +505,7 @@ describe NewUser::DossiersController, type: :controller do
it { expect(first_champ.reload.value).to eq('beautiful value') } it { expect(first_champ.reload.value).to eq('beautiful value') }
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_construction)) } 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
end end
@ -578,10 +578,7 @@ describe NewUser::DossiersController, type: :controller do
end end
describe '#show' do describe '#show' do
let(:new_dossier_details_enabled) { false }
before do before do
Flipflop::FeatureSet.current.test!.switch!(:new_dossier_details, new_dossier_details_enabled)
sign_in(user) sign_in(user)
end end
@ -594,17 +591,8 @@ describe NewUser::DossiersController, type: :controller do
context 'when the dossier has been submitted' do context 'when the dossier has been submitted' do
let(:dossier) { create(:dossier, :en_construction, user: user) } let(:dossier) { create(:dossier, :en_construction, user: user) }
it { expect(assigns(:dossier)).to eq(dossier) }
context 'and the new dossier details page is disabled' do it { is_expected.to render_template(:show) }
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
end end
@ -612,7 +600,6 @@ describe NewUser::DossiersController, type: :controller do
let(:dossier) { create(:dossier, :en_construction, user: user) } let(:dossier) { create(:dossier, :en_construction, user: user) }
before do before do
Flipflop::FeatureSet.current.test!.switch!(:new_dossier_details, true)
sign_in(user) sign_in(user)
end end

View file

@ -16,7 +16,7 @@ describe Users::Dossiers::InvitesController, type: :controller do
context 'and user is connected' do context 'and user is connected' do
let(:invite) { create :invite, dossier: dossier, user: user } let(:invite) { create :invite, dossier: dossier, user: user }
before { sign_in invite.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
end end
@ -54,23 +54,17 @@ describe Users::Dossiers::InvitesController, type: :controller do
context 'and dossier is a brouillon' do context 'and dossier is a brouillon' do
let(:dossier) { create :dossier, state: Dossier.states.fetch(:brouillon) } 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) } it { is_expected.to redirect_to brouillon_dossier_path(dossier) }
end end
context 'and dossier is not a brouillon' do context 'and dossier is not a brouillon' do
let(:dossier) { create :dossier, :en_construction } let(:dossier) { create :dossier, :en_construction }
it { is_expected.to redirect_to(dossier_path(dossier)) }
it { is_expected.to have_http_status(:ok) }
it { is_expected.to render_template('users/recapitulatif/show') }
end end
end end
context 'when invitation ID is not attached at the user email account' do context 'when invitation ID is not attached at the user email account' do
let(:email) { 'fake@email.com' } let(:email) { 'fake@email.com' }
it { is_expected.to have_http_status(302) }
it { is_expected.to redirect_to dossiers_path } it { is_expected.to redirect_to dossiers_path }
it { expect(flash[:alert]).to be_present } it { expect(flash[:alert]).to be_present }
end end

View file

@ -11,7 +11,7 @@ describe Users::RecapitulatifController, type: :controller do
describe 'GET #show' do describe 'GET #show' do
it 'returns http success' do it 'returns http success' do
get :show, params: { dossier_id: dossier.id } get :show, params: { dossier_id: dossier.id }
expect(response).to have_http_status(:success) expect(response).to redirect_to(dossier_path(dossier))
end end
it 'redirection vers siret si mauvais dossier ID' do it 'redirection vers siret si mauvais dossier ID' do

View file

@ -6,7 +6,6 @@ describe 'Dossier details:' do
let(:dossier) { create(:dossier, :en_construction, :for_individual, :with_commentaires, user: user, procedure: procedure) } let(:dossier) { create(:dossier, :en_construction, :for_individual, :with_commentaires, user: user, procedure: procedure) }
before do before do
Flipflop::FeatureSet.current.test!.switch!(:new_dossier_details, true)
visit_dossier dossier visit_dossier dossier
end end

View file

@ -75,10 +75,6 @@ feature 'Invitations' do
context 'when the dossier is en_construction' do context 'when the dossier is en_construction' do
let!(:dossier) { create(:dossier, :for_individual, :en_construction, user: owner, procedure: procedure) } 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 scenario 'on dossier details, the owner of a dossier can invite another user to collaborate on the dossier', js: true do
log_in(owner) log_in(owner)
navigate_to_dossier(dossier) navigate_to_dossier(dossier)
@ -101,43 +97,6 @@ feature 'Invitations' do
end end
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 private
def log_in(user) def log_in(user)
@ -171,12 +130,6 @@ feature 'Invitations' do
submit_login_form(invited_user.email, invited_user.password) submit_login_form(invited_user.email, invited_user.password)
end 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) def send_invite_to(invited_email)
click_on "Inviter une personne à modifier ce dossier" click_on "Inviter une personne à modifier ce dossier"
expect(page).to have_button("Envoyer une invitation", visible: true) expect(page).to have_button("Envoyer une invitation", visible: true)
@ -184,15 +137,4 @@ feature 'Invitations' do
fill_in 'invite_email', with: invited_email fill_in 'invite_email', with: invited_email
click_on "Envoyer une invitation" click_on "Envoyer une invitation"
end 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 end

View file

@ -48,7 +48,7 @@ describe 'user access to the list of his dossier' do
page.click_on(dossier1.procedure.libelle) page.click_on(dossier1.procedure.libelle)
end end
scenario 'user is redirected to dossier page' do 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
end end
@ -93,7 +93,7 @@ describe 'user access to the list of his dossier' do
end end
it "redirects to the dossier page" do 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 end
end end

View file

@ -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

View file

@ -36,7 +36,7 @@ RSpec.describe DossierHelper, type: :helper do
context "when the dossier is any other state" do context "when the dossier is any other state" do
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:en_construction)) } 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
end end

View file

@ -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.id)
expect(rendered).to have_text(dossier_en_construction.procedure.libelle) 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 end
context 'quand il ny a aucun dossier' do context 'quand il ny a aucun dossier' do