[#1421] Format value for display
This commit is contained in:
parent
55a685c183
commit
04892f6c55
2 changed files with 29 additions and 0 deletions
|
@ -28,6 +28,10 @@ class Champs::LinkedDropDownListChamp < Champ
|
|||
:primary_value
|
||||
end
|
||||
|
||||
def for_display
|
||||
[primary_value, secondary_value].compact.join(' / ')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def pack_value
|
||||
|
|
|
@ -15,4 +15,29 @@ describe Champs::LinkedDropDownListChamp do
|
|||
|
||||
it { expect(champ.value).to eq('["tata","tutu"]') }
|
||||
end
|
||||
|
||||
describe '#for_display' do
|
||||
let(:champ) { described_class.new(primary_value: primary_value, secondary_value: secondary_value) }
|
||||
let(:primary_value) { nil }
|
||||
let(:secondary_value) { nil }
|
||||
|
||||
subject { champ.for_display }
|
||||
|
||||
context 'with no value' do
|
||||
it { is_expected.to eq('') }
|
||||
end
|
||||
|
||||
context 'with primary value' do
|
||||
let(:primary_value) { 'primary' }
|
||||
|
||||
it { is_expected.to eq('primary') }
|
||||
end
|
||||
|
||||
context 'with secondary value' do
|
||||
let(:primary_value) { 'primary' }
|
||||
let(:secondary_value) { 'secondary' }
|
||||
|
||||
it { is_expected.to eq('primary / secondary') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue