fix(avis_controller): fix revoked acl on create_avis
This commit is contained in:
parent
3c477691c3
commit
6aa2ccacd4
2 changed files with 13 additions and 3 deletions
|
@ -4,7 +4,7 @@ module Experts
|
|||
include Zipline
|
||||
|
||||
before_action :authenticate_expert!, except: [:sign_up, :update_expert]
|
||||
before_action :check_if_avis_revoked, only: [:show, :instruction]
|
||||
before_action :check_if_avis_revoked, only: [:show, :instruction, :create_avis]
|
||||
before_action :redirect_if_no_sign_up_needed, only: [:sign_up, :update_expert]
|
||||
before_action :set_avis_and_dossier, only: [:show, :instruction, :messagerie, :create_commentaire, :delete_commentaire, :update, :telecharger_pjs]
|
||||
|
||||
|
|
|
@ -313,8 +313,9 @@ describe Experts::AvisController, type: :controller do
|
|||
|
||||
describe '#create_avis' do
|
||||
let(:previous_avis_confidentiel) { false }
|
||||
let!(:previous_avis) { create(:avis, dossier:, claimant:, experts_procedure:, confidentiel: previous_avis_confidentiel) }
|
||||
let(:emails) { "[\"a@b.com\"]" }
|
||||
let(:previous_revoked_at) { nil }
|
||||
let!(:previous_avis) { create(:avis, dossier:, claimant:, experts_procedure:, confidentiel: previous_avis_confidentiel, revoked_at: previous_revoked_at) }
|
||||
let(:emails) { '["a@b.com"]' }
|
||||
let(:introduction) { 'introduction' }
|
||||
let(:created_avis) { Avis.last }
|
||||
let!(:old_avis_count) { Avis.count }
|
||||
|
@ -330,6 +331,15 @@ describe Experts::AvisController, type: :controller do
|
|||
|
||||
after { Timecop.return }
|
||||
|
||||
context 'from a revoked avis' do
|
||||
let(:previous_revoked_at) { Time.zone.now }
|
||||
|
||||
it do
|
||||
expect(response).to redirect_to(root_path)
|
||||
expect(Avis.last).to eq(previous_avis)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when an invalid email' do
|
||||
let(:emails) { "[\"toto.fr\"]" }
|
||||
|
||||
|
|
Loading…
Reference in a new issue