commit
254d1d63cd
12 changed files with 123 additions and 49 deletions
72
Gemfile.lock
72
Gemfile.lock
|
@ -22,25 +22,25 @@ GEM
|
||||||
specs:
|
specs:
|
||||||
aasm (5.0.1)
|
aasm (5.0.1)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
actioncable (5.2.1.1)
|
actioncable (5.2.2)
|
||||||
actionpack (= 5.2.1.1)
|
actionpack (= 5.2.2)
|
||||||
nio4r (~> 2.0)
|
nio4r (~> 2.0)
|
||||||
websocket-driver (>= 0.6.1)
|
websocket-driver (>= 0.6.1)
|
||||||
actionmailer (5.2.1.1)
|
actionmailer (5.2.2)
|
||||||
actionpack (= 5.2.1.1)
|
actionpack (= 5.2.2)
|
||||||
actionview (= 5.2.1.1)
|
actionview (= 5.2.2)
|
||||||
activejob (= 5.2.1.1)
|
activejob (= 5.2.2)
|
||||||
mail (~> 2.5, >= 2.5.4)
|
mail (~> 2.5, >= 2.5.4)
|
||||||
rails-dom-testing (~> 2.0)
|
rails-dom-testing (~> 2.0)
|
||||||
actionpack (5.2.1.1)
|
actionpack (5.2.2)
|
||||||
actionview (= 5.2.1.1)
|
actionview (= 5.2.2)
|
||||||
activesupport (= 5.2.1.1)
|
activesupport (= 5.2.2)
|
||||||
rack (~> 2.0)
|
rack (~> 2.0)
|
||||||
rack-test (>= 0.6.3)
|
rack-test (>= 0.6.3)
|
||||||
rails-dom-testing (~> 2.0)
|
rails-dom-testing (~> 2.0)
|
||||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||||
actionview (5.2.1.1)
|
actionview (5.2.2)
|
||||||
activesupport (= 5.2.1.1)
|
activesupport (= 5.2.2)
|
||||||
builder (~> 3.1)
|
builder (~> 3.1)
|
||||||
erubi (~> 1.4)
|
erubi (~> 1.4)
|
||||||
rails-dom-testing (~> 2.0)
|
rails-dom-testing (~> 2.0)
|
||||||
|
@ -53,24 +53,24 @@ GEM
|
||||||
activemodel (>= 4.1, < 6)
|
activemodel (>= 4.1, < 6)
|
||||||
case_transform (>= 0.2)
|
case_transform (>= 0.2)
|
||||||
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
|
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
|
||||||
activejob (5.2.1.1)
|
activejob (5.2.2)
|
||||||
activesupport (= 5.2.1.1)
|
activesupport (= 5.2.2)
|
||||||
globalid (>= 0.3.6)
|
globalid (>= 0.3.6)
|
||||||
activemodel (5.2.1.1)
|
activemodel (5.2.2)
|
||||||
activesupport (= 5.2.1.1)
|
activesupport (= 5.2.2)
|
||||||
activemodel-serializers-xml (1.0.2)
|
activemodel-serializers-xml (1.0.2)
|
||||||
activemodel (> 5.x)
|
activemodel (> 5.x)
|
||||||
activesupport (> 5.x)
|
activesupport (> 5.x)
|
||||||
builder (~> 3.1)
|
builder (~> 3.1)
|
||||||
activerecord (5.2.1.1)
|
activerecord (5.2.2)
|
||||||
activemodel (= 5.2.1.1)
|
activemodel (= 5.2.2)
|
||||||
activesupport (= 5.2.1.1)
|
activesupport (= 5.2.2)
|
||||||
arel (>= 9.0)
|
arel (>= 9.0)
|
||||||
activestorage (5.2.1.1)
|
activestorage (5.2.2)
|
||||||
actionpack (= 5.2.1.1)
|
actionpack (= 5.2.2)
|
||||||
activerecord (= 5.2.1.1)
|
activerecord (= 5.2.2)
|
||||||
marcel (~> 0.3.1)
|
marcel (~> 0.3.1)
|
||||||
activesupport (5.2.1.1)
|
activesupport (5.2.2)
|
||||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||||
i18n (>= 0.7, < 2)
|
i18n (>= 0.7, < 2)
|
||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
|
@ -436,18 +436,18 @@ GEM
|
||||||
rack
|
rack
|
||||||
rack-test (1.1.0)
|
rack-test (1.1.0)
|
||||||
rack (>= 1.0, < 3)
|
rack (>= 1.0, < 3)
|
||||||
rails (5.2.1.1)
|
rails (5.2.2)
|
||||||
actioncable (= 5.2.1.1)
|
actioncable (= 5.2.2)
|
||||||
actionmailer (= 5.2.1.1)
|
actionmailer (= 5.2.2)
|
||||||
actionpack (= 5.2.1.1)
|
actionpack (= 5.2.2)
|
||||||
actionview (= 5.2.1.1)
|
actionview (= 5.2.2)
|
||||||
activejob (= 5.2.1.1)
|
activejob (= 5.2.2)
|
||||||
activemodel (= 5.2.1.1)
|
activemodel (= 5.2.2)
|
||||||
activerecord (= 5.2.1.1)
|
activerecord (= 5.2.2)
|
||||||
activestorage (= 5.2.1.1)
|
activestorage (= 5.2.2)
|
||||||
activesupport (= 5.2.1.1)
|
activesupport (= 5.2.2)
|
||||||
bundler (>= 1.3.0)
|
bundler (>= 1.3.0)
|
||||||
railties (= 5.2.1.1)
|
railties (= 5.2.2)
|
||||||
sprockets-rails (>= 2.0.0)
|
sprockets-rails (>= 2.0.0)
|
||||||
rails-controller-testing (1.0.3)
|
rails-controller-testing (1.0.3)
|
||||||
actionpack (>= 5.0.1.x)
|
actionpack (>= 5.0.1.x)
|
||||||
|
@ -461,9 +461,9 @@ GEM
|
||||||
rails-i18n (5.1.2)
|
rails-i18n (5.1.2)
|
||||||
i18n (>= 0.7, < 2)
|
i18n (>= 0.7, < 2)
|
||||||
railties (>= 5.0, < 6)
|
railties (>= 5.0, < 6)
|
||||||
railties (5.2.1.1)
|
railties (5.2.2)
|
||||||
actionpack (= 5.2.1.1)
|
actionpack (= 5.2.2)
|
||||||
activesupport (= 5.2.1.1)
|
activesupport (= 5.2.2)
|
||||||
method_source
|
method_source
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
thor (>= 0.19.0, < 2.0)
|
thor (>= 0.19.0, < 2.0)
|
||||||
|
|
|
@ -4,11 +4,11 @@ module NewUser
|
||||||
|
|
||||||
SESSION_USER_RETURN_LOCATION = 'user_return_to'
|
SESSION_USER_RETURN_LOCATION = 'user_return_to'
|
||||||
ACTIONS_ALLOWED_TO_ANY_USER = [:index, :recherche, :new]
|
ACTIONS_ALLOWED_TO_ANY_USER = [:index, :recherche, :new]
|
||||||
ACTIONS_ALLOWED_TO_OWNER_OR_INVITE = [:show, :demande, :messagerie, :brouillon, :update_brouillon, :modifier, :update, :create_commentaire]
|
ACTIONS_ALLOWED_TO_OWNER_OR_INVITE = [:show, :demande, :messagerie, :brouillon, :update_brouillon, :modifier, :update, :create_commentaire, :purge_champ_piece_justificative]
|
||||||
|
|
||||||
before_action :ensure_ownership!, except: ACTIONS_ALLOWED_TO_ANY_USER + ACTIONS_ALLOWED_TO_OWNER_OR_INVITE
|
before_action :ensure_ownership!, except: ACTIONS_ALLOWED_TO_ANY_USER + ACTIONS_ALLOWED_TO_OWNER_OR_INVITE
|
||||||
before_action :ensure_ownership_or_invitation!, only: ACTIONS_ALLOWED_TO_OWNER_OR_INVITE
|
before_action :ensure_ownership_or_invitation!, only: ACTIONS_ALLOWED_TO_OWNER_OR_INVITE
|
||||||
before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update_brouillon, :modifier, :update]
|
before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update_brouillon, :modifier, :update, :purge_champ_piece_justificative]
|
||||||
before_action :forbid_invite_submission!, only: [:update_brouillon]
|
before_action :forbid_invite_submission!, only: [:update_brouillon]
|
||||||
before_action :forbid_closed_submission!, only: [:update_brouillon]
|
before_action :forbid_closed_submission!, only: [:update_brouillon]
|
||||||
before_action :show_demarche_en_test_banner
|
before_action :show_demarche_en_test_banner
|
||||||
|
@ -230,6 +230,14 @@ module NewUser
|
||||||
redirect_to url_for dossiers_path
|
redirect_to url_for dossiers_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def purge_champ_piece_justificative
|
||||||
|
@champ = dossier.champs.find(params[:champ_id])
|
||||||
|
|
||||||
|
@champ.piece_justificative_file.purge
|
||||||
|
|
||||||
|
flash.notice = 'La pièce jointe a bien été supprimée.'
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def store_user_location!
|
def store_user_location!
|
||||||
|
|
|
@ -94,11 +94,9 @@ class Users::SessionsController < Sessions::SessionsController
|
||||||
administrateur = Administrateur.find_by(email: gestionnaire.email)
|
administrateur = Administrateur.find_by(email: gestionnaire.email)
|
||||||
[user, gestionnaire, administrateur].compact.each { |resource| sign_in(resource) }
|
[user, gestionnaire, administrateur].compact.each { |resource| sign_in(resource) }
|
||||||
|
|
||||||
if administrateur.present?
|
# redirect to procedure'url if stored by store_location_for(:user) in dossiers_controller
|
||||||
redirect_to admin_procedures_path
|
# redirect to root_path otherwise
|
||||||
else
|
redirect_to after_sign_in_path_for(:user)
|
||||||
redirect_to gestionnaire_procedures_path
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
flash[:alert] = 'Votre lien est invalide ou expiré, veuillez-vous reconnecter.'
|
flash[:alert] = 'Votre lien est invalide ou expiré, veuillez-vous reconnecter.'
|
||||||
redirect_to new_user_session_path
|
redirect_to new_user_session_path
|
||||||
|
|
|
@ -214,6 +214,7 @@ class Procedure < ApplicationRecord
|
||||||
procedure.published_at = nil
|
procedure.published_at = nil
|
||||||
procedure.logo_secure_token = nil
|
procedure.logo_secure_token = nil
|
||||||
procedure.remote_logo_url = self.logo_url
|
procedure.remote_logo_url = self.logo_url
|
||||||
|
procedure.lien_notice = nil
|
||||||
|
|
||||||
[:notice, :deliberation].each { |attachment| clone_attachment(procedure, attachment) }
|
[:notice, :deliberation].each { |attachment| clone_attachment(procedure, attachment) }
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
- if Rails.env.development?
|
- if Rails.env.development?
|
||||||
= stylesheet_link_tag :xray
|
= stylesheet_link_tag :xray
|
||||||
|
|
||||||
- if !current_user
|
|
||||||
= render partial: "layouts/matomo"
|
= render partial: "layouts/matomo"
|
||||||
|
|
||||||
:javascript
|
:javascript
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
<%= render_flash(timeout: 5000, sticky: true) %>
|
||||||
|
<%= remove_element("#piece_justificative_#{@champ.id}") %>
|
|
@ -10,8 +10,11 @@
|
||||||
id: "champs_#{champ.id}",
|
id: "champs_#{champ.id}",
|
||||||
direct_upload: true
|
direct_upload: true
|
||||||
- else
|
- else
|
||||||
|
%div{ id: "piece_justificative_#{champ.id}" }
|
||||||
= render partial: "shared/champs/piece_justificative/pj_link", locals: { champ: champ, user_can_upload: true }
|
= render partial: "shared/champs/piece_justificative/pj_link", locals: { champ: champ, user_can_upload: true }
|
||||||
%br
|
%br
|
||||||
|
= link_to 'supprimer', purge_champ_piece_justificative_dossier_path(champ_id: champ.id), remote: true, method: :delete
|
||||||
|
%br
|
||||||
Modifier :
|
Modifier :
|
||||||
= form.file_field :piece_justificative_file,
|
= form.file_field :piece_justificative_file,
|
||||||
id: "champs_#{champ.id}",
|
id: "champs_#{champ.id}",
|
||||||
|
|
|
@ -284,6 +284,7 @@ Rails.application.routes.draw do
|
||||||
post 'commentaire' => 'dossiers#create_commentaire'
|
post 'commentaire' => 'dossiers#create_commentaire'
|
||||||
post 'ask_deletion'
|
post 'ask_deletion'
|
||||||
get 'attestation'
|
get 'attestation'
|
||||||
|
delete 'purge_champ_piece_justificative'
|
||||||
end
|
end
|
||||||
|
|
||||||
collection do
|
collection do
|
||||||
|
|
|
@ -906,4 +906,45 @@ describe NewUser::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#purge_champ_piece_justificative' do
|
||||||
|
before { sign_in(user) }
|
||||||
|
|
||||||
|
subject { delete :purge_champ_piece_justificative, params: { id: champ.dossier.id, champ_id: champ.id }, format: :js }
|
||||||
|
|
||||||
|
context 'when dossier is owned by user' do
|
||||||
|
let(:dossier){ create(:dossier, user: user) }
|
||||||
|
let(:champ){ create(:champ_piece_justificative, dossier_id: dossier.id) }
|
||||||
|
|
||||||
|
it { is_expected.to have_http_status(200) }
|
||||||
|
|
||||||
|
it do
|
||||||
|
subject
|
||||||
|
expect(champ.reload.piece_justificative_file.attached?).to be(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'but champ is not linked to this dossier' do
|
||||||
|
let(:champ){ create(:champ_piece_justificative, dossier: create(:dossier)) }
|
||||||
|
|
||||||
|
it { is_expected.to redirect_to(root_path) }
|
||||||
|
|
||||||
|
it do
|
||||||
|
subject
|
||||||
|
expect(champ.reload.piece_justificative_file.attached?).to be(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when dossier is not owned by user' do
|
||||||
|
let(:dossier){ create(:dossier, user: create(:user)) }
|
||||||
|
let(:champ){ create(:champ_piece_justificative, dossier_id: dossier.id) }
|
||||||
|
|
||||||
|
it { is_expected.to redirect_to(root_path) }
|
||||||
|
|
||||||
|
it do
|
||||||
|
subject
|
||||||
|
expect(champ.reload.piece_justificative_file.attached?).to be(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -261,7 +261,9 @@ describe Users::SessionsController, type: :controller do
|
||||||
context 'when the token is valid' do
|
context 'when the token is valid' do
|
||||||
let(:login_token) { gestionnaire.login_token! }
|
let(:login_token) { gestionnaire.login_token! }
|
||||||
|
|
||||||
it { is_expected.to redirect_to gestionnaire_procedures_path }
|
# TODO when the gestionnaire has no other account, and the token is valid, and the user signing in was not starting a demarche,
|
||||||
|
# redirect to root_path, then redirect to gestionnaire_procedures_path (see root_controller)
|
||||||
|
it { is_expected.to redirect_to root_path }
|
||||||
it { expect(controller.current_gestionnaire).to eq(gestionnaire) }
|
it { expect(controller.current_gestionnaire).to eq(gestionnaire) }
|
||||||
it { expect(controller).to have_received(:trust_device) }
|
it { expect(controller).to have_received(:trust_device) }
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,6 +9,19 @@ feature 'The gestionnaire part' do
|
||||||
let!(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) }
|
let!(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) }
|
||||||
let!(:dossier) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure) }
|
let!(:dossier) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure) }
|
||||||
|
|
||||||
|
context 'when the gestionnaire is also a user' do
|
||||||
|
let!(:user) { create(:user, email: gestionnaire.email, password: password) }
|
||||||
|
|
||||||
|
scenario 'a gestionnaire can fill a dossier' do
|
||||||
|
visit commencer_path(path: procedure.path)
|
||||||
|
|
||||||
|
expect(page).to have_current_path new_user_session_path
|
||||||
|
sign_in_with(gestionnaire.email, password, true)
|
||||||
|
|
||||||
|
expect(page).to have_content(procedure.libelle)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
scenario 'A gestionnaire can accept a dossier', :js do
|
scenario 'A gestionnaire can accept a dossier', :js do
|
||||||
log_in(gestionnaire.email, password)
|
log_in(gestionnaire.email, password)
|
||||||
|
|
||||||
|
|
|
@ -413,6 +413,12 @@ describe Procedure do
|
||||||
expect(subject.assign_to).to eq([])
|
expect(subject.assign_to).to eq([])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'should not duplicate lien_notice' do
|
||||||
|
let(:procedure) { create(:procedure, lien_notice: "http://toto.com") }
|
||||||
|
|
||||||
|
it { expect(subject.lien_notice).to be_nil }
|
||||||
|
end
|
||||||
|
|
||||||
describe 'procedure status is reset' do
|
describe 'procedure status is reset' do
|
||||||
let(:procedure) { create(:procedure, :archived, received_mail: received_mail, service: service) }
|
let(:procedure) { create(:procedure, :archived, received_mail: received_mail, service: service) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue