travis-api/spec/integration/v1/builds_spec.rb
Piotr Sarnacki c6e3c29a57 Load the data for integration tests upfront
We can do it, because we use :transaction strategy with DatabaseCleaner,
which starts transaction before each test and rollbacks after it. That
way data before each test is consistent.

The big advantage of such approach is that tests are fast now - we need
to only load Scenario data once.

One of the drawbacks, on the other hand, is that we need to always load
this data, even if no integration tests need running.

We can try to be smart about it and check if any integration tests are
loaded.
2013-01-26 00:00:42 +01:00

33 lines
1.2 KiB
Ruby

require 'spec_helper'
describe 'Builds' do
let(:repo) { Repository.by_slug('svenfuchs/minimal').first }
let(:build) { repo.builds.first }
let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.1+json' } }
it 'GET /builds.json?repository_id=1' do
response = get '/builds.json', { repository_id: repo.id }, headers
response.should deliver_json_for(repo.builds.order('id DESC'), version: 'v1')
end
it 'GET /builds/1.json' do
response = get "/builds/#{build.id}.json", {}, headers
response.should deliver_json_for(build, version: 'v1')
end
it 'GET /builds/1?repository_id=1.json' do
response = get "/builds/#{build.id}.json", { repository_id: repo.id }, headers
response.should deliver_json_for(build, version: 'v1')
end
it 'GET /svenfuchs/minimal/builds.json' do
response = get '/svenfuchs/minimal/builds.json', {}, headers
response.should redirect_to('/repositories/svenfuchs/minimal/builds.json')
end
it 'GET /svenfuchs/minimal/builds/1.json' do
response = get "/svenfuchs/minimal/builds/#{build.id}.json", {}, headers
response.should redirect_to("/repositories/svenfuchs/minimal/builds/#{build.id}.json")
end
end