Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Capybara is not configuring the rails url options, visiting _url helpers break

Oliver Güntherb4a115401eff
diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb
index b81e4e1db34..5d09485db7d 100644
--- a/spec/support/capybara.rb
+++ b/spec/support/capybara.rb
@@ -5,7 +5,21 @@ require 'capybara-screenshot/rspec'
require 'rack_session_access/capybara'
require 'action_dispatch'
-RSpec.configure do |_config|
+RSpec.shared_context 'with default_url_options set' do
+ before do
+ @original_host = default_url_options[:host]
+ @original_port = default_url_options[:port]
+ default_url_options[:host] = Capybara.server_host
+ default_url_options[:port] = Capybara.server_port
+ end
+
+ after do
+ default_url_options[:host] = @original_host # rubocop:disable RSpec/InstanceVariable
+ default_url_options[:port] = @original_port # rubocop:disable RSpec/InstanceVariable
+ end
+end
+
+RSpec.configure do |config|
Capybara.default_max_wait_time = 4
Capybara.javascript_driver = :chrome_en
@@ -23,6 +37,9 @@ RSpec.configure do |_config|
else
Capybara.server_host = ENV.fetch('CAPYBARA_APP_HOSTNAME', 'localhost')
end
+
+ # Set the default options
+ config.include_context 'with default_url_options set', type: :feature
end
##