Commit 48fd4071 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch '200018-refactor-api-merge-reques-specs-2' into 'master'

Fix for "Refactor merge requests/issues API specs"

See merge request gitlab-org/gitlab!25243
parents a195f9d9 485845bf
...@@ -220,7 +220,7 @@ describe API::MergeRequests do ...@@ -220,7 +220,7 @@ describe API::MergeRequests do
it 'returns merge requests with given assignee ID' do it 'returns merge requests with given assignee ID' do
get api('/merge_requests', user), params: { assignee_id: user2.id } get api('/merge_requests', user), params: { assignee_id: user2.id }
expect_paginated_array_response([merge_request2.id, merge_request.id]) expect_response_contain_exactly(merge_request2.id, merge_request.id)
end end
end end
...@@ -237,7 +237,7 @@ describe API::MergeRequests do ...@@ -237,7 +237,7 @@ describe API::MergeRequests do
let(:approvers_param) { [merge_request_with_approver.approvers.first.user_id] } let(:approvers_param) { [merge_request_with_approver.approvers.first.user_id] }
it 'returns an array of merge requests which have specified the user as an approver' do it 'returns an array of merge requests which have specified the user as an approver' do
expect_paginated_array_response([merge_request_with_approver.id]) expect_response_contain_exactly(merge_request_with_approver.id)
end end
end end
...@@ -245,7 +245,7 @@ describe API::MergeRequests do ...@@ -245,7 +245,7 @@ describe API::MergeRequests do
let(:approvers_param) { 'None' } let(:approvers_param) { 'None' }
it 'returns an array of merge requests with no approvers' do it 'returns an array of merge requests with no approvers' do
expect_paginated_array_response([merge_request.id]) expect_response_contain_exactly(merge_request.id)
end end
end end
...@@ -253,7 +253,7 @@ describe API::MergeRequests do ...@@ -253,7 +253,7 @@ describe API::MergeRequests do
let(:approvers_param) { 'Any' } let(:approvers_param) { 'Any' }
it 'returns an array of merge requests with any approver' do it 'returns an array of merge requests with any approver' do
expect_paginated_array_response([merge_request_with_approver.id]) expect_response_contain_exactly(merge_request_with_approver.id)
end end
end end
...@@ -282,7 +282,7 @@ describe API::MergeRequests do ...@@ -282,7 +282,7 @@ describe API::MergeRequests do
let(:approvals_param) { [user2.id] } let(:approvals_param) { [user2.id] }
it 'returns an array of merge requests which have specified the user as an approver' do it 'returns an array of merge requests which have specified the user as an approver' do
expect_paginated_array_response([merge_request_with_approval.id]) expect_response_contain_exactly(merge_request_with_approval.id)
end end
end end
...@@ -290,7 +290,7 @@ describe API::MergeRequests do ...@@ -290,7 +290,7 @@ describe API::MergeRequests do
let(:approvals_param) { 'None' } let(:approvals_param) { 'None' }
it 'returns an array of merge requests with no approvers' do it 'returns an array of merge requests with no approvers' do
expect_paginated_array_response([merge_request.id]) expect_response_contain_exactly(merge_request.id)
end end
end end
...@@ -298,7 +298,7 @@ describe API::MergeRequests do ...@@ -298,7 +298,7 @@ describe API::MergeRequests do
let(:approvals_param) { 'Any' } let(:approvals_param) { 'Any' }
it 'returns an array of merge requests with any approver' do it 'returns an array of merge requests with any approver' do
expect_paginated_array_response([merge_request_with_approval.id]) expect_response_contain_exactly(merge_request_with_approval.id)
end end
end end
......
This diff is collapsed.
...@@ -58,6 +58,13 @@ module ApiHelpers ...@@ -58,6 +58,13 @@ module ApiHelpers
expect(json_response.map { |item| item['id'] }).to eq(Array(items)) expect(json_response.map { |item| item['id'] }).to eq(Array(items))
end end
def expect_response_contain_exactly(*items)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Array
expect(json_response.length).to eq(items.size)
expect(json_response.map { |item| item['id'] }).to contain_exactly(*items)
end
def stub_last_activity_update def stub_last_activity_update
allow_any_instance_of(Users::ActivityService).to receive(:execute) allow_any_instance_of(Users::ActivityService).to receive(:execute)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment