Spec: add spaces for readability

This commit is contained in:
simon lehericey 2018-09-26 14:39:17 +02:00
parent 68ce035bda
commit 674d231194

View file

@ -2,20 +2,27 @@ require 'spec_helper'
describe API::V1::ProceduresController, type: :controller do describe API::V1::ProceduresController, type: :controller do
let(:admin) { create(:administrateur, :with_api_token) } let(:admin) { create(:administrateur, :with_api_token) }
it { expect(described_class).to be < APIController } it { expect(described_class).to be < APIController }
describe 'GET show' do describe 'GET show' do
context 'when procedure does not exist' do context 'when procedure does not exist' do
subject { get :show, params: { id: 999_999_999, token: admin.api_token } } subject { get :show, params: { id: 999_999_999, token: admin.api_token } }
it { expect(subject.status).to eq(404) } it { expect(subject.status).to eq(404) }
end end
context 'when procedure does not belong to administrateur' do context 'when procedure does not belong to administrateur' do
let(:procedure) { create(:procedure, administrateur: create(:administrateur)) } let(:procedure) { create(:procedure, administrateur: create(:administrateur)) }
subject { get :show, params: { id: procedure, token: admin.api_token } } subject { get :show, params: { id: procedure, token: admin.api_token } }
it { expect(subject.status).to eq(404) } it { expect(subject.status).to eq(404) }
end end
context 'when procedure exist' do context 'when procedure exist' do
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, administrateur: admin) } let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, administrateur: admin) }
subject { get :show, params: { id: procedure, token: admin.api_token } } subject { get :show, params: { id: procedure, token: admin.api_token } }
it 'return REST code 200', :show_in_doc do it 'return REST code 200', :show_in_doc do
@ -26,6 +33,7 @@ describe API::V1::ProceduresController, type: :controller do
let(:module_api_carto) { create(:module_api_carto, use_api_carto: true, quartiers_prioritaires: true, cadastre: true) } let(:module_api_carto) { create(:module_api_carto, use_api_carto: true, quartiers_prioritaires: true, cadastre: true) }
let(:procedure) { create(:procedure, :with_type_de_champ, :with_two_type_de_piece_justificative, module_api_carto: module_api_carto, administrateur: admin) } let(:procedure) { create(:procedure, :with_type_de_champ, :with_two_type_de_piece_justificative, module_api_carto: module_api_carto, administrateur: admin) }
let(:response) { get :show, params: { id: procedure.id, token: admin.api_token } } let(:response) { get :show, params: { id: procedure.id, token: admin.api_token } }
subject { JSON.parse(response.body, symbolize_names: true)[:procedure] } subject { JSON.parse(response.body, symbolize_names: true)[:procedure] }
it { expect(subject[:id]).to eq(procedure.id) } it { expect(subject[:id]).to eq(procedure.id) }
@ -38,9 +46,12 @@ describe API::V1::ProceduresController, type: :controller do
it { expect(subject[:total_dossier]).to eq(procedure.total_dossier) } it { expect(subject[:total_dossier]).to eq(procedure.total_dossier) }
it { is_expected.to have_key(:types_de_champ) } it { is_expected.to have_key(:types_de_champ) }
it { expect(subject[:types_de_champ]).to be_an(Array) } it { expect(subject[:types_de_champ]).to be_an(Array) }
describe 'type_de_champ' do describe 'type_de_champ' do
subject { super()[:types_de_champ][0] } subject { super()[:types_de_champ][0] }
let(:champ) { procedure.types_de_champ.first } let(:champ) { procedure.types_de_champ.first }
it { expect(subject[:id]).to eq(champ.id) } it { expect(subject[:id]).to eq(champ.id) }
it { expect(subject[:libelle]).to eq(champ.libelle) } it { expect(subject[:libelle]).to eq(champ.libelle) }
it { expect(subject[:type_champ]).to eq(champ.type_champ) } it { expect(subject[:type_champ]).to eq(champ.type_champ) }
@ -50,16 +61,22 @@ describe API::V1::ProceduresController, type: :controller do
it { is_expected.to have_key(:types_de_piece_justificative) } it { is_expected.to have_key(:types_de_piece_justificative) }
it { expect(subject[:types_de_piece_justificative]).to be_an(Array) } it { expect(subject[:types_de_piece_justificative]).to be_an(Array) }
describe 'type_de_piece_jointe' do describe 'type_de_piece_jointe' do
subject { super()[:types_de_piece_justificative][0] } subject { super()[:types_de_piece_justificative][0] }
let(:pj) { procedure.types_de_piece_justificative.first } let(:pj) { procedure.types_de_piece_justificative.first }
it { expect(subject[:id]).to eq(pj.id) } it { expect(subject[:id]).to eq(pj.id) }
it { expect(subject[:libelle]).to eq(pj.libelle) } it { expect(subject[:libelle]).to eq(pj.libelle) }
it { expect(subject[:description]).to eq(pj.description) } it { expect(subject[:description]).to eq(pj.description) }
end end
it { is_expected.to have_key(:geographic_information) } it { is_expected.to have_key(:geographic_information) }
describe 'geographic_information' do describe 'geographic_information' do
subject { super()[:geographic_information] } subject { super()[:geographic_information] }
it { expect(subject[:use_api_carto]).to be_truthy } it { expect(subject[:use_api_carto]).to be_truthy }
it { expect(subject[:quartiers_prioritaires]).to be_truthy } it { expect(subject[:quartiers_prioritaires]).to be_truthy }
it { expect(subject[:cadastre]).to be_truthy } it { expect(subject[:cadastre]).to be_truthy }