diff --git a/app/models/type_de_champs.rb b/app/models/type_de_champs.rb index 8b59c5d82..679f78c61 100644 --- a/app/models/type_de_champs.rb +++ b/app/models/type_de_champs.rb @@ -1,13 +1,13 @@ class TypeDeChamps < ActiveRecord::Base - enum type: {text: 'text', - textarea: 'textarea', - datetime: 'datetime', - number: 'number' + enum type_champs: {text: 'text', + textarea: 'textarea', + datetime: 'datetime', + number: 'number' } 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 \ No newline at end of file diff --git a/db/migrate/20151027150850_change_attributs_to_type_de_champs.rb b/db/migrate/20151027150850_change_attributs_to_type_de_champs.rb new file mode 100644 index 000000000..23fd252d4 --- /dev/null +++ b/db/migrate/20151027150850_change_attributs_to_type_de_champs.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 3859754fd..781af478a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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| diff --git a/spec/models/type_de_champs_spec.rb b/spec/models/type_de_champs_spec.rb index 15f4f766b..4533c84eb 100644 --- a/spec/models/type_de_champs_spec.rb +++ b/spec/models/type_de_champs_spec.rb @@ -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