diff options
author | Rémy Coutable <remy@rymai.me> | 2017-07-27 11:15:57 +0200 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-07-28 16:33:30 +0200 |
commit | 60797a42b419841e14f50f85bf8daa2a115a72f9 (patch) | |
tree | 930ea47354df7c2e415cf77dbb727967da97296a /spec | |
parent | 48c51e207e4cba8a69e4ca65cba1e169d384cefa (diff) | |
download | gitlab-ce-60797a42b419841e14f50f85bf8daa2a115a72f9.tar.gz |
Ensure Gitlab::Application.routes.default_url_options are set correctly in Capybara + :js specs
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/dashboard/issues_spec.rb | 12 | ||||
-rw-r--r-- | spec/models/project_wiki_spec.rb | 2 | ||||
-rw-r--r-- | spec/spec_helper.rb | 1 | ||||
-rw-r--r-- | spec/support/capybara.rb | 9 |
4 files changed, 11 insertions, 13 deletions
diff --git a/spec/features/dashboard/issues_spec.rb b/spec/features/dashboard/issues_spec.rb index 7c0bf8de14c..82adde6258f 100644 --- a/spec/features/dashboard/issues_spec.rb +++ b/spec/features/dashboard/issues_spec.rb @@ -79,15 +79,7 @@ RSpec.describe 'Dashboard Issues' do end end - it 'shows the new issue page', js: true do - original_defaults = Gitlab::Application.routes.default_url_options - - Gitlab::Application.routes.default_url_options = { - host: Capybara.current_session.server.host, - port: Capybara.current_session.server.port, - protocol: 'http' - } - + it 'shows the new issue page', :js do find('.new-project-item-select-button').trigger('click') wait_for_requests find('.select2-results li').click @@ -97,8 +89,6 @@ RSpec.describe 'Dashboard Issues' do page.within('#content-body') do expect(page).to have_selector('.issue-form') end - - Gitlab::Application.routes.default_url_options = original_defaults end end end diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb index 7fcbeb459e0..c6ceb092810 100644 --- a/spec/models/project_wiki_spec.rb +++ b/spec/models/project_wiki_spec.rb @@ -21,7 +21,7 @@ describe ProjectWiki do describe '#web_url' do it 'returns the full web URL to the wiki' do - expect(subject.web_url).to match("https?://[^\/]+/#{project.path_with_namespace}/wikis/home") + expect(subject.web_url).to eq("#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/wikis/home") end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e7329210896..85335643921 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -59,6 +59,7 @@ RSpec.configure do |config| config.include Gitlab::Routing, type: :routing config.include MigrationsHelpers, :migration config.include StubFeatureFlags + config.include StubENV config.infer_spec_type_from_file_location! 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 |