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
attributes :content_url => :url
attributes :created_at,
:content_url => :url
end

View file

@ -1,5 +1,6 @@
class PieceJustificativeSerializer < ActiveModel::Serializer
attributes :content_url => :url
attributes :created_at,
:content_url => :url
has_one :type_de_piece_justificative
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.
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
enable_extension "plpgsql"
@ -68,8 +68,9 @@ ActiveRecord::Schema.define(version: 20160314102523) do
end
create_table "cerfas", force: :cascade do |t|
t.string "content"
t.integer "dossier_id"
t.string "content"
t.integer "dossier_id"
t.datetime "created_at"
end
add_index "cerfas", ["dossier_id"], name: "index_cerfas_on_dossier_id", using: :btree
@ -195,9 +196,10 @@ ActiveRecord::Schema.define(version: 20160314102523) do
add_index "module_api_cartos", ["procedure_id"], name: "index_module_api_cartos_on_procedure_id", unique: true, using: :btree
create_table "pieces_justificatives", force: :cascade do |t|
t.string "content"
t.integer "dossier_id"
t.integer "type_de_piece_justificative_id"
t.string "content"
t.integer "dossier_id"
t.integer "type_de_piece_justificative_id"
t.datetime "created_at"
end
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 }
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 }
describe 'type de piece justificative' do
@ -242,6 +243,7 @@ describe API::V1::DossiersController do
subject { super()[:cerfa] }
it { expect(subject[:created_at]).not_to be_nil }
it { expect(subject[:url]).to match /^http:\/\/.*downloads.*_CERFA\.pdf$/ }
end

View file

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

View file

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