Commit dc8ce956 authored by Stan Hu's avatar Stan Hu

Merge branch '9070-refactor-specs' into 'master'

Refactor epics/issues API specs

Closes #9070

See merge request gitlab-org/gitlab-ee!9086
parents afee5539 cf745a24
...@@ -69,16 +69,6 @@ describe API::Epics do ...@@ -69,16 +69,6 @@ describe API::Epics do
describe 'GET /groups/:id/epics' do describe 'GET /groups/:id/epics' do
let(:url) { "/groups/#{group.path}/epics" } let(:url) { "/groups/#{group.path}/epics" }
def expect_paginated_array_of_items(expected)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
items = json_response.map { |i| i['id'] }
expect(items).to eq(expected)
end
it_behaves_like 'error requests' it_behaves_like 'error requests'
context 'when the request is correct' do context 'when the request is correct' do
...@@ -125,61 +115,61 @@ describe API::Epics do ...@@ -125,61 +115,61 @@ describe API::Epics do
it 'returns epics authored by the given author id' do it 'returns epics authored by the given author id' do
get api(url, user), params: { author_id: user2.id } get api(url, user), params: { author_id: user2.id }
expect_paginated_array_of_items([epic2.id]) expect_paginated_array_response([epic2.id])
end end
it 'returns epics matching given search string for title' do it 'returns epics matching given search string for title' do
get api(url, user), params: { search: epic2.title } get api(url, user), params: { search: epic2.title }
expect_paginated_array_of_items([epic2.id]) expect_paginated_array_response([epic2.id])
end end
it 'returns epics matching given search string for description' do it 'returns epics matching given search string for description' do
get api(url, user), params: { search: epic2.description } get api(url, user), params: { search: epic2.description }
expect_paginated_array_of_items([epic2.id]) expect_paginated_array_response([epic2.id])
end end
it 'returns epics matching given status' do it 'returns epics matching given status' do
get api(url, user), params: { state: :opened } get api(url, user), params: { state: :opened }
expect_paginated_array_of_items([epic2.id]) expect_paginated_array_response([epic2.id])
end end
it 'returns all epics when state set to all' do it 'returns all epics when state set to all' do
get api(url, user), params: { state: :all } get api(url, user), params: { state: :all }
expect_paginated_array_of_items([epic2.id, epic.id]) expect_paginated_array_response([epic2.id, epic.id])
end end
it 'sorts by created_at descending by default' do it 'sorts by created_at descending by default' do
get api(url, user) get api(url, user)
expect_paginated_array_of_items([epic2.id, epic.id]) expect_paginated_array_response([epic2.id, epic.id])
end end
it 'sorts ascending when requested' do it 'sorts ascending when requested' do
get api(url, user), params: { sort: :asc } get api(url, user), params: { sort: :asc }
expect_paginated_array_of_items([epic.id, epic2.id]) expect_paginated_array_response([epic.id, epic2.id])
end end
it 'sorts by updated_at descending when requested' do it 'sorts by updated_at descending when requested' do
get api(url, user), params: { order_by: :updated_at } get api(url, user), params: { order_by: :updated_at }
expect_paginated_array_of_items([epic.id, epic2.id]) expect_paginated_array_response([epic.id, epic2.id])
end end
it 'sorts by updated_at ascending when requested' do it 'sorts by updated_at ascending when requested' do
get api(url, user), params: { order_by: :updated_at, sort: :asc } get api(url, user), params: { order_by: :updated_at, sort: :asc }
expect_paginated_array_of_items([epic2.id, epic.id]) expect_paginated_array_response([epic2.id, epic.id])
end end
it 'returns an array of labeled epics' do it 'returns an array of labeled epics' do
get api(url, user), params: { labels: label.title } get api(url, user), params: { labels: label.title }
expect_paginated_array_of_items([epic2.id]) expect_paginated_array_response([epic2.id])
end end
it_behaves_like 'can admin epics' it_behaves_like 'can admin epics'
...@@ -201,7 +191,7 @@ describe API::Epics do ...@@ -201,7 +191,7 @@ describe API::Epics do
get api(url, user), params: { page: page, per_page: per_page } get api(url, user), params: { page: page, per_page: per_page }
expect(response.headers['X-Page']).to eq(page.to_s) expect(response.headers['X-Page']).to eq(page.to_s)
expect_paginated_array_of_items(expected) expect_paginated_array_response(expected)
end end
end end
......
...@@ -38,31 +38,26 @@ describe API::Issues, :mailer do ...@@ -38,31 +38,26 @@ describe API::Issues, :mailer do
end end
describe "filtering by weight" do describe "filtering by weight" do
before do let!(:issue1) { create(:issue, author: user2, project: project, weight: 1, created_at: 3.days.ago) }
create(:issue, author: user2, project: project, weight: 1) let!(:issue2) { create(:issue, author: user2, project: project, weight: 5, created_at: 2.days.ago) }
create(:issue, author: user2, project: project, weight: 3) let!(:issue3) { create(:issue, author: user2, project: project, weight: 3, created_at: 1.day.ago) }
end
let!(:issue2) { create(:issue, author: user2, project: project, weight: 5) }
it 'returns issues with specific weight' do it 'returns issues with specific weight' do
get api('/issues', user), params: { weight: 5, scope: 'all' } get api('/issues', user), params: { weight: 5, scope: 'all' }
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue2.id)
expect(json_response.first['id']).to eq(issue2.id)
end end
it 'returns issues with no weight' do it 'returns issues with no weight' do
get api('/issues', user), params: { weight: 'None', scope: 'all' } get api('/issues', user), params: { weight: 'None', scope: 'all' }
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue.id)
expect(json_response.first['id']).to eq(issue.id)
end end
it 'returns issues with any weight' do it 'returns issues with any weight' do
get api('/issues', user), params: { weight: 'Any', scope: 'all' } get api('/issues', user), params: { weight: 'Any', scope: 'all' }
expect_paginated_array_response(size: 3) expect_paginated_array_response([issue3.id, issue2.id, issue1.id])
end end
end end
end end
...@@ -131,11 +126,4 @@ describe API::Issues, :mailer do ...@@ -131,11 +126,4 @@ describe API::Issues, :mailer do
end end
end end
end end
def expect_paginated_array_response(size: nil)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(size) if size
end
end end
...@@ -96,12 +96,10 @@ describe API::Issues do ...@@ -96,12 +96,10 @@ describe API::Issues do
end end
context "when authenticated" do context "when authenticated" do
let(:first_issue) { json_response.first }
it "returns an array of issues" do it "returns an array of issues" do
get api("/issues", user) get api("/issues", user)
expect_paginated_array_response(size: 2) expect_paginated_array_response([issue.id, closed_issue.id])
expect(json_response.first['title']).to eq(issue.title) expect(json_response.first['title']).to eq(issue.title)
expect(json_response.last).to have_key('web_url') expect(json_response.last).to have_key('web_url')
end end
...@@ -109,23 +107,19 @@ describe API::Issues do ...@@ -109,23 +107,19 @@ describe API::Issues do
it 'returns an array of closed issues' do it 'returns an array of closed issues' do
get api('/issues', user), params: { state: :closed } get api('/issues', user), params: { state: :closed }
expect_paginated_array_response(size: 1) expect_paginated_array_response(closed_issue.id)
expect(first_issue['id']).to eq(closed_issue.id)
end end
it 'returns an array of opened issues' do it 'returns an array of opened issues' do
get api('/issues', user), params: { state: :opened } get api('/issues', user), params: { state: :opened }
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue.id)
expect(first_issue['id']).to eq(issue.id)
end end
it 'returns an array of all issues' do it 'returns an array of all issues' do
get api('/issues', user), params: { state: :all } get api('/issues', user), params: { state: :all }
expect_paginated_array_response(size: 2) expect_paginated_array_response([issue.id, closed_issue.id])
expect(first_issue['id']).to eq(issue.id)
expect(json_response.second['id']).to eq(closed_issue.id)
end end
it 'returns issues assigned to me' do it 'returns issues assigned to me' do
...@@ -133,8 +127,7 @@ describe API::Issues do ...@@ -133,8 +127,7 @@ describe API::Issues do
get api('/issues', user2), params: { scope: 'assigned_to_me' } get api('/issues', user2), params: { scope: 'assigned_to_me' }
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue2.id)
expect(first_issue['id']).to eq(issue2.id)
end end
it 'returns issues assigned to me (kebab-case)' do it 'returns issues assigned to me (kebab-case)' do
...@@ -142,8 +135,7 @@ describe API::Issues do ...@@ -142,8 +135,7 @@ describe API::Issues do
get api('/issues', user2), params: { scope: 'assigned-to-me' } get api('/issues', user2), params: { scope: 'assigned-to-me' }
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue2.id)
expect(first_issue['id']).to eq(issue2.id)
end end
it 'returns issues authored by the given author id' do it 'returns issues authored by the given author id' do
...@@ -151,8 +143,7 @@ describe API::Issues do ...@@ -151,8 +143,7 @@ describe API::Issues do
get api('/issues', user), params: { author_id: user2.id, scope: 'all' } get api('/issues', user), params: { author_id: user2.id, scope: 'all' }
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue2.id)
expect(first_issue['id']).to eq(issue2.id)
end end
it 'returns issues assigned to the given assignee id' do it 'returns issues assigned to the given assignee id' do
...@@ -160,8 +151,7 @@ describe API::Issues do ...@@ -160,8 +151,7 @@ describe API::Issues do
get api('/issues', user), params: { assignee_id: user2.id, scope: 'all' } get api('/issues', user), params: { assignee_id: user2.id, scope: 'all' }
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue2.id)
expect(first_issue['id']).to eq(issue2.id)
end end
it 'returns issues authored by the given author id and assigned to the given assignee id' do it 'returns issues authored by the given author id and assigned to the given assignee id' do
...@@ -169,8 +159,7 @@ describe API::Issues do ...@@ -169,8 +159,7 @@ describe API::Issues do
get api('/issues', user), params: { author_id: user2.id, assignee_id: user2.id, scope: 'all' } get api('/issues', user), params: { author_id: user2.id, assignee_id: user2.id, scope: 'all' }
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue2.id)
expect(first_issue['id']).to eq(issue2.id)
end end
it 'returns issues with no assignee' do it 'returns issues with no assignee' do
...@@ -178,8 +167,7 @@ describe API::Issues do ...@@ -178,8 +167,7 @@ describe API::Issues do
get api('/issues', user), params: { assignee_id: 0, scope: 'all' } get api('/issues', user), params: { assignee_id: 0, scope: 'all' }
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue2.id)
expect(first_issue['id']).to eq(issue2.id)
end end
it 'returns issues with no assignee' do it 'returns issues with no assignee' do
...@@ -187,8 +175,7 @@ describe API::Issues do ...@@ -187,8 +175,7 @@ describe API::Issues do
get api('/issues', user), params: { assignee_id: 'None', scope: 'all' } get api('/issues', user), params: { assignee_id: 'None', scope: 'all' }
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue2.id)
expect(first_issue['id']).to eq(issue2.id)
end end
it 'returns issues with any assignee' do it 'returns issues with any assignee' do
...@@ -197,18 +184,17 @@ describe API::Issues do ...@@ -197,18 +184,17 @@ describe API::Issues do
get api('/issues', user), params: { assignee_id: 'Any', scope: 'all' } get api('/issues', user), params: { assignee_id: 'Any', scope: 'all' }
expect_paginated_array_response(size: 3) expect_paginated_array_response([issue.id, confidential_issue.id, closed_issue.id])
end end
it 'returns issues reacted by the authenticated user' do it 'returns issues reacted by the authenticated user' do
issue2 = create(:issue, project: project, author: user, assignees: [user]) issue2 = create(:issue, project: project, author: user, assignees: [user])
create(:award_emoji, awardable: issue2, user: user2, name: 'star') create(:award_emoji, awardable: issue2, user: user2, name: 'star')
create(:award_emoji, awardable: issue, user: user2, name: 'thumbsup') create(:award_emoji, awardable: issue, user: user2, name: 'thumbsup')
get api('/issues', user2), params: { my_reaction_emoji: 'Any', scope: 'all' } get api('/issues', user2), params: { my_reaction_emoji: 'Any', scope: 'all' }
expect_paginated_array_response(size: 2) expect_paginated_array_response([issue2.id, issue.id])
end end
it 'returns issues not reacted by the authenticated user' do it 'returns issues not reacted by the authenticated user' do
...@@ -217,21 +203,19 @@ describe API::Issues do ...@@ -217,21 +203,19 @@ describe API::Issues do
get api('/issues', user2), params: { my_reaction_emoji: 'None', scope: 'all' } get api('/issues', user2), params: { my_reaction_emoji: 'None', scope: 'all' }
expect_paginated_array_response(size: 2) expect_paginated_array_response([issue.id, closed_issue.id])
end end
it 'returns issues matching given search string for title' do it 'returns issues matching given search string for title' do
get api("/issues", user), params: { search: issue.title } get api("/issues", user), params: { search: issue.title }
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue.id)
expect(json_response.first['id']).to eq(issue.id)
end end
it 'returns issues matching given search string for description' do it 'returns issues matching given search string for description' do
get api("/issues", user), params: { search: issue.description } get api("/issues", user), params: { search: issue.description }
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue.id)
expect(first_issue['id']).to eq(issue.id)
end end
context 'filtering before a specific date' do context 'filtering before a specific date' do
...@@ -240,15 +224,13 @@ describe API::Issues do ...@@ -240,15 +224,13 @@ describe API::Issues do
it 'returns issues created before a specific date' do it 'returns issues created before a specific date' do
get api('/issues?created_before=2000-01-02T00:00:00.060Z', user) get api('/issues?created_before=2000-01-02T00:00:00.060Z', user)
expect(json_response.size).to eq(1) expect_paginated_array_response(issue2.id)
expect(first_issue['id']).to eq(issue2.id)
end end
it 'returns issues updated before a specific date' do it 'returns issues updated before a specific date' do
get api('/issues?updated_before=2000-01-02T00:00:00.060Z', user) get api('/issues?updated_before=2000-01-02T00:00:00.060Z', user)
expect(json_response.size).to eq(1) expect_paginated_array_response(issue2.id)
expect(first_issue['id']).to eq(issue2.id)
end end
end end
...@@ -258,23 +240,21 @@ describe API::Issues do ...@@ -258,23 +240,21 @@ describe API::Issues do
it 'returns issues created after a specific date' do it 'returns issues created after a specific date' do
get api("/issues?created_after=#{issue2.created_at}", user) get api("/issues?created_after=#{issue2.created_at}", user)
expect(json_response.size).to eq(1) expect_paginated_array_response(issue2.id)
expect(first_issue['id']).to eq(issue2.id)
end end
it 'returns issues updated after a specific date' do it 'returns issues updated after a specific date' do
get api("/issues?updated_after=#{issue2.updated_at}", user) get api("/issues?updated_after=#{issue2.updated_at}", user)
expect(json_response.size).to eq(1) expect_paginated_array_response(issue2.id)
expect(first_issue['id']).to eq(issue2.id)
end end
end end
it 'returns an array of labeled issues' do it 'returns an array of labeled issues' do
get api("/issues", user), params: { labels: label.title } get api("/issues", user), params: { labels: label.title }
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue.id)
expect(first_issue['labels']).to eq([label.title]) expect(json_response.first['labels']).to eq([label.title])
end end
it 'returns an array of labeled issues when all labels matches' do it 'returns an array of labeled issues when all labels matches' do
...@@ -286,20 +266,20 @@ describe API::Issues do ...@@ -286,20 +266,20 @@ describe API::Issues do
get api("/issues", user), params: { labels: "#{label.title},#{label_b.title},#{label_c.title}" } get api("/issues", user), params: { labels: "#{label.title},#{label_b.title},#{label_c.title}" }
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue.id)
expect(json_response.first['labels']).to eq([label_c.title, label_b.title, label.title]) expect(json_response.first['labels']).to eq([label_c.title, label_b.title, label.title])
end end
it 'returns an empty array if no issue matches labels' do it 'returns an empty array if no issue matches labels' do
get api('/issues', user), params: { labels: 'foo,bar' } get api('/issues', user), params: { labels: 'foo,bar' }
expect_paginated_array_response(size: 0) expect_paginated_array_response([])
end end
it 'returns an array of labeled issues matching given state' do it 'returns an array of labeled issues matching given state' do
get api("/issues", user), params: { labels: label.title, state: :opened } get api("/issues", user), params: { labels: label.title, state: :opened }
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue.id)
expect(json_response.first['labels']).to eq([label.title]) expect(json_response.first['labels']).to eq([label.title])
expect(json_response.first['state']).to eq('opened') expect(json_response.first['state']).to eq('opened')
end end
...@@ -307,112 +287,96 @@ describe API::Issues do ...@@ -307,112 +287,96 @@ describe API::Issues do
it 'returns an empty array if no issue matches labels and state filters' do it 'returns an empty array if no issue matches labels and state filters' do
get api("/issues", user), params: { labels: label.title, state: :closed } get api("/issues", user), params: { labels: label.title, state: :closed }
expect_paginated_array_response(size: 0) expect_paginated_array_response([])
end end
it 'returns an array of issues with any label' do it 'returns an array of issues with any label' do
get api("/issues", user), params: { labels: IssuesFinder::FILTER_ANY } get api("/issues", user), params: { labels: IssuesFinder::FILTER_ANY }
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue.id)
expect(json_response.first['id']).to eq(issue.id)
end end
it 'returns an array of issues with no label' do it 'returns an array of issues with no label' do
get api("/issues", user), params: { labels: IssuesFinder::FILTER_NONE } get api("/issues", user), params: { labels: IssuesFinder::FILTER_NONE }
expect_paginated_array_response(size: 1) expect_paginated_array_response(closed_issue.id)
expect(json_response.first['id']).to eq(closed_issue.id)
end end
it 'returns an array of issues with no label when using the legacy No+Label filter' do it 'returns an array of issues with no label when using the legacy No+Label filter' do
get api("/issues", user), params: { labels: "No Label" } get api("/issues", user), params: { labels: "No Label" }
expect_paginated_array_response(size: 1) expect_paginated_array_response(closed_issue.id)
expect(json_response.first['id']).to eq(closed_issue.id)
end end
it 'returns an empty array if no issue matches milestone' do it 'returns an empty array if no issue matches milestone' do
get api("/issues?milestone=#{empty_milestone.title}", user) get api("/issues?milestone=#{empty_milestone.title}", user)
expect_paginated_array_response(size: 0) expect_paginated_array_response([])
end end
it 'returns an empty array if milestone does not exist' do it 'returns an empty array if milestone does not exist' do
get api("/issues?milestone=foo", user) get api("/issues?milestone=foo", user)
expect_paginated_array_response(size: 0) expect_paginated_array_response([])
end end
it 'returns an array of issues in given milestone' do it 'returns an array of issues in given milestone' do
get api("/issues?milestone=#{milestone.title}", user) get api("/issues?milestone=#{milestone.title}", user)
expect_paginated_array_response(size: 2) expect_paginated_array_response([issue.id, closed_issue.id])
expect(json_response.first['id']).to eq(issue.id)
expect(json_response.second['id']).to eq(closed_issue.id)
end end
it 'returns an array of issues matching state in milestone' do it 'returns an array of issues matching state in milestone' do
get api("/issues?milestone=#{milestone.title}"\ get api("/issues?milestone=#{milestone.title}"\
'&state=closed', user) '&state=closed', user)
expect_paginated_array_response(size: 1) expect_paginated_array_response(closed_issue.id)
expect(json_response.first['id']).to eq(closed_issue.id)
end end
it 'returns an array of issues with no milestone' do it 'returns an array of issues with no milestone' do
get api("/issues?milestone=#{no_milestone_title}", author) get api("/issues?milestone=#{no_milestone_title}", author)
expect_paginated_array_response(size: 1) expect_paginated_array_response(confidential_issue.id)
expect(json_response.first['id']).to eq(confidential_issue.id)
end end
it 'returns an array of issues found by iids' do it 'returns an array of issues found by iids' do
get api('/issues', user), params: { iids: [closed_issue.iid] } get api('/issues', user), params: { iids: [closed_issue.iid] }
expect_paginated_array_response(size: 1) expect_paginated_array_response(closed_issue.id)
expect(json_response.first['id']).to eq(closed_issue.id)
end end
it 'returns an empty array if iid does not exist' do it 'returns an empty array if iid does not exist' do
get api("/issues", user), params: { iids: [99999] } get api("/issues", user), params: { iids: [99999] }
expect_paginated_array_response(size: 0) expect_paginated_array_response([])
end end
it 'sorts by created_at descending by default' do it 'sorts by created_at descending by default' do
get api('/issues', user) get api('/issues', user)
response_dates = json_response.map { |issue| issue['created_at'] } expect_paginated_array_response([issue.id, closed_issue.id])
expect_paginated_array_response(size: 2)
expect(response_dates).to eq(response_dates.sort.reverse)
end end
it 'sorts ascending when requested' do it 'sorts ascending when requested' do
get api('/issues?sort=asc', user) get api('/issues?sort=asc', user)
response_dates = json_response.map { |issue| issue['created_at'] } expect_paginated_array_response([closed_issue.id, issue.id])
expect_paginated_array_response(size: 2)
expect(response_dates).to eq(response_dates.sort)
end end
it 'sorts by updated_at descending when requested' do it 'sorts by updated_at descending when requested' do
get api('/issues?order_by=updated_at', user) get api('/issues?order_by=updated_at', user)
response_dates = json_response.map { |issue| issue['updated_at'] } issue.touch(:updated_at)
expect_paginated_array_response(size: 2) expect_paginated_array_response([issue.id, closed_issue.id])
expect(response_dates).to eq(response_dates.sort.reverse)
end end
it 'sorts by updated_at ascending when requested' do it 'sorts by updated_at ascending when requested' do
get api('/issues?order_by=updated_at&sort=asc', user) get api('/issues?order_by=updated_at&sort=asc', user)
response_dates = json_response.map { |issue| issue['updated_at'] } issue.touch(:updated_at)
expect_paginated_array_response(size: 2) expect_paginated_array_response([closed_issue.id, issue.id])
expect(response_dates).to eq(response_dates.sort)
end end
it 'matches V4 response schema' do it 'matches V4 response schema' do
...@@ -434,7 +398,8 @@ describe API::Issues do ...@@ -434,7 +398,8 @@ describe API::Issues do
project: group_project, project: group_project,
state: :closed, state: :closed,
milestone: group_milestone, milestone: group_milestone,
updated_at: 3.hours.ago updated_at: 3.hours.ago,
created_at: 1.day.ago
end end
let!(:group_confidential_issue) do let!(:group_confidential_issue) do
create :issue, create :issue,
...@@ -442,7 +407,8 @@ describe API::Issues do ...@@ -442,7 +407,8 @@ describe API::Issues do
project: group_project, project: group_project,
author: author, author: author,
assignees: [assignee], assignees: [assignee],
updated_at: 2.hours.ago updated_at: 2.hours.ago,
created_at: 2.days.ago
end end
let!(:group_issue) do let!(:group_issue) do
create :issue, create :issue,
...@@ -452,7 +418,8 @@ describe API::Issues do ...@@ -452,7 +418,8 @@ describe API::Issues do
milestone: group_milestone, milestone: group_milestone,
updated_at: 1.hour.ago, updated_at: 1.hour.ago,
title: issue_title, title: issue_title,
description: issue_description description: issue_description,
created_at: 5.days.ago
end end
let!(:group_label) do let!(:group_label) do
create(:label, title: 'group_lbl', color: '#FFAABB', project: group_project) create(:label, title: 'group_lbl', color: '#FFAABB', project: group_project)
...@@ -483,10 +450,7 @@ describe API::Issues do ...@@ -483,10 +450,7 @@ describe API::Issues do
it 'also returns subgroups projects issues' do it 'also returns subgroups projects issues' do
get api(base_url, user) get api(base_url, user)
issue_ids = json_response.map { |issue| issue['id'] } expect_paginated_array_response([issue_2.id, issue_1.id, group_closed_issue.id, group_confidential_issue.id, group_issue.id])
expect_paginated_array_response(size: 5)
expect(issue_ids).to include(issue_1.id, issue_2.id)
end end
end end
...@@ -494,7 +458,7 @@ describe API::Issues do ...@@ -494,7 +458,7 @@ describe API::Issues do
it 'lists all issues in public projects' do it 'lists all issues in public projects' do
get api(base_url) get api(base_url)
expect_paginated_array_response(size: 2) expect_paginated_array_response([group_closed_issue.id, group_issue.id])
end end
end end
...@@ -506,65 +470,62 @@ describe API::Issues do ...@@ -506,65 +470,62 @@ describe API::Issues do
it 'returns all group issues (including opened and closed)' do it 'returns all group issues (including opened and closed)' do
get api(base_url, admin) get api(base_url, admin)
expect_paginated_array_response(size: 3) expect_paginated_array_response([group_closed_issue.id, group_confidential_issue.id, group_issue.id])
end end
it 'returns group issues without confidential issues for non project members' do it 'returns group issues without confidential issues for non project members' do
get api(base_url, non_member), params: { state: :opened } get api(base_url, non_member), params: { state: :opened }
expect_paginated_array_response(size: 1) expect_paginated_array_response(group_issue.id)
expect(json_response.first['title']).to eq(group_issue.title)
end end
it 'returns group confidential issues for author' do it 'returns group confidential issues for author' do
get api(base_url, author), params: { state: :opened } get api(base_url, author), params: { state: :opened }
expect_paginated_array_response(size: 2) expect_paginated_array_response([group_confidential_issue.id, group_issue.id])
end end
it 'returns group confidential issues for assignee' do it 'returns group confidential issues for assignee' do
get api(base_url, assignee), params: { state: :opened } get api(base_url, assignee), params: { state: :opened }
expect_paginated_array_response(size: 2) expect_paginated_array_response([group_confidential_issue.id, group_issue.id])
end end
it 'returns group issues with confidential issues for project members' do it 'returns group issues with confidential issues for project members' do
get api(base_url, user), params: { state: :opened } get api(base_url, user), params: { state: :opened }
expect_paginated_array_response(size: 2) expect_paginated_array_response([group_confidential_issue.id, group_issue.id])
end end
it 'returns group confidential issues for admin' do it 'returns group confidential issues for admin' do
get api(base_url, admin), params: { state: :opened } get api(base_url, admin), params: { state: :opened }
expect_paginated_array_response(size: 2) expect_paginated_array_response([group_confidential_issue.id, group_issue.id])
end end
it 'returns an array of labeled group issues' do it 'returns an array of labeled group issues' do
get api(base_url, user), params: { labels: group_label.title } get api(base_url, user), params: { labels: group_label.title }
expect_paginated_array_response(size: 1) expect_paginated_array_response(group_issue.id)
expect(json_response.first['labels']).to eq([group_label.title]) expect(json_response.first['labels']).to eq([group_label.title])
end end
it 'returns an array of labeled group issues where all labels match' do it 'returns an array of labeled group issues where all labels match' do
get api(base_url, user), params: { labels: "#{group_label.title},foo,bar" } get api(base_url, user), params: { labels: "#{group_label.title},foo,bar" }
expect_paginated_array_response(size: 0) expect_paginated_array_response([])
end end
it 'returns issues matching given search string for title' do it 'returns issues matching given search string for title' do
get api(base_url, user), params: { search: group_issue.title } get api(base_url, user), params: { search: group_issue.title }
expect_paginated_array_response(size: 1) expect_paginated_array_response(group_issue.id)
expect(json_response.first['id']).to eq(group_issue.id)
end end
it 'returns issues matching given search string for description' do it 'returns issues matching given search string for description' do
get api(base_url, user), params: { search: group_issue.description } get api(base_url, user), params: { search: group_issue.description }
expect_paginated_array_response(size: 1) expect_paginated_array_response(group_issue.id)
expect(json_response.first['id']).to eq(group_issue.id)
end end
it 'returns an array of labeled issues when all labels matches' do it 'returns an array of labeled issues when all labels matches' do
...@@ -576,69 +537,64 @@ describe API::Issues do ...@@ -576,69 +537,64 @@ describe API::Issues do
get api(base_url, user), params: { labels: "#{group_label.title},#{label_b.title},#{label_c.title}" } get api(base_url, user), params: { labels: "#{group_label.title},#{label_b.title},#{label_c.title}" }
expect_paginated_array_response(size: 1) expect_paginated_array_response(group_issue.id)
expect(json_response.first['labels']).to eq([label_c.title, label_b.title, group_label.title]) expect(json_response.first['labels']).to eq([label_c.title, label_b.title, group_label.title])
end end
it 'returns an array of issues found by iids' do it 'returns an array of issues found by iids' do
get api(base_url, user), params: { iids: [group_issue.iid] } get api(base_url, user), params: { iids: [group_issue.iid] }
expect_paginated_array_response(size: 1) expect_paginated_array_response(group_issue.id)
expect(json_response.first['id']).to eq(group_issue.id) expect(json_response.first['id']).to eq(group_issue.id)
end end
it 'returns an empty array if iid does not exist' do it 'returns an empty array if iid does not exist' do
get api(base_url, user), params: { iids: [99999] } get api(base_url, user), params: { iids: [99999] }
expect_paginated_array_response(size: 0) expect_paginated_array_response([])
end end
it 'returns an empty array if no group issue matches labels' do it 'returns an empty array if no group issue matches labels' do
get api(base_url, user), params: { labels: 'foo,bar' } get api(base_url, user), params: { labels: 'foo,bar' }
expect_paginated_array_response(size: 0) expect_paginated_array_response([])
end end
it 'returns an array of group issues with any label' do it 'returns an array of group issues with any label' do
get api(base_url, user), params: { labels: IssuesFinder::FILTER_ANY } get api(base_url, user), params: { labels: IssuesFinder::FILTER_ANY }
expect_paginated_array_response(size: 1) expect_paginated_array_response(group_issue.id)
expect(json_response.first['id']).to eq(group_issue.id) expect(json_response.first['id']).to eq(group_issue.id)
end end
it 'returns an array of group issues with no label' do it 'returns an array of group issues with no label' do
get api(base_url, user), params: { labels: IssuesFinder::FILTER_NONE } get api(base_url, user), params: { labels: IssuesFinder::FILTER_NONE }
response_ids = json_response.map { |issue| issue['id'] } expect_paginated_array_response([group_closed_issue.id, group_confidential_issue.id])
expect_paginated_array_response(size: 2)
expect(response_ids).to contain_exactly(group_closed_issue.id, group_confidential_issue.id)
end end
it 'returns an empty array if no issue matches milestone' do it 'returns an empty array if no issue matches milestone' do
get api(base_url, user), params: { milestone: group_empty_milestone.title } get api(base_url, user), params: { milestone: group_empty_milestone.title }
expect_paginated_array_response(size: 0) expect_paginated_array_response([])
end end
it 'returns an empty array if milestone does not exist' do it 'returns an empty array if milestone does not exist' do
get api(base_url, user), params: { milestone: 'foo' } get api(base_url, user), params: { milestone: 'foo' }
expect_paginated_array_response(size: 0) expect_paginated_array_response([])
end end
it 'returns an array of issues in given milestone' do it 'returns an array of issues in given milestone' do
get api(base_url, user), params: { state: :opened, milestone: group_milestone.title } get api(base_url, user), params: { state: :opened, milestone: group_milestone.title }
expect_paginated_array_response(size: 1) expect_paginated_array_response(group_issue.id)
expect(json_response.first['id']).to eq(group_issue.id)
end end
it 'returns an array of issues matching state in milestone' do it 'returns an array of issues matching state in milestone' do
get api(base_url, user), params: { milestone: group_milestone.title, state: :closed } get api(base_url, user), params: { milestone: group_milestone.title, state: :closed }
expect_paginated_array_response(size: 1) expect_paginated_array_response(group_closed_issue.id)
expect(json_response.first['id']).to eq(group_closed_issue.id)
end end
it 'returns an array of issues with no milestone' do it 'returns an array of issues with no milestone' do
...@@ -646,44 +602,33 @@ describe API::Issues do ...@@ -646,44 +602,33 @@ describe API::Issues do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
expect_paginated_array_response(size: 1) expect_paginated_array_response(group_confidential_issue.id)
expect(json_response.first['id']).to eq(group_confidential_issue.id)
end end
it 'sorts by created_at descending by default' do it 'sorts by created_at descending by default' do
get api(base_url, user) get api(base_url, user)
response_dates = json_response.map { |issue| issue['created_at'] } expect_paginated_array_response([group_closed_issue.id, group_confidential_issue.id, group_issue.id])
expect_paginated_array_response(size: 3)
expect(response_dates).to eq(response_dates.sort.reverse)
end end
it 'sorts ascending when requested' do it 'sorts ascending when requested' do
get api("#{base_url}?sort=asc", user) get api("#{base_url}?sort=asc", user)
response_dates = json_response.map { |issue| issue['created_at'] } expect_paginated_array_response([group_issue.id, group_confidential_issue.id, group_closed_issue.id])
expect_paginated_array_response(size: 3)
expect(response_dates).to eq(response_dates.sort)
end end
it 'sorts by updated_at descending when requested' do it 'sorts by updated_at descending when requested' do
get api("#{base_url}?order_by=updated_at", user) get api("#{base_url}?order_by=updated_at", user)
response_dates = json_response.map { |issue| issue['updated_at'] } group_issue.touch(:updated_at)
expect_paginated_array_response(size: 3) expect_paginated_array_response([group_issue.id, group_confidential_issue.id, group_closed_issue.id])
expect(response_dates).to eq(response_dates.sort.reverse)
end end
it 'sorts by updated_at ascending when requested' do it 'sorts by updated_at ascending when requested' do
get api(base_url, user), params: { order_by: :updated_at, sort: :asc } get api(base_url, user), params: { order_by: :updated_at, sort: :asc }
response_dates = json_response.map { |issue| issue['updated_at'] } expect_paginated_array_response([group_closed_issue.id, group_confidential_issue.id, group_issue.id])
expect_paginated_array_response(size: 3)
expect(response_dates).to eq(response_dates.sort)
end end
end end
end end
...@@ -695,8 +640,7 @@ describe API::Issues do ...@@ -695,8 +640,7 @@ describe API::Issues do
it 'returns public project issues' do it 'returns public project issues' do
get api("/projects/#{project.id}/issues") get api("/projects/#{project.id}/issues")
expect_paginated_array_response(size: 2) expect_paginated_array_response([issue.id, closed_issue.id])
expect(json_response.first['title']).to eq(issue.title)
end end
end end
...@@ -735,56 +679,49 @@ describe API::Issues do ...@@ -735,56 +679,49 @@ describe API::Issues do
get api("/projects/#{restricted_project.id}/issues", non_member) get api("/projects/#{restricted_project.id}/issues", non_member)
expect_paginated_array_response(size: 0) expect_paginated_array_response([])
end end
it 'returns project issues without confidential issues for non project members' do it 'returns project issues without confidential issues for non project members' do
get api("#{base_url}/issues", non_member) get api("#{base_url}/issues", non_member)
expect_paginated_array_response(size: 2) expect_paginated_array_response([issue.id, closed_issue.id])
expect(json_response.first['title']).to eq(issue.title)
end end
it 'returns project issues without confidential issues for project members with guest role' do it 'returns project issues without confidential issues for project members with guest role' do
get api("#{base_url}/issues", guest) get api("#{base_url}/issues", guest)
expect_paginated_array_response(size: 2) expect_paginated_array_response([issue.id, closed_issue.id])
expect(json_response.first['title']).to eq(issue.title)
end end
it 'returns project confidential issues for author' do it 'returns project confidential issues for author' do
get api("#{base_url}/issues", author) get api("#{base_url}/issues", author)
expect_paginated_array_response(size: 3) expect_paginated_array_response([issue.id, confidential_issue.id, closed_issue.id])
expect(json_response.first['title']).to eq(issue.title)
end end
it 'returns project confidential issues for assignee' do it 'returns project confidential issues for assignee' do
get api("#{base_url}/issues", assignee) get api("#{base_url}/issues", assignee)
expect_paginated_array_response(size: 3) expect_paginated_array_response([issue.id, confidential_issue.id, closed_issue.id])
expect(json_response.first['title']).to eq(issue.title)
end end
it 'returns project issues with confidential issues for project members' do it 'returns project issues with confidential issues for project members' do
get api("#{base_url}/issues", user) get api("#{base_url}/issues", user)
expect_paginated_array_response(size: 3) expect_paginated_array_response([issue.id, confidential_issue.id, closed_issue.id])
expect(json_response.first['title']).to eq(issue.title)
end end
it 'returns project confidential issues for admin' do it 'returns project confidential issues for admin' do
get api("#{base_url}/issues", admin) get api("#{base_url}/issues", admin)
expect_paginated_array_response(size: 3) expect_paginated_array_response([issue.id, confidential_issue.id, closed_issue.id])
expect(json_response.first['title']).to eq(issue.title)
end end
it 'returns an array of labeled project issues' do it 'returns an array of labeled project issues' do
get api("#{base_url}/issues", user), params: { labels: label.title } get api("#{base_url}/issues", user), params: { labels: label.title }
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue.id)
expect(json_response.first['labels']).to eq([label.title])
end end
it 'returns an array of labeled issues when all labels matches' do it 'returns an array of labeled issues when all labels matches' do
...@@ -796,142 +733,117 @@ describe API::Issues do ...@@ -796,142 +733,117 @@ describe API::Issues do
get api("#{base_url}/issues", user), params: { labels: "#{label.title},#{label_b.title},#{label_c.title}" } get api("#{base_url}/issues", user), params: { labels: "#{label.title},#{label_b.title},#{label_c.title}" }
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue.id)
expect(json_response.first['labels']).to eq([label_c.title, label_b.title, label.title])
end end
it 'returns issues matching given search string for title' do it 'returns issues matching given search string for title' do
get api("#{base_url}/issues?search=#{issue.title}", user) get api("#{base_url}/issues?search=#{issue.title}", user)
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue.id)
expect(json_response.first['id']).to eq(issue.id)
end end
it 'returns issues matching given search string for description' do it 'returns issues matching given search string for description' do
get api("#{base_url}/issues?search=#{issue.description}", user) get api("#{base_url}/issues?search=#{issue.description}", user)
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue.id)
expect(json_response.first['id']).to eq(issue.id)
end end
it 'returns an array of issues found by iids' do it 'returns an array of issues found by iids' do
get api("#{base_url}/issues", user), params: { iids: [issue.iid] } get api("#{base_url}/issues", user), params: { iids: [issue.iid] }
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue.id)
expect(json_response.first['id']).to eq(issue.id)
end end
it 'returns an empty array if iid does not exist' do it 'returns an empty array if iid does not exist' do
get api("#{base_url}/issues", user), params: { iids: [99999] } get api("#{base_url}/issues", user), params: { iids: [99999] }
expect_paginated_array_response(size: 0) expect_paginated_array_response([])
end end
it 'returns an empty array if not all labels matches' do it 'returns an empty array if not all labels matches' do
get api("#{base_url}/issues?labels=#{label.title},foo", user) get api("#{base_url}/issues?labels=#{label.title},foo", user)
expect_paginated_array_response(size: 0) expect_paginated_array_response([])
end end
it 'returns an array of project issues with any label' do it 'returns an array of project issues with any label' do
get api("#{base_url}/issues", user), params: { labels: IssuesFinder::FILTER_ANY } get api("#{base_url}/issues", user), params: { labels: IssuesFinder::FILTER_ANY }
expect_paginated_array_response(size: 1) expect_paginated_array_response(issue.id)
expect(json_response.first['id']).to eq(issue.id)
end end
it 'returns an array of project issues with no label' do it 'returns an array of project issues with no label' do
get api("#{base_url}/issues", user), params: { labels: IssuesFinder::FILTER_NONE } get api("#{base_url}/issues", user), params: { labels: IssuesFinder::FILTER_NONE }
response_ids = json_response.map { |issue| issue['id'] } expect_paginated_array_response([confidential_issue.id, closed_issue.id])
expect_paginated_array_response(size: 2)
expect(response_ids).to contain_exactly(closed_issue.id, confidential_issue.id)
end end
it 'returns an empty array if no project issue matches labels' do it 'returns an empty array if no project issue matches labels' do
get api("#{base_url}/issues", user), params: { labels: 'foo,bar' } get api("#{base_url}/issues", user), params: { labels: 'foo,bar' }
expect_paginated_array_response(size: 0) expect_paginated_array_response([])
end end
it 'returns an empty array if no issue matches milestone' do it 'returns an empty array if no issue matches milestone' do
get api("#{base_url}/issues", user), params: { milestone: empty_milestone.title } get api("#{base_url}/issues", user), params: { milestone: empty_milestone.title }
expect_paginated_array_response(size: 0) expect_paginated_array_response([])
end end
it 'returns an empty array if milestone does not exist' do it 'returns an empty array if milestone does not exist' do
get api("#{base_url}/issues", user), params: { milestone: :foo } get api("#{base_url}/issues", user), params: { milestone: :foo }
expect_paginated_array_response(size: 0) expect_paginated_array_response([])
end end
it 'returns an array of issues in given milestone' do it 'returns an array of issues in given milestone' do
get api("#{base_url}/issues", user), params: { milestone: milestone.title } get api("#{base_url}/issues", user), params: { milestone: milestone.title }
expect_paginated_array_response(size: 2) expect_paginated_array_response([issue.id, closed_issue.id])
expect(json_response.first['id']).to eq(issue.id)
expect(json_response.second['id']).to eq(closed_issue.id)
end end
it 'returns an array of issues matching state in milestone' do it 'returns an array of issues matching state in milestone' do
get api("#{base_url}/issues", user), params: { milestone: milestone.title, state: :closed } get api("#{base_url}/issues", user), params: { milestone: milestone.title, state: :closed }
expect_paginated_array_response(size: 1) expect_paginated_array_response(closed_issue.id)
expect(json_response.first['id']).to eq(closed_issue.id)
end end
it 'returns an array of issues with no milestone' do it 'returns an array of issues with no milestone' do
get api("#{base_url}/issues", user), params: { milestone: no_milestone_title } get api("#{base_url}/issues", user), params: { milestone: no_milestone_title }
expect_paginated_array_response(size: 1) expect_paginated_array_response(confidential_issue.id)
expect(json_response.first['id']).to eq(confidential_issue.id)
end end
it 'returns an array of issues with any milestone' do it 'returns an array of issues with any milestone' do
get api("#{base_url}/issues", user), params: { milestone: any_milestone_title } get api("#{base_url}/issues", user), params: { milestone: any_milestone_title }
response_ids = json_response.map { |issue| issue['id'] } expect_paginated_array_response([issue.id, closed_issue.id])
expect_paginated_array_response(size: 2)
expect(response_ids).to contain_exactly(closed_issue.id, issue.id)
end end
it 'sorts by created_at descending by default' do it 'sorts by created_at descending by default' do
get api("#{base_url}/issues", user) get api("#{base_url}/issues", user)
response_dates = json_response.map { |issue| issue['created_at'] } expect_paginated_array_response([issue.id, confidential_issue.id, closed_issue.id])
expect_paginated_array_response(size: 3)
expect(response_dates).to eq(response_dates.sort.reverse)
end end
it 'sorts ascending when requested' do it 'sorts ascending when requested' do
get api("#{base_url}/issues", user), params: { sort: :asc } get api("#{base_url}/issues", user), params: { sort: :asc }
response_dates = json_response.map { |issue| issue['created_at'] } expect_paginated_array_response([closed_issue.id, confidential_issue.id, issue.id])
expect_paginated_array_response(size: 3)
expect(response_dates).to eq(response_dates.sort)
end end
it 'sorts by updated_at descending when requested' do it 'sorts by updated_at descending when requested' do
get api("#{base_url}/issues", user), params: { order_by: :updated_at } get api("#{base_url}/issues", user), params: { order_by: :updated_at }
response_dates = json_response.map { |issue| issue['updated_at'] } issue.touch(:updated_at)
expect_paginated_array_response(size: 3) expect_paginated_array_response([issue.id, confidential_issue.id, closed_issue.id])
expect(response_dates).to eq(response_dates.sort.reverse)
end end
it 'sorts by updated_at ascending when requested' do it 'sorts by updated_at ascending when requested' do
get api("#{base_url}/issues", user), params: { order_by: :updated_at, sort: :asc } get api("#{base_url}/issues", user), params: { order_by: :updated_at, sort: :asc }
response_dates = json_response.map { |issue| issue['updated_at'] } expect_paginated_array_response([closed_issue.id, confidential_issue.id, issue.id])
expect_paginated_array_response(size: 3)
expect(response_dates).to eq(response_dates.sort)
end end
end end
...@@ -1832,21 +1744,21 @@ describe API::Issues do ...@@ -1832,21 +1744,21 @@ describe API::Issues do
it 'return public project issues' do it 'return public project issues' do
get api("/projects/#{project.id}/issues/#{issue.iid}/closed_by") get api("/projects/#{project.id}/issues/#{issue.iid}/closed_by")
expect_paginated_array_response(size: 1) expect_paginated_array_response(merge_request.id)
end end
end end
it 'returns merge requests that will close issue on merge' do it 'returns merge requests that will close issue on merge' do
get api("/projects/#{project.id}/issues/#{issue.iid}/closed_by", user) get api("/projects/#{project.id}/issues/#{issue.iid}/closed_by", user)
expect_paginated_array_response(size: 1) expect_paginated_array_response(merge_request.id)
end end
context 'when no merge requests will close issue' do context 'when no merge requests will close issue' do
it 'returns empty array' do it 'returns empty array' do
get api("/projects/#{project.id}/issues/#{closed_issue.iid}/closed_by", user) get api("/projects/#{project.id}/issues/#{closed_issue.iid}/closed_by", user)
expect_paginated_array_response(size: 0) expect_paginated_array_response([])
end end
end end
...@@ -1882,7 +1794,7 @@ describe API::Issues do ...@@ -1882,7 +1794,7 @@ describe API::Issues do
it 'return list of referenced merge requests from issue' do it 'return list of referenced merge requests from issue' do
get_related_merge_requests(project.id, issue.iid) get_related_merge_requests(project.id, issue.iid)
expect_paginated_array_response(size: 1) expect_paginated_array_response(related_mr.id)
end end
it 'renders 404 if project is not visible' do it 'renders 404 if project is not visible' do
...@@ -1906,15 +1818,14 @@ describe API::Issues do ...@@ -1906,15 +1818,14 @@ describe API::Issues do
get_related_merge_requests(project.id, issue.iid, user) get_related_merge_requests(project.id, issue.iid, user)
expect_paginated_array_response(size: 1) expect_paginated_array_response(related_mr.id)
expect(json_response.first['id']).to eq(related_mr.id)
end end
context 'no merge request mentioned a issue' do context 'no merge request mentioned a issue' do
it 'returns empty array' do it 'returns empty array' do
get_related_merge_requests(project.id, closed_issue.iid, user) get_related_merge_requests(project.id, closed_issue.iid, user)
expect_paginated_array_response(size: 0) expect_paginated_array_response([])
end end
end end
...@@ -1952,13 +1863,6 @@ describe API::Issues do ...@@ -1952,13 +1863,6 @@ describe API::Issues do
end end
end end
def expect_paginated_array_response(size: nil)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(size) if size
end
describe 'GET projects/:id/issues/:issue_iid/participants' do describe 'GET projects/:id/issues/:issue_iid/participants' do
it_behaves_like 'issuable participants endpoint' do it_behaves_like 'issuable participants endpoint' do
let(:entity) { issue } let(:entity) { issue }
......
...@@ -36,4 +36,11 @@ module ApiHelpers ...@@ -36,4 +36,11 @@ module ApiHelpers
full_path full_path
end end
def expect_paginated_array_response(items)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.map { |item| item['id'] }).to eq(Array(items))
end
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