summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJan Provaznik <jprovaznik@gitlab.com>2018-03-02 09:25:25 +0100
committerJan Provaznik <jprovaznik@gitlab.com>2018-03-02 11:44:18 +0100
commit1f4ee653fa7f8879192c38f65b277c5ffc786a0f (patch)
treedd95c9ec39e71282b9ad624172022c72489a97d0 /spec
parent911fd7c252dd6c43b9771b2833460f1605dc99a2 (diff)
downloadgitlab-ce-1f4ee653fa7f8879192c38f65b277c5ffc786a0f.tar.gz
Allow to include also descendant group labels
Because epic index page includes also epics from subgroups it's necessary to also get descendant group labels for filtering. https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/4773#note_61236542
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/groups/labels_controller_spec.rb14
-rw-r--r--spec/finders/labels_finder_spec.rb19
2 files changed, 26 insertions, 7 deletions
diff --git a/spec/controllers/groups/labels_controller_spec.rb b/spec/controllers/groups/labels_controller_spec.rb
index 3269f47f327..185b6b4ce57 100644
--- a/spec/controllers/groups/labels_controller_spec.rb
+++ b/spec/controllers/groups/labels_controller_spec.rb
@@ -1,9 +1,9 @@
require 'spec_helper'
describe Groups::LabelsController do
- let(:group) { create(:group) }
- let(:user) { create(:user) }
- let(:project) { create(:project, namespace: group) }
+ set(:group) { create(:group) }
+ set(:user) { create(:user) }
+ set(:project) { create(:project, namespace: group) }
before do
group.add_owner(user)
@@ -12,8 +12,8 @@ describe Groups::LabelsController do
end
describe 'GET #index' do
- let!(:label_1) { create(:label, project: project, title: 'label_1') }
- let!(:group_label_1) { create(:group_label, group: group, title: 'group_label_1') }
+ set(:label_1) { create(:label, project: project, title: 'label_1') }
+ set(:group_label_1) { create(:group_label, group: group, title: 'group_label_1') }
it 'returns group and project labels by default' do
get :index, group_id: group, format: :json
@@ -23,8 +23,8 @@ describe Groups::LabelsController do
end
context 'with ancestor group', :nested_groups do
- let(:subgroup) { create(:group, parent: group) }
- let!(:subgroup_label_1) { create(:group_label, group: subgroup, title: 'subgroup_label_1') }
+ set(:subgroup) { create(:group, parent: group) }
+ set(:subgroup_label_1) { create(:group_label, group: subgroup, title: 'subgroup_label_1') }
before do
subgroup.add_owner(user)
diff --git a/spec/finders/labels_finder_spec.rb b/spec/finders/labels_finder_spec.rb
index dc76efea35b..d434c501110 100644
--- a/spec/finders/labels_finder_spec.rb
+++ b/spec/finders/labels_finder_spec.rb
@@ -89,6 +89,25 @@ describe LabelsFinder do
expect(finder.execute).to eq [private_subgroup_label_1]
end
end
+
+ context 'when including labels from group descendants', :nested_groups do
+ it 'returns labels from group and its descendants' do
+ private_group_1.add_developer(user)
+ private_subgroup_1.add_developer(user)
+
+ finder = described_class.new(user, group_id: private_group_1.id, only_group_labels: true, include_descendant_groups: true)
+
+ expect(finder.execute).to eq [private_group_label_1, private_subgroup_label_1]
+ end
+
+ it 'ignores labels from groups which user can not read' do
+ private_subgroup_1.add_developer(user)
+
+ finder = described_class.new(user, group_id: private_group_1.id, only_group_labels: true, include_descendant_groups: true)
+
+ expect(finder.execute).to eq [private_subgroup_label_1]
+ end
+ end
end
context 'filtering by project_id' do