summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorblackst0ne <blackst0ne.ru@gmail.com>2018-06-16 19:12:46 +1100
committerblackst0ne <blackst0ne.ru@gmail.com>2018-06-16 19:12:46 +1100
commit79c3ec014c7db667457268a75f9c47bee8653650 (patch)
tree064c180b882d131f7acf0c3570030272e79ad5e6
parentf733d4f8979a7570a9347186dbe0f8c663c2ff4f (diff)
downloadgitlab-ce-79c3ec014c7db667457268a75f9c47bee8653650.tar.gz
Refactor sessions_controller_spec to work both in rails4 and rails5. Remove the stubbed `request.referer` method, set real header instead.
-rw-r--r--changelogs/unreleased/blackst0ne-rails5-expected-search-search-seed_project-got-nil.yml5
-rw-r--r--spec/controllers/sessions_controller_spec.rb10
2 files changed, 10 insertions, 5 deletions
diff --git a/changelogs/unreleased/blackst0ne-rails5-expected-search-search-seed_project-got-nil.yml b/changelogs/unreleased/blackst0ne-rails5-expected-search-search-seed_project-got-nil.yml
new file mode 100644
index 00000000000..e7bb2703b03
--- /dev/null
+++ b/changelogs/unreleased/blackst0ne-rails5-expected-search-search-seed_project-got-nil.yml
@@ -0,0 +1,5 @@
+---
+title: "[Rails5] Fix sessions_controller_spec"
+merge_request: 19936
+author: "@blackst0ne"
+type: fixed
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb
index 555b186fe31..2b61e0d4a85 100644
--- a/spec/controllers/sessions_controller_spec.rb
+++ b/spec/controllers/sessions_controller_spec.rb
@@ -257,15 +257,15 @@ describe SessionsController do
end
end
- describe '#new' do
+ describe "#new" do
before do
set_devise_mapping(context: @request)
end
- it 'redirects correctly for referer on same host with params' do
- search_path = '/search?search=seed_project'
- allow(controller.request).to receive(:referer)
- .and_return('http://%{host}%{path}' % { host: 'test.host', path: search_path })
+ it "redirects correctly for referer on same host with params" do
+ host = "test.host"
+ search_path = "/search?search=seed_project"
+ request.headers[:HTTP_REFERER] = "http://#{host}#{search_path}"
get(:new, redirect_to_referer: :yes)