[#1677] No longer create InviteGestionnaire
s
This commit is contained in:
parent
6c3f287f68
commit
c413dfa127
2 changed files with 36 additions and 36 deletions
|
@ -30,11 +30,10 @@ class InvitesController < ApplicationController
|
||||||
private
|
private
|
||||||
|
|
||||||
def gestionnaire_or_user?
|
def gestionnaire_or_user?
|
||||||
if !user_signed_in? && !gestionnaire_signed_in?
|
if !user_signed_in?
|
||||||
return redirect_to root_path
|
return redirect_to root_path
|
||||||
end
|
end
|
||||||
|
|
||||||
@current_devise_profil = current_user if user_signed_in?
|
@current_devise_profil = current_user if user_signed_in?
|
||||||
@current_devise_profil = current_gestionnaire if gestionnaire_signed_in?
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,8 +17,7 @@ describe InvitesController, type: :controller do
|
||||||
let(:signed_in_profile) { create(:gestionnaire) }
|
let(:signed_in_profile) { create(:gestionnaire) }
|
||||||
|
|
||||||
shared_examples_for "he can not create invitation" do
|
shared_examples_for "he can not create invitation" do
|
||||||
it { expect { subject }.to raise_error(ActiveRecord::RecordNotFound) }
|
it { expect { subject rescue nil }.to change(Invite, :count).by(0) }
|
||||||
it { expect { subject rescue nil }.to change(InviteGestionnaire, :count).by(0) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when gestionnaire has no access to dossier' do
|
context 'when gestionnaire has no access to dossier' do
|
||||||
|
@ -36,18 +35,47 @@ describe InvitesController, type: :controller do
|
||||||
signed_in_profile.procedures << dossier.procedure
|
signed_in_profile.procedures << dossier.procedure
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect { subject }.to change(InviteGestionnaire, :count).by(1) }
|
it_behaves_like "he can not create invitation"
|
||||||
|
|
||||||
context 'when is a user who is loged' do
|
context 'when is a user who is loged' do
|
||||||
|
let(:user) { create(:user) }
|
||||||
before do
|
before do
|
||||||
sign_in create(:user)
|
dossier.update(user: user)
|
||||||
|
sign_in(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect { subject }.to change(InviteGestionnaire, :count).by(1) }
|
it { expect { subject }.to change(InviteUser, :count).by(1) }
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when user is signed_in" do
|
||||||
|
let(:signed_in_profile) { create(:user) }
|
||||||
|
|
||||||
|
shared_examples_for "he can not create a invite" do
|
||||||
|
it { expect { subject }.to raise_error(ActiveRecord::RecordNotFound) }
|
||||||
|
it { expect { subject rescue nil }.to change(InviteUser, :count).by(0) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when user has no access to dossier' do
|
||||||
|
it_behaves_like "he can not create a invite"
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when user is invited on dossier' do
|
||||||
|
before { Invite.create(user: signed_in_profile, email: signed_in_profile.email, dossier: dossier) }
|
||||||
|
|
||||||
|
it_behaves_like "he can not create a invite"
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when user has access to dossier' do
|
||||||
|
before do
|
||||||
|
dossier.update(user: signed_in_profile)
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect { subject }.to change(InviteUser, :count).by(1) }
|
||||||
|
|
||||||
context 'when email is assign to an user' do
|
context 'when email is assign to an user' do
|
||||||
let! (:user) { create(:user, email: email) }
|
let! (:user_invite) { create(:user, email: email) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
subject
|
subject
|
||||||
|
@ -62,7 +90,7 @@ describe InvitesController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(invite.user).to eq user }
|
it { expect(invite.user).to eq user_invite }
|
||||||
it { expect(flash[:notice]).to be_present }
|
it { expect(flash[:notice]).to be_present }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -124,32 +152,5 @@ describe InvitesController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when user is signed_in" do
|
|
||||||
let(:signed_in_profile) { create(:user) }
|
|
||||||
|
|
||||||
shared_examples_for "he can not create a invite" do
|
|
||||||
it { expect { subject }.to raise_error(ActiveRecord::RecordNotFound) }
|
|
||||||
it { expect { subject rescue nil }.to change(InviteUser, :count).by(0) }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when user has no access to dossier' do
|
|
||||||
it_behaves_like "he can not create a invite"
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when user is invited on dossier' do
|
|
||||||
before { Invite.create(user: signed_in_profile, email: signed_in_profile.email, dossier: dossier) }
|
|
||||||
|
|
||||||
it_behaves_like "he can not create a invite"
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when user has access to dossier' do
|
|
||||||
before do
|
|
||||||
dossier.update(user: signed_in_profile)
|
|
||||||
end
|
|
||||||
|
|
||||||
it { expect { subject }.to change(InviteUser, :count).by(1) }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue