[Rails5] Fix sessions_controller_spec

Refactor sessions_controller_spec to work both in rails4 and rails5.
Remove the stubbed `request.referer` method, set real header instead.
This commit is contained in:
blackst0ne 2018-06-16 19:12:46 +11:00
parent f733d4f897
commit 79c3ec014c
2 changed files with 10 additions and 5 deletions

View File

@ -0,0 +1,5 @@
---
title: "[Rails5] Fix sessions_controller_spec"
merge_request: 19936
author: "@blackst0ne"
type: fixed

View File

@ -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)