oauth cleanup: test fakes and generic provider

This commit is contained in:
2016-09-17 21:53:41 -05:00
parent 5dc60e0b41
commit b9177bb55d
10 changed files with 96 additions and 23 deletions

View File

@ -0,0 +1,34 @@
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