2015-09-28 18:55:16 +02:00
|
|
|
require 'spec_helper'
|
2016-09-14 16:36:01 +02:00
|
|
|
require 'controllers/users/carte_controller_shared_example'
|
2015-09-28 18:55:16 +02:00
|
|
|
|
|
|
|
RSpec.describe Users::CarteController, type: :controller do
|
|
|
|
let(:bad_adresse) { 'babouba' }
|
|
|
|
|
2016-01-18 12:03:18 +01:00
|
|
|
let(:module_api_carto) { create(:module_api_carto, :with_api_carto) }
|
|
|
|
let(:procedure) { create(:procedure, module_api_carto: module_api_carto) }
|
2016-01-25 15:54:21 +01:00
|
|
|
let(:dossier) { create(:dossier, procedure: procedure) }
|
2015-12-08 11:18:49 +01:00
|
|
|
|
2016-09-14 16:36:01 +02:00
|
|
|
let(:owner_user) { dossier.user }
|
|
|
|
let(:invite_by_user) { create :user, email: 'invite@plop.com' }
|
|
|
|
|
2016-02-04 14:08:35 +01:00
|
|
|
let(:dossier_with_no_carto) { create(:dossier) }
|
2015-09-28 18:55:16 +02:00
|
|
|
let!(:etablissement) { create(:etablissement, dossier: dossier) }
|
|
|
|
let(:bad_dossier_id) { Dossier.count + 1000 }
|
2016-01-07 11:47:52 +01:00
|
|
|
let(:adresse) { etablissement.geo_adresse }
|
2015-09-28 18:55:16 +02:00
|
|
|
|
2015-10-09 14:43:19 +02:00
|
|
|
before do
|
2016-09-14 16:36:01 +02:00
|
|
|
create :invite, dossier: dossier, user: invite_by_user, email: invite_by_user.email, type: 'InviteUser'
|
2015-10-09 17:33:33 +02:00
|
|
|
|
2016-09-14 16:36:01 +02:00
|
|
|
sign_in user
|
2015-09-28 18:55:16 +02:00
|
|
|
end
|
|
|
|
|
2016-09-14 16:36:01 +02:00
|
|
|
context 'when sign in user is the owner' do
|
|
|
|
let(:user) { owner_user }
|
2016-01-18 12:03:18 +01:00
|
|
|
|
2016-09-14 16:36:01 +02:00
|
|
|
it_should_behave_like "carte_controller_spec"
|
2015-09-28 18:55:16 +02:00
|
|
|
end
|
2015-11-25 10:26:55 +01:00
|
|
|
|
2016-09-14 16:36:01 +02:00
|
|
|
context 'when sign in user is an invite by owner' do
|
|
|
|
let(:user) { invite_by_user }
|
2015-11-25 10:26:55 +01:00
|
|
|
|
2016-09-14 16:36:01 +02:00
|
|
|
it_should_behave_like "carte_controller_spec"
|
2015-11-25 10:26:55 +01:00
|
|
|
end
|
2015-09-28 18:55:16 +02:00
|
|
|
end
|