diff options
author | Felipe Artur <felipefac@gmail.com> | 2018-01-17 17:28:36 +0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2018-01-18 18:51:46 +0300 |
commit | a956fac221e9e20e04e9b8557ac84ff4f920c891 (patch) | |
tree | e046e97dc2a39a03629decb9eb769246b529ff0e /spec | |
parent | 5c51cbca06b099427e15309b352d01d960f641e3 (diff) |
Remove unnecessary query from labels filter
Diffstat (limited to 'spec')
-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 |