2015-08-10 11:05:06 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2016-09-14 16:36:01 +02:00
|
|
|
require 'controllers/users/description_controller_shared_example'
|
|
|
|
|
2018-01-16 13:34:24 +01:00
|
|
|
describe Users::DescriptionController, type: :controller, vcr: { cassette_name: 'controllers_users_description_controller' } do
|
2016-09-14 16:36:01 +02:00
|
|
|
let(:owner_user) { create(:user) }
|
|
|
|
let(:invite_by_user) { create :user, email: 'invite@plop.com' }
|
2017-07-10 23:42:33 +02:00
|
|
|
let(:archived_at) { nil }
|
2017-12-14 15:51:45 +01:00
|
|
|
let(:state) { 'en_construction' }
|
2016-02-04 14:08:35 +01:00
|
|
|
|
2017-07-13 16:22:59 +02:00
|
|
|
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime, cerfa_flag: true, published_at: Time.now, archived_at: archived_at) }
|
2017-03-06 15:03:51 +01:00
|
|
|
let(:dossier) { create(:dossier, procedure: procedure, user: owner_user, state: state) }
|
2016-02-04 14:08:35 +01:00
|
|
|
|
2015-08-20 16:25:54 +02:00
|
|
|
let(:dossier_id) { dossier.id }
|
2016-02-04 14:08:35 +01:00
|
|
|
let(:bad_dossier_id) { Dossier.count + 10000 }
|
2015-08-10 11:05:06 +02:00
|
|
|
|
2016-03-22 17:36:36 +01:00
|
|
|
let(:name_piece_justificative) { 'dossierPDF.pdf' }
|
|
|
|
let(:name_piece_justificative_0) { 'piece_justificative_0.pdf' }
|
|
|
|
let(:name_piece_justificative_1) { 'piece_justificative_1.pdf' }
|
|
|
|
|
|
|
|
let(:cerfa_pdf) { Rack::Test::UploadedFile.new("./spec/support/files/#{name_piece_justificative}", 'application/pdf') }
|
|
|
|
let(:piece_justificative_0) { Rack::Test::UploadedFile.new("./spec/support/files/#{name_piece_justificative_0}", 'application/pdf') }
|
|
|
|
let(:piece_justificative_1) { Rack::Test::UploadedFile.new("./spec/support/files/#{name_piece_justificative_1}", 'application/pdf') }
|
|
|
|
|
2015-10-09 14:43:19 +02:00
|
|
|
before do
|
2016-04-15 15:32:15 +02:00
|
|
|
allow(ClamavService).to receive(:safe_file?).and_return(true)
|
|
|
|
|
2016-09-14 16:36:01 +02:00
|
|
|
create :invite, dossier: dossier, user: invite_by_user, email: invite_by_user.email, type: 'InviteUser'
|
2016-01-25 15:54:21 +01:00
|
|
|
|
2016-09-14 16:36:01 +02:00
|
|
|
sign_in user
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
|
|
|
|
2016-09-14 16:36:01 +02:00
|
|
|
context 'when sign in user is the owner' do
|
|
|
|
let(:user) { owner_user }
|
|
|
|
let(:recapitulatif_path) { users_dossier_recapitulatif_path }
|
2016-03-15 17:17:56 +01:00
|
|
|
|
2016-09-14 16:36:01 +02:00
|
|
|
it_should_behave_like "description_controller_spec"
|
|
|
|
it_should_behave_like "description_controller_spec_POST_piece_justificatives_for_owner"
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
2016-03-22 17:36:36 +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 }
|
|
|
|
let(:recapitulatif_path) { users_dossiers_invite_path(id: dossier_id) }
|
2016-03-22 17:36:36 +01:00
|
|
|
|
2016-09-14 16:36:01 +02:00
|
|
|
it_should_behave_like "description_controller_spec"
|
2016-03-22 17:36:36 +01:00
|
|
|
end
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|