diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 15:44:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 15:44:42 +0000 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /spec/requests/api/merge_requests_spec.rb | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) | |
download | gitlab-ce-4555e1b21c365ed8303ffb7a3325d773c9b8bf31.tar.gz |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'spec/requests/api/merge_requests_spec.rb')
-rw-r--r-- | spec/requests/api/merge_requests_spec.rb | 78 |
1 files changed, 74 insertions, 4 deletions
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 37cb8fb7ee5..a13db1bb414 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -52,7 +52,7 @@ RSpec.describe API::MergeRequests do end context 'when authenticated' do - it 'avoids N+1 queries' do + it 'avoids N+1 queries', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/330335' do control = ActiveRecord::QueryRecorder.new do get api(endpoint_path, user) end @@ -142,7 +142,7 @@ RSpec.describe API::MergeRequests do expect(json_response.last['labels'].first).to match_schema('/public_api/v4/label_basic') end - it 'avoids N+1 queries' do + it 'avoids N+1 queries', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/330335' do path = endpoint_path + "?with_labels_details=true" control = ActiveRecord::QueryRecorder.new do @@ -973,6 +973,14 @@ RSpec.describe API::MergeRequests do it_behaves_like 'merge requests list' + context 'when :api_caching_merge_requests is disabled' do + before do + stub_feature_flags(api_caching_merge_requests: false) + end + + it_behaves_like 'merge requests list' + end + it "returns 404 for non public projects" do project = create(:project, :private) @@ -1049,7 +1057,7 @@ RSpec.describe API::MergeRequests do include_context 'with merge requests' - it 'avoids N+1 queries' do + it 'avoids N+1 queries', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/330335' do control = ActiveRecord::QueryRecorder.new do get api("/projects/#{project.id}/merge_requests", user) end.count @@ -2146,7 +2154,7 @@ RSpec.describe API::MergeRequests do end end - describe 'PUT /projects/:id/merge_reuests/:merge_request_iid' do + describe 'PUT /projects/:id/merge_requests/:merge_request_iid' do it_behaves_like 'issuable update endpoint' do let(:entity) { merge_request } end @@ -2168,6 +2176,68 @@ RSpec.describe API::MergeRequests do end end + context 'when assignee_id=user2.id' do + let(:params) do + { + assignee_id: user2.id + } + end + + it 'sets the assignees' do + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: params + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['assignees']).to contain_exactly( + a_hash_including('name' => user2.name) + ) + end + end + + context 'when only assignee_ids are provided, and the list is empty' do + let(:params) do + { + assignee_ids: [] + } + end + + it 'clears the assignees' do + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: params + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['assignees']).to be_empty + end + end + + context 'when only assignee_ids are provided, and the list contains the sentinel value' do + let(:params) do + { + assignee_ids: [0] + } + end + + it 'clears the assignees' do + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: params + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['assignees']).to be_empty + end + end + + context 'when only assignee_id=0' do + let(:params) do + { + assignee_id: 0 + } + end + + it 'clears the assignees' do + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: params + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['assignees']).to be_empty + end + end + context 'accepts reviewer_ids' do let(:params) do { |