Merge branch 'master' into cd-coreless-migrations
This commit is contained in:
commit
41ef072a94
|
@ -93,7 +93,7 @@ GIT
|
|||
|
||||
GIT
|
||||
remote: git://github.com/travis-ci/travis-yaml.git
|
||||
revision: 9ebe328e7546c696dd374a8cf773d93276f98e4f
|
||||
revision: 032caed23af8ed1ed55e9204bb91316f3ada2f74
|
||||
specs:
|
||||
travis-yaml (0.2.0)
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ module Travis
|
|||
def data
|
||||
{
|
||||
'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) } : [],
|
||||
'annotations' => options[:include_jobs] ? Annotations.new(annotations(build), @options).data["annotations"] : [],
|
||||
}
|
||||
|
@ -44,11 +44,12 @@ module Travis
|
|||
}
|
||||
end
|
||||
|
||||
def commit_data(commit)
|
||||
def commit_data(commit, repository)
|
||||
{
|
||||
'id' => commit.id,
|
||||
'sha' => commit.commit,
|
||||
'branch' => commit.branch,
|
||||
'branch_is_default' => branch_is_default(commit, repository),
|
||||
'message' => commit.message,
|
||||
'committed_at' => format_date(commit.committed_at),
|
||||
'author_name' => commit.author_name,
|
||||
|
@ -78,6 +79,10 @@ module Travis
|
|||
}
|
||||
end
|
||||
|
||||
def branch_is_default(commit, repository)
|
||||
repository.default_branch == commit.branch
|
||||
end
|
||||
|
||||
def annotations(build)
|
||||
build.matrix.map(&:annotations).flatten
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ module Travis
|
|||
def data
|
||||
{
|
||||
'job' => job_data(job),
|
||||
'commit' => commit_data(job.commit),
|
||||
'commit' => commit_data(job.commit, job.repository),
|
||||
'annotations' => Annotations.new(job.annotations, @options).data["annotations"],
|
||||
}
|
||||
end
|
||||
|
@ -42,11 +42,12 @@ module Travis
|
|||
}
|
||||
end
|
||||
|
||||
def commit_data(commit)
|
||||
def commit_data(commit, repository)
|
||||
{
|
||||
'id' => commit.id,
|
||||
'sha' => commit.commit,
|
||||
'branch' => commit.branch,
|
||||
'branch_is_default' => branch_is_default(commit, repository),
|
||||
'message' => commit.message,
|
||||
'committed_at' => format_date(commit.committed_at),
|
||||
'author_name' => commit.author_name,
|
||||
|
@ -56,6 +57,10 @@ module Travis
|
|||
'compare_url' => commit.compare_url,
|
||||
}
|
||||
end
|
||||
|
||||
def branch_is_default(commit, repository)
|
||||
repository.default_branch == commit.branch
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,6 +35,7 @@ module Travis
|
|||
NotImplemented = ServerError .create('request not (yet) implemented', status: 501)
|
||||
RequestLimitReached = ClientError .create('request limit reached for resource', status: 429)
|
||||
AlreadySyncing = ClientError .create('sync already in progress', status: 409)
|
||||
MethodNotAllowed = ClientError .create('method not allowed', status: 405)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,8 +15,9 @@ module Travis::API::V3
|
|||
return service_index(env) if env['PATH_INFO'.freeze] == ?/.freeze
|
||||
metrics = @metrics_processor.create
|
||||
access_control = AccessControl.new(env)
|
||||
factory, params = routes.factory_for(env['REQUEST_METHOD'.freeze], env['PATH_INFO'.freeze])
|
||||
env_params = params(env)
|
||||
factory, params = routes.factory_for(env['REQUEST_METHOD'.freeze], env['PATH_INFO'.freeze])
|
||||
|
||||
|
||||
raise NotFound unless factory
|
||||
metrics.name_after(factory)
|
||||
|
|
|
@ -29,6 +29,7 @@ describe Travis::Api::V2::Http::Build do
|
|||
'id' => 1,
|
||||
'sha' => '62aae5f70ceee39123ef',
|
||||
'branch' => 'master',
|
||||
'branch_is_default' => true,
|
||||
'message' => 'the commit message',
|
||||
'compare_url' => 'https://github.com/svenfuchs/minimal/compare/master...develop',
|
||||
'committed_at' => json_format_time(Time.now.utc - 1.hour),
|
||||
|
|
|
@ -31,6 +31,7 @@ describe Travis::Api::V2::Http::Job do
|
|||
'sha' => '62aae5f70ceee39123ef',
|
||||
'message' => 'the commit message',
|
||||
'branch' => 'master',
|
||||
'branch_is_default' => true,
|
||||
'message' => 'the commit message',
|
||||
'committed_at' => json_format_time(Time.now.utc - 1.hour),
|
||||
'committer_name' => 'Sven Fuchs',
|
||||
|
|
15
spec/v3/error_handling_spec.rb
Normal file
15
spec/v3/error_handling_spec.rb
Normal 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
|
Loading…
Reference in New Issue
Block a user