diff options
author | Jacob Schatz <jschatz@gitlab.com> | 2016-06-07 18:15:07 +0300 |
---|---|---|
committer | Jacob Schatz <jschatz@gitlab.com> | 2016-06-07 18:15:07 +0300 |
commit | 5b83abcc01bd4a24268126dc52019b9f11152a7c (patch) | |
tree | 195d1b0b10dcaf5ae58472075d350812b270612e /spec/controllers | |
parent | 25370fd158e95d9672340ac25d13ed51e8dc77af (diff) | |
parent | ee26c3cab4651c8876efc45b6a63539727e6a42e (diff) |
Merge branch 'issue_14189' into 'master'
Ability to prioritize labels
Closes #14189
See merge request !4009
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/projects/labels_controller_spec.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/controllers/projects/labels_controller_spec.rb b/spec/controllers/projects/labels_controller_spec.rb new file mode 100644 index 00000000000..ab1dd34ed57 --- /dev/null +++ b/spec/controllers/projects/labels_controller_spec.rb @@ -0,0 +1,53 @@ +require 'spec_helper' + +describe Projects::LabelsController do + let(:project) { create(:project) } + let(:user) { create(:user) } + + before do + project.team << [user, :master] + sign_in(user) + end + + describe 'GET #index' do + def create_label(attributes) + create(:label, attributes.merge(project: project)) + end + + before do + 15.times { |i| create_label(priority: (i % 3) + 1, title: "label #{15 - i}") } + 5.times { |i| create_label(title: "label #{100 - i}") } + + + get :index, namespace_id: project.namespace.to_param, project_id: project.to_param + end + + context '@prioritized_labels' do + let(:prioritized_labels) { assigns(:prioritized_labels) } + + it 'contains only prioritized labels' do + expect(prioritized_labels).to all(have_attributes(priority: a_value > 0)) + end + + it 'is sorted by priority, then label title' do + priorities_and_titles = prioritized_labels.pluck(:priority, :title) + + expect(priorities_and_titles.sort).to eq(priorities_and_titles) + end + end + + context '@labels' do + let(:labels) { assigns(:labels) } + + it 'contains only unprioritized labels' do + expect(labels).to all(have_attributes(priority: nil)) + end + + it 'is sorted by label title' do + titles = labels.pluck(:title) + + expect(titles.sort).to eq(titles) + end + end + end +end |