Ensure that both ways to get repos by ids are tested
In 222a970
I added a way to get repos by ids using format ids=1,2,3. It
turned out that getting by ids was already supported with
ids[]=1&ids[]=2 format, but it wasn't tested. I added tests for both
methods and left the comma separated ids list as we already support it
in other places.
This commit is contained in:
parent
222a97028a
commit
3cac519143
|
@ -5,15 +5,22 @@ describe 'Repos' do
|
||||||
let(:repo) { Repository.by_slug('svenfuchs/minimal').first }
|
let(:repo) { Repository.by_slug('svenfuchs/minimal').first }
|
||||||
let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' } }
|
let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' } }
|
||||||
|
|
||||||
describe 'with a list of ids' do
|
it 'returns repositories by ids with ids=1,2,3 format' do
|
||||||
it 'returns repositories by ids' do
|
repos = Repository.all
|
||||||
repos = Repository.all
|
ids = repos[0..1].map(&:id)
|
||||||
ids = repos[0..1].map(&:id)
|
response = get "/repos?ids=#{ids.join(',')}", {}, headers
|
||||||
response = get "/repos?ids=#{ids.join(',')}", {}, headers
|
body = JSON.parse(response.body)
|
||||||
body = JSON.parse(response.body)
|
|
||||||
|
|
||||||
body['repos'].map { |r| r['id'] }.should == ids
|
body['repos'].map { |r| r['id'] }.should == ids
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'returns repositories by ids with ids[] format' do
|
||||||
|
repos = Repository.all
|
||||||
|
ids = repos[0..1].map(&:id)
|
||||||
|
response = get "/repos?ids[]=#{ids[0]}&ids[]=#{ids[1]}", {}, headers
|
||||||
|
body = JSON.parse(response.body)
|
||||||
|
|
||||||
|
body['repos'].map { |r| r['id'] }.should == ids
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'with authenticated user' do
|
describe 'with authenticated user' do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user