Add description to type_de_champs table

This commit is contained in:
Xavier J 2015-10-27 16:15:25 +01:00
parent 5c643c6373
commit 2d548acba0
4 changed files with 28 additions and 14 deletions

View file

@ -1,5 +1,5 @@
class TypeDeChamps < ActiveRecord::Base
enum type: {text: 'text',
enum type_champs: {text: 'text',
textarea: 'textarea',
datetime: 'datetime',
number: 'number'
@ -8,6 +8,6 @@ class TypeDeChamps < ActiveRecord::Base
belongs_to :procedure
validates :libelle, presence: true, allow_blank: false, allow_nil: false
validates :type, presence: true, allow_blank: false, allow_nil: false
validates :type_champs, presence: true, allow_blank: false, allow_nil: false
validates :order_place, presence: true, allow_blank: false, allow_nil: false
end

View file

@ -0,0 +1,6 @@
class ChangeAttributsToTypeDeChamps < ActiveRecord::Migration
def change
rename_column :types_de_champs, :type, :type_champs
add_column :types_de_champs, :description, :text
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: 20151026155158) do
ActiveRecord::Schema.define(version: 20151027150850) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -144,9 +144,10 @@ ActiveRecord::Schema.define(version: 20151026155158) do
create_table "types_de_champs", force: :cascade do |t|
t.string "libelle"
t.string "type"
t.string "type_champs"
t.integer "order_place"
t.integer "procedure_id"
t.text "description"
end
create_table "types_de_piece_justificative", force: :cascade do |t|

View file

@ -3,8 +3,9 @@ require 'spec_helper'
describe TypeDeChamps do
describe 'database columns' do
it { is_expected.to have_db_column(:libelle) }
it { is_expected.to have_db_column(:type) }
it { is_expected.to have_db_column(:type_champs) }
it { is_expected.to have_db_column(:order_place) }
it { is_expected.to have_db_column(:description) }
end
describe 'associations' do
@ -19,13 +20,13 @@ describe TypeDeChamps do
end
context 'type' do
it { is_expected.not_to allow_value(nil).for(:type) }
it { is_expected.not_to allow_value('').for(:type) }
it { is_expected.not_to allow_value(nil).for(:type_champs) }
it { is_expected.not_to allow_value('').for(:type_champs) }
it { is_expected.to allow_value('text').for(:type) }
it { is_expected.to allow_value('textarea').for(:type) }
it { is_expected.to allow_value('datetime').for(:type) }
it { is_expected.to allow_value('number').for(:type) }
it { is_expected.to allow_value('text').for(:type_champs) }
it { is_expected.to allow_value('textarea').for(:type_champs) }
it { is_expected.to allow_value('datetime').for(:type_champs) }
it { is_expected.to allow_value('number').for(:type_champs) }
end
context 'order_place' do
@ -33,5 +34,11 @@ describe TypeDeChamps do
it { is_expected.not_to allow_value('').for(:order_place) }
it { is_expected.to allow_value(1).for(:order_place) }
end
context 'description' do
it { is_expected.to allow_value(nil).for(:description) }
it { is_expected.to allow_value('').for(:description) }
it { is_expected.to allow_value('blabla').for(:description) }
end
end
end