Merge branch 'master' of github.com:travis-ci/travis-api
This commit is contained in:
commit
7f6df5f8b1
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
config/travis.yml
|
config/travis.yml
|
||||||
|
.yardoc
|
||||||
|
|
7
Gemfile
7
Gemfile
|
@ -3,10 +3,11 @@ ruby '1.9.3' rescue nil
|
||||||
source :rubygems
|
source :rubygems
|
||||||
gemspec
|
gemspec
|
||||||
|
|
||||||
gem 'puma'
|
gem 'unicorn'
|
||||||
gem 'travis-support', github: 'travis-ci/travis-support'
|
gem 'travis-support', github: 'travis-ci/travis-support'
|
||||||
gem 'travis-core', github: 'travis-ci/travis-core', branch: 'sf-travis-api'
|
gem 'travis-core', github: 'travis-ci/travis-core'
|
||||||
gem 'hubble', github: 'roidrage/hubble'
|
gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs', require: nil
|
||||||
|
gem "sentry-raven", github: 'getsentry/raven-ruby'
|
||||||
gem 'yard-sinatra', github: 'rkh/yard-sinatra'
|
gem 'yard-sinatra', github: 'rkh/yard-sinatra'
|
||||||
gem 'rack-contrib', github: 'rack/rack-contrib'
|
gem 'rack-contrib', github: 'rack/rack-contrib'
|
||||||
gem 'rack-cache', '~> 1.2'
|
gem 'rack-cache', '~> 1.2'
|
||||||
|
|
71
Gemfile.lock
71
Gemfile.lock
|
@ -4,6 +4,16 @@ GIT
|
||||||
specs:
|
specs:
|
||||||
micro_migrations (0.0.1)
|
micro_migrations (0.0.1)
|
||||||
|
|
||||||
|
GIT
|
||||||
|
remote: git://github.com/getsentry/raven-ruby.git
|
||||||
|
revision: 5d0e0eacbee39744bdf5b775efb3734d5b4361c7
|
||||||
|
specs:
|
||||||
|
sentry-raven (0.3)
|
||||||
|
faraday (~> 0.8.0.rc2)
|
||||||
|
hashie
|
||||||
|
multi_json (~> 1.0)
|
||||||
|
uuidtools
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/rack/rack-contrib.git
|
remote: git://github.com/rack/rack-contrib.git
|
||||||
revision: b7e7c38fd02c3b5da91aa57af78b3f571c6ebcd0
|
revision: b7e7c38fd02c3b5da91aa57af78b3f571c6ebcd0
|
||||||
|
@ -30,18 +40,9 @@ GIT
|
||||||
yard-sinatra (1.0.0)
|
yard-sinatra (1.0.0)
|
||||||
yard (~> 0.7)
|
yard (~> 0.7)
|
||||||
|
|
||||||
GIT
|
|
||||||
remote: git://github.com/roidrage/hubble.git
|
|
||||||
revision: f5e6301ac24eabeebaf8f4485d71cdcf93b2f3f8
|
|
||||||
specs:
|
|
||||||
hubble (0.1.2)
|
|
||||||
faraday
|
|
||||||
json (~> 1.6)
|
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/travis-ci/travis-core.git
|
remote: git://github.com/travis-ci/travis-core.git
|
||||||
revision: a55d84819e2f655c7b56472bc62c5037c94bbfc4
|
revision: 23c0c1b07f34033e598f02bfd03ec99b01198fce
|
||||||
branch: sf-travis-api
|
|
||||||
specs:
|
specs:
|
||||||
travis-core (0.0.1)
|
travis-core (0.0.1)
|
||||||
actionmailer (~> 3.2.3)
|
actionmailer (~> 3.2.3)
|
||||||
|
@ -60,6 +61,14 @@ GIT
|
||||||
simple_states (~> 0.1.1)
|
simple_states (~> 0.1.1)
|
||||||
thor (~> 0.14.6)
|
thor (~> 0.14.6)
|
||||||
|
|
||||||
|
GIT
|
||||||
|
remote: git://github.com/travis-ci/travis-sidekiqs.git
|
||||||
|
revision: 24d6afcc366979de91ee5bf2fbb4b628fc1a3d7a
|
||||||
|
specs:
|
||||||
|
travis-sidekiqs (0.0.1)
|
||||||
|
sentry-raven
|
||||||
|
sidekiq (~> 2.5.0)
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/travis-ci/travis-support.git
|
remote: git://github.com/travis-ci/travis-support.git
|
||||||
revision: f78d9161369f574f12b9c0c0dbfe13b997766bdd
|
revision: f78d9161369f574f12b9c0c0dbfe13b997766bdd
|
||||||
|
@ -114,10 +123,14 @@ GEM
|
||||||
arel (3.0.2)
|
arel (3.0.2)
|
||||||
atomic (1.0.1)
|
atomic (1.0.1)
|
||||||
avl_tree (1.1.3)
|
avl_tree (1.1.3)
|
||||||
backports (2.6.4)
|
backports (2.6.5)
|
||||||
builder (3.0.4)
|
builder (3.0.4)
|
||||||
bunny (0.8.0)
|
bunny (0.8.0)
|
||||||
|
celluloid (0.12.3)
|
||||||
|
facter (>= 1.6.12)
|
||||||
|
timers (>= 1.0.0)
|
||||||
coderay (1.0.8)
|
coderay (1.0.8)
|
||||||
|
connection_pool (0.9.2)
|
||||||
daemons (1.1.9)
|
daemons (1.1.9)
|
||||||
dalli (2.3.0)
|
dalli (2.3.0)
|
||||||
data_migrations (0.0.1)
|
data_migrations (0.0.1)
|
||||||
|
@ -127,18 +140,23 @@ GEM
|
||||||
diff-lcs (1.1.3)
|
diff-lcs (1.1.3)
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
eventmachine (1.0.0)
|
eventmachine (1.0.0)
|
||||||
|
facter (1.6.14)
|
||||||
factory_girl (2.4.2)
|
factory_girl (2.4.2)
|
||||||
activesupport
|
activesupport
|
||||||
faraday (0.8.4)
|
faraday (0.8.4)
|
||||||
multipart-post (~> 1.1)
|
multipart-post (~> 1.1)
|
||||||
foreman (0.60.2)
|
foreman (0.60.2)
|
||||||
thor (>= 0.13.6)
|
thor (>= 0.13.6)
|
||||||
|
hashie (1.2.0)
|
||||||
hashr (0.0.22)
|
hashr (0.0.22)
|
||||||
hike (1.2.1)
|
hike (1.2.1)
|
||||||
hitimes (1.1.1)
|
hitimes (1.1.1)
|
||||||
|
hubble (0.1.2)
|
||||||
|
yajl-ruby (~> 1.1)
|
||||||
i18n (0.6.1)
|
i18n (0.6.1)
|
||||||
journey (1.0.4)
|
journey (1.0.4)
|
||||||
json (1.7.5)
|
json (1.7.5)
|
||||||
|
kgio (2.7.4)
|
||||||
listen (0.5.3)
|
listen (0.5.3)
|
||||||
mail (2.4.4)
|
mail (2.4.4)
|
||||||
i18n (>= 0.4.0)
|
i18n (>= 0.4.0)
|
||||||
|
@ -153,14 +171,14 @@ GEM
|
||||||
mime-types (1.19)
|
mime-types (1.19)
|
||||||
mocha (0.12.7)
|
mocha (0.12.7)
|
||||||
metaclass (~> 0.0.1)
|
metaclass (~> 0.0.1)
|
||||||
multi_json (1.3.6)
|
multi_json (1.3.7)
|
||||||
multipart-post (1.1.5)
|
multipart-post (1.1.5)
|
||||||
net-http-persistent (2.8)
|
net-http-persistent (2.8)
|
||||||
net-http-pipeline (1.0.1)
|
net-http-pipeline (1.0.1)
|
||||||
newrelic_rpm (3.3.5)
|
newrelic_rpm (3.3.5)
|
||||||
pg (0.13.2)
|
pg (0.13.2)
|
||||||
polyglot (0.3.3)
|
polyglot (0.3.3)
|
||||||
postmark (0.9.13)
|
postmark (0.9.15)
|
||||||
json
|
json
|
||||||
rake
|
rake
|
||||||
postmark-rails (0.4.1)
|
postmark-rails (0.4.1)
|
||||||
|
@ -171,8 +189,6 @@ GEM
|
||||||
coderay (~> 1.0.5)
|
coderay (~> 1.0.5)
|
||||||
method_source (~> 0.8)
|
method_source (~> 0.8)
|
||||||
slop (~> 3.3.1)
|
slop (~> 3.3.1)
|
||||||
puma (1.6.3)
|
|
||||||
rack (~> 1.2)
|
|
||||||
pusher (0.9.4)
|
pusher (0.9.4)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
signature (~> 0.1.2)
|
signature (~> 0.1.2)
|
||||||
|
@ -192,11 +208,14 @@ GEM
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
rdoc (~> 3.4)
|
rdoc (~> 3.4)
|
||||||
thor (>= 0.14.6, < 2.0)
|
thor (>= 0.14.6, < 2.0)
|
||||||
|
raindrops (0.10.0)
|
||||||
rake (0.9.2.2)
|
rake (0.9.2.2)
|
||||||
rdoc (3.12)
|
rdoc (3.12)
|
||||||
json (~> 1.4)
|
json (~> 1.4)
|
||||||
redcarpet (2.2.2)
|
redcarpet (2.2.2)
|
||||||
redis (3.0.2)
|
redis (3.0.2)
|
||||||
|
redis-namespace (1.2.1)
|
||||||
|
redis (~> 3.0.0)
|
||||||
rerun (0.7.1)
|
rerun (0.7.1)
|
||||||
listen
|
listen
|
||||||
rollout (1.1.0)
|
rollout (1.1.0)
|
||||||
|
@ -208,6 +227,12 @@ GEM
|
||||||
rspec-expectations (2.11.3)
|
rspec-expectations (2.11.3)
|
||||||
diff-lcs (~> 1.1.3)
|
diff-lcs (~> 1.1.3)
|
||||||
rspec-mocks (2.11.3)
|
rspec-mocks (2.11.3)
|
||||||
|
sidekiq (2.5.2)
|
||||||
|
celluloid (~> 0.12.0)
|
||||||
|
connection_pool (~> 0.9.2)
|
||||||
|
multi_json (~> 1)
|
||||||
|
redis (~> 3)
|
||||||
|
redis-namespace
|
||||||
signature (0.1.4)
|
signature (0.1.4)
|
||||||
simple_states (0.1.1)
|
simple_states (0.1.1)
|
||||||
activesupport
|
activesupport
|
||||||
|
@ -234,10 +259,17 @@ GEM
|
||||||
rack (>= 1.0.0)
|
rack (>= 1.0.0)
|
||||||
thor (0.14.6)
|
thor (0.14.6)
|
||||||
tilt (1.3.3)
|
tilt (1.3.3)
|
||||||
treetop (1.4.11)
|
timers (1.0.1)
|
||||||
|
treetop (1.4.12)
|
||||||
polyglot
|
polyglot
|
||||||
polyglot (>= 0.3.1)
|
polyglot (>= 0.3.1)
|
||||||
tzinfo (0.3.33)
|
tzinfo (0.3.35)
|
||||||
|
unicorn (4.4.0)
|
||||||
|
kgio (~> 2.6)
|
||||||
|
rack
|
||||||
|
raindrops (~> 0.7)
|
||||||
|
uuidtools (2.1.3)
|
||||||
|
yajl-ruby (1.1.0)
|
||||||
yard (0.8.3)
|
yard (0.8.3)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
|
@ -250,17 +282,18 @@ DEPENDENCIES
|
||||||
factory_girl (~> 2.4.0)
|
factory_girl (~> 2.4.0)
|
||||||
foreman
|
foreman
|
||||||
gh!
|
gh!
|
||||||
hubble!
|
|
||||||
micro_migrations!
|
micro_migrations!
|
||||||
mocha (~> 0.12)
|
mocha (~> 0.12)
|
||||||
pry
|
pry
|
||||||
puma
|
|
||||||
rack-cache (~> 1.2)
|
rack-cache (~> 1.2)
|
||||||
rack-contrib!
|
rack-contrib!
|
||||||
rake (~> 0.9.2)
|
rake (~> 0.9.2)
|
||||||
rerun
|
rerun
|
||||||
rspec (~> 2.11)
|
rspec (~> 2.11)
|
||||||
|
sentry-raven!
|
||||||
travis-api!
|
travis-api!
|
||||||
travis-core!
|
travis-core!
|
||||||
|
travis-sidekiqs!
|
||||||
travis-support!
|
travis-support!
|
||||||
|
unicorn
|
||||||
yard-sinatra!
|
yard-sinatra!
|
||||||
|
|
23
config/unicorn.rb
Normal file
23
config/unicorn.rb
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# http://michaelvanrooijen.com/articles/2011/06/01-more-concurrency-on-a-single-heroku-dyno-with-the-new-celadon-cedar-stack/
|
||||||
|
|
||||||
|
worker_processes 3 # amount of unicorn workers to spin up
|
||||||
|
timeout 30 # restarts workers that hang for 15 seconds
|
||||||
|
|
||||||
|
preload_app true
|
||||||
|
|
||||||
|
before_fork do |server, worker|
|
||||||
|
ActiveRecord::Base.connection.disconnect! if defined?(ActiveRecord::Base)
|
||||||
|
end
|
||||||
|
|
||||||
|
after_fork do |server, worker|
|
||||||
|
require 'travis'
|
||||||
|
|
||||||
|
Travis::Amqp.connect
|
||||||
|
|
||||||
|
ActiveRecord::Base.establish_connection if defined?(ActiveRecord::Base)
|
||||||
|
|
||||||
|
if $metriks_reporter
|
||||||
|
$metriks_reporter.stop
|
||||||
|
$metriks_reporter.start
|
||||||
|
end
|
||||||
|
end
|
|
@ -7,8 +7,8 @@ require 'rack/cache'
|
||||||
require 'active_record'
|
require 'active_record'
|
||||||
require 'redis'
|
require 'redis'
|
||||||
require 'gh'
|
require 'gh'
|
||||||
require 'hubble'
|
require 'raven'
|
||||||
require 'hubble/middleware'
|
require 'sidekiq'
|
||||||
|
|
||||||
# Rack class implementing the HTTP API.
|
# Rack class implementing the HTTP API.
|
||||||
# Instances respond to #call.
|
# Instances respond to #call.
|
||||||
|
@ -25,6 +25,7 @@ module Travis::Api
|
||||||
autoload :Helpers, 'travis/api/app/helpers'
|
autoload :Helpers, 'travis/api/app/helpers'
|
||||||
autoload :Middleware, 'travis/api/app/middleware'
|
autoload :Middleware, 'travis/api/app/middleware'
|
||||||
autoload :Responders, 'travis/api/app/responders'
|
autoload :Responders, 'travis/api/app/responders'
|
||||||
|
autoload :Cors, 'travis/api/app/cors'
|
||||||
|
|
||||||
Rack.autoload :SSL, 'rack/ssl'
|
Rack.autoload :SSL, 'rack/ssl'
|
||||||
|
|
||||||
|
@ -52,9 +53,11 @@ module Travis::Api
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@app = Rack::Builder.app do
|
@app = Rack::Builder.app do
|
||||||
use Hubble::Rescuer, env: Travis.env, codename: ENV['CODENAME'] if Endpoint.production? && ENV['HUBBLE_ENDPOINT']
|
use Travis::Api::App::Cors
|
||||||
|
use Raven::Rack if Endpoint.production?
|
||||||
use Rack::Protection::PathTraversal
|
use Rack::Protection::PathTraversal
|
||||||
use Rack::SSL if Endpoint.production?
|
use Rack::SSL if Endpoint.production?
|
||||||
|
use ActiveRecord::ConnectionAdapters::ConnectionManagement
|
||||||
use ActiveRecord::QueryCache
|
use ActiveRecord::QueryCache
|
||||||
|
|
||||||
if memcache_servers = ENV['MEMCACHE_SERVERS']
|
if memcache_servers = ENV['MEMCACHE_SERVERS']
|
||||||
|
@ -67,7 +70,6 @@ module Travis::Api
|
||||||
use Rack::Deflater
|
use Rack::Deflater
|
||||||
use Rack::PostBodyContentTypeParser
|
use Rack::PostBodyContentTypeParser
|
||||||
use Rack::JSONP
|
use Rack::JSONP
|
||||||
use ActiveRecord::ConnectionAdapters::ConnectionManagement
|
|
||||||
|
|
||||||
use Rack::Config do |env|
|
use Rack::Config do |env|
|
||||||
env['travis.global_prefix'] = env['SCRIPT_NAME']
|
env['travis.global_prefix'] = env['SCRIPT_NAME']
|
||||||
|
@ -81,6 +83,12 @@ module Travis::Api
|
||||||
# Rack protocol
|
# Rack protocol
|
||||||
def call(env)
|
def call(env)
|
||||||
app.call(env)
|
app.call(env)
|
||||||
|
rescue
|
||||||
|
if Endpoint.production?
|
||||||
|
[500, {'Content-Type' => 'text/plain'}, ['Travis encountered an error, sorry :(']]
|
||||||
|
else
|
||||||
|
raise
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -96,6 +104,14 @@ module Travis::Api
|
||||||
Travis::Amqp.config = Travis.config.amqp
|
Travis::Amqp.config = Travis.config.amqp
|
||||||
Travis::Database.connect
|
Travis::Database.connect
|
||||||
Travis.services = Travis::Services
|
Travis.services = Travis::Services
|
||||||
|
Travis::Features.start
|
||||||
|
Sidekiq.configure_client do |config|
|
||||||
|
config.redis = Travis.config.redis.merge(size: 1, namespace: Travis.config.sidekiq.namespace)
|
||||||
|
end
|
||||||
|
|
||||||
|
Raven.configure do |config|
|
||||||
|
config.dsn = Travis.config.sentry.dsn
|
||||||
|
end if Travis.config.sentry
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.load_endpoints
|
def self.load_endpoints
|
||||||
|
|
20
lib/travis/api/app/cors.rb
Normal file
20
lib/travis/api/app/cors.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
require 'travis/api/app'
|
||||||
|
|
||||||
|
class Travis::Api::App
|
||||||
|
# Implements Cross-Origin Resource Sharing. Supported by all major browsers.
|
||||||
|
# See http://www.w3.org/TR/cors/
|
||||||
|
#
|
||||||
|
# TODO: Be smarter about origin.
|
||||||
|
class Cors < Base
|
||||||
|
before do
|
||||||
|
headers['Access-Control-Allow-Origin'] = "*"
|
||||||
|
headers['Access-Control-Allow-Credentials'] = "true"
|
||||||
|
headers['Access-Control-Expose-Headers'] = "Content-Type, Cache-Control, Expires, Etag, Last-Modified"
|
||||||
|
end
|
||||||
|
|
||||||
|
options // do
|
||||||
|
headers['Access-Control-Allow-Methods'] = "HEAD, GET, POST, PATCH, PUT, DELETE"
|
||||||
|
headers['Access-Control-Allow-Headers'] = "Content-Type, Authorization, Accept, If-None-Match, If-Modified-Since"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,22 +0,0 @@
|
||||||
require 'travis/api/app'
|
|
||||||
|
|
||||||
class Travis::Api::App
|
|
||||||
class Middleware
|
|
||||||
# Implements Cross-Origin Resource Sharing. Supported by all major browsers.
|
|
||||||
# See http://www.w3.org/TR/cors/
|
|
||||||
#
|
|
||||||
# TODO: Be smarter about origin.
|
|
||||||
class Cors < Middleware
|
|
||||||
before do
|
|
||||||
headers['Access-Control-Allow-Origin'] = "*"
|
|
||||||
headers['Access-Control-Allow-Credentials'] = "true"
|
|
||||||
headers['Access-Control-Expose-Headers'] = "Content-Type, Cache-Control, Expires, Etag, Last-Modified"
|
|
||||||
end
|
|
||||||
|
|
||||||
options // do
|
|
||||||
headers['Access-Control-Allow-Methods'] = "HEAD, GET, POST, PATCH, PUT, DELETE"
|
|
||||||
headers['Access-Control-Allow-Headers'] = "Content-Type, Authorization, Accept, If-None-Match, If-Modified-Since"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -16,7 +16,7 @@ module Travis::Api::App::Responders
|
||||||
def cache_control
|
def cache_control
|
||||||
if final?
|
if final?
|
||||||
mode = endpoint.public? ? :public : :private
|
mode = endpoint.public? ? :public : :private
|
||||||
endpoint.expires(31536000, mode, :must_revalidate) # 1 year
|
endpoint.expires(31536000, mode) # 1 year
|
||||||
else
|
else
|
||||||
# FIXME: Chrome WTF?
|
# FIXME: Chrome WTF?
|
||||||
endpoint.cache_control :no_cache
|
endpoint.cache_control :no_cache
|
||||||
|
|
|
@ -3,6 +3,6 @@ cd "$(dirname "$0")/.."
|
||||||
[ $PORT ] || PORT=3000
|
[ $PORT ] || PORT=3000
|
||||||
[ $RACK_ENV ] || RACK_ENV=development
|
[ $RACK_ENV ] || RACK_ENV=development
|
||||||
|
|
||||||
cmd="ruby -I lib -S bundle exec ruby -I lib -S puma config.ru -p $PORT -e $RACK_ENV --threads 0:16"
|
cmd="ruby -I lib -S bundle exec ruby -I lib -S unicorn config.ru -p $PORT -E $RACK_ENV"
|
||||||
[[ $RACK_ENV == "development" ]] && exec rerun "$cmd -b tcp://127.0.0.1:$PORT"
|
[[ $RACK_ENV == "development" ]] && exec rerun "$cmd -l 127.0.0.1:$PORT"
|
||||||
exec $cmd
|
exec $cmd
|
||||||
|
|
|
@ -37,8 +37,9 @@ describe 'Hooks' do
|
||||||
it 'sets the hook' do
|
it 'sets the hook' do
|
||||||
GH.stubs(:[]).returns([])
|
GH.stubs(:[]).returns([])
|
||||||
GH.expects(:post).with(target, payload).returns(GH.load(PAYLOADS[:github][:hook_active]))
|
GH.expects(:post).with(target, payload).returns(GH.load(PAYLOADS[:github][:hook_active]))
|
||||||
put 'hooks', { hook: { id: hook.id, active: 'true' } }, headers
|
response = put 'hooks', { hook: { id: hook.id, active: 'true' } }, headers
|
||||||
repo.reload.active?.should be_true
|
repo.reload.active?.should be_true
|
||||||
|
response.should be_successful
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Travis::Api::App::Middleware::Cors do
|
describe Travis::Api::App::Cors do
|
||||||
before do
|
before do
|
||||||
mock_app do
|
mock_app do
|
||||||
use Travis::Api::App::Middleware::Cors
|
use Travis::Api::App::Cors
|
||||||
get('/check_cors') { 'ok' }
|
get('/check_cors') { 'ok' }
|
||||||
end
|
end
|
||||||
end
|
end
|
21
spec/unit/responders/service_spec.rb
Normal file
21
spec/unit/responders/service_spec.rb
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Travis::Api::App::Responders::Service do
|
||||||
|
class MyService < Travis::Api::App::Responders::Service
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:endpoint) { stub 'endpoint', public?: true }
|
||||||
|
let(:resource) { stub 'resource', run: {} }
|
||||||
|
let(:options) { {} }
|
||||||
|
let(:service) { MyService.new(endpoint, resource, options) }
|
||||||
|
|
||||||
|
context 'with final resource' do
|
||||||
|
before { resource.expects(:final?).returns(true) }
|
||||||
|
|
||||||
|
it 'caches resource for a year' do
|
||||||
|
endpoint.expects(:expires).with(31536000, :public)
|
||||||
|
service.apply
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user