diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-29 09:08:49 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-29 09:08:49 +0000 |
commit | 46b10c0fc884400941c17e2777b242ac54d111e5 (patch) | |
tree | 184bc49764f03791610c8ae716c03e0100ed45f5 /spec/controllers | |
parent | 3358e1fdb8fe1e8f739024ee4f3d1071b296a010 (diff) | |
download | gitlab-ce-46b10c0fc884400941c17e2777b242ac54d111e5.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/groups/milestones_controller_spec.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/controllers/groups/milestones_controller_spec.rb b/spec/controllers/groups/milestones_controller_spec.rb index 8fb9f0c516c..068ed7fd380 100644 --- a/spec/controllers/groups/milestones_controller_spec.rb +++ b/spec/controllers/groups/milestones_controller_spec.rb @@ -130,6 +130,40 @@ describe Groups::MilestonesController do end end end + + context 'when subgroup milestones are present' do + let(:subgroup) { create(:group, :private, parent: group) } + let(:sub_project) { create(:project, :private, group: subgroup) } + let!(:group_milestone) { create(:milestone, group: group, title: 'Group milestone') } + let!(:sub_project_milestone) { create(:milestone, project: sub_project, title: 'Sub Project Milestone') } + let!(:subgroup_milestone) { create(:milestone, title: 'Subgroup Milestone', group: subgroup) } + + it 'shows subgroup milestones that user has access to' do + get :index, params: { group_id: group.to_param } + + expect(response).to have_gitlab_http_status(200) + expect(response.body).to include(group_milestone.title) + expect(response.body).to include(sub_project_milestone.title) + expect(response.body).to include(subgroup_milestone.title) + end + + context 'when user has no access to subgroups' do + let(:non_member) { create(:user) } + + before do + sign_in(non_member) + end + + it 'does not show subgroup milestones' do + get :index, params: { group_id: group.to_param } + + expect(response).to have_gitlab_http_status(200) + expect(response.body).to include(group_milestone.title) + expect(response.body).not_to include(sub_project_milestone.title) + expect(response.body).not_to include(subgroup_milestone.title) + end + end + end end context 'as JSON' do @@ -149,6 +183,19 @@ describe Groups::MilestonesController do expect(response.content_type).to eq 'application/json' end + context 'with subgroup milestones' do + it 'lists descendants group milestones' do + subgroup = create(:group, :public, parent: group) + create(:milestone, group: subgroup, title: 'subgroup milestone') + + get :index, params: { group_id: group.to_param }, format: :json + milestones = json_response + + expect(milestones.count).to eq(3) + expect(milestones.second["title"]).to eq("subgroup milestone") + end + end + context 'for a subgroup' do let(:subgroup) { create(:group, parent: group) } |