demarches-normaliennes/spec/services/user_routes_authorization_service_spec.rb

211 lines
5 KiB
Ruby
Raw Normal View History

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-26 15:52:05 +01:00
let(:use_api_carto) { false }
2016-01-26 15:52:05 +01:00
subject { described_class.authorized_route? controller, dossier }
2016-01-26 15:52:05 +01:00
describe 'Users::DossiersController' do
let(:controller) { Users::DossiersController }
describe 'draft' do
let(:state) { 'draft' }
it { is_expected.to be_truthy }
end
describe 'initiated' do
let(:state) { 'initiated' }
it { is_expected.to be_falsey }
end
2016-01-26 15:52:05 +01:00
describe 'replied' do
let(:state) { 'replied' }
it { is_expected.to be_falsey }
end
2016-01-26 15:52:05 +01:00
describe 'updated' do
let(:state) { 'updated' }
it { is_expected.to be_falsey }
end
describe 'validated' do
let(:state) { 'validated' }
it { is_expected.to be_falsey }
end
describe 'submitted' do
let(:state) { 'submitted' }
it { is_expected.to be_falsey }
end
describe 'closed' do
let(:state) { 'closed' }
it { is_expected.to be_falsey }
end
end
2016-01-26 15:52:05 +01:00
describe 'carte' do
let(:controller) { Users::CarteController }
context 'when use_api_carto is false' do
describe 'draft' do
let(:state) { 'draft' }
2016-01-26 15:52:05 +01:00
it { is_expected.to be_falsey }
end
describe 'initiated' do
let(:state) { 'initiated' }
it { is_expected.to be_falsey }
end
describe 'replied' do
let(:state) { 'replied' }
it { is_expected.to be_falsey }
end
describe 'updated' do
let(:state) { 'updated' }
it { is_expected.to be_falsey }
end
describe 'validated' do
let(:state) { 'validated' }
it { is_expected.to be_falsey }
end
describe 'submitted' do
let(:state) { 'submitted' }
it { is_expected.to be_falsey }
end
describe 'closed' do
let(:state) { 'closed' }
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 }
describe 'draft' do
let(:state) { 'draft' }
it { is_expected.to be_truthy }
end
describe 'initiated' do
let(:state) { 'initiated' }
it { is_expected.to be_truthy }
end
describe 'replied' do
let(:state) { 'replied' }
it { is_expected.to be_truthy }
end
describe 'updated' do
let(:state) { 'updated' }
it { is_expected.to be_truthy }
end
describe 'validated' do
let(:state) { 'validated' }
it { is_expected.to be_falsey }
end
describe 'submitted' do
let(:state) { 'submitted' }
it { is_expected.to be_falsey }
end
describe 'closed' do
let(:state) { 'closed' }
it { is_expected.to be_falsey }
end
end
2016-01-26 15:52:05 +01:00
end
2016-01-26 15:52:05 +01:00
describe 'Users::DescriptionController' do
let(:controller) { Users::DescriptionController }
2016-01-26 15:52:05 +01:00
describe 'draft' do
let(:state) { 'draft' }
it { is_expected.to be_truthy }
end
2016-01-26 15:52:05 +01:00
describe 'initiated' do
let(:state) { 'initiated' }
it { is_expected.to be_truthy }
end
2016-01-26 15:52:05 +01:00
describe 'replied' do
let(:state) { 'replied' }
it { is_expected.to be_truthy }
end
2016-01-26 15:52:05 +01:00
describe 'updated' do
let(:state) { 'updated' }
it { is_expected.to be_truthy }
end
2016-01-26 15:52:05 +01:00
describe 'validated' do
let(:state) { 'validated' }
it { is_expected.to be_falsey }
end
2016-01-26 15:52:05 +01:00
describe 'submitted' do
let(:state) { 'submitted' }
it { is_expected.to be_falsey }
end
2016-01-26 15:52:05 +01:00
describe 'closed' do
let(:state) { 'closed' }
it { is_expected.to be_falsey }
end
end
describe 'recapitulatif' do
let(:controller) { Users::RecapitulatifController }
describe 'draft' do
let(:state) { 'draft' }
it { is_expected.to be_falsey }
end
describe 'initiated' do
let(:state) { 'initiated' }
it { is_expected.to be_truthy }
end
describe 'replied' do
let(:state) { 'replied' }
it { is_expected.to be_truthy }
end
describe 'updated' do
let(:state) { 'updated' }
it { is_expected.to be_truthy }
end
describe 'validated' do
let(:state) { 'validated' }
it { is_expected.to be_truthy }
end
describe 'submitted' do
let(:state) { 'submitted' }
it { is_expected.to be_truthy }
end
describe 'closed' do
let(:state) { 'closed' }
it { is_expected.to be_truthy }
end
end
end
end