File tree 2 files changed +24
-1
lines changed
2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 1
1
class AuthServicesController < ApplicationController
2
2
def new
3
- referer_path = URI ( request . referer ) . path
3
+ referer_path = URI ( request . referer ) . path if request . referer
4
4
if Rails . application . routes . recognize_path ( referer_path ) [ :controller ] . in? ( %w[ workshops events meetings ] )
5
5
session [ :referer_path ] = referer_path
6
6
end
Original file line number Diff line number Diff line change
1
+ require "spec_helper"
2
+
3
+ RSpec . describe AuthServicesController , type : :controller do
4
+ describe "GET #new" do
5
+ it "redirects when referer is missing" do
6
+ expected_referer_path = nil
7
+ request . env [ "HTTP_REFERER" ] = expected_referer_path
8
+
9
+ get :new
10
+ expect ( response ) . to redirect_to ( "/auth/github" )
11
+ expect ( session [ :referer_path ] ) . to eq ( expected_referer_path )
12
+ end
13
+
14
+ it "redirects when referer is present" do
15
+ expected_referer_path = "workshops/42"
16
+ request . env [ "HTTP_REFERER" ] = expected_referer_path
17
+
18
+ get :new
19
+ expect ( response ) . to redirect_to ( "/auth/github" )
20
+ expect ( session [ :referer_path ] ) . to eq ( expected_referer_path )
21
+ end
22
+ end
23
+ end
You can’t perform that action at this time.
0 commit comments