summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2018-06-05 06:25:55 +0000
committerSean McGivern <sean@mcgivern.me.uk>2018-06-05 06:25:55 +0000
commitfb3f95bcaf78955c17f35b59755a69ca89386c88 (patch)
tree9542ede92175d5492c5d12d8011855f65f174894 /spec
parent6bc89c0e3baf064425a47401ba97d27d8e943a59 (diff)
parent6426b507244b7f1cec4a7308ab29978d20c8ec98 (diff)
downloadgitlab-ce-fb3f95bcaf78955c17f35b59755a69ca89386c88.tar.gz
Merge branch '36862-subgroup-milestones' into 'master'
Include all ancestors milestones in json list & autocomplete Closes #36862 See merge request gitlab-org/gitlab-ce!19317
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/projects/milestones_controller_spec.rb35
-rw-r--r--spec/services/projects/autocomplete_service_spec.rb15
2 files changed, 41 insertions, 9 deletions
diff --git a/spec/controllers/projects/milestones_controller_spec.rb b/spec/controllers/projects/milestones_controller_spec.rb
index 548c5ef36e7..02b30f9bc6d 100644
--- a/spec/controllers/projects/milestones_controller_spec.rb
+++ b/spec/controllers/projects/milestones_controller_spec.rb
@@ -57,19 +57,36 @@ describe Projects::MilestonesController do
context "as json" do
let!(:group) { create(:group, :public) }
let!(:group_milestone) { create(:milestone, group: group) }
- let!(:group_member) { create(:group_member, group: group, user: user) }
- before do
- project.update(namespace: group)
- get :index, namespace_id: project.namespace.id, project_id: project.id, format: :json
+ context 'with a single group ancestor' do
+ before do
+ project.update(namespace: group)
+ get :index, namespace_id: project.namespace.id, project_id: project.id, format: :json
+ end
+
+ it "queries projects milestones and groups milestones" do
+ milestones = assigns(:milestones)
+
+ expect(milestones.count).to eq(2)
+ expect(milestones).to match_array([milestone, group_milestone])
+ end
end
- it "queries projects milestones and groups milestones" do
- milestones = assigns(:milestones)
+ context 'with nested groups', :nested_groups do
+ let!(:subgroup) { create(:group, :public, parent: group) }
+ let!(:subgroup_milestone) { create(:milestone, group: subgroup) }
+
+ before do
+ project.update(namespace: subgroup)
+ get :index, namespace_id: project.namespace.id, project_id: project.id, format: :json
+ end
+
+ it "queries projects milestones and all ancestors milestones" do
+ milestones = assigns(:milestones)
- expect(milestones.count).to eq(2)
- expect(milestones.where(project_id: nil).first).to eq(group_milestone)
- expect(milestones.where(group_id: nil).first).to eq(milestone)
+ expect(milestones.count).to eq(3)
+ expect(milestones).to match_array([milestone, group_milestone, subgroup_milestone])
+ end
end
end
end
diff --git a/spec/services/projects/autocomplete_service_spec.rb b/spec/services/projects/autocomplete_service_spec.rb
index f7ff8b80bd7..6fd73a50511 100644
--- a/spec/services/projects/autocomplete_service_spec.rb
+++ b/spec/services/projects/autocomplete_service_spec.rb
@@ -115,5 +115,20 @@ describe Projects::AutocompleteService do
expect(milestone_titles).to eq([group_milestone2.title, group_milestone1.title])
end
+
+ context 'with nested groups', :nested_groups do
+ let(:subgroup) { create(:group, :public, parent: group) }
+ let!(:subgroup_milestone) { create(:milestone, group: subgroup) }
+
+ before do
+ project.update(namespace: subgroup)
+ end
+
+ it 'includes project milestones and all acestors milestones' do
+ expect(milestone_titles).to match_array(
+ [project_milestone.title, group_milestone2.title, group_milestone1.title, subgroup_milestone.title]
+ )
+ end
+ end
end
end