From 3cac519143a19bd13f0dd9cb28c9b3ecc562baa5 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki <drogus@gmail.com> Date: Thu, 16 Apr 2015 13:49:23 +0200 Subject: [PATCH] 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. --- spec/integration/v2/repositories_spec.rb | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/spec/integration/v2/repositories_spec.rb b/spec/integration/v2/repositories_spec.rb index 954ca44d..c3bbe09f 100644 --- a/spec/integration/v2/repositories_spec.rb +++ b/spec/integration/v2/repositories_spec.rb @@ -5,15 +5,22 @@ describe 'Repos' do let(:repo) { Repository.by_slug('svenfuchs/minimal').first } let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' } } - describe 'with a list of ids' do - it 'returns repositories by ids' do - repos = Repository.all - ids = repos[0..1].map(&:id) - response = get "/repos?ids=#{ids.join(',')}", {}, headers - body = JSON.parse(response.body) + it 'returns repositories by ids with ids=1,2,3 format' do + repos = Repository.all + ids = repos[0..1].map(&:id) + response = get "/repos?ids=#{ids.join(',')}", {}, headers + body = JSON.parse(response.body) - body['repos'].map { |r| r['id'] }.should == ids - end + body['repos'].map { |r| r['id'] }.should == ids + 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 describe 'with authenticated user' do