specs: add spec for DossierController#forbid_invite_submission!
This commit is contained in:
parent
bdd05937e2
commit
a386a0ffb2
1 changed files with 41 additions and 0 deletions
|
@ -96,6 +96,47 @@ describe NewUser::DossiersController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#forbid_invite_submission!" do
|
||||
let(:user) { create(:user) }
|
||||
let(:asked_dossier) { create(:dossier) }
|
||||
let(:ensure_authorized) { :forbid_invite_submission! }
|
||||
let(:submit_action) { 'submit' }
|
||||
|
||||
before do
|
||||
@controller.params = @controller.params.merge(dossier_id: asked_dossier.id, submit_action: submit_action)
|
||||
allow(@controller).to receive(:current_user).and_return(user)
|
||||
allow(@controller).to receive(:redirect_to)
|
||||
end
|
||||
|
||||
context 'when a user save their own draft' do
|
||||
let(:asked_dossier) { create(:dossier, user: user) }
|
||||
let(:submit_action) { 'draft' }
|
||||
|
||||
it_behaves_like 'does not redirect nor flash'
|
||||
end
|
||||
|
||||
context 'when a user submit their own dossier' do
|
||||
let(:asked_dossier) { create(:dossier, user: user) }
|
||||
let(:submit_action) { 'submit' }
|
||||
|
||||
it_behaves_like 'does not redirect nor flash'
|
||||
end
|
||||
|
||||
context 'when an invite save the draft for a dossier where they where invited' do
|
||||
before { create(:invite, dossier: asked_dossier, user: user, type: 'InviteUser') }
|
||||
let(:submit_action) { 'draft' }
|
||||
|
||||
it_behaves_like 'does not redirect nor flash'
|
||||
end
|
||||
|
||||
context 'when an invite submit a dossier where they where invited' do
|
||||
before { create(:invite, dossier: asked_dossier, user: user, type: 'InviteUser') }
|
||||
let(:submit_action) { 'submit' }
|
||||
|
||||
it_behaves_like 'redirects and flashes'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'attestation' do
|
||||
before { sign_in(user) }
|
||||
|
||||
|
|
Loading…
Reference in a new issue