Add description to type_de_champs table
This commit is contained in:
parent
5c643c6373
commit
2d548acba0
4 changed files with 28 additions and 14 deletions
|
@ -1,13 +1,13 @@
|
||||||
class TypeDeChamps < ActiveRecord::Base
|
class TypeDeChamps < ActiveRecord::Base
|
||||||
enum type: {text: 'text',
|
enum type_champs: {text: 'text',
|
||||||
textarea: 'textarea',
|
textarea: 'textarea',
|
||||||
datetime: 'datetime',
|
datetime: 'datetime',
|
||||||
number: 'number'
|
number: 'number'
|
||||||
}
|
}
|
||||||
|
|
||||||
belongs_to :procedure
|
belongs_to :procedure
|
||||||
|
|
||||||
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
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
|
validates :order_place, presence: true, allow_blank: false, allow_nil: false
|
||||||
end
|
end
|
|
@ -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
|
|
@ -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: 20151026155158) do
|
ActiveRecord::Schema.define(version: 20151027150850) 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"
|
||||||
|
@ -144,9 +144,10 @@ ActiveRecord::Schema.define(version: 20151026155158) do
|
||||||
|
|
||||||
create_table "types_de_champs", force: :cascade do |t|
|
create_table "types_de_champs", force: :cascade do |t|
|
||||||
t.string "libelle"
|
t.string "libelle"
|
||||||
t.string "type"
|
t.string "type_champs"
|
||||||
t.integer "order_place"
|
t.integer "order_place"
|
||||||
t.integer "procedure_id"
|
t.integer "procedure_id"
|
||||||
|
t.text "description"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "types_de_piece_justificative", force: :cascade do |t|
|
create_table "types_de_piece_justificative", force: :cascade do |t|
|
||||||
|
|
|
@ -3,8 +3,9 @@ require 'spec_helper'
|
||||||
describe TypeDeChamps do
|
describe TypeDeChamps do
|
||||||
describe 'database columns' do
|
describe 'database columns' do
|
||||||
it { is_expected.to have_db_column(:libelle) }
|
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(:order_place) }
|
||||||
|
it { is_expected.to have_db_column(:description) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'associations' do
|
describe 'associations' do
|
||||||
|
@ -19,13 +20,13 @@ describe TypeDeChamps do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'type' do
|
context 'type' do
|
||||||
it { is_expected.not_to allow_value(nil).for(:type) }
|
it { is_expected.not_to allow_value(nil).for(:type_champs) }
|
||||||
it { is_expected.not_to allow_value('').for(:type) }
|
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('text').for(:type_champs) }
|
||||||
it { is_expected.to allow_value('textarea').for(:type) }
|
it { is_expected.to allow_value('textarea').for(:type_champs) }
|
||||||
it { is_expected.to allow_value('datetime').for(:type) }
|
it { is_expected.to allow_value('datetime').for(:type_champs) }
|
||||||
it { is_expected.to allow_value('number').for(:type) }
|
it { is_expected.to allow_value('number').for(:type_champs) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'order_place' do
|
context 'order_place' do
|
||||||
|
@ -33,5 +34,11 @@ describe TypeDeChamps do
|
||||||
it { is_expected.not_to allow_value('').for(:order_place) }
|
it { is_expected.not_to allow_value('').for(:order_place) }
|
||||||
it { is_expected.to allow_value(1).for(:order_place) }
|
it { is_expected.to allow_value(1).for(:order_place) }
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue