Project

General

Profile

« Previous | Next » 

Revision 26dade0f

Added by Daniel Lobato Garcia about 8 years ago

Fixes #14097 - Only run DatabaseCleaner truncation on JS tests

Problem:
DatabaseCleaner runs after all integration tests, on truncation mode.
However, for tests where we use rack-test instead of poltergeist, this
is not necessary and slows down the test suite.

Solution:
Mark the tests that use javascript and only run DatabaseCleaner on
truncation mode on these, the rest of them can run in transaction mode
(faster).

Some basic benchmarking of rake test:integration suggests this is 15% faster
than before this patch (before, 3m 42s avg, now 3m 09s avg).

Additionally this patch allows login to happen only once for integration
tests that require JS (it logged in twice before), and loads fewer
dependencies for integration tests when ran on isolation (rake test:integration)

View differences:

test/integration/audit_test.rb
require 'test_helper'
require 'integration_test_helper'
class AuditIntegrationTest < ActionDispatch::IntegrationTest
test "index page" do
......
visit audits_path
assert has_content?("updated Host"), "expected 'updated Host' but it doesn't exist"
end
test "show audit with diff" do
Capybara.current_driver = Capybara.javascript_driver
login_admin
audit = FactoryGirl.create(:audit, :with_diff)
visit audit_path(audit)
assert has_content?('-old')
assert has_content?('+new')
end
end

Also available in: Unified diff