Convert params['ids'] to array
Services like find_builds can accept :ids as a param, but it needs to be an array, string will be passed to find and converted into integer.
This commit is contained in:
parent
40430ac34d
commit
b6a351c766
|
@ -5,6 +5,7 @@ class Travis::Api::App
|
|||
class Builds < Endpoint
|
||||
get '/' do
|
||||
name = params[:branches] ? :find_branches : :find_builds
|
||||
params['ids'] = params['ids'].split(',') if params['ids'].respond_to?(:split)
|
||||
respond_with service(name, params)
|
||||
end
|
||||
|
||||
|
|
|
@ -63,6 +63,8 @@ class Travis::Api::App
|
|||
#
|
||||
# json(:builds)
|
||||
get '/:owner_name/:name/builds' do
|
||||
name = params[:branches] ? :find_branches : :find_builds
|
||||
params['ids'] = params['ids'].split(',') if params['ids'].respond_to?(:split)
|
||||
respond_with service(:find_builds, params)
|
||||
end
|
||||
|
||||
|
|
|
@ -25,6 +25,18 @@ describe 'Builds' do
|
|||
response.should deliver_json_for(repo.builds.order('id DESC'), version: 'v2', type: :builds)
|
||||
end
|
||||
|
||||
it 'GET /repos/svenfuchs/minimal/builds?ids=1,2' do
|
||||
ids = repo.builds.map(&:id).sort.join(',')
|
||||
response = get "/repos/svenfuchs/minimal/builds?ids=#{ids}", {}, headers
|
||||
response.should deliver_json_for(repo.builds.order('id ASC'), version: 'v2')
|
||||
end
|
||||
|
||||
it 'GET /builds?ids=1,2' do
|
||||
ids = repo.builds.map(&:id).sort.join(',')
|
||||
response = get "/builds?ids=#{ids}", {}, headers
|
||||
response.should deliver_json_for(repo.builds.order('id ASC'), version: 'v2')
|
||||
end
|
||||
|
||||
it 'GET /repos/svenfuchs/minimal/builds/1' do
|
||||
response = get "/repos/svenfuchs/minimal/builds/#{build.id}", {}, headers
|
||||
response.should deliver_json_for(build, version: 'v2')
|
||||
|
|
Loading…
Reference in New Issue
Block a user