diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 18:09:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 18:09:08 +0300 |
commit | b3a736ed88a1db0391cd9881e70b987bab7d89d1 (patch) | |
tree | a91ca3a06abd4c3412775ac3c49b11e3151df2be /spec/requests | |
parent | 5366964a10484c2783a646b35a6da9eece01b242 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/group_import_spec.rb | 36 | ||||
-rw-r--r-- | spec/requests/api/lsif_data_spec.rb | 6 | ||||
-rw-r--r-- | spec/requests/api/merge_requests_spec.rb | 102 | ||||
-rw-r--r-- | spec/requests/self_monitoring_project_spec.rb | 24 |
4 files changed, 96 insertions, 72 deletions
diff --git a/spec/requests/api/group_import_spec.rb b/spec/requests/api/group_import_spec.rb index 016ed6ff491..1594881677f 100644 --- a/spec/requests/api/group_import_spec.rb +++ b/spec/requests/api/group_import_spec.rb @@ -45,6 +45,14 @@ describe API::GroupImport do expect(response).to have_gitlab_http_status(202) end + it 'creates private group' do + expect { subject }.to change { Group.count }.by(1) + + group = Group.find_by(name: 'test-import-group') + + expect(group.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE) + end + context 'when importing to a parent group' do before do group.add_owner(user) @@ -59,6 +67,34 @@ describe API::GroupImport do expect(group.children.count).to eq(1) end + context 'when parent group is private or internal' do + let(:public_parent_group) { create(:group, :public) } + let(:internal_parent_group) { create(:group, :internal) } + + before do + public_parent_group.add_owner(user) + internal_parent_group.add_owner(user) + end + + it 'imports public group' do + params[:parent_id] = public_parent_group.id + + subject + + expect(response).to have_gitlab_http_status(202) + expect(public_parent_group.children.first.visibility_level).to eq(Gitlab::VisibilityLevel::PUBLIC) + end + + it 'imports internal group' do + params[:parent_id] = internal_parent_group.id + + subject + + expect(response).to have_gitlab_http_status(202) + expect(internal_parent_group.children.first.visibility_level).to eq(Gitlab::VisibilityLevel::INTERNAL) + end + end + context 'when parent group is invalid' do it 'returns 404 and does not create new group' do params[:parent_id] = 99999 diff --git a/spec/requests/api/lsif_data_spec.rb b/spec/requests/api/lsif_data_spec.rb index 2e0670ded95..214bc832cda 100644 --- a/spec/requests/api/lsif_data_spec.rb +++ b/spec/requests/api/lsif_data_spec.rb @@ -61,7 +61,11 @@ describe API::LsifData do 'end_line' => 8, 'start_char' => 13, 'start_line' => 8, - 'definition_url' => project_blob_path(project, "#{commit.id}/morestrings/reverse.go", anchor: 'L5') + 'definition_url' => project_blob_path(project, "#{commit.id}/morestrings/reverse.go", anchor: 'L5'), + 'hover' => [{ + 'language' => 'go', + 'value' => Gitlab::Highlight.highlight(nil, 'func Func2(i int) string', language: 'go') + }] }) end diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 00af0937dd7..58190beb38a 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -267,8 +267,7 @@ describe API::MergeRequests do it 'returns an array of merge requests with any label when filtering by any label' do get api(endpoint_path, user), params: { labels: [" #{label.title} ", " #{label2.title} "] } - expect_successful_response_with_paginated_array - expect(json_response.length).to eq(1) + expect_paginated_array_response([merge_request.id]) expect(json_response.first['labels']).to eq([label2.title, label.title]) expect(json_response.first['id']).to eq(merge_request.id) end @@ -276,8 +275,7 @@ describe API::MergeRequests do it 'returns an array of merge requests with any label when filtering by any label' do get api(endpoint_path, user), params: { labels: ["#{label.title} , #{label2.title}"] } - expect_successful_response_with_paginated_array - expect(json_response.length).to eq(1) + expect_paginated_array_response([merge_request.id]) expect(json_response.first['labels']).to eq([label2.title, label.title]) expect(json_response.first['id']).to eq(merge_request.id) end @@ -285,17 +283,16 @@ describe API::MergeRequests do it 'returns an array of merge requests with any label when filtering by any label' do get api(endpoint_path, user), params: { labels: IssuesFinder::FILTER_ANY } - expect_successful_response_with_paginated_array - expect(json_response.length).to eq(1) + expect_paginated_array_response([merge_request.id]) expect(json_response.first['id']).to eq(merge_request.id) end it 'returns an array of merge requests without a label when filtering by no label' do get api(endpoint_path, user), params: { labels: IssuesFinder::FILTER_NONE } - expect_paginated_array_response([ + expect_response_contain_exactly( merge_request_merged.id, merge_request_locked.id, merge_request_closed.id - ]) + ) end end @@ -315,7 +312,7 @@ describe API::MergeRequests do get api(path, user) - expect_paginated_array_response([mr2.id]) + expect_response_contain_exactly(mr2.id) end context 'with ordering' do @@ -413,9 +410,9 @@ describe API::MergeRequests do it 'returns merge requests with the given source branch' do get api(endpoint_path, user), params: { source_branch: merge_request_closed.source_branch, state: 'all' } - expect_paginated_array_response([ + expect_response_contain_exactly( merge_request_merged.id, merge_request_locked.id, merge_request_closed.id - ]) + ) end end @@ -423,9 +420,9 @@ describe API::MergeRequests do it 'returns merge requests with the given target branch' do get api(endpoint_path, user), params: { target_branch: merge_request_closed.target_branch, state: 'all' } - expect_paginated_array_response([ + expect_response_contain_exactly( merge_request_merged.id, merge_request_locked.id, merge_request_closed.id - ]) + ) end end end @@ -448,10 +445,10 @@ describe API::MergeRequests do it 'returns an array of all merge requests' do get api('/merge_requests', user), params: { scope: 'all' } - expect_paginated_array_response([ + expect_response_contain_exactly( merge_request_merged.id, merge_request_locked.id, merge_request_closed.id, merge_request.id - ]) + ) end it "returns authentication error without any scope" do @@ -487,9 +484,10 @@ describe API::MergeRequests do it 'returns an array of all merge requests except unauthorized ones' do get api('/merge_requests', user), params: { scope: :all } - expect_paginated_array_response([ - merge_request_merged.id, merge_request2.id, merge_request_locked.id, merge_request_closed.id, merge_request.id - ]) + expect_response_contain_exactly( + merge_request_merged.id, merge_request2.id, merge_request_locked.id, + merge_request_closed.id, merge_request.id + ) end it "returns an array of no merge_requests when wip=yes" do @@ -501,9 +499,10 @@ describe API::MergeRequests do it "returns an array of no merge_requests when wip=no" do get api("/merge_requests", user), params: { wip: 'no' } - expect_paginated_array_response([ - merge_request_merged.id, merge_request2.id, merge_request_locked.id, merge_request_closed.id, merge_request.id - ]) + expect_response_contain_exactly( + merge_request_merged.id, merge_request2.id, merge_request_locked.id, + merge_request_closed.id, merge_request.id + ) end it 'does not return unauthorized merge requests' do @@ -512,9 +511,10 @@ describe API::MergeRequests do get api('/merge_requests', user), params: { scope: :all } - expect_paginated_array_response([ - merge_request_merged.id, merge_request2.id, merge_request_locked.id, merge_request_closed.id, merge_request.id - ]) + expect_response_contain_exactly( + merge_request_merged.id, merge_request2.id, merge_request_locked.id, + merge_request_closed.id, merge_request.id + ) expect(json_response.map { |mr| mr['id'] }).not_to include(merge_request3.id) end @@ -523,7 +523,7 @@ describe API::MergeRequests do get api('/merge_requests', user2) - expect_paginated_array_response([merge_request3.id]) + expect_response_contain_exactly(merge_request3.id) end it 'returns an array of merge requests authored by the given user' do @@ -531,7 +531,7 @@ describe API::MergeRequests do get api('/merge_requests', user), params: { author_id: user2.id, scope: :all } - expect_paginated_array_response([merge_request3.id]) + expect_response_contain_exactly(merge_request3.id) end it 'returns an array of merge requests assigned to the given user' do @@ -539,7 +539,7 @@ describe API::MergeRequests do get api('/merge_requests', user), params: { assignee_id: user2.id, scope: :all } - expect_paginated_array_response([merge_request3.id]) + expect_response_contain_exactly(merge_request3.id) end it 'returns an array of merge requests with no assignee' do @@ -547,7 +547,7 @@ describe API::MergeRequests do get api('/merge_requests', user), params: { assignee_id: 'None', scope: :all } - expect_paginated_array_response([merge_request3.id]) + expect_response_contain_exactly(merge_request3.id) end it 'returns an array of merge requests with any assignee' do @@ -556,10 +556,10 @@ describe API::MergeRequests do get api('/merge_requests', user), params: { assignee_id: 'Any', scope: :all } - expect_paginated_array_response([ + expect_response_contain_exactly( merge_request_merged.id, merge_request2.id, merge_request_locked.id, merge_request_closed.id, merge_request.id - ]) + ) end it 'returns an array of merge requests assigned to me' do @@ -567,7 +567,7 @@ describe API::MergeRequests do get api('/merge_requests', user2), params: { scope: 'assigned_to_me' } - expect_paginated_array_response([merge_request3.id]) + expect_response_contain_exactly(merge_request3.id) end it 'returns an array of merge requests assigned to me (kebab-case)' do @@ -575,7 +575,7 @@ describe API::MergeRequests do get api('/merge_requests', user2), params: { scope: 'assigned-to-me' } - expect_paginated_array_response([merge_request3.id]) + expect_response_contain_exactly(merge_request3.id) end it 'returns an array of merge requests created by me' do @@ -583,7 +583,7 @@ describe API::MergeRequests do get api('/merge_requests', user2), params: { scope: 'created_by_me' } - expect_paginated_array_response([merge_request3.id]) + expect_response_contain_exactly(merge_request3.id) end it 'returns an array of merge requests created by me (kebab-case)' do @@ -591,7 +591,7 @@ describe API::MergeRequests do get api('/merge_requests', user2), params: { scope: 'created-by-me' } - expect_paginated_array_response([merge_request3.id]) + expect_response_contain_exactly(merge_request3.id) end it 'returns merge requests reacted by the authenticated user by the given emoji' do @@ -600,16 +600,16 @@ describe API::MergeRequests do get api('/merge_requests', user2), params: { my_reaction_emoji: award_emoji.name, scope: 'all' } - expect_paginated_array_response([merge_request3.id]) + expect_response_contain_exactly(merge_request3.id) end context 'source_branch param' do it 'returns merge requests with the given source branch' do get api('/merge_requests', user), params: { source_branch: merge_request_closed.source_branch, state: 'all' } - expect_paginated_array_response([ + expect_response_contain_exactly( merge_request_merged.id, merge_request_locked.id, merge_request_closed.id - ]) + ) end end @@ -617,9 +617,9 @@ describe API::MergeRequests do it 'returns merge requests with the given target branch' do get api('/merge_requests', user), params: { target_branch: merge_request_closed.target_branch, state: 'all' } - expect_paginated_array_response([ + expect_response_contain_exactly( merge_request_merged.id, merge_request_locked.id, merge_request_closed.id - ]) + ) end end @@ -628,7 +628,7 @@ describe API::MergeRequests do get api('/merge_requests?created_before=2000-01-02T00:00:00.060Z', user) - expect_paginated_array_response([merge_request2.id]) + expect_response_contain_exactly(merge_request2.id) end it 'returns merge requests created after a specific date' do @@ -636,7 +636,7 @@ describe API::MergeRequests do get api("/merge_requests?created_after=#{merge_request2.created_at}", user) - expect_paginated_array_response([merge_request2.id]) + expect_response_contain_exactly(merge_request2.id) end it 'returns merge requests updated before a specific date' do @@ -644,7 +644,7 @@ describe API::MergeRequests do get api('/merge_requests?updated_before=2000-01-02T00:00:00.060Z', user) - expect_paginated_array_response([merge_request2.id]) + expect_response_contain_exactly(merge_request2.id) end it 'returns merge requests updated after a specific date' do @@ -652,7 +652,7 @@ describe API::MergeRequests do get api("/merge_requests?updated_after=#{merge_request2.updated_at}", user) - expect_paginated_array_response([merge_request2.id]) + expect_response_contain_exactly(merge_request2.id) end context 'search params' do @@ -663,13 +663,13 @@ describe API::MergeRequests do it 'returns merge requests matching given search string for title' do get api("/merge_requests", user), params: { search: merge_request.title } - expect_paginated_array_response([merge_request.id]) + expect_response_contain_exactly(merge_request.id) end it 'returns merge requests matching given search string for title and scoped in title' do get api("/merge_requests", user), params: { search: merge_request.title, in: 'title' } - expect_paginated_array_response([merge_request.id]) + expect_response_contain_exactly(merge_request.id) end it 'returns an empty array if no merge request matches given search string for description and scoped in title' do @@ -681,7 +681,7 @@ describe API::MergeRequests do it 'returns merge requests for project matching given search string for description' do get api("/merge_requests", user), params: { project_id: project.id, search: merge_request.description } - expect_paginated_array_response([merge_request.id]) + expect_response_contain_exactly(merge_request.id) end end @@ -689,7 +689,7 @@ describe API::MergeRequests do it 'returns merge requests with the given state' do get api('/merge_requests', user), params: { state: 'locked' } - expect_paginated_array_response([merge_request_locked.id]) + expect_response_contain_exactly(merge_request_locked.id) end end end @@ -792,10 +792,10 @@ describe API::MergeRequests do it 'returns an array excluding merge_requests from archived projects' do get api(endpoint_path, user) - expect_paginated_array_response([ + expect_response_contain_exactly( merge_request_merged.id, merge_request_locked.id, merge_request_closed.id, merge_request.id - ]) + ) end context 'with non_archived param set as false' do @@ -804,10 +804,10 @@ describe API::MergeRequests do get api(path, user) - expect_paginated_array_response([ + expect_response_contain_exactly( merge_request_merged.id, merge_request_archived.id, merge_request_locked.id, merge_request_closed.id, merge_request.id - ]) + ) end end end diff --git a/spec/requests/self_monitoring_project_spec.rb b/spec/requests/self_monitoring_project_spec.rb index 5e46645e7a0..6a0258c349f 100644 --- a/spec/requests/self_monitoring_project_spec.rb +++ b/spec/requests/self_monitoring_project_spec.rb @@ -17,11 +17,7 @@ describe 'Self-Monitoring project requests' do login_as(admin) end - context 'with feature flag disabled' do - it_behaves_like 'not accessible if feature flag is disabled' - end - - context 'with feature flag enabled' do + context 'when the self monitoring project is created' do let(:status_api) { status_create_self_monitoring_project_admin_application_settings_path } it_behaves_like 'triggers async worker, returns sidekiq job_id with response accepted' @@ -45,11 +41,7 @@ describe 'Self-Monitoring project requests' do login_as(admin) end - context 'with feature flag disabled' do - it_behaves_like 'not accessible if feature flag is disabled' - end - - context 'with feature flag enabled' do + context 'when the self monitoring project is being created' do it_behaves_like 'handles invalid job_id' context 'when job is in progress' do @@ -129,11 +121,7 @@ describe 'Self-Monitoring project requests' do login_as(admin) end - context 'with feature flag disabled' do - it_behaves_like 'not accessible if feature flag is disabled' - end - - context 'with feature flag enabled' do + context 'when the self monitoring project is deleted' do let(:status_api) { status_delete_self_monitoring_project_admin_application_settings_path } it_behaves_like 'triggers async worker, returns sidekiq job_id with response accepted' @@ -157,11 +145,7 @@ describe 'Self-Monitoring project requests' do login_as(admin) end - context 'with feature flag disabled' do - it_behaves_like 'not accessible if feature flag is disabled' - end - - context 'with feature flag enabled' do + context 'when the self monitoring project is being deleted' do it_behaves_like 'handles invalid job_id' context 'when job is in progress' do |