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] }
|
type_champs.map { |champ| [I18n.t("activerecord.attributes.type_de_champ.type_champs.#{champ.last}"), champ.first] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def field_for_list?
|
def check_mandatory
|
||||||
!(type_champ == 'textarea' || type_champ == 'header_section')
|
if non_fillable?
|
||||||
|
self.mandatory = false
|
||||||
|
else
|
||||||
|
true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_mandatory
|
def non_fillable?
|
||||||
self.mandatory = false if %w(header_section explication).include?(self.type_champ)
|
type_champ.in?(['header_section', 'explication'])
|
||||||
true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def private?
|
def private?
|
||||||
|
|
|
@ -29,14 +29,4 @@ shared_examples 'type_de_champ_spec' do
|
||||||
it { is_expected.to allow_value('blabla').for(:description) }
|
it { is_expected.to allow_value('blabla').for(:description) }
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue