diff options
Diffstat (limited to 'spec/helpers/issuables_helper_spec.rb')
-rw-r--r-- | spec/helpers/issuables_helper_spec.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/helpers/issuables_helper_spec.rb b/spec/helpers/issuables_helper_spec.rb index d601cbdb39b..c8d64d64cf4 100644 --- a/spec/helpers/issuables_helper_spec.rb +++ b/spec/helpers/issuables_helper_spec.rb @@ -192,4 +192,33 @@ describe IssuablesHelper do expect(JSON.parse(helper.issuable_initial_data(issue))).to eq(expected_data) end end + + describe '#selected_labels' do + context 'if label_name param is a string' do + it 'returns a new label with title' do + allow(helper).to receive(:params) + .and_return(ActionController::Parameters.new(label_name: 'test label')) + + labels = helper.selected_labels + + expect(labels).to be_an(Array) + expect(labels.size).to eq(1) + expect(labels.first.title).to eq('test label') + end + end + + context 'if label_name param is an array' do + it 'returns a new label with title for each element' do + allow(helper).to receive(:params) + .and_return(ActionController::Parameters.new(label_name: ['test label 1', 'test label 2'])) + + labels = helper.selected_labels + + expect(labels).to be_an(Array) + expect(labels.size).to eq(2) + expect(labels.first.title).to eq('test label 1') + expect(labels.second.title).to eq('test label 2') + end + end + end end |