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