Fix bug enterprise's date_creation

This commit is contained in:
Xavier J 2016-01-28 11:29:44 +01:00
parent cef48fb03c
commit 68bb4935e7
8 changed files with 30 additions and 20 deletions

View file

@ -0,0 +1,9 @@
class ChangeDateCreationTypeToEntreprise < ActiveRecord::Migration
def up
change_column :entreprises, :date_creation, "timestamp USING to_timestamp(date_creation) at time zone 'UTC-2'"
end
def down
change_column :entreprises, :date_creation, "integer USING extract(epoch from date_creation::timestamp with time zone)::integer"
end
end

View file

@ -11,8 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160121110603) do
ActiveRecord::Schema.define(version: 20160127170437) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -100,7 +99,7 @@ ActiveRecord::Schema.define(version: 20160121110603) do
t.string "raison_sociale"
t.string "siret_siege_social"
t.string "code_effectif_entreprise"
t.integer "date_creation"
t.datetime "date_creation"
t.string "nom"
t.string "prenom"
t.integer "dossier_id"

View file

@ -15,6 +15,8 @@ class SIADE::EntrepriseAdapter
data_source[:entreprise].each do |k, v|
params[k] = v if attr_to_fetch.include?(k)
end
params[:date_creation] = Time.at(params[:date_creation]).to_datetime
params
rescue
nil

View file

@ -144,7 +144,7 @@ describe API::V1::DossiersController do
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') }
it { expect(subject[:date_creation]).to eq(1_004_914_800) }
it { expect(subject[:date_creation]).to eq('2016-01-28T10:16:29.000Z') }
it { expect(subject.keys).to match_array(field_list) }
end

View file

@ -53,7 +53,7 @@ describe EntrepriseDecorator do
describe '#pretty_date_creation' do
it 'pretty print date creation' do
expect(subject.pretty_date_creation).to eq('05-11-2001')
expect(subject.pretty_date_creation).to eq('28-01-2016')
end
end
end

View file

@ -9,6 +9,6 @@ FactoryGirl.define do
raison_sociale 'GRTGAZ'
siret_siege_social '44011762001530'
code_effectif_entreprise '51'
date_creation 1_004_914_800
date_creation Time.at(1453976189).to_datetime
end
end

View file

@ -50,7 +50,7 @@ describe SIADE::EntrepriseAdapter do
end
it 'L\'entreprise contient bien une date_creation' do
expect(subject[:date_creation]).to eq(891_381_600)
expect(subject[:date_creation]).to eq('Mon, 01 Jan 1900 00:00:00.000000000 +0100')
end
it 'L\'entreprise contient bien un nom' do

View file

@ -11,7 +11,7 @@
"raison_sociale": "OCTO-TECHNOLOGY",
"siret_siege_social": "41816609600051",
"code_effectif_entreprise": "22",
"date_creation": 891381600,
"date_creation": -2208992400,
"nom": "test_nom",
"prenom": "test_prenom",
"etat_administratif": {