
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.
18 lines
580 B
Ruby
18 lines
580 B
Ruby
require 'spec_helper'
|
|
|
|
describe 'Hooks' do
|
|
before(:each) do
|
|
user.permissions.create repository: repo, admin: true
|
|
end
|
|
|
|
let(:user) { User.where(login: 'svenfuchs').first }
|
|
let(:repo) { Repository.first }
|
|
let(:token) { Travis::Api::App::AccessToken.create(user: user, app_id: -1) }
|
|
let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.1+json', 'HTTP_AUTHORIZATION' => "token #{token}" } }
|
|
|
|
it 'GET /hooks' do
|
|
response = get '/hooks', {}, headers
|
|
response.should deliver_json_for(user.service_hooks, version: 'v1', type: 'hooks')
|
|
end
|
|
end
|