diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-01-18 20:21:41 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-01-18 20:21:41 +0300 |
commit | 210e6e8a654a026443af1fd1f007a5fc093e7ac2 (patch) | |
tree | fa01a090fedc9d5efca909cb200aa4b7e1269fa8 /spec | |
parent | 91374baf8685cc58bb7334ed131bc223ad0875e2 (diff) | |
parent | a956fac221e9e20e04e9b8557ac84ff4f920c891 (diff) |
Merge branch 'issue_37143_2' into 'master'
Remove unnecessary query from labels dropdown
Closes #37143
See merge request gitlab-org/gitlab-ce!16520
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 |