35 lines
710 B
Ruby
35 lines
710 B
Ruby
|
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
|