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.
This commit is contained in:
parent
85e8f27047
commit
c6e3c29a57
|
@ -1,8 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'Branches' do
|
||||
before { Scenario.default }
|
||||
|
||||
let(:repo) { Repository.by_slug('svenfuchs/minimal').first }
|
||||
let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.1+json' } }
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'Builds' do
|
||||
before { Scenario.default }
|
||||
|
||||
let(:repo) { Repository.by_slug('svenfuchs/minimal').first }
|
||||
let(:build) { repo.builds.first }
|
||||
let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.1+json' } }
|
||||
|
|
|
@ -2,7 +2,6 @@ require 'spec_helper'
|
|||
|
||||
describe 'Hooks' do
|
||||
before(:each) do
|
||||
Scenario.default
|
||||
user.permissions.create repository: repo, admin: true
|
||||
end
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'v1 repos' do
|
||||
before(:each) { Scenario.default }
|
||||
|
||||
let(:repo) { Repository.by_slug('svenfuchs/minimal').first }
|
||||
let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.1+json' } }
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'Branches' do
|
||||
before { Scenario.default }
|
||||
|
||||
let(:repo) { Repository.by_slug('svenfuchs/minimal').first }
|
||||
let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' } }
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'Builds' do
|
||||
before { Scenario.default }
|
||||
|
||||
let(:repo) { Repository.by_slug('svenfuchs/minimal').first }
|
||||
let(:build) { repo.builds.first }
|
||||
let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' } }
|
||||
|
|
|
@ -3,7 +3,6 @@ require 'travis/testing/payloads'
|
|||
|
||||
describe 'Hooks' do
|
||||
before(:each) do
|
||||
Scenario.default
|
||||
user.permissions.create repository: repo, admin: true
|
||||
end
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'Repos' do
|
||||
before(:each) { Scenario.default }
|
||||
|
||||
let(:repo) { Repository.by_slug('svenfuchs/minimal').first }
|
||||
let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' } }
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'Users' do
|
||||
let(:user) { Factory(:user, locale: 'en') }
|
||||
let(:user) { User.first }
|
||||
let(:token) { Travis::Api::App::AccessToken.create(user: user, app_id: -1) }
|
||||
let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json', 'HTTP_AUTHORIZATION' => "token #{token}" } }
|
||||
|
||||
|
|
|
@ -41,7 +41,8 @@ RSpec.configure do |c|
|
|||
|
||||
c.before :suite do
|
||||
DatabaseCleaner.strategy = :transaction
|
||||
DatabaseCleaner.clean_with :transaction
|
||||
DatabaseCleaner.clean_with :truncation
|
||||
Scenario.default
|
||||
end
|
||||
|
||||
c.before :each do
|
||||
|
|
|
@ -18,7 +18,7 @@ describe Travis::Api::App::Endpoint::Accounts do
|
|||
'login' => user.login,
|
||||
'name' => user.name,
|
||||
'type' => 'user',
|
||||
'repos_count' => nil
|
||||
'repos_count' => 1
|
||||
}]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user