[#2258] Let dynamic type validate the type de champ
This commit is contained in:
parent
695426316c
commit
3fea14c07d
3 changed files with 34 additions and 0 deletions
|
@ -79,5 +79,26 @@ shared_examples 'type_de_champ_spec' do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'delegate validation to dynamic type' do
|
||||
subject { build(:type_de_champ_text) }
|
||||
let(:dynamic_type) do
|
||||
Class.new(TypesDeChamp::TypeDeChampBase) do
|
||||
validate :never_valid
|
||||
|
||||
def never_valid
|
||||
errors.add(:troll, 'always invalid')
|
||||
end
|
||||
end.new(subject)
|
||||
end
|
||||
|
||||
before { subject.instance_variable_set(:@dynamic_type, dynamic_type) }
|
||||
|
||||
it { is_expected.to be_invalid }
|
||||
it do
|
||||
subject.validate
|
||||
expect(subject.errors.full_messages.to_sentence).to eq('Troll always invalid')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue