
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.
25 lines
859 B
Ruby
25 lines
859 B
Ruby
require 'spec_helper'
|
|
|
|
describe Travis::Api::App::Endpoint::Accounts do
|
|
include Travis::Testing::Stubs
|
|
let(:access_token) { Travis::Api::App::AccessToken.create(user: user, app_id: -1) }
|
|
|
|
before do
|
|
User.stubs(:find_by_github_id).returns(user)
|
|
User.stubs(:find).returns(user)
|
|
user.stubs(:repositories).returns(stub(administratable: stub(select: [repository])))
|
|
user.stubs(:attributes).returns(:id => user.id, :login => user.login, :name => user.name)
|
|
end
|
|
|
|
it 'includes accounts' do
|
|
get('/accounts', { access_token: access_token.to_s }, 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json, */*; q=0.01').should be_ok
|
|
parsed_body['accounts'].should == [{
|
|
'id' => user.id,
|
|
'login' => user.login,
|
|
'name' => user.name,
|
|
'type' => 'user',
|
|
'repos_count' => 1
|
|
}]
|
|
end
|
|
end
|