2016-01-20 15:48:46 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe API::V1::DossiersController do
|
2018-09-26 15:07:33 +02:00
|
|
|
let(:admin) { create(:administrateur) }
|
|
|
|
let(:token) { admin.renew_api_token }
|
2018-10-31 13:32:17 +01:00
|
|
|
let(:procedure) { create(:procedure, :with_api_carto, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_type_de_champ_private, administrateur: admin) }
|
2016-01-20 15:48:46 +01:00
|
|
|
let(:wrong_procedure) { create(:procedure) }
|
|
|
|
|
|
|
|
it { expect(described_class).to be < APIController }
|
2016-02-04 14:08:35 +01:00
|
|
|
|
2018-03-08 17:41:54 +01:00
|
|
|
describe 'GET index (with bearer token)' do
|
2018-09-26 15:07:33 +02:00
|
|
|
let(:authorization_header) { ActionController::HttpAuthentication::Token.encode_credentials(token) }
|
2018-03-08 17:41:54 +01:00
|
|
|
let(:retour) do
|
|
|
|
request.env['HTTP_AUTHORIZATION'] = authorization_header
|
|
|
|
get :index, params: { procedure_id: procedure_id }
|
|
|
|
end
|
|
|
|
|
|
|
|
subject { retour }
|
|
|
|
|
|
|
|
context 'when procedure is not found' do
|
|
|
|
let(:procedure_id) { 99_999_999 }
|
|
|
|
it { expect(subject.code).to eq('404') }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-01-20 15:48:46 +01:00
|
|
|
describe 'GET index' do
|
2018-09-26 15:07:33 +02:00
|
|
|
let(:retour) { get :index, params: { token: token, procedure_id: procedure_id } }
|
2016-01-20 15:48:46 +01:00
|
|
|
|
2016-02-26 14:16:17 +01:00
|
|
|
subject { retour }
|
2016-01-20 15:48:46 +01:00
|
|
|
|
|
|
|
context 'when procedure is not found' do
|
|
|
|
let(:procedure_id) { 99_999_999 }
|
|
|
|
it { expect(subject.code).to eq('404') }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when procedure does not belong to admin' do
|
|
|
|
let(:procedure_id) { wrong_procedure.id }
|
2018-09-26 16:49:21 +02:00
|
|
|
it { expect(subject.code).to eq('401') }
|
2016-01-20 15:48:46 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when procedure is found and belongs to admin' do
|
|
|
|
let(:procedure_id) { procedure.id }
|
2018-10-25 17:03:03 +02:00
|
|
|
let(:date_creation) { Time.zone.local(2008, 9, 1, 10, 5, 0) }
|
2017-12-14 15:51:45 +01:00
|
|
|
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, :en_construction, procedure: procedure) } }
|
2016-02-26 14:16:17 +01:00
|
|
|
let(:body) { JSON.parse(retour.body, symbolize_names: true) }
|
2016-02-04 14:08:35 +01:00
|
|
|
|
2016-02-22 19:42:47 +01:00
|
|
|
it 'return REST code 200', :show_in_doc do
|
2016-02-26 14:16:17 +01:00
|
|
|
expect(retour.code).to eq('200')
|
2016-02-22 19:42:47 +01:00
|
|
|
end
|
2016-02-04 14:08:35 +01:00
|
|
|
|
2016-01-20 15:48:46 +01:00
|
|
|
it { expect(body).to have_key :pagination }
|
2016-02-04 14:08:35 +01:00
|
|
|
|
2016-01-20 15:48:46 +01:00
|
|
|
it { expect(body).to have_key :dossiers }
|
|
|
|
|
|
|
|
describe 'pagination' do
|
|
|
|
subject { body[:pagination] }
|
|
|
|
it { is_expected.to have_key(:page) }
|
|
|
|
it { expect(subject[:page]).to eq(1) }
|
|
|
|
it { is_expected.to have_key(:resultats_par_page) }
|
2018-03-08 17:42:12 +01:00
|
|
|
it { expect(subject[:resultats_par_page]).to eq(described_class.const_get(:DEFAULT_PAGE_SIZE)) }
|
2016-01-20 15:48:46 +01:00
|
|
|
it { is_expected.to have_key(:nombre_de_page) }
|
|
|
|
it { expect(subject[:nombre_de_page]).to eq(1) }
|
|
|
|
end
|
|
|
|
|
2018-06-29 17:34:35 +02:00
|
|
|
describe 'with custom resultats_par_page' do
|
2018-09-26 15:07:33 +02:00
|
|
|
let(:retour) { get :index, params: { token: token, procedure_id: procedure_id, resultats_par_page: 18 } }
|
2018-06-29 17:34:35 +02:00
|
|
|
subject { body[:pagination] }
|
|
|
|
it { is_expected.to have_key(:resultats_par_page) }
|
|
|
|
it { expect(subject[:resultats_par_page]).to eq(18) }
|
|
|
|
end
|
|
|
|
|
2016-01-20 15:48:46 +01:00
|
|
|
describe 'dossiers' do
|
|
|
|
subject { body[:dossiers] }
|
|
|
|
it { expect(subject).to be_an(Array) }
|
|
|
|
describe 'dossier' do
|
|
|
|
subject { super().first }
|
|
|
|
it { expect(subject[:id]).to eq(dossier.id) }
|
2018-10-31 10:29:03 +01:00
|
|
|
it { expect(subject[:updated_at]).to eq("2008-09-01T08:05:00.000Z") }
|
|
|
|
it { expect(subject[:initiated_at]).to eq("2008-09-01T08:06:00.000Z") }
|
2018-10-08 17:56:18 +02:00
|
|
|
it { expect(subject[:state]).to eq("initiated") }
|
|
|
|
it { expect(subject.keys.size).to eq(4) }
|
2016-01-20 15:48:46 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when there are multiple pages' do
|
2018-09-26 15:07:33 +02:00
|
|
|
let(:retour) { get :index, params: { token: token, procedure_id: procedure_id, page: 2 } }
|
2016-02-04 14:08:35 +01:00
|
|
|
|
2018-08-28 14:10:55 +02:00
|
|
|
let!(:dossier1) { create(:dossier, :with_entreprise, procedure: procedure, state: Dossier.states.fetch(:en_construction)) }
|
|
|
|
let!(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure, state: Dossier.states.fetch(:en_construction)) }
|
2016-02-04 14:08:35 +01:00
|
|
|
|
2016-01-20 15:48:46 +01:00
|
|
|
before do
|
2017-12-28 19:31:28 +01:00
|
|
|
allow(controller).to receive(:per_page).and_return(1)
|
2016-01-20 15:48:46 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'pagination' do
|
|
|
|
subject { body[:pagination] }
|
2016-02-04 14:08:35 +01:00
|
|
|
|
2016-01-20 15:48:46 +01:00
|
|
|
it { expect(subject[:page]).to eq(2) }
|
|
|
|
it { expect(subject[:resultats_par_page]).to eq(1) }
|
|
|
|
it { expect(subject[:nombre_de_page]).to eq(3) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-01-25 16:08:10 +01:00
|
|
|
|
|
|
|
describe 'GET show' do
|
2018-09-26 15:07:33 +02:00
|
|
|
let(:retour) { get :show, params: { token: token, procedure_id: procedure_id, id: dossier_id } }
|
2016-02-26 14:16:17 +01:00
|
|
|
subject { retour }
|
2016-01-25 16:08:10 +01:00
|
|
|
|
|
|
|
context 'when procedure is not found' do
|
|
|
|
let(:procedure_id) { 99_999_999 }
|
|
|
|
let(:dossier_id) { 1 }
|
|
|
|
it { expect(subject.code).to eq('404') }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when procedure exists and does not belong to current admin' do
|
|
|
|
let(:procedure_id) { wrong_procedure.id }
|
|
|
|
let(:dossier_id) { 1 }
|
2018-09-26 16:49:21 +02:00
|
|
|
it { expect(subject.code).to eq('401') }
|
2016-01-25 16:08:10 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when procedure is found and belongs to current admin' do
|
|
|
|
context 'when dossier does not exist' do
|
|
|
|
let(:procedure_id) { procedure.id }
|
|
|
|
let(:dossier_id) { 99999 }
|
|
|
|
it { expect(subject.code).to eq('404') }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when dossier exists but does not belong to procedure' do
|
|
|
|
let(:procedure_id) { procedure.id }
|
|
|
|
let(:dossier) { create(:dossier, :with_entreprise, procedure: wrong_procedure) }
|
|
|
|
let(:dossier_id) { dossier.id }
|
|
|
|
it { expect(subject.code).to eq('404') }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when dossier exists and belongs to procedure' do
|
|
|
|
let(:procedure_id) { procedure.id }
|
2018-10-25 17:03:03 +02:00
|
|
|
let(:date_creation) { Time.zone.local(2008, 9, 1, 10, 5, 0) }
|
2018-11-01 14:04:32 +01:00
|
|
|
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, :en_construction, procedure: procedure, motivation: "Motivation") } }
|
2016-01-25 16:08:10 +01:00
|
|
|
let(:dossier_id) { dossier.id }
|
2016-02-26 14:16:17 +01:00
|
|
|
let(:body) { JSON.parse(retour.body, symbolize_names: true) }
|
2018-10-10 09:06:32 +02:00
|
|
|
let(:field_list) { [:id, :created_at, :updated_at, :archived, :individual, :entreprise, :etablissement, :cerfa, :types_de_piece_justificative, :pieces_justificatives, :champs, :champs_private, :commentaires, :state, :simplified_state, :initiated_at, :processed_at, :received_at, :motivation, :email, :instructeurs] }
|
2016-01-25 16:08:10 +01:00
|
|
|
subject { body[:dossier] }
|
|
|
|
|
2016-02-22 19:42:47 +01:00
|
|
|
it 'return REST code 200', :show_in_doc do
|
2016-02-26 14:16:17 +01:00
|
|
|
expect(retour.code).to eq('200')
|
2016-02-22 19:42:47 +01:00
|
|
|
end
|
2016-11-15 09:54:17 +01:00
|
|
|
|
2016-01-25 16:08:10 +01:00
|
|
|
it { expect(subject[:id]).to eq(dossier.id) }
|
2018-11-01 14:04:32 +01:00
|
|
|
it { expect(subject[:state]).to eq('initiated') }
|
2018-10-31 10:29:03 +01:00
|
|
|
it { expect(subject[:created_at]).to eq('2008-09-01T08:05:00.000Z') }
|
|
|
|
it { expect(subject[:updated_at]).to eq('2008-09-01T08:05:00.000Z') }
|
2016-01-25 16:08:10 +01:00
|
|
|
it { expect(subject[:archived]).to eq(dossier.archived) }
|
2016-02-26 12:17:41 +01:00
|
|
|
|
2016-01-25 16:08:10 +01:00
|
|
|
it { expect(subject.keys).to match_array(field_list) }
|
|
|
|
|
|
|
|
describe 'entreprise' do
|
2018-01-15 18:54:57 +01:00
|
|
|
let(:field_list) {
|
|
|
|
[
|
2016-02-26 12:17:41 +01:00
|
|
|
:siren,
|
|
|
|
:capital_social,
|
|
|
|
:numero_tva_intracommunautaire,
|
|
|
|
:forme_juridique,
|
|
|
|
:forme_juridique_code,
|
|
|
|
:nom_commercial,
|
|
|
|
:raison_sociale,
|
|
|
|
:siret_siege_social,
|
|
|
|
:code_effectif_entreprise,
|
|
|
|
:date_creation,
|
|
|
|
:nom,
|
2018-01-15 18:54:57 +01:00
|
|
|
:prenom
|
|
|
|
]
|
2017-06-12 14:10:49 +02:00
|
|
|
}
|
2016-02-26 12:17:41 +01:00
|
|
|
subject { super()[:entreprise] }
|
|
|
|
|
|
|
|
it { expect(subject[:siren]).to eq('440117620') }
|
|
|
|
it { expect(subject[:capital_social]).to eq(537_100_000) }
|
|
|
|
it { expect(subject[:numero_tva_intracommunautaire]).to eq('FR27440117620') }
|
|
|
|
it { expect(subject[:forme_juridique]).to eq('SA à conseil d\'administration (s.a.i.)') }
|
2016-01-25 16:08:10 +01:00
|
|
|
it { expect(subject[:forme_juridique_code]).to eq('5599') }
|
|
|
|
it { expect(subject[:nom_commercial]).to eq('GRTGAZ') }
|
|
|
|
it { expect(subject[:raison_sociale]).to eq('GRTGAZ') }
|
|
|
|
it { expect(subject[:siret_siege_social]).to eq('44011762001530') }
|
|
|
|
it { expect(subject[:code_effectif_entreprise]).to eq('51') }
|
2018-04-23 12:01:03 +02:00
|
|
|
it { expect(subject[:date_creation]).to eq('1990-04-24T00:00:00.000+00:00') }
|
2016-01-25 16:08:10 +01:00
|
|
|
it { expect(subject.keys).to match_array(field_list) }
|
|
|
|
end
|
|
|
|
|
2016-03-17 14:50:10 +01:00
|
|
|
describe 'types_de_piece_justificative' do
|
2018-01-15 18:54:57 +01:00
|
|
|
let(:field_list) { [:id, :libelle, :description] }
|
2016-03-17 14:50:10 +01:00
|
|
|
subject { super()[:types_de_piece_justificative] }
|
2016-02-26 12:17:41 +01:00
|
|
|
|
|
|
|
it { expect(subject.length).to eq 2 }
|
|
|
|
|
2016-03-17 14:50:10 +01:00
|
|
|
describe 'first type de piece justificative' do
|
2016-02-26 12:17:41 +01:00
|
|
|
subject { super().first }
|
|
|
|
|
2018-05-18 18:06:48 +02:00
|
|
|
it { expect(subject.key?(:id)).to be_truthy }
|
2016-03-17 14:50:10 +01:00
|
|
|
it { expect(subject[:libelle]).to eq('RIB') }
|
|
|
|
it { expect(subject[:description]).to eq('Releve identité bancaire') }
|
2016-03-17 17:33:38 +01:00
|
|
|
end
|
|
|
|
end
|
2016-02-26 12:17:41 +01:00
|
|
|
|
2018-01-16 13:34:24 +01:00
|
|
|
describe 'piece justificative', vcr: { cassette_name: 'controllers_api_v1_dossiers_controller_piece_justificative' } do
|
2016-03-17 17:33:38 +01:00
|
|
|
before do
|
2016-04-20 16:51:57 +02:00
|
|
|
create :piece_justificative, :rib, dossier: dossier, type_de_piece_justificative: dossier.procedure.types_de_piece_justificative.first, user: dossier.user
|
2016-03-17 17:33:38 +01:00
|
|
|
end
|
2016-02-26 12:17:41 +01:00
|
|
|
|
2018-01-15 18:54:57 +01:00
|
|
|
let(:field_list) { [:url, :created_at, :type_de_piece_justificative_id] }
|
2017-06-12 14:10:49 +02:00
|
|
|
subject { super()[:pieces_justificatives].first }
|
2016-03-17 17:33:38 +01:00
|
|
|
|
2018-05-18 18:06:48 +02:00
|
|
|
it { expect(subject.key?(:content_url)).to be_truthy }
|
2016-03-17 17:33:38 +01:00
|
|
|
it { expect(subject[:created_at]).not_to be_nil }
|
|
|
|
it { expect(subject[:type_de_piece_justificative_id]).not_to be_nil }
|
|
|
|
|
2018-05-18 18:06:48 +02:00
|
|
|
it { expect(subject.key?(:user)).to be_truthy }
|
2016-03-17 17:33:38 +01:00
|
|
|
|
|
|
|
describe 'user' do
|
2016-11-15 09:54:17 +01:00
|
|
|
subject { super()[:user] }
|
2016-03-17 17:33:38 +01:00
|
|
|
|
|
|
|
it { expect(subject[:email]).not_to be_nil }
|
2016-02-26 12:17:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'champs' do
|
2018-01-15 19:22:02 +01:00
|
|
|
let(:field_list) { [:url] }
|
2016-02-26 12:17:41 +01:00
|
|
|
subject { super()[:champs] }
|
|
|
|
|
|
|
|
it { expect(subject.length).to eq 1 }
|
|
|
|
|
|
|
|
describe 'first champs' do
|
2016-08-08 12:52:30 +02:00
|
|
|
subject { super().first }
|
|
|
|
|
2018-05-18 18:06:48 +02:00
|
|
|
it { expect(subject.key?(:value)).to be_truthy }
|
|
|
|
it { expect(subject.key?(:type_de_champ)).to be_truthy }
|
2016-08-08 12:52:30 +02:00
|
|
|
|
|
|
|
describe 'type de champ' do
|
2018-01-15 18:54:57 +01:00
|
|
|
let(:field_list) {
|
|
|
|
[
|
2016-08-08 12:52:30 +02:00
|
|
|
:id,
|
|
|
|
:libelle,
|
|
|
|
:description,
|
|
|
|
:order_place,
|
2018-01-15 18:54:57 +01:00
|
|
|
:type
|
|
|
|
]
|
2017-06-12 14:10:49 +02:00
|
|
|
}
|
2016-08-08 12:52:30 +02:00
|
|
|
subject { super()[:type_de_champ] }
|
|
|
|
|
2018-05-18 18:06:48 +02:00
|
|
|
it { expect(subject.key?(:id)).to be_truthy }
|
2017-07-19 15:40:26 +02:00
|
|
|
it { expect(subject[:libelle]).to include('Libelle du champ') }
|
|
|
|
it { expect(subject[:description]).to include('description du champ') }
|
2018-05-18 18:06:48 +02:00
|
|
|
it { expect(subject.key?(:order_place)).to be_truthy }
|
2016-08-08 12:52:30 +02:00
|
|
|
it { expect(subject[:type_champ]).to eq('text') }
|
|
|
|
end
|
|
|
|
end
|
2017-10-27 15:36:07 +02:00
|
|
|
|
|
|
|
context 'when the dossier includes a quartier prioritaire' do
|
|
|
|
before do
|
|
|
|
dossier.quartier_prioritaires << create(:quartier_prioritaire)
|
|
|
|
end
|
|
|
|
|
|
|
|
subject do
|
|
|
|
super().find { |champ| champ[:type_de_champ][:type_champ] == 'quartier_prioritaire' }
|
|
|
|
end
|
|
|
|
|
2018-01-16 13:34:24 +01:00
|
|
|
it { expect(subject[:type_de_champ]).to match({ id: -1, libelle: 'quartier prioritaire', type_champ: 'quartier_prioritaire', order_place: -1, descripton: '' }) }
|
2017-10-27 15:36:07 +02:00
|
|
|
it { expect(subject[:value]).to match(dossier.quartier_prioritaires.first.geometry.symbolize_keys) }
|
|
|
|
end
|
2017-10-27 15:36:36 +02:00
|
|
|
|
|
|
|
context 'when the dossier includes a cadastre' do
|
|
|
|
before do
|
|
|
|
dossier.cadastres << create(:cadastre)
|
|
|
|
end
|
|
|
|
|
|
|
|
subject do
|
|
|
|
super().find { |champ| champ[:type_de_champ][:type_champ] == 'cadastre' }
|
|
|
|
end
|
|
|
|
|
2018-01-16 13:34:24 +01:00
|
|
|
it { expect(subject[:type_de_champ]).to match({ id: -1, libelle: 'cadastre', type_champ: 'cadastre', order_place: -1, descripton: '' }) }
|
2017-10-27 15:36:36 +02:00
|
|
|
it { expect(subject[:value]).to match(dossier.cadastres.first.geometry.symbolize_keys) }
|
|
|
|
end
|
2017-10-30 16:54:33 +01:00
|
|
|
|
|
|
|
context 'when the dossier includes some user geometry' do
|
|
|
|
before do
|
|
|
|
dossier.json_latlngs = '[[{"lat": 2.0, "lng": 102.0}, {"lat": 3.0, "lng": 103.0}, {"lat": 2.0, "lng": 102.0}]]'
|
|
|
|
dossier.save
|
|
|
|
end
|
|
|
|
|
|
|
|
subject do
|
|
|
|
super().find { |champ| champ[:type_de_champ][:type_champ] == 'user_geometry' }
|
|
|
|
end
|
|
|
|
|
2018-01-16 13:34:24 +01:00
|
|
|
it { expect(subject[:type_de_champ]).to match({ id: -1, libelle: 'user_geometry', type_champ: 'user_geometry', order_place: -1, descripton: '' }) }
|
2017-10-30 16:54:33 +01:00
|
|
|
it { expect(subject[:value]).to match(UserGeometry.new(dossier.json_latlngs).value) }
|
|
|
|
end
|
2016-08-08 12:52:30 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'champs_private' do
|
2018-01-15 18:54:57 +01:00
|
|
|
let(:field_list) { [:url] }
|
2016-08-08 12:52:30 +02:00
|
|
|
subject { super()[:champs_private] }
|
|
|
|
|
|
|
|
it { expect(subject.length).to eq 1 }
|
|
|
|
|
|
|
|
describe 'first champs' do
|
2016-02-26 12:17:41 +01:00
|
|
|
subject { super().first }
|
|
|
|
|
2018-05-18 18:06:48 +02:00
|
|
|
it { expect(subject.key?(:value)).to be_truthy }
|
|
|
|
it { expect(subject.key?(:type_de_champ)).to be_truthy }
|
2016-02-26 12:17:41 +01:00
|
|
|
|
|
|
|
describe 'type de champ' do
|
2018-01-15 18:54:57 +01:00
|
|
|
let(:field_list) {
|
|
|
|
[
|
2016-02-26 12:17:41 +01:00
|
|
|
:id,
|
|
|
|
:libelle,
|
|
|
|
:description,
|
|
|
|
:order_place,
|
2018-01-15 18:54:57 +01:00
|
|
|
:type
|
|
|
|
]
|
2017-06-12 14:10:49 +02:00
|
|
|
}
|
2016-02-26 12:17:41 +01:00
|
|
|
subject { super()[:type_de_champ] }
|
|
|
|
|
2018-05-18 18:06:48 +02:00
|
|
|
it { expect(subject.key?(:id)).to be_truthy }
|
2017-07-19 15:40:26 +02:00
|
|
|
it { expect(subject[:libelle]).to include('Libelle champ privé') }
|
|
|
|
it { expect(subject[:description]).to include('description du champ privé') }
|
2018-05-18 18:06:48 +02:00
|
|
|
it { expect(subject.key?(:order_place)).to be_truthy }
|
2016-08-03 18:19:56 +02:00
|
|
|
it { expect(subject[:type_champ]).to eq('text') }
|
2016-02-26 12:17:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-03-14 10:34:46 +01:00
|
|
|
describe 'commentaires' do
|
|
|
|
let!(:commentaire) { create :commentaire, body: 'plop', created_at: '2016-03-14 14:00:00', email: 'plop@plip.com', dossier: dossier }
|
|
|
|
let!(:commentaire_2) { create :commentaire, body: 'plip', created_at: '2016-03-14 15:00:00', email: 'plip@plap.com', dossier: dossier }
|
|
|
|
|
|
|
|
subject { super()[:commentaires] }
|
|
|
|
|
|
|
|
it { expect(subject.size).to eq 2 }
|
|
|
|
|
|
|
|
it { expect(subject.first[:body]).to eq 'plop' }
|
2018-10-31 10:29:03 +01:00
|
|
|
it { expect(subject.first[:created_at]).to eq '2016-03-14T13:00:00.000Z' }
|
2016-03-14 10:34:46 +01:00
|
|
|
it { expect(subject.first[:email]).to eq 'plop@plip.com' }
|
|
|
|
end
|
|
|
|
|
2016-01-25 16:08:10 +01:00
|
|
|
describe 'etablissement' do
|
2018-01-15 18:54:57 +01:00
|
|
|
let(:field_list) {
|
|
|
|
[
|
2016-02-26 12:17:41 +01:00
|
|
|
:siret,
|
|
|
|
:siege_social,
|
|
|
|
:naf,
|
|
|
|
:libelle_naf,
|
|
|
|
:adresse,
|
|
|
|
:numero_voie,
|
|
|
|
:type_voie,
|
|
|
|
:nom_voie,
|
|
|
|
:complement_adresse,
|
|
|
|
:code_postal,
|
|
|
|
:localite,
|
|
|
|
:code_insee_localite
|
2017-06-12 14:10:49 +02:00
|
|
|
]
|
|
|
|
}
|
2016-02-26 12:17:41 +01:00
|
|
|
subject { super()[:etablissement] }
|
2016-01-25 16:08:10 +01:00
|
|
|
|
|
|
|
it { expect(subject[:siret]).to eq('44011762001530') }
|
|
|
|
it { expect(subject[:siege_social]).to eq(true) }
|
|
|
|
it { expect(subject[:naf]).to eq('4950Z') }
|
|
|
|
it { expect(subject[:libelle_naf]).to eq('Transports par conduites') }
|
|
|
|
it { expect(subject[:adresse]).to eq("GRTGAZ\r IMMEUBLE BORA\r 6 RUE RAOUL NORDLING\r 92270 BOIS COLOMBES\r") }
|
|
|
|
it { expect(subject[:numero_voie]).to eq('6') }
|
|
|
|
it { expect(subject[:type_voie]).to eq('RUE') }
|
|
|
|
it { expect(subject[:nom_voie]).to eq('RAOUL NORDLING') }
|
|
|
|
it { expect(subject[:complement_adresse]).to eq('IMMEUBLE BORA') }
|
|
|
|
it { expect(subject[:code_postal]).to eq('92270') }
|
|
|
|
it { expect(subject[:localite]).to eq('BOIS COLOMBES') }
|
|
|
|
it { expect(subject[:code_insee_localite]).to eq('92009') }
|
|
|
|
it { expect(subject.keys).to match_array(field_list) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-01-20 15:48:46 +01:00
|
|
|
end
|