2016-01-25 15:54:21 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe UserRoutesAuthorizationService do
|
|
|
|
describe '#authorize_route?' do
|
2016-01-26 15:52:05 +01:00
|
|
|
let(:module_api_carto) { create :module_api_carto, use_api_carto: use_api_carto }
|
|
|
|
let(:procedure) { create :procedure, module_api_carto: module_api_carto }
|
|
|
|
let(:dossier) { create :dossier, procedure: procedure, state: state }
|
2016-01-25 15:54:21 +01:00
|
|
|
|
2016-01-26 15:52:05 +01:00
|
|
|
let(:use_api_carto) { false }
|
2016-01-25 15:54:21 +01:00
|
|
|
|
2016-01-26 15:52:05 +01:00
|
|
|
subject { described_class.authorized_route? controller, dossier }
|
2016-01-25 15:54:21 +01:00
|
|
|
|
2016-01-26 15:52:05 +01:00
|
|
|
describe 'Users::DossiersController' do
|
|
|
|
let(:controller) { Users::DossiersController }
|
|
|
|
|
2017-12-04 16:17:15 +01:00
|
|
|
describe 'brouillon' do
|
|
|
|
let(:state) { 'brouillon' }
|
2016-01-26 15:52:05 +01:00
|
|
|
it { is_expected.to be_truthy }
|
|
|
|
end
|
|
|
|
|
2017-12-14 15:51:45 +01:00
|
|
|
describe 'en_construction' do
|
|
|
|
let(:state) { 'en_construction' }
|
2016-01-26 15:52:05 +01:00
|
|
|
it { is_expected.to be_falsey }
|
|
|
|
end
|
2016-01-25 15:54:21 +01:00
|
|
|
|
2017-12-04 18:00:12 +01:00
|
|
|
describe 'accepte' do
|
|
|
|
let(:state) { 'accepte' }
|
2016-01-26 15:52:05 +01:00
|
|
|
it { is_expected.to be_falsey }
|
|
|
|
end
|
2016-01-25 15:54:21 +01:00
|
|
|
end
|
|
|
|
|
2016-01-26 15:52:05 +01:00
|
|
|
describe 'carte' do
|
|
|
|
let(:controller) { Users::CarteController }
|
|
|
|
|
|
|
|
context 'when use_api_carto is false' do
|
2017-12-04 16:17:15 +01:00
|
|
|
describe 'brouillon' do
|
|
|
|
let(:state) { 'brouillon' }
|
2016-01-26 15:52:05 +01:00
|
|
|
it { is_expected.to be_falsey }
|
2016-01-25 15:54:21 +01:00
|
|
|
end
|
|
|
|
|
2017-12-14 15:51:45 +01:00
|
|
|
describe 'en_construction' do
|
|
|
|
let(:state) { 'en_construction' }
|
2016-01-25 15:54:21 +01:00
|
|
|
it { is_expected.to be_falsey }
|
|
|
|
end
|
|
|
|
|
2017-12-04 18:00:12 +01:00
|
|
|
describe 'accepte' do
|
|
|
|
let(:state) { 'accepte' }
|
2016-01-25 15:54:21 +01:00
|
|
|
it { is_expected.to be_falsey }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-01-26 15:52:05 +01:00
|
|
|
context 'when use_api_carto is true' do
|
|
|
|
let(:use_api_carto) { true }
|
2016-01-25 15:54:21 +01:00
|
|
|
|
2017-12-04 16:17:15 +01:00
|
|
|
describe 'brouillon' do
|
|
|
|
let(:state) { 'brouillon' }
|
2016-01-25 15:54:21 +01:00
|
|
|
it { is_expected.to be_truthy }
|
|
|
|
end
|
|
|
|
|
2017-12-14 15:51:45 +01:00
|
|
|
describe 'en_construction' do
|
|
|
|
let(:state) { 'en_construction' }
|
2016-01-25 15:54:21 +01:00
|
|
|
it { is_expected.to be_truthy }
|
|
|
|
end
|
|
|
|
|
2017-12-04 18:00:12 +01:00
|
|
|
describe 'accepte' do
|
|
|
|
let(:state) { 'accepte' }
|
2016-01-25 15:54:21 +01:00
|
|
|
it { is_expected.to be_falsey }
|
|
|
|
end
|
|
|
|
end
|
2016-01-26 15:52:05 +01:00
|
|
|
end
|
2016-01-25 15:54:21 +01:00
|
|
|
|
2016-01-26 15:52:05 +01:00
|
|
|
describe 'recapitulatif' do
|
|
|
|
let(:controller) { Users::RecapitulatifController }
|
|
|
|
|
2017-12-04 16:17:15 +01:00
|
|
|
describe 'brouillon' do
|
|
|
|
let(:state) { 'brouillon' }
|
2016-01-26 15:52:05 +01:00
|
|
|
it { is_expected.to be_falsey }
|
|
|
|
end
|
|
|
|
|
2017-12-14 15:51:45 +01:00
|
|
|
describe 'en_construction' do
|
|
|
|
let(:state) { 'en_construction' }
|
2016-01-26 15:52:05 +01:00
|
|
|
it { is_expected.to be_truthy }
|
|
|
|
end
|
|
|
|
|
2017-12-04 18:00:12 +01:00
|
|
|
describe 'accepte' do
|
|
|
|
let(:state) { 'accepte' }
|
2016-01-26 15:52:05 +01:00
|
|
|
it { is_expected.to be_truthy }
|
2016-01-25 15:54:21 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|