add specs for build status image urls that filter by multiple branches
This commit is contained in:
parent
876564ca12
commit
28b3099bd0
|
@ -40,7 +40,7 @@ GIT
|
|||
|
||||
GIT
|
||||
remote: git://github.com/travis-ci/travis-core.git
|
||||
revision: e70720c28f47dad3e3accb3d61e7da9c3e7e0d48
|
||||
revision: 6c02e7a1ddddc73054bd7eb351c53ce8523d7cb1
|
||||
branch: sf-travis-api
|
||||
specs:
|
||||
travis-core (0.0.1)
|
||||
|
|
|
@ -70,34 +70,39 @@ describe 'v1 repos' do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'GET /svenfuchs/minimal.png?branch=dev' do
|
||||
let(:commit) { Factory(:commit, branch: 'dev') }
|
||||
describe 'GET /svenfuchs/minimal.png?branch=foo,bar' do
|
||||
let(:on_foo) { Factory(:commit, branch: 'foo') }
|
||||
let(:on_bar) { Factory(:commit, branch: 'bar') }
|
||||
|
||||
it '"unknown" when the repository does not exist' do
|
||||
get('/svenfuchs/does-not-exist.png?branch=dev').should deliver_result_image_for('unknown')
|
||||
get('/svenfuchs/does-not-exist.png?branch=foo,bar').should deliver_result_image_for('unknown')
|
||||
end
|
||||
|
||||
it '"unknown" when it only has a build that is not finished' do
|
||||
it '"unknown" when it only has unfinished builds on the relevant branches' do
|
||||
Build.delete_all
|
||||
Factory(:build, repository: repo, state: :started, result: nil, commit: commit)
|
||||
get('/svenfuchs/minimal.png?branch=dev').should deliver_result_image_for('unknown')
|
||||
Factory(:build, repository: repo, state: :started, result: nil, commit: on_foo)
|
||||
Factory(:build, repository: repo, state: :started, result: nil, commit: on_bar)
|
||||
get('/svenfuchs/minimal.png?branch=foo,bar').should deliver_result_image_for('unknown')
|
||||
end
|
||||
|
||||
it '"failing" when the last build has failed' do
|
||||
Factory(:build, repository: repo, state: :finished, result: 1, commit: commit)
|
||||
get('/svenfuchs/minimal.png?branch=dev').should deliver_result_image_for('failing')
|
||||
Factory(:build, repository: repo, state: :finished, result: 1, commit: on_foo)
|
||||
Factory(:build, repository: repo, state: :finished, result: 1, commit: on_bar)
|
||||
get('/svenfuchs/minimal.png?branch=foo,bar').should deliver_result_image_for('failing')
|
||||
end
|
||||
|
||||
it '"passing" when the last build has passed' do
|
||||
Factory(:build, repository: repo, state: :finished, result: 0, commit: commit)
|
||||
get('/svenfuchs/minimal.png?branch=dev').should deliver_result_image_for('passing')
|
||||
Factory(:build, repository: repo, state: :finished, result: 1, commit: on_foo)
|
||||
Factory(:build, repository: repo, state: :finished, result: 0, commit: on_bar)
|
||||
get('/svenfuchs/minimal.png?branch=foo,bar').should deliver_result_image_for('passing')
|
||||
end
|
||||
|
||||
it '"passing" when there is a running build but the previous one has passed' do
|
||||
Factory(:build, repository: repo, state: :finished, result: 0, commit: commit)
|
||||
Factory(:build, repository: repo, state: :started, result: nil, commit: commit)
|
||||
Factory(:build, repository: repo, state: :finished, result: 0, commit: on_foo)
|
||||
Factory(:build, repository: repo, state: :finished, result: 0, commit: on_bar)
|
||||
Factory(:build, repository: repo, state: :started, result: nil, commit: on_bar)
|
||||
repo.update_attributes!(last_build_result: nil)
|
||||
get('/svenfuchs/minimal.png?branch=dev').should deliver_result_image_for('passing')
|
||||
get('/svenfuchs/minimal.png?branch=foo,bar').should deliver_result_image_for('passing')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -41,63 +41,44 @@ describe 'Repos' do
|
|||
response.should deliver_xml_for(Repository.by_slug('svenfuchs/minimal').first, version: 'v2')
|
||||
end
|
||||
|
||||
describe 'GET /repos/svenfuchs/minimal.png' do
|
||||
describe 'GET /repos/svenfuchs/minimal.png?branch=foo,bar' do
|
||||
let(:on_foo) { Factory(:commit, branch: 'foo') }
|
||||
let(:on_bar) { Factory(:commit, branch: 'bar') }
|
||||
|
||||
it '"unknown" when the repository does not exist' do
|
||||
get('/svenfuchs/does-not-exist.png').should deliver_result_image_for('unknown')
|
||||
result = get('/repos/svenfuchs/does-not-exist.png?branch=foo,bar', {}, headers)
|
||||
result.should deliver_result_image_for('unknown')
|
||||
end
|
||||
|
||||
it '"unknown" when it only has one build that is not finished' do
|
||||
it '"unknown" when it only has unfinished builds on the relevant branches' do
|
||||
Build.delete_all
|
||||
Factory(:build, repository: repo, state: :created, result: nil)
|
||||
repo.update_attributes!(last_build_result: nil)
|
||||
get('/repos/svenfuchs/minimal.png').should deliver_result_image_for('unknown')
|
||||
Factory(:build, repository: repo, state: :started, result: nil, commit: on_foo)
|
||||
Factory(:build, repository: repo, state: :started, result: nil, commit: on_bar)
|
||||
result = get('/repos/svenfuchs/minimal.png?branch=foo,bar', {}, headers)
|
||||
result.should deliver_result_image_for('unknown')
|
||||
end
|
||||
|
||||
it '"failing" when the last build has failed' do
|
||||
repo.update_attributes!(last_build_result: 1)
|
||||
get('/repos/svenfuchs/minimal.png').should deliver_result_image_for('failing')
|
||||
Factory(:build, repository: repo, state: :finished, result: 1, commit: on_foo)
|
||||
Factory(:build, repository: repo, state: :finished, result: 1, commit: on_bar)
|
||||
result = get('/repos/svenfuchs/minimal.png?branch=foo,bar', {}, headers)
|
||||
result.should deliver_result_image_for('failing')
|
||||
end
|
||||
|
||||
it '"passing" when the last build has passed' do
|
||||
repo.update_attributes!(last_build_result: 0)
|
||||
get('/repos/svenfuchs/minimal.png').should deliver_result_image_for('passing')
|
||||
Factory(:build, repository: repo, state: :finished, result: 1, commit: on_foo)
|
||||
Factory(:build, repository: repo, state: :finished, result: 0, commit: on_bar)
|
||||
result = get('/repos/svenfuchs/minimal.png?branch=foo,bar', {}, headers)
|
||||
result.should deliver_result_image_for('passing')
|
||||
end
|
||||
|
||||
it '"passing" when there is a running build but the previous one has passed' do
|
||||
Factory(:build, repository: repo, state: :finished, result: nil, previous_result: 0)
|
||||
Factory(:build, repository: repo, state: :finished, result: 0, commit: on_foo)
|
||||
Factory(:build, repository: repo, state: :finished, result: 0, commit: on_bar)
|
||||
Factory(:build, repository: repo, state: :started, result: nil, commit: on_bar)
|
||||
repo.update_attributes!(last_build_result: nil)
|
||||
get('/repos/svenfuchs/minimal.png').should deliver_result_image_for('passing')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET /repos/svenfuchs/minimal.png?branch=dev' do
|
||||
let(:commit) { Factory(:commit, branch: 'dev') }
|
||||
|
||||
it '"unknown" when the repository does not exist' do
|
||||
get('/repos/svenfuchs/does-not-exist.png?branch=dev').should deliver_result_image_for('unknown')
|
||||
end
|
||||
|
||||
it '"unknown" when it only has a build that is not finished' do
|
||||
Build.delete_all
|
||||
Factory(:build, repository: repo, state: :started, result: nil, commit: commit)
|
||||
get('/repos/svenfuchs/minimal.png?branch=dev').should deliver_result_image_for('unknown')
|
||||
end
|
||||
|
||||
it '"failing" when the last build has failed' do
|
||||
Factory(:build, repository: repo, state: :finished, result: 1, commit: commit)
|
||||
get('/repos/svenfuchs/minimal.png?branch=dev').should deliver_result_image_for('failing')
|
||||
end
|
||||
|
||||
it '"passing" when the last build has passed' do
|
||||
Factory(:build, repository: repo, state: :finished, result: 0, commit: commit)
|
||||
get('/repos/svenfuchs/minimal.png?branch=dev').should deliver_result_image_for('passing')
|
||||
end
|
||||
|
||||
it '"passing" when there is a running build but the previous one has passed' do
|
||||
Factory(:build, repository: repo, state: :finished, result: 0, commit: commit)
|
||||
Factory(:build, repository: repo, state: :started, result: nil, commit: commit)
|
||||
repo.update_attributes!(last_build_result: nil)
|
||||
get('/repos/svenfuchs/minimal.png?branch=dev').should deliver_result_image_for('passing')
|
||||
result = get('/repos/svenfuchs/minimal.png?branch=foo,bar', {}, headers)
|
||||
result.should deliver_result_image_for('passing')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,8 +10,8 @@ describe 'Users' do
|
|||
params = {user: {id: user.id, locale: 'pl'}}
|
||||
response = put "/users/#{user.id}", params, headers
|
||||
response.should be_successful
|
||||
response.should deliver_json_for(user.reload, version: 'v2')
|
||||
user.locale.should == 'pl'
|
||||
response.should deliver_json_for('result' => true, 'flash' => [{ 'notice' => 'Your profile was successfully updated.' }])
|
||||
user.reload.locale.should == 'pl'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ RSpec::Matchers.define :deliver_json_for do |resource, options = {}|
|
|||
match do |response|
|
||||
if response.status == 200
|
||||
actual = parse(response.body)
|
||||
expected = Travis::Api.data(resource, options)
|
||||
expected = resource.is_a?(Hash) ? resource : Travis::Api.data(resource, options)
|
||||
|
||||
failure_message_for_should do
|
||||
"expected\n\n#{actual}\n\nto equal\n\n#{expected}"
|
||||
|
|
Loading…
Reference in New Issue
Block a user