From 94757951431454e0adf59767f2b0f07bad1a1dd3 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Thu, 25 Oct 2018 17:03:03 +0200 Subject: [PATCH] fix spec --- lib/tasks/2018_09_12_fix_templates.rake | 6 +++++- .../controllers/api/v1/dossiers_controller_spec.rb | 14 +++++++------- .../france_connect/particulier_controller_spec.rb | 2 +- spec/services/france_connect_service_spec.rb | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/tasks/2018_09_12_fix_templates.rake b/lib/tasks/2018_09_12_fix_templates.rake index a9fc3eeb6..8ca36b559 100644 --- a/lib/tasks/2018_09_12_fix_templates.rake +++ b/lib/tasks/2018_09_12_fix_templates.rake @@ -7,7 +7,11 @@ namespace :'2018_09_12_fix_templates' do end # 16:15 in Paris -> 14:15 UTC - DEPLOY_DATETIME = Time.zone.local(2018, 9, 5, 14, 15, 0) + + # rubocop:disable Rails/TimeZone + # because we are in a ruby context so Time.zone = nil + DEPLOY_DATETIME = Time.local(2018, 9, 5, 14, 15, 0) + # rubocop:enable Rails/TimeZone def find_dossiers_with_sent_and_invalid_attestations invalid_procedures_ids = AttestationTemplate diff --git a/spec/controllers/api/v1/dossiers_controller_spec.rb b/spec/controllers/api/v1/dossiers_controller_spec.rb index ff66fb2f0..6873f031c 100644 --- a/spec/controllers/api/v1/dossiers_controller_spec.rb +++ b/spec/controllers/api/v1/dossiers_controller_spec.rb @@ -40,7 +40,7 @@ describe API::V1::DossiersController do context 'when procedure is found and belongs to admin' do let(:procedure_id) { procedure.id } - let(:date_creation) { Time.utc(2008, 9, 1, 10, 5, 0) } + let(:date_creation) { Time.zone.local(2008, 9, 1, 10, 5, 0) } let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, :en_construction, procedure: procedure) } } let(:body) { JSON.parse(retour.body, symbolize_names: true) } @@ -75,8 +75,8 @@ describe API::V1::DossiersController do describe 'dossier' do subject { super().first } it { expect(subject[:id]).to eq(dossier.id) } - it { expect(subject[:updated_at]).to eq("2008-09-01T10:05:00.000Z") } - it { expect(subject[:initiated_at]).to eq("2008-09-01T10:06:00.000Z") } + it { expect(subject[:updated_at]).to eq("2008-09-01T10:05:00.000+02:00") } + it { expect(subject[:initiated_at]).to eq("2008-09-01T10:06:00.000+02:00") } it { expect(subject[:state]).to eq("initiated") } it { expect(subject.keys.size).to eq(4) } end @@ -135,7 +135,7 @@ describe API::V1::DossiersController do context 'when dossier exists and belongs to procedure' do let(:procedure_id) { procedure.id } - let(:date_creation) { Time.utc(2008, 9, 1, 10, 5, 0) } + let(:date_creation) { Time.zone.local(2008, 9, 1, 10, 5, 0) } let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure, motivation: "Motivation") } } let(:dossier_id) { dossier.id } let(:body) { JSON.parse(retour.body, symbolize_names: true) } @@ -148,8 +148,8 @@ describe API::V1::DossiersController do it { expect(subject[:id]).to eq(dossier.id) } it { expect(subject[:state]).to eq(dossier.state) } - it { expect(subject[:created_at]).to eq('2008-09-01T10:05:00.000Z') } - it { expect(subject[:updated_at]).to eq('2008-09-01T10:05:00.000Z') } + it { expect(subject[:created_at]).to eq('2008-09-01T10:05:00.000+02:00') } + it { expect(subject[:updated_at]).to eq('2008-09-01T10:05:00.000+02:00') } it { expect(subject[:archived]).to eq(dossier.archived) } it { expect(subject.keys).to match_array(field_list) } @@ -337,7 +337,7 @@ describe API::V1::DossiersController do it { expect(subject.size).to eq 2 } it { expect(subject.first[:body]).to eq 'plop' } - it { expect(subject.first[:created_at]).to eq '2016-03-14T14:00:00.000Z' } + it { expect(subject.first[:created_at]).to eq '2016-03-14T14:00:00.000+01:00' } it { expect(subject.first[:email]).to eq 'plop@plip.com' } end diff --git a/spec/controllers/france_connect/particulier_controller_spec.rb b/spec/controllers/france_connect/particulier_controller_spec.rb index 3f3027597..498087145 100644 --- a/spec/controllers/france_connect/particulier_controller_spec.rb +++ b/spec/controllers/france_connect/particulier_controller_spec.rb @@ -82,7 +82,7 @@ describe FranceConnect::ParticulierController, type: :controller do before { subject } - it { expect(stored_fci).to have_attributes(user_info.merge(birthdate: Time.zone.parse(birthdate))) } + it { expect(stored_fci).to have_attributes(user_info.merge(birthdate: Date.parse(birthdate))) } end it { is_expected.to redirect_to(root_path) } diff --git a/spec/services/france_connect_service_spec.rb b/spec/services/france_connect_service_spec.rb index 404034099..fb6ba85a2 100644 --- a/spec/services/france_connect_service_spec.rb +++ b/spec/services/france_connect_service_spec.rb @@ -33,7 +33,7 @@ describe FranceConnectService do expect(subject).to have_attributes({ given_name: given_name, family_name: family_name, - birthdate: Time.zone.parse(birthdate), + birthdate: Date.parse(birthdate), birthplace: birthplace, gender: gender, email_france_connect: email,