Skip to content

Commit c252961

Browse files
committed
Fixes rb#461
Rollbar was complaining when we hit this endpoint without a referer.
1 parent b01c8f7 commit c252961

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

app/controllers/auth_services_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class AuthServicesController < ApplicationController
22
def new
3-
referer_path = URI(request.referer).path
3+
referer_path = URI(request.referer).path if request.referer
44
if Rails.application.routes.recognize_path(referer_path)[:controller].in?(%w[workshops events meetings])
55
session[:referer_path] = referer_path
66
end
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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

0 commit comments

Comments
 (0)