-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #542 from songjiayang/cache_referrer
Skip referrer cache if it's from other site
- Loading branch information
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'rails_helper' | ||
|
||
describe SessionsController, type: :controller do | ||
describe ':new' do | ||
before { request.env["devise.mapping"] = Devise.mappings[:user] } | ||
it 'should render new tempalte' do | ||
get :new | ||
expect(response).to render_template(:new) | ||
end | ||
|
||
it "should store referrer if it's from self site" do | ||
referrer = "#{request.base_url}/account/edit" | ||
request.env["HTTP_REFERER"] = referrer | ||
get :new | ||
session['user_return_to'].should be referrer | ||
end | ||
|
||
it "should skip referrer if it's from other site" do | ||
referrer = "http://#{SecureRandom.hex(4)}.com" | ||
request.env["HTTP_REFERER"] = referrer | ||
get :new | ||
session['user_return_to'].should be_nil | ||
end | ||
end | ||
end |