[#1421] Format linked dropdown menus in spreadsheet export
This commit is contained in:
parent
06efd9681c
commit
e794515c8e
2 changed files with 26 additions and 0 deletions
|
@ -34,6 +34,10 @@ class Champs::LinkedDropDownListChamp < Champ
|
|||
|
||||
private
|
||||
|
||||
def value_for_export
|
||||
"#{primary_value || ''};#{secondary_value || ''}"
|
||||
end
|
||||
|
||||
def pack_value
|
||||
self.value = JSON.generate([ primary_value, secondary_value ])
|
||||
end
|
||||
|
|
|
@ -40,4 +40,26 @@ describe Champs::LinkedDropDownListChamp do
|
|||
it { is_expected.to eq('primary / secondary') }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'for_export' do
|
||||
subject { champ.for_export }
|
||||
|
||||
context 'with no value' do
|
||||
let(:champ) { described_class.new }
|
||||
|
||||
it { is_expected.to be_nil }
|
||||
end
|
||||
|
||||
context 'with primary value' do
|
||||
let(:champ) { described_class.new(primary_value: 'primary') }
|
||||
|
||||
it { is_expected.to eq('primary;') }
|
||||
end
|
||||
|
||||
context 'with secondary value' do
|
||||
let(:champ) { described_class.new(primary_value: 'primary', secondary_value: 'secondary') }
|
||||
|
||||
it { is_expected.to eq('primary;secondary') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue