2015-10-09 17:33:33 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2016-11-15 04:24:09 +01:00
|
|
|
require 'controllers/users_controller_shared_example'
|
2015-10-09 17:33:33 +02:00
|
|
|
|
2016-09-14 16:36:01 +02:00
|
|
|
describe UsersController, type: :controller do
|
2015-11-02 16:36:52 +01:00
|
|
|
describe '#current_user_dossier' do
|
2016-09-14 16:36:01 +02:00
|
|
|
let(:owner_user) { create(:user) }
|
|
|
|
let(:invite_user) { create :user, email: 'invite@plop.com' }
|
|
|
|
let(:not_invite_user) { create :user, email: 'not_invite@plop.com' }
|
2015-10-09 17:33:33 +02:00
|
|
|
|
2016-09-14 16:36:01 +02:00
|
|
|
let(:dossier) { create(:dossier, user: owner_user) }
|
2015-10-09 17:33:33 +02:00
|
|
|
|
2016-09-14 16:36:01 +02:00
|
|
|
context 'when user is the owner' do
|
|
|
|
before do
|
|
|
|
sign_in owner_user
|
2015-10-09 17:33:33 +02:00
|
|
|
end
|
|
|
|
|
2016-09-14 16:36:01 +02:00
|
|
|
it_should_behave_like "current_user_dossier_spec"
|
2015-10-09 17:33:33 +02:00
|
|
|
end
|
|
|
|
|
2016-09-14 16:36:01 +02:00
|
|
|
context 'when user is invite by the owner' do
|
|
|
|
before do
|
|
|
|
create :invite, email: invite_user.email, dossier: dossier, user: invite_user, type: 'InviteUser'
|
|
|
|
sign_in invite_user
|
2015-10-09 17:33:33 +02:00
|
|
|
end
|
|
|
|
|
2016-09-14 16:36:01 +02:00
|
|
|
it_should_behave_like "current_user_dossier_spec"
|
2015-10-09 17:33:33 +02:00
|
|
|
end
|
|
|
|
end
|
2016-09-14 16:36:01 +02:00
|
|
|
end
|