2016-09-18 09:41:51 -05:00
|
|
|
# frozen_string_literal: true
|
2016-09-17 21:53:41 -05:00
|
|
|
module TestAuthHelper
|
|
|
|
## Monkey patch AuthController, because...auth.
|
|
|
|
AuthController.class_eval do
|
|
|
|
alias_method :org_callback, :callback
|
|
|
|
|
|
|
|
def callback
|
|
|
|
session[:token] = "fake-auth-token-thing"
|
|
|
|
session[:name] = "Fake Name"
|
|
|
|
|
|
|
|
redirect_to accounts_path
|
|
|
|
end
|
|
|
|
|
|
|
|
alias_method :auth, :callback
|
|
|
|
end
|
|
|
|
|
|
|
|
def auth_user
|
|
|
|
get '/auth/callback'
|
|
|
|
end
|
|
|
|
|
|
|
|
def last_line_in_callback
|
|
|
|
path, line_no = AuthController.instance_method(:org_callback).source_location
|
|
|
|
|
|
|
|
file = File.open(path)
|
|
|
|
line_no.times { file.readline }
|
|
|
|
tmp_line = nil
|
|
|
|
until tmp_line == 'end'
|
|
|
|
last_line = tmp_line
|
|
|
|
tmp_line = file.readline.strip
|
|
|
|
end
|
|
|
|
file.close
|
|
|
|
|
|
|
|
last_line
|
|
|
|
end
|
|
|
|
end
|