Add column created_at on cerfa and piece_justificative

This commit is contained in:
Xavier J 2016-03-14 17:30:22 +01:00
parent abfb6367d6
commit 26431ac528
8 changed files with 27 additions and 8 deletions

View file

@ -1,5 +1,7 @@
class CerfaSerializer < ActiveModel::Serializer class CerfaSerializer < ActiveModel::Serializer
attributes :content_url => :url attributes :created_at,
:content_url => :url
end end

View file

@ -1,5 +1,6 @@
class PieceJustificativeSerializer < ActiveModel::Serializer class PieceJustificativeSerializer < ActiveModel::Serializer
attributes :content_url => :url attributes :created_at,
:content_url => :url
has_one :type_de_piece_justificative has_one :type_de_piece_justificative
end end

View file

@ -0,0 +1,5 @@
class AddCreatedAtToCerfa < ActiveRecord::Migration
def change
add_column :cerfas, :created_at, :datetime
end
end

View file

@ -0,0 +1,5 @@
class AddCreatedAtToPieceJustificative < ActiveRecord::Migration
def change
add_column :pieces_justificatives, :created_at, :datetime
end
end

View file

@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160314102523) do ActiveRecord::Schema.define(version: 20160314161959) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -70,6 +70,7 @@ ActiveRecord::Schema.define(version: 20160314102523) do
create_table "cerfas", force: :cascade do |t| create_table "cerfas", force: :cascade do |t|
t.string "content" t.string "content"
t.integer "dossier_id" t.integer "dossier_id"
t.datetime "created_at"
end end
add_index "cerfas", ["dossier_id"], name: "index_cerfas_on_dossier_id", using: :btree add_index "cerfas", ["dossier_id"], name: "index_cerfas_on_dossier_id", using: :btree
@ -198,6 +199,7 @@ ActiveRecord::Schema.define(version: 20160314102523) do
t.string "content" t.string "content"
t.integer "dossier_id" t.integer "dossier_id"
t.integer "type_de_piece_justificative_id" t.integer "type_de_piece_justificative_id"
t.datetime "created_at"
end end
add_index "pieces_justificatives", ["type_de_piece_justificative_id"], name: "index_pieces_justificatives_on_type_de_piece_justificative_id", using: :btree add_index "pieces_justificatives", ["type_de_piece_justificative_id"], name: "index_pieces_justificatives_on_type_de_piece_justificative_id", using: :btree

View file

@ -172,6 +172,7 @@ describe API::V1::DossiersController do
subject { super().first } subject { super().first }
it { expect(subject.keys.include?(:url)).to be_truthy } it { expect(subject.keys.include?(:url)).to be_truthy }
it { expect(subject[:created_at]).not_to be_nil }
it { expect(subject.keys.include?(:type_de_piece_justificative)).to be_truthy } it { expect(subject.keys.include?(:type_de_piece_justificative)).to be_truthy }
describe 'type de piece justificative' do describe 'type de piece justificative' do
@ -242,6 +243,7 @@ describe API::V1::DossiersController do
subject { super()[:cerfa] } subject { super()[:cerfa] }
it { expect(subject[:created_at]).not_to be_nil }
it { expect(subject[:url]).to match /^http:\/\/.*downloads.*_CERFA\.pdf$/ } it { expect(subject[:url]).to match /^http:\/\/.*downloads.*_CERFA\.pdf$/ }
end end

View file

@ -3,6 +3,7 @@ require 'spec_helper'
describe Cerfa do describe Cerfa do
describe 'database columns' do describe 'database columns' do
it { is_expected.to have_db_column(:content) } it { is_expected.to have_db_column(:content) }
it { is_expected.to have_db_column(:created_at) }
end end
describe 'associations' do describe 'associations' do

View file

@ -3,6 +3,7 @@ require 'spec_helper'
describe PieceJustificative do describe PieceJustificative do
describe 'database columns' do describe 'database columns' do
it { is_expected.to have_db_column(:content) } it { is_expected.to have_db_column(:content) }
it { is_expected.to have_db_column(:created_at) }
end end
describe 'associations' do describe 'associations' do