adapt most specs for new states api, some stuff still failing

This commit is contained in:
Sven Fuchs 2012-12-05 15:24:59 +01:00
parent f29577e225
commit 751e88411b
2 changed files with 24 additions and 24 deletions

View File

@ -49,23 +49,23 @@ describe 'v1 repos' do
it '"unknown" when it only has one build that is not finished' do it '"unknown" when it only has one build that is not finished' do
Build.delete_all Build.delete_all
Factory(:build, repository: repo, state: :created, result: nil) Factory(:build, repository: repo, state: :created, result: nil)
repo.update_attributes!(last_build_result: nil) repo.update_attributes!(last_build_state: nil)
get('/svenfuchs/minimal.png').should deliver_result_image_for('unknown') get('/svenfuchs/minimal.png').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) repo.update_attributes!(last_build_state: 'failed')
get('/svenfuchs/minimal.png').should deliver_result_image_for('failing') get('/svenfuchs/minimal.png').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) repo.update_attributes!(last_build_state: 'passed')
get('/svenfuchs/minimal.png').should deliver_result_image_for('passing') get('/svenfuchs/minimal.png').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: nil, previous_result: 0)
repo.update_attributes!(last_build_result: nil) repo.update_attributes!(last_build_state: 'started')
get('/svenfuchs/minimal.png').should deliver_result_image_for('passing') get('/svenfuchs/minimal.png').should deliver_result_image_for('passing')
end end
end end
@ -80,28 +80,28 @@ describe 'v1 repos' do
it '"unknown" when it only has unfinished builds on the relevant branches' 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: on_foo) Factory(:build, repository: repo, state: :started, commit: on_foo)
Factory(:build, repository: repo, state: :started, result: nil, commit: on_bar) Factory(:build, repository: repo, state: :started, commit: on_bar)
get('/svenfuchs/minimal.png?branch=foo,bar').should deliver_result_image_for('unknown') 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: on_foo) Factory(:build, repository: repo, state: :failed, commit: on_foo)
Factory(:build, repository: repo, state: :finished, result: 1, commit: on_bar) Factory(:build, repository: repo, state: :failed, commit: on_bar)
get('/svenfuchs/minimal.png?branch=foo,bar').should deliver_result_image_for('failing') 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: 1, commit: on_foo) Factory(:build, repository: repo, state: :failed, commit: on_foo)
Factory(:build, repository: repo, state: :finished, result: 0, commit: on_bar) Factory(:build, repository: repo, state: :passed, commit: on_bar)
get('/svenfuchs/minimal.png?branch=foo,bar').should deliver_result_image_for('passing') 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: on_foo) Factory(:build, repository: repo, state: :passed, commit: on_foo)
Factory(:build, repository: repo, state: :finished, result: 0, commit: on_bar) Factory(:build, repository: repo, state: :passed, commit: on_bar)
Factory(:build, repository: repo, state: :started, result: nil, commit: on_bar) Factory(:build, repository: repo, state: :started, commit: on_bar)
repo.update_attributes!(last_build_result: nil) repo.update_attributes!(last_build_state: 'started')
get('/svenfuchs/minimal.png?branch=foo,bar').should deliver_result_image_for('passing') get('/svenfuchs/minimal.png?branch=foo,bar').should deliver_result_image_for('passing')
end end
end end

View File

@ -99,31 +99,31 @@ describe 'Repos' do
it '"unknown" when it only has unfinished builds on the relevant branches' 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: on_foo) Factory(:build, repository: repo, state: :started, commit: on_foo)
Factory(:build, repository: repo, state: :started, result: nil, commit: on_bar) Factory(:build, repository: repo, state: :started, commit: on_bar)
result = get('/repos/svenfuchs/minimal.png?branch=foo,bar', {}, headers) result = get('/repos/svenfuchs/minimal.png?branch=foo,bar', {}, headers)
result.should deliver_result_image_for('unknown') 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
Factory(:build, repository: repo, state: :finished, result: 1, commit: on_foo) Factory(:build, repository: repo, state: :failed, commit: on_foo)
Factory(:build, repository: repo, state: :finished, result: 1, commit: on_bar) Factory(:build, repository: repo, state: :failed, commit: on_bar)
result = get('/repos/svenfuchs/minimal.png?branch=foo,bar', {}, headers) result = get('/repos/svenfuchs/minimal.png?branch=foo,bar', {}, headers)
result.should deliver_result_image_for('failing') 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
Factory(:build, repository: repo, state: :finished, result: 1, commit: on_foo) Factory(:build, repository: repo, state: :failed, commit: on_foo)
Factory(:build, repository: repo, state: :finished, result: 0, commit: on_bar) Factory(:build, repository: repo, state: :passed, commit: on_bar)
result = get('/repos/svenfuchs/minimal.png?branch=foo,bar', {}, headers) result = get('/repos/svenfuchs/minimal.png?branch=foo,bar', {}, headers)
result.should deliver_result_image_for('passing') 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: 0, commit: on_foo) Factory(:build, repository: repo, state: :passed, commit: on_foo)
Factory(:build, repository: repo, state: :finished, result: 0, commit: on_bar) Factory(:build, repository: repo, state: :passed, commit: on_bar)
Factory(:build, repository: repo, state: :started, result: nil, commit: on_bar) Factory(:build, repository: repo, state: :started, commit: on_bar)
repo.update_attributes!(last_build_result: nil) repo.update_attributes!(last_build_state: nil)
result = get('/repos/svenfuchs/minimal.png?branch=foo,bar', {}, headers) result = get('/repos/svenfuchs/minimal.png?branch=foo,bar', {}, headers)
result.should deliver_result_image_for('passing') result.should deliver_result_image_for('passing')
end end