Re-add puma for single-process testing

This commit is contained in:
Oliver Günther
2018-11-19 21:31:44 +01:00
parent 93c2d17dc0
commit 9772f9e883
7 changed files with 39 additions and 55 deletions
+2 -1
View File
@@ -217,7 +217,7 @@ group :test do
# brings back testing for 'assigns' and 'assert_template' extracted in rails 5
gem 'rails-controller-testing', '~> 1.0.2'
gem 'capybara', '~> 3.0.0'
gem 'capybara', '~> 3.11.1'
gem 'capybara-screenshot', '~> 1.0.17'
gem 'capybara-select2', git: 'https://github.com/goodwill/capybara-select2', ref: '585192e'
gem 'chromedriver-helper', '~> 1.2.0'
@@ -251,6 +251,7 @@ end
group :development, :test do
gem 'thin', '~> 1.7.2'
gem 'ruby-prof', require: false
gem 'puma', '~> 3.11.3'
gem 'pry-rails', '~> 0.3.6'
gem 'pry-stack_explorer', '~> 0.4.9.2'
+11 -7
View File
@@ -291,13 +291,14 @@ GEM
thor (~> 0.19)
builder (3.2.3)
byebug (10.0.2)
capybara (3.0.2)
capybara (3.11.1)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
xpath (~> 3.0)
regexp_parser (~> 1.2)
xpath (~> 3.2)
capybara-screenshot (1.0.19)
capybara (>= 1.0, < 4)
launchy
@@ -495,7 +496,7 @@ GEM
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_mime (1.0.0)
mini_mime (1.0.1)
mini_portile2 (2.3.0)
minisyntax (0.2.5)
minitest (5.11.3)
@@ -575,7 +576,8 @@ GEM
pry-stack_explorer (0.4.9.2)
binding_of_caller (>= 0.7)
pry (>= 0.9.11)
public_suffix (3.0.2)
public_suffix (3.0.3)
puma (3.11.4)
rabl (0.13.1)
activesupport (>= 2.3.14)
rack (2.0.6)
@@ -642,6 +644,7 @@ GEM
reform-rails (0.1.7)
activemodel (>= 3.2)
reform (>= 2.2.0)
regexp_parser (1.3.0)
representable (3.0.4)
declarative (< 0.1.0)
declarative-option (< 0.2.0)
@@ -808,7 +811,7 @@ GEM
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
will_paginate (3.1.6)
xpath (3.0.0)
xpath (3.2.0)
nokogiri (~> 1.8)
PLATFORMS
@@ -830,7 +833,7 @@ DEPENDENCIES
bcrypt (~> 3.1.6)
bootsnap (~> 1.1.2)
bourbon (~> 4.3.4)
capybara (~> 3.0.0)
capybara (~> 3.11.1)
capybara-screenshot (~> 1.0.17)
capybara-select2!
carrierwave (~> 1.2.2)
@@ -903,6 +906,7 @@ DEPENDENCIES
pry-rails (~> 0.3.6)
pry-rescue (~> 1.4.5)
pry-stack_explorer (~> 0.4.9.2)
puma (~> 3.11.3)
rabl (~> 0.13.0)
rack-attack (~> 5.2.0)
rack-protection (~> 2.0.0)
@@ -964,4 +968,4 @@ RUBY VERSION
ruby 2.5.1p57
BUNDLED WITH
1.16.5
1.17.1
-3
View File
@@ -67,9 +67,6 @@ RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# We're using DatabaseCleaner, so avoid test wrapping in transctions
# cf., spec/support/database_cleaner
config.use_transactional_fixtures = false
# Filter lines from Rails gems in backtraces.
config.filter_rails_from_backtrace!
+2 -6
View File
@@ -15,12 +15,8 @@ end
# Remove old images automatically
Capybara::Screenshot.prune_strategy = :keep_last_run
# Don't silence puma if we're using it
Capybara.register_server :thin do |app, port, host|
require 'rack/handler/thin'
Rack::Handler::Thin.run(app, Port: port, Host: host, signals: false)
end
Capybara.server = :thin
# silence puma if we're using it
Capybara.server = :puma, { Silent: true }
# Set up S3 uploads if desired
if ENV['OPENPROJECT_ENABLE_CAPYBARA_SCREENSHOT_S3_UPLOADS'] && ENV['AWS_ACCESS_KEY_ID']
@@ -104,7 +104,7 @@ module Components
within_modal do
if impaired
input = find "input[type=checkbox][title='#{name}'"
input = find "input[type=checkbox][title='#{name}']"
input.set false
else
container = find('.select2-search-choice', text: name)
+10 -37
View File
@@ -1,42 +1,15 @@
RSpec.configure do |config|
config.before(:suite) do
if config.use_transactional_fixtures?
raise(<<-MSG)
Delete line `config.use_transactional_fixtures = true` from rails_helper.rb
(or set it to false) to prevent uncommitted transactions being used in
JavaScript-dependent specs.
During testing, the app-under-test that the browser driver connects to
uses a different database connection to the database connection used by
the spec. The app's database connection would not be able to access
uncommitted transaction data setup over the spec's database connection.
MSG
end
# Since Rails 5.1., we can force the application server and capybara to share the same connection,
# which results in database_cleaner no longer being necessary.
# This will only work with a server that works in single mode (e.g., Puma)
# We're still using database_cleaner in cucumber however, so we can use it to ensure we run
# with a clean database (which use_transactional_fixtures does not ensure).
# c.f., spec/support/database_cleaner
config.use_transactional_fixtures = true
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, type: :feature) do
# :rack_test driver's Rack app under test shares database connection
# with the specs, so continue to use transaction strategy for speed.
driver_shares_db_connection_with_specs = Capybara.current_driver == :rack_test
if !driver_shares_db_connection_with_specs
# Driver is probably for an external browser with an app
# under test that does *not* share a database connection with the
# specs, so use truncation strategy.
DatabaseCleaner.strategy = :truncation
end
end
config.before(:each) do
DatabaseCleaner.start
end
config.append_after(:each) do
DatabaseCleaner.clean
end
end
+13
View File
@@ -0,0 +1,13 @@
RSpec.configure do |config|
##
# default to rack-test when using system tests without JS
config.before(:each, type: :system) do
driven_by :rack_test
end
##
# Use selenium-backed firefox driver for JS tests
config.before(:each, type: :system, js: true) do
driven_by :selenium
end
end