From 60797a42b419841e14f50f85bf8daa2a115a72f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Thu, 27 Jul 2017 11:15:57 +0200 Subject: Ensure Gitlab::Application.routes.default_url_options are set correctly in Capybara + :js specs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- spec/support/capybara.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'spec/support/capybara.rb') diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index 3e5d6cf1364..c45c4a4310d 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -36,7 +36,14 @@ RSpec.configure do |config| $capybara_server_already_started = true end - config.after(:each, :js) do |example| + config.before(:example, :js) do + allow(Gitlab::Application.routes).to receive(:default_url_options).and_return( + host: Capybara.current_session.server.host, + port: Capybara.current_session.server.port, + protocol: 'http') + end + + config.after(:example, :js) do |example| # capybara/rspec already calls Capybara.reset_sessions! in an `after` hook, # but `block_and_wait_for_requests_complete` is called before it so by # calling it explicitely here, we prevent any new requests from being fired -- cgit v1.2.3