Merge branch 'master' of github.com:travis-ci/travis-api

This commit is contained in:
Tyranja 2016-03-21 15:48:33 +01:00
commit 2de73fd974
25 changed files with 561 additions and 414 deletions

View File

@ -18,4 +18,7 @@ services:
- redis - redis
before_script: before_script:
- 'RAILS_ENV=test bundle exec rake db:create db:migrate --trace' - 'RAILS_ENV=test bundle exec rake db:create --trace'
script:
- bundle exec rspec spec

View File

@ -42,6 +42,7 @@ group :test do
gem 'factory_girl', '~> 2.4.0' gem 'factory_girl', '~> 2.4.0'
gem 'mocha', '~> 0.12' gem 'mocha', '~> 0.12'
gem 'database_cleaner', '~> 0.8.0' gem 'database_cleaner', '~> 0.8.0'
gem 'travis-migrations', github: 'travis-ci/travis-migrations'
end end
group :development do group :development do

View File

@ -28,9 +28,9 @@ GIT
GIT GIT
remote: git://github.com/rtomayko/rack-cache.git remote: git://github.com/rtomayko/rack-cache.git
revision: f96febebed7700337e8c362403b081e45b8e4f13 revision: 2d6618172c39c53dceab2e2946d87496154f3e52
specs: specs:
rack-cache (1.5.1) rack-cache (1.6.1)
rack (>= 0.4) rack (>= 0.4)
GIT GIT
@ -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: 96ee8c449ebe305c5c95633cea13eb88fe978abb revision: f7b3a76b3f39c28bb5cf7b9dc24acec13908a11a
specs: specs:
travis-core (0.0.1) travis-core (0.0.1)
actionmailer (~> 3.2.19) actionmailer (~> 3.2.19)
@ -70,6 +70,12 @@ GIT
travis-config (~> 0.1.0) travis-config (~> 0.1.0)
virtus (~> 1.0.0) virtus (~> 1.0.0)
GIT
remote: git://github.com/travis-ci/travis-migrations.git
revision: fcf6eea3e3122a7cbb857826db835de69974c54d
specs:
travis-migrations (0.0.1)
GIT GIT
remote: git://github.com/travis-ci/travis-sidekiqs.git remote: git://github.com/travis-ci/travis-sidekiqs.git
revision: 21a2fee158e25252dd78f5fa31e81b4f6583be23 revision: 21a2fee158e25252dd78f5fa31e81b4f6583be23
@ -85,7 +91,7 @@ GIT
GIT GIT
remote: git://github.com/travis-ci/travis-yaml.git remote: git://github.com/travis-ci/travis-yaml.git
revision: 9ebe328e7546c696dd374a8cf773d93276f98e4f revision: 032caed23af8ed1ed55e9204bb91316f3ada2f74
specs: specs:
travis-yaml (0.2.0) travis-yaml (0.2.0)
@ -109,12 +115,12 @@ PATH
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actionmailer (3.2.22) actionmailer (3.2.22.2)
actionpack (= 3.2.22) actionpack (= 3.2.22.2)
mail (~> 2.5.4) mail (~> 2.5.4)
actionpack (3.2.22) actionpack (3.2.22.2)
activemodel (= 3.2.22) activemodel (= 3.2.22.2)
activesupport (= 3.2.22) activesupport (= 3.2.22.2)
builder (~> 3.0.0) builder (~> 3.0.0)
erubis (~> 2.7.0) erubis (~> 2.7.0)
journey (~> 1.0.4) journey (~> 1.0.4)
@ -124,15 +130,15 @@ GEM
sprockets (~> 2.2.1) sprockets (~> 2.2.1)
active_model_serializers (0.9.0) active_model_serializers (0.9.0)
activemodel (>= 3.2) activemodel (>= 3.2)
activemodel (3.2.22) activemodel (3.2.22.2)
activesupport (= 3.2.22) activesupport (= 3.2.22.2)
builder (~> 3.0.0) builder (~> 3.0.0)
activerecord (3.2.22) activerecord (3.2.22.2)
activemodel (= 3.2.22) activemodel (= 3.2.22.2)
activesupport (= 3.2.22) activesupport (= 3.2.22.2)
arel (~> 3.0.2) arel (~> 3.0.2)
tzinfo (~> 0.3.29) tzinfo (~> 0.3.29)
activesupport (3.2.22) activesupport (3.2.22.2)
i18n (~> 0.6, >= 0.6.4) i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0) multi_json (~> 1.0)
addressable (2.4.0) addressable (2.4.0)
@ -143,7 +149,7 @@ GEM
descendants_tracker (~> 0.0.4) descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0) ice_nine (~> 0.11.0)
thread_safe (~> 0.3, >= 0.3.1) thread_safe (~> 0.3, >= 0.3.1)
backports (3.6.7) backports (3.6.8)
builder (3.0.4) builder (3.0.4)
bunny (0.8.0) bunny (0.8.0)
celluloid (0.16.0) celluloid (0.16.0)
@ -191,9 +197,9 @@ GEM
httparty (0.11.0) httparty (0.11.0)
multi_json (~> 1.0) multi_json (~> 1.0)
multi_xml (>= 0.5.2) multi_xml (>= 0.5.2)
httpclient (2.7.0.1) httpclient (2.7.1)
i18n (0.7.0) i18n (0.7.0)
ice_nine (0.11.1) 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)
@ -244,9 +250,9 @@ GEM
rack rack
rack-test (0.6.3) rack-test (0.6.3)
rack (>= 1.0) rack (>= 1.0)
railties (3.2.22) railties (3.2.22.2)
actionpack (= 3.2.22) actionpack (= 3.2.22.2)
activesupport (= 3.2.22) activesupport (= 3.2.22.2)
rack-ssl (~> 1.3.2) rack-ssl (~> 1.3.2)
rake (>= 0.8.7) rake (>= 0.8.7)
rdoc (~> 3.4) rdoc (~> 3.4)
@ -325,7 +331,7 @@ GEM
treetop (1.4.15) treetop (1.4.15)
polyglot polyglot
polyglot (>= 0.3.1) polyglot (>= 0.3.1)
tzinfo (0.3.46) tzinfo (0.3.47)
unicorn (4.8.3) unicorn (4.8.3)
kgio (~> 2.6) kgio (~> 2.6)
rack rack
@ -376,8 +382,12 @@ DEPENDENCIES
travis-api! travis-api!
travis-config (~> 0.1.0) travis-config (~> 0.1.0)
travis-core! travis-core!
travis-migrations!
travis-sidekiqs! travis-sidekiqs!
travis-support! travis-support!
travis-yaml! travis-yaml!
unicorn unicorn
yard-sinatra! yard-sinatra!
BUNDLED WITH
1.11.2

View File

@ -17,8 +17,10 @@ This is the app running on https://api.travis-ci.org/
### Database setup ### Database setup
1. `rake db:create db:migrate` NB detail for how `rake` sets up the database can be found in the `Rakefile`. In the `namespace :db` block you will see the database name for development is hardcoded to `travis-development`. If you are using a different configuration you will have to make your own adjustments.
2. for testing 'RAILS_ENV=test bundle exec rake db:create db:migrate --trace'
1. `bundle exec rake db:create`
2. for testing 'RAILS_ENV=test bundle exec rake db:create --trace'
1. Clone `travis-logs` and copy the `logs` database (assume the PostgreSQL user is `postgres`): 1. Clone `travis-logs` and copy the `logs` database (assume the PostgreSQL user is `postgres`):
```sh-session ```sh-session
cd .. cd ..
@ -31,7 +33,7 @@ pg_dump -t logs travis_logs_development | psql -U postgres travis_development
Repeat the database steps for `RAILS_ENV=test`. Repeat the database steps for `RAILS_ENV=test`.
```sh-session ```sh-session
RAILS_ENV=test rake db:create db:structure:load RAILS_ENV=test bundle exec rake db:create
pushd ../travis-logs pushd ../travis-logs
RAILS_ENV=test rvm jruby do bundle exec rake db:migrate RAILS_ENV=test rvm jruby do bundle exec rake db:migrate
psql -c "DROP TABLE IF EXISTS logs CASCADE" -U postgres travis_test psql -c "DROP TABLE IF EXISTS logs CASCADE" -U postgres travis_test

150
Rakefile
View File

@ -1,127 +1,45 @@
require 'bundler/setup' require 'rake'
require 'travis' require 'travis/migrations'
require 'travis/engine'
begin task default: :spec
ENV['SCHEMA'] = File.expand_path('../db/schema.rb', $:.detect { |p| p.include?('travis-core') })
require 'micro_migrations'
rescue LoadError
# we can't load micro migrations on production
end
require 'travis'
begin namespace :db do
require 'rspec/core/rake_task' if ENV["RAILS_ENV"] == 'test'
RSpec::Core::RakeTask.new desc 'Create and migrate the test database'
task default: :spec task :create do
rescue LoadError sh 'createdb travis_test' rescue nil
warn "could not load rspec" sh "psql -q travis_test < #{Gem.loaded_specs['travis-migrations'].full_gem_path}/db/structure.sql"
end
else
desc 'Create and migrate the development database'
task :create do
sh 'createdb travis_development' rescue nil
sh "psql -q travis_development < #{Gem.loaded_specs['travis-migrations'].full_gem_path}/db/structure.sql"
end
end
end end
desc "generate gemspec" desc "generate gemspec"
task 'travis-api.gemspec' do task 'travis-api.gemspec' do
content = File.read 'travis-api.gemspec' content = File.read 'travis-api.gemspec'
fields = { fields = {
authors: `git shortlog -sn`.scan(/[^\d\s].*/), authors: `git shortlog -sn`.scan(/[^\d\s].*/),
email: `git shortlog -sne`.scan(/[^<]+@[^>]+/), email: `git shortlog -sne`.scan(/[^<]+@[^>]+/),
files: `git ls-files`.split("\n").reject { |f| f =~ /^(\.|Gemfile)/ } files: `git ls-files`.split("\n").reject { |f| f =~ /^(\.|Gemfile)/ }
} }
fields.each do |field, values| fields.each do |field, values|
updated = " s.#{field} = [" updated = " s.#{field} = ["
updated << values.map { |v| "\n %p" % v }.join(',') updated << values.map { |v| "\n %p" % v }.join(',')
updated << "\n ]" updated << "\n ]"
content.sub!(/ s\.#{field} = \[\n( .*\n)* \]/, updated) content.sub!(/ s\.#{field} = \[\n( .*\n)* \]/, updated)
end end
File.open('travis-api.gemspec', 'w') { |f| f << content } File.open('travis-api.gemspec', 'w') { |f| f << content }
end end
task default: 'travis-api.gemspec' task default: 'travis-api.gemspec'
tasks_path = File.expand_path('../lib/tasks/*.rake', __FILE__) tasks_path = File.expand_path('../lib/tasks/*.rake', __FILE__)
Dir.glob(tasks_path).each { |r| import r } Dir.glob(tasks_path).each { |r| import r }
module ActiveRecord
class Migration
class << self
attr_accessor :disable_ddl_transaction
end
# Disable DDL transactions for this migration.
def self.disable_ddl_transaction!
@disable_ddl_transaction = true
end
def disable_ddl_transaction # :nodoc:
self.class.disable_ddl_transaction
end
end
class Migrator
def use_transaction?(migration)
!migration.disable_ddl_transaction && Base.connection.supports_ddl_transactions?
end
def ddl_transaction(migration, &block)
if use_transaction?(migration)
Base.transaction { block.call }
else
block.call
end
end
def migrate(&block)
current = migrations.detect { |m| m.version == current_version }
target = migrations.detect { |m| m.version == @target_version }
if target.nil? && @target_version && @target_version > 0
raise UnknownMigrationVersionError.new(@target_version)
end
start = up? ? 0 : (migrations.index(current) || 0)
finish = migrations.index(target) || migrations.size - 1
runnable = migrations[start..finish]
# skip the last migration if we're headed down, but not ALL the way down
runnable.pop if down? && target
ran = []
runnable.each do |migration|
if block && !block.call(migration)
next
end
Base.logger.info "Migrating to #{migration.name} (#{migration.version})" if Base.logger
seen = migrated.include?(migration.version.to_i)
# On our way up, we skip migrating the ones we've already migrated
next if up? && seen
# On our way down, we skip reverting the ones we've never migrated
if down? && !seen
migration.announce 'never migrated, skipping'; migration.write
next
end
begin
ddl_transaction(migration) do
migration.migrate(@direction)
record_version_state_after_migrating(migration.version)
end
ran << migration
rescue => e
canceled_msg = Base.connection.supports_ddl_transactions? ? "this and " : ""
raise StandardError, "An error has occurred, #{canceled_msg}all later migrations canceled:\n\n#{e}", e.backtrace
end
end
ran
end
end
class MigrationProxy
delegate :disable_ddl_transaction, to: :migration
end
end

View File

@ -20,4 +20,3 @@ development:
test: test:
<<: *defaults <<: *defaults
database: travis_test database: travis_test

View File

@ -202,8 +202,10 @@ module Travis::Api
Travis::Database.connect Travis::Database.connect
if Travis.config.logs_database if Travis.config.logs_database
Log.establish_connection 'logs_database' pool_size = ENV['DATABASE_POOL_SIZE']
Log::Part.establish_connection 'logs_database' Travis.config.logs_database[:pool] = pool_size.to_i if pool_size
Travis::LogsModel.establish_connection 'logs_database'
end end
end end

View File

@ -61,7 +61,7 @@ class Rack::Attack
# Ban after: 10 POST requests within 30 seconds # Ban after: 10 POST requests within 30 seconds
blacklist('spamming with POST requests') do |request| blacklist('spamming with POST requests') do |request|
Rack::Attack::Allow2Ban.filter(request.identifier, maxretry: 10, findtime: 30.seconds, bantime: bantime(1.hour)) do Rack::Attack::Allow2Ban.filter(request.identifier, maxretry: 10, findtime: 30.seconds, bantime: bantime(1.hour)) do
request.post? and not POST_WHITELISTED.include? '/auth/github' request.post? and not POST_WHITELISTED.include? request.path
end end
end end

View File

@ -17,7 +17,7 @@ module Travis
def data def data
{ {
'build' => build_data(build), 'build' => build_data(build),
'commit' => commit_data(build.commit), 'commit' => commit_data(build.commit, build.repository),
'jobs' => options[:include_jobs] ? build.matrix.map { |job| job_data(job) } : [], 'jobs' => options[:include_jobs] ? build.matrix.map { |job| job_data(job) } : [],
'annotations' => options[:include_jobs] ? Annotations.new(annotations(build), @options).data["annotations"] : [], 'annotations' => options[:include_jobs] ? Annotations.new(annotations(build), @options).data["annotations"] : [],
} }
@ -44,11 +44,12 @@ module Travis
} }
end end
def commit_data(commit) def commit_data(commit, repository)
{ {
'id' => commit.id, 'id' => commit.id,
'sha' => commit.commit, 'sha' => commit.commit,
'branch' => commit.branch, 'branch' => commit.branch,
'branch_is_default' => branch_is_default(commit, repository),
'message' => commit.message, 'message' => commit.message,
'committed_at' => format_date(commit.committed_at), 'committed_at' => format_date(commit.committed_at),
'author_name' => commit.author_name, 'author_name' => commit.author_name,
@ -78,6 +79,10 @@ module Travis
} }
end end
def branch_is_default(commit, repository)
repository.default_branch == commit.branch
end
def annotations(build) def annotations(build)
build.matrix.map(&:annotations).flatten build.matrix.map(&:annotations).flatten
end end

View File

@ -15,7 +15,7 @@ module Travis
def data def data
{ {
'job' => job_data(job), 'job' => job_data(job),
'commit' => commit_data(job.commit), 'commit' => commit_data(job.commit, job.repository),
'annotations' => Annotations.new(job.annotations, @options).data["annotations"], 'annotations' => Annotations.new(job.annotations, @options).data["annotations"],
} }
end end
@ -42,11 +42,12 @@ module Travis
} }
end end
def commit_data(commit) def commit_data(commit, repository)
{ {
'id' => commit.id, 'id' => commit.id,
'sha' => commit.commit, 'sha' => commit.commit,
'branch' => commit.branch, 'branch' => commit.branch,
'branch_is_default' => branch_is_default(commit, repository),
'message' => commit.message, 'message' => commit.message,
'committed_at' => format_date(commit.committed_at), 'committed_at' => format_date(commit.committed_at),
'author_name' => commit.author_name, 'author_name' => commit.author_name,
@ -56,6 +57,10 @@ module Travis
'compare_url' => commit.compare_url, 'compare_url' => commit.compare_url,
} }
end end
def branch_is_default(commit, repository)
repository.default_branch == commit.branch
end
end end
end end
end end

View File

@ -35,6 +35,7 @@ module Travis
NotImplemented = ServerError .create('request not (yet) implemented', status: 501) NotImplemented = ServerError .create('request not (yet) implemented', status: 501)
RequestLimitReached = ClientError .create('request limit reached for resource', status: 429) RequestLimitReached = ClientError .create('request limit reached for resource', status: 429)
AlreadySyncing = ClientError .create('sync already in progress', status: 409) AlreadySyncing = ClientError .create('sync already in progress', status: 409)
MethodNotAllowed = ClientError .create('method not allowed', status: 405)
end end
end end
end end

View File

@ -9,5 +9,6 @@ module Travis::API::V3
belongs_to :build, autosave: true, foreign_key: 'source_id' belongs_to :build, autosave: true, foreign_key: 'source_id'
belongs_to :owner, polymorphic: true belongs_to :owner, polymorphic: true
serialize :config serialize :config
serialize :debug_options
end end
end end

View File

@ -9,5 +9,9 @@ module Travis::API::V3
def restart? def restart?
write? write?
end end
def debug?
write?
end
end end
end end

View File

@ -1,7 +1,7 @@
module Travis::API::V3 module Travis::API::V3
class Queries::Repositories < Query class Queries::Repositories < Query
params :active, :private, :starred, prefix: :repository params :active, :private, :starred, prefix: :repository
sortable_by :id, :github_id, :owner_name, :name, active: sort_condition(:active) sortable_by :id, :github_id, :owner_name, :name, active: sort_condition(:active), :'default_branch.last_build' => 'builds.started_at'
def for_member(user, **options) def for_member(user, **options)
all(user: user, **options).joins(:users).where(users: user_condition(user), invalidated_at: nil) all(user: user, **options).joins(:users).where(users: user_condition(user), invalidated_at: nil)

View File

@ -15,8 +15,9 @@ module Travis::API::V3
return service_index(env) if env['PATH_INFO'.freeze] == ?/.freeze return service_index(env) if env['PATH_INFO'.freeze] == ?/.freeze
metrics = @metrics_processor.create metrics = @metrics_processor.create
access_control = AccessControl.new(env) access_control = AccessControl.new(env)
factory, params = routes.factory_for(env['REQUEST_METHOD'.freeze], env['PATH_INFO'.freeze])
env_params = params(env) env_params = params(env)
factory, params = routes.factory_for(env['REQUEST_METHOD'.freeze], env['PATH_INFO'.freeze])
raise NotFound unless factory raise NotFound unless factory
metrics.name_after(factory) metrics.name_after(factory)

View File

@ -34,6 +34,7 @@ module Travis::API::V3
post :cancel, '/cancel' post :cancel, '/cancel'
post :restart, '/restart' post :restart, '/restart'
post :debug, '/debug'
end end
resource :organization do resource :organization do

View File

@ -0,0 +1,29 @@
module Travis::API::V3
class Services::Job::Debug < Service
params "quiet"
attr_reader :job
def run
raise LoginRequired unless access_control.logged_in? or access_control.full_access?
raise NotFound unless @job = find(:job)
raise WrongCredentials unless Travis.config.debug_tools_enabled or Travis::Features.active?(:debug_tools, job.repository)
access_control.permissions(job).debug!
job.debug_options = debug_data
job.save!
query.restart(access_control.user)
accepted(job: job, state_change: :created)
end
def debug_data
{
stage: 'before_install',
previous_state: job.state,
created_by: access_control.user.login,
quiet: params["quiet"] || false
}
end
end
end

View File

@ -7,11 +7,13 @@ require 'travis/api/workers/job_cancellation'
require 'travis/api/workers/job_restart' require 'travis/api/workers/job_restart'
require 'travis/support/amqp' require 'travis/support/amqp'
pool_size = ENV['SIDEKIQ_DB_POOL_SIZE'] || 5
Travis.config.database[:pool] = pool_size.to_i
Travis.config.logs_database[:pool] = pool_size.to_i
Travis::Database.connect Travis::Database.connect
if Travis.config.logs_database if Travis.config.logs_database
Log.establish_connection 'logs_database' Travis::LogsModel.establish_connection 'logs_database'
Log::Part.establish_connection 'logs_database'
end end
Travis::Async.enabled = true Travis::Async.enabled = true

View File

@ -29,6 +29,7 @@ describe Travis::Api::V2::Http::Build do
'id' => 1, 'id' => 1,
'sha' => '62aae5f70ceee39123ef', 'sha' => '62aae5f70ceee39123ef',
'branch' => 'master', 'branch' => 'master',
'branch_is_default' => true,
'message' => 'the commit message', 'message' => 'the commit message',
'compare_url' => 'https://github.com/svenfuchs/minimal/compare/master...develop', 'compare_url' => 'https://github.com/svenfuchs/minimal/compare/master...develop',
'committed_at' => json_format_time(Time.now.utc - 1.hour), 'committed_at' => json_format_time(Time.now.utc - 1.hour),

View File

@ -31,6 +31,7 @@ describe Travis::Api::V2::Http::Job do
'sha' => '62aae5f70ceee39123ef', 'sha' => '62aae5f70ceee39123ef',
'message' => 'the commit message', 'message' => 'the commit message',
'branch' => 'master', 'branch' => 'master',
'branch_is_default' => true,
'message' => 'the commit message', 'message' => 'the commit message',
'committed_at' => json_format_time(Time.now.utc - 1.hour), 'committed_at' => json_format_time(Time.now.utc - 1.hour),
'committer_name' => 'Sven Fuchs', 'committer_name' => 'Sven Fuchs',

View File

@ -0,0 +1,15 @@
require 'spec_helper'
describe Travis::API::V3::ServiceIndex do
let(:headers) {{ }}
let(:path) { "/v3/repo/1/enable" }
let(:json) { JSON.load(response.body) }
let(:response) { get(path, {}, headers) }
let(:resources) { json.fetch('resources') }
it "handles wrong HTTP method with 405 status" do
response.status.should == 405
end
end

View File

@ -0,0 +1,70 @@
require 'spec_helper'
describe Travis::API::V3::Services::Job::Debug do
let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
let(:owner_type) { repo.owner_type.constantize }
let(:owner) { owner_type.find(repo.owner_id)}
let(:build) { repo.builds.last }
let(:jobs) { Travis::API::V3::Models::Build.find(build.id).jobs }
let(:job) { jobs.last }
before { repo.requests.each(&:delete) }
before do
Travis::Features.stubs(:owner_active?).returns(true)
@original_sidekiq = Sidekiq::Client
Sidekiq.send(:remove_const, :Client) # to avoid a warning
Sidekiq::Client = []
Travis.config.stubs(:debug_tools_enabled).returns true
end
after do
Sidekiq.send(:remove_const, :Client) # to avoid a warning
Sidekiq::Client = @original_sidekiq
end
describe "#run" do
context "when unauthenticated" do
before { post("/v3/job/#{job.id}/debug") }
example { expect(last_response.status).to be == 403 }
example { expect(JSON.load(body)).to be == {
"@type" => "error",
"error_type" => "login_required",
"error_message" => "login required"
}}
end
context "when authenticated" do
let(:token) { Travis::Api::App::AccessToken.create(user: repo.owner, app_id: 1) }
let(:headers) {{ 'HTTP_AUTHORIZATION' => "token #{token}" }}
context "without sufficient authorization" do
before { post("/v3/job/#{job.id}/debug", {}, headers) }
example { expect(last_response.status).to be == 403 }
example { expect(JSON.load(body)).to include(
"@type" => "error",
"error_type" => "insufficient_access",
"error_message" => "operation requires debug access to job",
"resource_type" => "job",
)}
end
context "with sufficient authorization" do
let(:params) {{}}
before { Travis::API::V3::Models::Permission.create(repository: repo, user: repo.owner, push: true) }
before { post("/v3/job/#{job.id}/debug", {}, headers) }
example { expect(last_response.status).to be == 202 }
example { expect(job.reload.debug_options).to include(
stage: "before_install",
created_by: owner.login,
quiet: false
) }
end
end
end
end

View File

@ -23,7 +23,8 @@ describe Travis::API::V3::Services::Job::Find do
"@permissions" => { "@permissions" => {
"read" => true, "read" => true,
"cancel" => false, "cancel" => false,
"restart" => false }, "restart" => false,
"debug" => false },
"id" => job.id, "id" => job.id,
"number" => job.number, "number" => job.number,
"state" => job.state, "state" => job.state,
@ -93,7 +94,8 @@ describe Travis::API::V3::Services::Job::Find do
"@permissions" => { "@permissions" => {
"read" => true, "read" => true,
"cancel" => false, "cancel" => false,
"restart" => false }, "restart" => false,
"debug" => false },
"id" => job.id, "id" => job.id,
"number" => job.number, "number" => job.number,
"state" => job.state, "state" => job.state,

View File

@ -21,7 +21,8 @@ describe Travis::API::V3::Services::Jobs::Find do
"@permissions" => { "@permissions" => {
"read" => true, "read" => true,
"cancel" => false, "cancel" => false,
"restart" => false }, "restart" => false,
"debug" => false },
"id" => jobs[0].id, "id" => jobs[0].id,
"number" => "#{jobs[0].number}", "number" => "#{jobs[0].number}",
"state" => "configured", "state" => "configured",
@ -30,45 +31,46 @@ describe Travis::API::V3::Services::Jobs::Find do
"build" => { "build" => {
"@type" => "build", "@type" => "build",
"@href" => "/v3/build/#{build.id}", "@href" => "/v3/build/#{build.id}",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => build.id, "id" => build.id,
"number" => build.number, "number" => build.number,
"state" => "configured", "state" => "configured",
"duration" => nil, "duration" => nil,
"event_type" => "push", "event_type" => "push",
"previous_state" => "passed", "previous_state" => "passed",
"started_at" => "2010-11-12T13:00:00Z", "started_at" => "2010-11-12T13:00:00Z",
"finished_at" => nil}, "finished_at" => nil},
"queue" => "builds.linux", "queue" => "builds.linux",
"repository" =>{ "repository" =>{
"@type" => "repository", "@type" => "repository",
"@href" => "/v3/repo/1", "@href" => "/v3/repo/1",
"@representation"=>"minimal", "@representation"=>"minimal",
"id" => repo.id, "id" => repo.id,
"name" => "minimal", "name" => "minimal",
"slug" => "svenfuchs/minimal"}, "slug" => "svenfuchs/minimal"},
"commit" =>{ "commit" =>{
"@type" => "commit", "@type" => "commit",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => commit.id, "id" => commit.id,
"sha" => commit.commit, "sha" => commit.commit,
"ref" => commit.ref, "ref" => commit.ref,
"message" => commit.message, "message" => commit.message,
"compare_url" => commit.compare_url, "compare_url" => commit.compare_url,
"committed_at" =>"2010-11-12T12:55:00Z"}, "committed_at" =>"2010-11-12T12:55:00Z"},
"owner" =>{ "owner" =>{
"@type" => "user", "@type" => "user",
"@href" => "/v3/user/1", "@href" => "/v3/user/1",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => 1, "id" => 1,
"login" => "svenfuchs"}}, "login" => "svenfuchs"}},
{"@type" => "job", {"@type" => "job",
"@href" => "/v3/job/#{jobs[1].id}", "@href" => "/v3/job/#{jobs[1].id}",
"@representation" => "standard", "@representation" => "standard",
"@permissions" => { "@permissions" => {
"read" => true, "read" => true,
"cancel" => false, "cancel" => false,
"restart" => false }, "restart" => false,
"debug" => false },
"id" => jobs[1].id, "id" => jobs[1].id,
"number" => "#{jobs[1].number}", "number" => "#{jobs[1].number}",
"state" => "configured", "state" => "configured",
@ -77,45 +79,46 @@ describe Travis::API::V3::Services::Jobs::Find do
"build" => { "build" => {
"@type" => "build", "@type" => "build",
"@href" => "/v3/build/#{build.id}", "@href" => "/v3/build/#{build.id}",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => build.id, "id" => build.id,
"number" => build.number, "number" => build.number,
"state" => "configured", "state" => "configured",
"duration" => nil, "duration" => nil,
"event_type" => "push", "event_type" => "push",
"previous_state" => "passed", "previous_state" => "passed",
"started_at" => "2010-11-12T13:00:00Z", "started_at" => "2010-11-12T13:00:00Z",
"finished_at" => nil}, "finished_at" => nil},
"queue" => "builds.linux", "queue" => "builds.linux",
"repository" =>{ "repository" =>{
"@type" => "repository", "@type" => "repository",
"@href" => "/v3/repo/1", "@href" => "/v3/repo/1",
"@representation"=>"minimal", "@representation"=>"minimal",
"id" => repo.id, "id" => repo.id,
"name" => "minimal", "name" => "minimal",
"slug" => "svenfuchs/minimal"}, "slug" => "svenfuchs/minimal"},
"commit" =>{ "commit" =>{
"@type" => "commit", "@type" => "commit",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => commit.id, "id" => commit.id,
"sha" => commit.commit, "sha" => commit.commit,
"ref" => commit.ref, "ref" => commit.ref,
"message" => commit.message, "message" => commit.message,
"compare_url" => commit.compare_url, "compare_url" => commit.compare_url,
"committed_at" =>"2010-11-12T12:55:00Z"}, "committed_at" =>"2010-11-12T12:55:00Z"},
"owner" =>{ "owner" =>{
"@type" => "user", "@type" => "user",
"@href" => "/v3/user/1", "@href" => "/v3/user/1",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => 1, "id" => 1,
"login" => "svenfuchs"}}, "login" => "svenfuchs"}},
{"@type" => "job", {"@type" => "job",
"@href" => "/v3/job/#{jobs[2].id}", "@href" => "/v3/job/#{jobs[2].id}",
"@representation" => "standard", "@representation" => "standard",
"@permissions" => { "@permissions" => {
"read" => true, "read" => true,
"cancel" => false, "cancel" => false,
"restart" => false }, "restart" => false,
"debug" => false },
"id" => jobs[2].id, "id" => jobs[2].id,
"number" => "#{jobs[2].number}", "number" => "#{jobs[2].number}",
"state" => "configured", "state" => "configured",
@ -124,45 +127,46 @@ describe Travis::API::V3::Services::Jobs::Find do
"build" => { "build" => {
"@type" => "build", "@type" => "build",
"@href" => "/v3/build/#{build.id}", "@href" => "/v3/build/#{build.id}",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => build.id, "id" => build.id,
"number" => build.number, "number" => build.number,
"state" => "configured", "state" => "configured",
"duration" => nil, "duration" => nil,
"event_type" => "push", "event_type" => "push",
"previous_state" => "passed", "previous_state" => "passed",
"started_at" => "2010-11-12T13:00:00Z", "started_at" => "2010-11-12T13:00:00Z",
"finished_at" => nil}, "finished_at" => nil},
"queue" => "builds.linux", "queue" => "builds.linux",
"repository" =>{ "repository" =>{
"@type" => "repository", "@type" => "repository",
"@href" => "/v3/repo/1", "@href" => "/v3/repo/1",
"@representation"=>"minimal", "@representation"=>"minimal",
"id" => repo.id, "id" => repo.id,
"name" => "minimal", "name" => "minimal",
"slug" => "svenfuchs/minimal"}, "slug" => "svenfuchs/minimal"},
"commit" =>{ "commit" =>{
"@type" => "commit", "@type" => "commit",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => commit.id, "id" => commit.id,
"sha" => commit.commit, "sha" => commit.commit,
"ref" => commit.ref, "ref" => commit.ref,
"message" => commit.message, "message" => commit.message,
"compare_url" => commit.compare_url, "compare_url" => commit.compare_url,
"committed_at" =>"2010-11-12T12:55:00Z"}, "committed_at" =>"2010-11-12T12:55:00Z"},
"owner" =>{ "owner" =>{
"@type" => "user", "@type" => "user",
"@href" => "/v3/user/1", "@href" => "/v3/user/1",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => 1, "id" => 1,
"login" => "svenfuchs"}}, "login" => "svenfuchs"}},
{"@type" => "job", {"@type" => "job",
"@href" => "/v3/job/#{jobs[3].id}", "@href" => "/v3/job/#{jobs[3].id}",
"@representation" => "standard", "@representation" => "standard",
"@permissions" => { "@permissions" => {
"read" => true, "read" => true,
"cancel" => false, "cancel" => false,
"restart" => false }, "restart" => false,
"debug" => false },
"id" => jobs[3].id, "id" => jobs[3].id,
"number" => "#{jobs[3].number}", "number" => "#{jobs[3].number}",
"state" => "configured", "state" => "configured",
@ -171,38 +175,38 @@ describe Travis::API::V3::Services::Jobs::Find do
"build" => { "build" => {
"@type" => "build", "@type" => "build",
"@href" => "/v3/build/#{build.id}", "@href" => "/v3/build/#{build.id}",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => build.id, "id" => build.id,
"number" => build.number, "number" => build.number,
"state" => "configured", "state" => "configured",
"duration" => nil, "duration" => nil,
"event_type" => "push", "event_type" => "push",
"previous_state" => "passed", "previous_state" => "passed",
"started_at" => "2010-11-12T13:00:00Z", "started_at" => "2010-11-12T13:00:00Z",
"finished_at" => nil}, "finished_at" => nil},
"queue" => "builds.linux", "queue" => "builds.linux",
"repository" =>{ "repository" =>{
"@type" => "repository", "@type" => "repository",
"@href" => "/v3/repo/1", "@href" => "/v3/repo/1",
"@representation"=>"minimal", "@representation"=>"minimal",
"id" => repo.id, "id" => repo.id,
"name" => "minimal", "name" => "minimal",
"slug" => "svenfuchs/minimal"}, "slug" => "svenfuchs/minimal"},
"commit" =>{ "commit" =>{
"@type" => "commit", "@type" => "commit",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => commit.id, "id" => commit.id,
"sha" => commit.commit, "sha" => commit.commit,
"ref" => commit.ref, "ref" => commit.ref,
"message" => commit.message, "message" => commit.message,
"compare_url" => commit.compare_url, "compare_url" => commit.compare_url,
"committed_at" =>"2010-11-12T12:55:00Z"}, "committed_at" =>"2010-11-12T12:55:00Z"},
"owner" =>{ "owner" =>{
"@type" => "user", "@type" => "user",
"@href" => "/v3/user/1", "@href" => "/v3/user/1",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => 1, "id" => 1,
"login" => "svenfuchs"}} "login" => "svenfuchs"}}
] ]
} }
} }
@ -227,7 +231,8 @@ describe Travis::API::V3::Services::Jobs::Find do
"@permissions" => { "@permissions" => {
"read" => true, "read" => true,
"cancel" => false, "cancel" => false,
"restart" => false }, "restart" => false,
"debug" => false },
"id" => jobs[0].id, "id" => jobs[0].id,
"number" => "#{jobs[0].number}", "number" => "#{jobs[0].number}",
"state" => "configured", "state" => "configured",
@ -236,45 +241,46 @@ describe Travis::API::V3::Services::Jobs::Find do
"build" => { "build" => {
"@type" => "build", "@type" => "build",
"@href" => "/v3/build/#{build.id}", "@href" => "/v3/build/#{build.id}",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => build.id, "id" => build.id,
"number" => build.number, "number" => build.number,
"state" => "configured", "state" => "configured",
"duration" => nil, "duration" => nil,
"event_type" => "push", "event_type" => "push",
"previous_state" => "passed", "previous_state" => "passed",
"started_at" => "2010-11-12T13:00:00Z", "started_at" => "2010-11-12T13:00:00Z",
"finished_at" => nil}, "finished_at" => nil},
"queue" => "builds.linux", "queue" => "builds.linux",
"repository" =>{ "repository" =>{
"@type" => "repository", "@type" => "repository",
"@href" => "/v3/repo/1", "@href" => "/v3/repo/1",
"@representation"=>"minimal", "@representation"=>"minimal",
"id" => repo.id, "id" => repo.id,
"name" => "minimal", "name" => "minimal",
"slug" => "svenfuchs/minimal"}, "slug" => "svenfuchs/minimal"},
"commit" =>{ "commit" =>{
"@type" => "commit", "@type" => "commit",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => commit.id, "id" => commit.id,
"sha" => commit.commit, "sha" => commit.commit,
"ref" => commit.ref, "ref" => commit.ref,
"message" => commit.message, "message" => commit.message,
"compare_url" => commit.compare_url, "compare_url" => commit.compare_url,
"committed_at" =>"2010-11-12T12:55:00Z"}, "committed_at" =>"2010-11-12T12:55:00Z"},
"owner" =>{ "owner" =>{
"@type" => "user", "@type" => "user",
"@href" => "/v3/user/1", "@href" => "/v3/user/1",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => 1, "id" => 1,
"login" => "svenfuchs"}}, "login" => "svenfuchs"}},
{"@type" => "job", {"@type" => "job",
"@href" => "/v3/job/#{jobs[1].id}", "@href" => "/v3/job/#{jobs[1].id}",
"@representation" => "standard", "@representation" => "standard",
"@permissions" => { "@permissions" => {
"read" => true, "read" => true,
"cancel" => false, "cancel" => false,
"restart" => false }, "restart" => false,
"debug" => false },
"id" => jobs[1].id, "id" => jobs[1].id,
"number" => "#{jobs[1].number}", "number" => "#{jobs[1].number}",
"state" => "configured", "state" => "configured",
@ -283,45 +289,46 @@ describe Travis::API::V3::Services::Jobs::Find do
"build" => { "build" => {
"@type" => "build", "@type" => "build",
"@href" => "/v3/build/#{build.id}", "@href" => "/v3/build/#{build.id}",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => build.id, "id" => build.id,
"number" => build.number, "number" => build.number,
"state" => "configured", "state" => "configured",
"duration" => nil, "duration" => nil,
"event_type" => "push", "event_type" => "push",
"previous_state" => "passed", "previous_state" => "passed",
"started_at" => "2010-11-12T13:00:00Z", "started_at" => "2010-11-12T13:00:00Z",
"finished_at" => nil}, "finished_at" => nil},
"queue" => "builds.linux", "queue" => "builds.linux",
"repository" =>{ "repository" =>{
"@type" => "repository", "@type" => "repository",
"@href" => "/v3/repo/1", "@href" => "/v3/repo/1",
"@representation"=>"minimal", "@representation"=>"minimal",
"id" => repo.id, "id" => repo.id,
"name" => "minimal", "name" => "minimal",
"slug" => "svenfuchs/minimal"}, "slug" => "svenfuchs/minimal"},
"commit" =>{ "commit" =>{
"@type" => "commit", "@type" => "commit",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => commit.id, "id" => commit.id,
"sha" => commit.commit, "sha" => commit.commit,
"ref" => commit.ref, "ref" => commit.ref,
"message" => commit.message, "message" => commit.message,
"compare_url" => commit.compare_url, "compare_url" => commit.compare_url,
"committed_at" =>"2010-11-12T12:55:00Z"}, "committed_at" =>"2010-11-12T12:55:00Z"},
"owner" =>{ "owner" =>{
"@type" => "user", "@type" => "user",
"@href" => "/v3/user/1", "@href" => "/v3/user/1",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => 1, "id" => 1,
"login" => "svenfuchs"}}, "login" => "svenfuchs"}},
{"@type" => "job", {"@type" => "job",
"@href" => "/v3/job/#{jobs[2].id}", "@href" => "/v3/job/#{jobs[2].id}",
"@representation" => "standard", "@representation" => "standard",
"@permissions" => { "@permissions" => {
"read" => true, "read" => true,
"cancel" => false, "cancel" => false,
"restart" => false }, "restart" => false,
"debug" => false },
"id" => jobs[2].id, "id" => jobs[2].id,
"number" => "#{jobs[2].number}", "number" => "#{jobs[2].number}",
"state" => "configured", "state" => "configured",
@ -330,45 +337,46 @@ describe Travis::API::V3::Services::Jobs::Find do
"build" => { "build" => {
"@type" => "build", "@type" => "build",
"@href" => "/v3/build/#{build.id}", "@href" => "/v3/build/#{build.id}",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => build.id, "id" => build.id,
"number" => build.number, "number" => build.number,
"state" => "configured", "state" => "configured",
"duration" => nil, "duration" => nil,
"event_type" => "push", "event_type" => "push",
"previous_state" => "passed", "previous_state" => "passed",
"started_at" => "2010-11-12T13:00:00Z", "started_at" => "2010-11-12T13:00:00Z",
"finished_at" => nil}, "finished_at" => nil},
"queue" => "builds.linux", "queue" => "builds.linux",
"repository" =>{ "repository" =>{
"@type" => "repository", "@type" => "repository",
"@href" => "/v3/repo/1", "@href" => "/v3/repo/1",
"@representation"=>"minimal", "@representation"=>"minimal",
"id" => repo.id, "id" => repo.id,
"name" => "minimal", "name" => "minimal",
"slug" => "svenfuchs/minimal"}, "slug" => "svenfuchs/minimal"},
"commit" =>{ "commit" =>{
"@type" => "commit", "@type" => "commit",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => commit.id, "id" => commit.id,
"sha" => commit.commit, "sha" => commit.commit,
"ref" => commit.ref, "ref" => commit.ref,
"message" => commit.message, "message" => commit.message,
"compare_url" => commit.compare_url, "compare_url" => commit.compare_url,
"committed_at" =>"2010-11-12T12:55:00Z"}, "committed_at" =>"2010-11-12T12:55:00Z"},
"owner" =>{ "owner" =>{
"@type" => "user", "@type" => "user",
"@href" => "/v3/user/1", "@href" => "/v3/user/1",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => 1, "id" => 1,
"login" => "svenfuchs"}}, "login" => "svenfuchs"}},
{"@type" => "job", {"@type" => "job",
"@href" => "/v3/job/#{jobs[3].id}", "@href" => "/v3/job/#{jobs[3].id}",
"@representation" => "standard", "@representation" => "standard",
"@permissions" => { "@permissions" => {
"read" => true, "read" => true,
"cancel" => false, "cancel" => false,
"restart" => false }, "restart" => false,
"debug" => false },
"id" => jobs[3].id, "id" => jobs[3].id,
"number" => "#{jobs[3].number}", "number" => "#{jobs[3].number}",
"state" => "configured", "state" => "configured",
@ -377,38 +385,38 @@ describe Travis::API::V3::Services::Jobs::Find do
"build" => { "build" => {
"@type" => "build", "@type" => "build",
"@href" => "/v3/build/#{build.id}", "@href" => "/v3/build/#{build.id}",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => build.id, "id" => build.id,
"number" => build.number, "number" => build.number,
"state" => "configured", "state" => "configured",
"duration" => nil, "duration" => nil,
"event_type" => "push", "event_type" => "push",
"previous_state" => "passed", "previous_state" => "passed",
"started_at" => "2010-11-12T13:00:00Z", "started_at" => "2010-11-12T13:00:00Z",
"finished_at" => nil}, "finished_at" => nil},
"queue" => "builds.linux", "queue" => "builds.linux",
"repository" =>{ "repository" =>{
"@type" => "repository", "@type" => "repository",
"@href" => "/v3/repo/1", "@href" => "/v3/repo/1",
"@representation"=>"minimal", "@representation"=>"minimal",
"id" => repo.id, "id" => repo.id,
"name" => "minimal", "name" => "minimal",
"slug" => "svenfuchs/minimal"}, "slug" => "svenfuchs/minimal"},
"commit" =>{ "commit" =>{
"@type" => "commit", "@type" => "commit",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => commit.id, "id" => commit.id,
"sha" => commit.commit, "sha" => commit.commit,
"ref" => commit.ref, "ref" => commit.ref,
"message" => commit.message, "message" => commit.message,
"compare_url" => commit.compare_url, "compare_url" => commit.compare_url,
"committed_at" =>"2010-11-12T12:55:00Z"}, "committed_at" =>"2010-11-12T12:55:00Z"},
"owner" =>{ "owner" =>{
"@type" => "user", "@type" => "user",
"@href" => "/v3/user/1", "@href" => "/v3/user/1",
"@representation"=> "minimal", "@representation"=> "minimal",
"id" => 1, "id" => 1,
"login" => "svenfuchs"}} "login" => "svenfuchs"}}
] ]
} }
} }

View File

@ -11,6 +11,7 @@ describe Travis::API::V3::Services::Repositories::ForOwner do
before { repo.update_attribute(:private, true) } before { repo.update_attribute(:private, true) }
after { repo.update_attribute(:private, false) } after { repo.update_attribute(:private, false) }
describe "private repository, private API, authenticated as user with access" do describe "private repository, private API, authenticated as user with access" do
before { get("/v3/owner/svenfuchs/repos", {}, headers) } before { get("/v3/owner/svenfuchs/repos", {}, headers) }
example { expect(last_response).to be_ok } example { expect(last_response).to be_ok }
@ -103,4 +104,69 @@ describe Travis::API::V3::Services::Repositories::ForOwner do
example { expect(JSON.load(body)['@href']) .to be == "/v3/repos?starred=false" } example { expect(JSON.load(body)['@href']) .to be == "/v3/repos?starred=false" }
example { expect(JSON.load(body)['repositories']) .to be_empty } example { expect(JSON.load(body)['repositories']) .to be_empty }
end end
describe "sorting by default_branch.last_build" do
let(:repo2) { Travis::API::V3::Models::Repository.create(owner_name: 'svenfuchs', name: 'maximal', owner_id: 1, owner_type: "User", last_build_state: "passed", active: true, last_build_id: 1788, next_build_number: 3) }
before { repo2.save! }
before { get("/v3/owner/svenfuchs/repos?sort_by=default_branch.last_build", {}, headers) }
example { expect(last_response).to be_ok }
example { expect(JSON.load(body)['@href']) .to be == "/v3/owner/svenfuchs/repos?sort_by=default_branch.last_build" }
example { expect(JSON.load(body)['repositories']) .to be == [{
"@type" => "repository",
"@href" => "/v3/repo/1",
"@representation" => "standard",
"@permissions" => {
"read" => true,
"enable" => false,
"disable" => false,
"star" => false,
"unstar" => false,
"create_request"=> false },
"id" => 1,
"name" => "minimal",
"slug" => "svenfuchs/minimal",
"description" => nil,
"github_language" => nil,
"active" => true,
"private" => true,
"owner" => {
"@type" => "user",
"id" => 1,
"login" => "svenfuchs",
"@href" => "/v3/user/1" },
"default_branch" => {
"@type" => "branch",
"@href" => "/v3/repo/1/branch/master",
"@representation"=>"minimal",
"name" => "master" },
"starred" => false }, {
"@type" => "repository",
"@href" => "/v3/repo/#{repo2.id}",
"@representation" => "standard",
"@permissions" => {
"read" => true,
"enable" => false,
"disable" => false,
"star" => false,
"unstar" => false,
"create_request"=> false },
"id" => repo2.id,
"name" => "maximal",
"slug" => "svenfuchs/maximal",
"description" => nil,
"github_language" => nil,
"active" => true,
"private" => false,
"owner" => {
"@type" => "user",
"id" => 1,
"login" => "svenfuchs",
"@href" => "/v3/user/1" },
"default_branch" => {
"@type" => "branch",
"@href" => "/v3/repo/#{repo2.id}/branch/master",
"@representation"=>"minimal",
"name" =>"master" },
"starred"=>false}]}
end
end end