refactor(pays): champ pays to use simple select
This commit is contained in:
parent
4d4c378724
commit
f7c1dff22a
5 changed files with 120 additions and 37 deletions
71
spec/models/champs/pays_champ_spec.rb
Normal file
71
spec/models/champs/pays_champ_spec.rb
Normal file
|
@ -0,0 +1,71 @@
|
|||
describe Champs::PaysChamp, type: :model do
|
||||
let(:champ) { described_class.new }
|
||||
|
||||
describe 'value' do
|
||||
it 'with code' do
|
||||
champ.value = 'GB'
|
||||
expect(champ.external_id).to eq('GB')
|
||||
expect(champ.value).to eq('Royaume-Uni')
|
||||
expect(champ.selected).to eq('GB')
|
||||
expect(champ.to_s).to eq('Royaume-Uni')
|
||||
I18n.with_locale(:en) do
|
||||
expect(champ.to_s).to eq('United Kingdom')
|
||||
end
|
||||
I18n.with_locale(:fr) do
|
||||
expect(champ.to_s).to eq('Royaume-Uni')
|
||||
end
|
||||
end
|
||||
|
||||
it 'with name' do
|
||||
champ.value = 'Royaume-Uni'
|
||||
expect(champ.external_id).to eq('GB')
|
||||
expect(champ.value).to eq('Royaume-Uni')
|
||||
expect(champ.selected).to eq('GB')
|
||||
expect(champ.to_s).to eq('Royaume-Uni')
|
||||
end
|
||||
|
||||
it 'with nil' do
|
||||
champ.write_attribute(:value, 'Royaume-Uni')
|
||||
champ.write_attribute(:external_id, 'GB')
|
||||
champ.value = nil
|
||||
expect(champ.external_id).to be_nil
|
||||
expect(champ.value).to be_nil
|
||||
expect(champ.selected).to be_nil
|
||||
expect(champ.to_s).to eq('')
|
||||
end
|
||||
|
||||
it 'with blank' do
|
||||
champ.write_attribute(:value, 'Royaume-Uni')
|
||||
champ.write_attribute(:external_id, 'GB')
|
||||
champ.value = ''
|
||||
expect(champ.external_id).to be_nil
|
||||
expect(champ.value).to be_nil
|
||||
expect(champ.selected).to be_nil
|
||||
expect(champ.to_s).to eq('')
|
||||
end
|
||||
|
||||
it 'with initial nil' do
|
||||
champ.write_attribute(:value, nil)
|
||||
expect(champ.external_id).to be_nil
|
||||
expect(champ.value).to be_nil
|
||||
expect(champ.selected).to be_nil
|
||||
expect(champ.to_s).to eq('')
|
||||
end
|
||||
|
||||
it 'with initial name' do
|
||||
champ.write_attribute(:value, 'Royaume-Uni')
|
||||
expect(champ.external_id).to be_nil
|
||||
expect(champ.value).to eq('Royaume-Uni')
|
||||
expect(champ.selected).to eq('GB')
|
||||
expect(champ.to_s).to eq('Royaume-Uni')
|
||||
end
|
||||
|
||||
it 'with initial bad name' do
|
||||
champ.write_attribute(:value, 'ROYAUME-UNIS')
|
||||
expect(champ.external_id).to be_nil
|
||||
expect(champ.value).to eq('ROYAUME-UNIS')
|
||||
expect(champ.selected).to eq('ROYAUME-UNIS')
|
||||
expect(champ.to_s).to eq('ROYAUME-UNIS')
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue