Add RNAInformation model

This commit is contained in:
Xavier J 2015-12-11 11:05:38 +01:00
parent 704e491cd0
commit 05298f7a40
6 changed files with 46 additions and 1 deletions

View file

@ -1,4 +1,5 @@
class Entreprise < ActiveRecord::Base
belongs_to :dossier
has_one :etablissement
has_one :rna_information
end

View file

@ -0,0 +1,3 @@
class RNAInformation < ActiveRecord::Base
belongs_to :entreprise
end

View file

@ -0,0 +1,14 @@
class CreateRNAInformationTable < ActiveRecord::Migration
def change
create_table :rna_informations do |t|
t.string :association_id
t.string :titre
t.text :objet
t.date :date_creation
t.date :date_declaration
t.date :date_publication
end
add_reference :rna_informations, :entreprise, references: :entreprise
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: 20151210150958) do
ActiveRecord::Schema.define(version: 20151211093833) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -172,6 +172,16 @@ ActiveRecord::Schema.define(version: 20151210150958) do
t.integer "dossier_id"
end
create_table "rna_informations", force: :cascade do |t|
t.string "association_id"
t.string "titre"
t.text "objet"
t.date "date_creation"
t.date "date_declaration"
t.date "date_publication"
t.integer "entreprise_id"
end
create_table "types_de_champ", force: :cascade do |t|
t.string "libelle"
t.string "type_champ"

View file

@ -19,5 +19,6 @@ describe Entreprise do
describe 'associations' do
it { is_expected.to belong_to(:dossier) }
it { is_expected.to have_one(:etablissement) }
it { is_expected.to have_one(:rna_information) }
end
end

View file

@ -0,0 +1,16 @@
require 'spec_helper'
describe RNAInformation do
describe 'databse columns' do
it { is_expected.to have_db_column(:association_id) }
it { is_expected.to have_db_column(:titre) }
it { is_expected.to have_db_column(:objet) }
it { is_expected.to have_db_column(:date_creation) }
it { is_expected.to have_db_column(:date_publication) }
it { is_expected.to have_db_column(:date_declaration) }
end
describe 'associations' do
it { is_expected.to belong_to(:entreprise) }
end
end