Use in?
in type_champ
tests
This commit is contained in:
parent
0c10f2bd47
commit
b3e07d8504
2 changed files with 8 additions and 15 deletions
|
@ -52,13 +52,16 @@ class TypeDeChamp < ActiveRecord::Base
|
|||
type_champs.map { |champ| [I18n.t("activerecord.attributes.type_de_champ.type_champs.#{champ.last}"), champ.first] }
|
||||
end
|
||||
|
||||
def field_for_list?
|
||||
!(type_champ == 'textarea' || type_champ == 'header_section')
|
||||
def check_mandatory
|
||||
if non_fillable?
|
||||
self.mandatory = false
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
def check_mandatory
|
||||
self.mandatory = false if %w(header_section explication).include?(self.type_champ)
|
||||
true
|
||||
def non_fillable?
|
||||
type_champ.in?(['header_section', 'explication'])
|
||||
end
|
||||
|
||||
def private?
|
||||
|
|
|
@ -29,14 +29,4 @@ shared_examples 'type_de_champ_spec' do
|
|||
it { is_expected.to allow_value('blabla').for(:description) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'field_for_list?' do
|
||||
let(:type_de_champ_yes) { create :type_de_champ_public, type_champ: 'text' }
|
||||
let(:type_de_champ_no_1) { create :type_de_champ_public, type_champ: 'textarea' }
|
||||
let(:type_de_champ_no_2) { create :type_de_champ_public, type_champ: 'header_section' }
|
||||
|
||||
it { expect(type_de_champ_yes.field_for_list?).to be_truthy }
|
||||
it { expect(type_de_champ_no_1.field_for_list?).to be_falsey }
|
||||
it { expect(type_de_champ_no_2.field_for_list?).to be_falsey }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue