allow integers only
This commit is contained in:
parent
0aacaee2c2
commit
35f4874b69
6 changed files with 57 additions and 2 deletions
37
spec/models/champs/dossier_link_champ_spec.rb
Normal file
37
spec/models/champs/dossier_link_champ_spec.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
describe Champs::DossierLinkChamp, type: :model do
|
||||
describe 'prefilling validations' do
|
||||
describe 'value' do
|
||||
subject { build(:champ_dossier_link, value: value).valid?(:prefill) }
|
||||
|
||||
context 'when nil' do
|
||||
let(:value) { nil }
|
||||
|
||||
it { expect(subject).to eq(true) }
|
||||
end
|
||||
|
||||
context 'when empty' do
|
||||
let(:value) { '' }
|
||||
|
||||
it { expect(subject).to eq(true) }
|
||||
end
|
||||
|
||||
context 'when an integer' do
|
||||
let(:value) { 42 }
|
||||
|
||||
it { expect(subject).to eq(true) }
|
||||
end
|
||||
|
||||
context 'when a string representing an integer' do
|
||||
let(:value) { "42" }
|
||||
|
||||
it { expect(subject).to eq(true) }
|
||||
end
|
||||
|
||||
context 'when it can be casted as integer' do
|
||||
let(:value) { 'totoro' }
|
||||
|
||||
it { expect(subject).to eq(false) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue