oauth cleanup: test fakes and generic provider
This commit is contained in:
34
test/test_helpers/test_auth_helper.rb
Normal file
34
test/test_helpers/test_auth_helper.rb
Normal 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
|
Reference in New Issue
Block a user