Commit 44b2d759 authored by Nermin Vehabovic's avatar Nermin Vehabovic

Added: Specs to cover other endpoints for the same reason

parent c8352c9f
...@@ -641,10 +641,38 @@ describe API::Issues do ...@@ -641,10 +641,38 @@ describe API::Issues do
expect_paginated_array_response(group_confidential_issue.id) expect_paginated_array_response(group_confidential_issue.id)
end end
it 'sorts by created_at descending by default' do context 'without sort params' do
get api(base_url, user) it 'sorts by created_at descending by default' do
get api(base_url, user)
expect_paginated_array_response([group_closed_issue.id, group_confidential_issue.id, group_issue.id]) expect_paginated_array_response([group_closed_issue.id, group_confidential_issue.id, group_issue.id])
end
context 'with 2 issues with same created_at' do
let!(:group_issue2) do
create :issue,
author: user,
assignees: [user],
project: group_project,
milestone: group_milestone,
updated_at: 1.hour.ago,
title: issue_title,
description: issue_description,
created_at: group_issue.created_at
end
it 'page breaks first page correctly' do
get api("#{base_url}?per_page=3", user)
expect_paginated_array_response([group_closed_issue.id, group_confidential_issue.id, group_issue2.id])
end
it 'page breaks second page correctly' do
get api("#{base_url}?per_page=3&page=2", user)
expect_paginated_array_response([group_issue.id])
end
end
end end
it 'sorts ascending when requested' do it 'sorts ascending when requested' do
...@@ -856,10 +884,38 @@ describe API::Issues do ...@@ -856,10 +884,38 @@ describe API::Issues do
expect_paginated_array_response([issue.id, closed_issue.id]) expect_paginated_array_response([issue.id, closed_issue.id])
end end
it 'sorts by created_at descending by default' do context 'without sort params' do
get api("#{base_url}/issues", user) it 'sorts by created_at descending by default' do
get api("#{base_url}/issues", user)
expect_paginated_array_response([issue.id, confidential_issue.id, closed_issue.id]) expect_paginated_array_response([issue.id, confidential_issue.id, closed_issue.id])
end
context 'with 2 issues with same created_at' do
let!(:closed_issue2) do
create :closed_issue,
author: user,
assignees: [user],
project: project,
milestone: milestone,
created_at: closed_issue.created_at,
updated_at: 1.hour.ago,
title: issue_title,
description: issue_description
end
it 'page breaks first page correctly' do
get api("#{base_url}/issues?per_page=3", user)
expect_paginated_array_response([issue.id, confidential_issue.id, closed_issue2.id])
end
it 'page breaks second page correctly' do
get api("#{base_url}/issues?per_page=3&page=2", user)
expect_paginated_array_response([closed_issue.id])
end
end
end end
it 'sorts ascending when requested' do it 'sorts ascending when requested' do
......
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