merge
This commit is contained in:
commit
ec62a5b918
42
Gemfile.lock
42
Gemfile.lock
|
@ -48,7 +48,7 @@ GIT
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/travis-ci/travis-core.git
|
remote: git://github.com/travis-ci/travis-core.git
|
||||||
revision: a66c345d44fd9c28884d694acfff3b1a0fbc5232
|
revision: f1d4c3246ea7a5434076fdc7026aa11a2c90bdac
|
||||||
specs:
|
specs:
|
||||||
travis-core (0.0.1)
|
travis-core (0.0.1)
|
||||||
actionmailer (~> 3.2.19)
|
actionmailer (~> 3.2.19)
|
||||||
|
@ -56,6 +56,7 @@ GIT
|
||||||
coder (~> 0.4.0)
|
coder (~> 0.4.0)
|
||||||
data_migrations (~> 0.0.1)
|
data_migrations (~> 0.0.1)
|
||||||
gh
|
gh
|
||||||
|
google-api-client (~> 0.9.4)
|
||||||
hashr
|
hashr
|
||||||
metriks (~> 0.9.7)
|
metriks (~> 0.9.7)
|
||||||
multi_json
|
multi_json
|
||||||
|
@ -66,7 +67,7 @@ GIT
|
||||||
rollout (~> 1.1.0)
|
rollout (~> 1.1.0)
|
||||||
s3 (~> 0.3)
|
s3 (~> 0.3)
|
||||||
simple_states (~> 1.0.0)
|
simple_states (~> 1.0.0)
|
||||||
thor (~> 0.14.6)
|
thor
|
||||||
travis-config (~> 0.1.0)
|
travis-config (~> 0.1.0)
|
||||||
virtus (~> 1.0.0)
|
virtus (~> 1.0.0)
|
||||||
|
|
||||||
|
@ -191,6 +192,24 @@ GEM
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
net-http-persistent (>= 2.7)
|
net-http-persistent (>= 2.7)
|
||||||
net-http-pipeline
|
net-http-pipeline
|
||||||
|
google-api-client (0.9.4)
|
||||||
|
addressable (~> 2.3)
|
||||||
|
googleauth (~> 0.5)
|
||||||
|
httpclient (~> 2.7)
|
||||||
|
hurley (~> 0.1)
|
||||||
|
memoist (~> 0.11)
|
||||||
|
mime-types (>= 1.6)
|
||||||
|
representable (~> 2.3.0)
|
||||||
|
retriable (~> 2.0)
|
||||||
|
thor (~> 0.19)
|
||||||
|
googleauth (0.5.1)
|
||||||
|
faraday (~> 0.9)
|
||||||
|
jwt (~> 1.4)
|
||||||
|
logging (~> 2.0)
|
||||||
|
memoist (~> 0.12)
|
||||||
|
multi_json (~> 1.11)
|
||||||
|
os (~> 0.9)
|
||||||
|
signet (~> 0.7)
|
||||||
hashr (0.0.22)
|
hashr (0.0.22)
|
||||||
hike (1.2.3)
|
hike (1.2.3)
|
||||||
hitimes (1.2.3)
|
hitimes (1.2.3)
|
||||||
|
@ -198,20 +217,27 @@ GEM
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
multi_xml (>= 0.5.2)
|
multi_xml (>= 0.5.2)
|
||||||
httpclient (2.7.1)
|
httpclient (2.7.1)
|
||||||
|
hurley (0.2)
|
||||||
i18n (0.7.0)
|
i18n (0.7.0)
|
||||||
ice_nine (0.11.2)
|
ice_nine (0.11.2)
|
||||||
jemalloc (1.0.1)
|
jemalloc (1.0.1)
|
||||||
journey (1.0.4)
|
journey (1.0.4)
|
||||||
json (1.8.3)
|
json (1.8.3)
|
||||||
|
jwt (1.5.4)
|
||||||
kgio (2.9.2)
|
kgio (2.9.2)
|
||||||
listen (1.0.3)
|
listen (1.0.3)
|
||||||
rb-fsevent (>= 0.9.3)
|
rb-fsevent (>= 0.9.3)
|
||||||
rb-inotify (>= 0.9)
|
rb-inotify (>= 0.9)
|
||||||
rb-kqueue (>= 0.2)
|
rb-kqueue (>= 0.2)
|
||||||
|
little-plugger (1.1.4)
|
||||||
|
logging (2.1.0)
|
||||||
|
little-plugger (~> 1.1)
|
||||||
|
multi_json (~> 1.10)
|
||||||
mail (2.5.4)
|
mail (2.5.4)
|
||||||
mime-types (~> 1.16)
|
mime-types (~> 1.16)
|
||||||
treetop (~> 1.4.8)
|
treetop (~> 1.4.8)
|
||||||
memcachier (0.0.2)
|
memcachier (0.0.2)
|
||||||
|
memoist (0.14.0)
|
||||||
metaclass (0.0.4)
|
metaclass (0.0.4)
|
||||||
method_source (0.8.2)
|
method_source (0.8.2)
|
||||||
metriks (0.9.9.6)
|
metriks (0.9.9.6)
|
||||||
|
@ -229,6 +255,7 @@ GEM
|
||||||
multipart-post (2.0.0)
|
multipart-post (2.0.0)
|
||||||
net-http-persistent (2.9.4)
|
net-http-persistent (2.9.4)
|
||||||
net-http-pipeline (1.0.1)
|
net-http-pipeline (1.0.1)
|
||||||
|
os (0.9.6)
|
||||||
pg (0.18.2)
|
pg (0.18.2)
|
||||||
polyglot (0.3.5)
|
polyglot (0.3.5)
|
||||||
proxies (0.2.1)
|
proxies (0.2.1)
|
||||||
|
@ -270,8 +297,11 @@ GEM
|
||||||
redis (3.2.2)
|
redis (3.2.2)
|
||||||
redis-namespace (1.5.1)
|
redis-namespace (1.5.1)
|
||||||
redis (~> 3.0, >= 3.0.4)
|
redis (~> 3.0, >= 3.0.4)
|
||||||
|
representable (2.3.0)
|
||||||
|
uber (~> 0.0.7)
|
||||||
rerun (0.8.2)
|
rerun (0.8.2)
|
||||||
listen (~> 1.0.3)
|
listen (~> 1.0.3)
|
||||||
|
retriable (2.1.0)
|
||||||
rollout (1.1.0)
|
rollout (1.1.0)
|
||||||
rspec (2.99.0)
|
rspec (2.99.0)
|
||||||
rspec-core (~> 2.99.0)
|
rspec-core (~> 2.99.0)
|
||||||
|
@ -292,6 +322,11 @@ GEM
|
||||||
json
|
json
|
||||||
redis (>= 3.0.6)
|
redis (>= 3.0.6)
|
||||||
redis-namespace (>= 1.3.1)
|
redis-namespace (>= 1.3.1)
|
||||||
|
signet (0.7.2)
|
||||||
|
addressable (~> 2.3)
|
||||||
|
faraday (~> 0.9)
|
||||||
|
jwt (~> 1.5)
|
||||||
|
multi_json (~> 1.10)
|
||||||
simple_states (1.0.1)
|
simple_states (1.0.1)
|
||||||
activesupport
|
activesupport
|
||||||
hashr (~> 0.0.10)
|
hashr (~> 0.0.10)
|
||||||
|
@ -320,7 +355,7 @@ GEM
|
||||||
rack (~> 1.0)
|
rack (~> 1.0)
|
||||||
tilt (~> 1.1, != 1.3.0)
|
tilt (~> 1.1, != 1.3.0)
|
||||||
stackprof (0.2.7)
|
stackprof (0.2.7)
|
||||||
thor (0.14.6)
|
thor (0.19.1)
|
||||||
thread_safe (0.3.5)
|
thread_safe (0.3.5)
|
||||||
tilt (1.4.1)
|
tilt (1.4.1)
|
||||||
timers (4.0.1)
|
timers (4.0.1)
|
||||||
|
@ -332,6 +367,7 @@ GEM
|
||||||
polyglot
|
polyglot
|
||||||
polyglot (>= 0.3.1)
|
polyglot (>= 0.3.1)
|
||||||
tzinfo (0.3.48)
|
tzinfo (0.3.48)
|
||||||
|
uber (0.0.15)
|
||||||
unicorn (4.8.3)
|
unicorn (4.8.3)
|
||||||
kgio (~> 2.6)
|
kgio (~> 2.6)
|
||||||
rack
|
rack
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
module Travis::API::V3
|
module Travis::API::V3
|
||||||
class Models::Request < Model
|
class Models::Request < Model
|
||||||
|
BRANCH_REF = %r{refs/heads/(.*?)$}
|
||||||
|
|
||||||
belongs_to :commit
|
belongs_to :commit
|
||||||
belongs_to :repository
|
belongs_to :repository
|
||||||
belongs_to :owner, polymorphic: true
|
belongs_to :owner, polymorphic: true
|
||||||
|
@ -7,11 +9,12 @@ module Travis::API::V3
|
||||||
serialize :config
|
serialize :config
|
||||||
serialize :payload
|
serialize :payload
|
||||||
|
|
||||||
has_one :branch,
|
def branch_name
|
||||||
primary_key: [:id, :branch_name]
|
ref =~ BRANCH_REF and $1
|
||||||
|
end
|
||||||
|
|
||||||
def branch
|
def ref
|
||||||
read_attribute(:branch)
|
payload['ref'] if payload
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,6 @@ require 'travis/api/v3/renderer/model_renderer'
|
||||||
module Travis::API::V3
|
module Travis::API::V3
|
||||||
class Renderer::Request < Renderer::ModelRenderer
|
class Renderer::Request < Renderer::ModelRenderer
|
||||||
representation(:minimal, :id)
|
representation(:minimal, :id)
|
||||||
representation(:standard, :id, :repository, :branch, :commit, :owner, :created_at, :result, :message, :event_type)
|
representation(:standard, :id, :repository, :branch_name, :commit, :owner, :created_at, :result, :message, :event_type)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
60
spec/v3/services/requests/find_spec.rb
Normal file
60
spec/v3/services/requests/find_spec.rb
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Travis::API::V3::Services::Requests::Find do
|
||||||
|
let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
|
||||||
|
let(:request) { repo.requests.first }
|
||||||
|
|
||||||
|
describe "fetching requests on a public repository" do
|
||||||
|
before { get("/v3/repo/#{repo.id}/requests") }
|
||||||
|
example { expect(last_response).to be_ok }
|
||||||
|
example { expect(JSON.load(body).to_s).to include(
|
||||||
|
"@type",
|
||||||
|
"requests",
|
||||||
|
"/v3/repo/#{repo.id}/requests",
|
||||||
|
"repository",
|
||||||
|
"commit",
|
||||||
|
"message",
|
||||||
|
"the commit message",
|
||||||
|
"branch_name",
|
||||||
|
"representation",
|
||||||
|
"@pagination",
|
||||||
|
"owner",
|
||||||
|
"created_at",
|
||||||
|
"result",
|
||||||
|
"sha",
|
||||||
|
"svenfuchs/minimal",
|
||||||
|
"event_type",
|
||||||
|
"push")
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "fetching requests on private repository, private API, authenticated as user with access" do
|
||||||
|
let(:token) { Travis::Api::App::AccessToken.create(user: repo.owner, app_id: 1) }
|
||||||
|
let(:headers) {{ 'HTTP_AUTHORIZATION' => "token #{token}" }}
|
||||||
|
before { Travis::API::V3::Models::Permission.create(repository: repo, user: repo.owner, pull: true) }
|
||||||
|
before { repo.update_attribute(:private, true) }
|
||||||
|
before { get("/v3/repo/#{repo.id}/requests", {}, headers) }
|
||||||
|
after { repo.update_attribute(:private, false) }
|
||||||
|
example { expect(last_response).to be_ok }
|
||||||
|
example { expect(JSON.load(body).to_s).to include(
|
||||||
|
"@type",
|
||||||
|
"requests",
|
||||||
|
"/v3/repo/#{repo.id}/requests",
|
||||||
|
"repository",
|
||||||
|
"commit",
|
||||||
|
"message",
|
||||||
|
"the commit message",
|
||||||
|
"branch_name",
|
||||||
|
"representation",
|
||||||
|
"@pagination",
|
||||||
|
"owner",
|
||||||
|
"created_at",
|
||||||
|
"result",
|
||||||
|
"sha",
|
||||||
|
"svenfuchs/minimal",
|
||||||
|
"event_type",
|
||||||
|
"push")
|
||||||
|
}
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user