2013-02-13 02:15:44 -05:00
|
|
|
require "spec_helper"
|
2013-08-25 21:04:16 -04:00
|
|
|
|
|
|
|
require "auth/authenticator"
|
2013-08-23 03:00:18 -04:00
|
|
|
require_dependency "auth/result"
|
2013-02-13 02:15:44 -05:00
|
|
|
|
|
|
|
describe "users/omniauth_callbacks/complete.html.erb" do
|
|
|
|
|
2013-08-23 03:00:18 -04:00
|
|
|
let :rendered_data do
|
|
|
|
returned = JSON.parse(rendered.match(/window.opener.Discourse.authenticationComplete\((.*)\)/)[1])
|
2013-02-13 02:15:44 -05:00
|
|
|
end
|
|
|
|
|
2013-08-23 03:00:18 -04:00
|
|
|
it "renders auth info" do
|
|
|
|
result = Auth::Result.new
|
|
|
|
result.user = User.new
|
2013-05-23 16:40:50 -04:00
|
|
|
|
2013-08-23 03:00:18 -04:00
|
|
|
assign(:data, result)
|
2013-02-13 02:15:44 -05:00
|
|
|
|
|
|
|
render
|
|
|
|
|
2013-08-23 03:00:18 -04:00
|
|
|
rendered_data["authenticated"].should eq(false)
|
|
|
|
rendered_data["awaiting_activation"].should eq(false)
|
|
|
|
rendered_data["awaiting_approval"].should eq(false)
|
2013-02-13 02:15:44 -05:00
|
|
|
end
|
|
|
|
|
2013-08-23 03:00:18 -04:00
|
|
|
it "renders cas data " do
|
|
|
|
result = Auth::Result.new
|
2013-02-13 02:15:44 -05:00
|
|
|
|
2013-08-23 03:00:18 -04:00
|
|
|
result.email = "xxx@xxx.com"
|
2013-08-25 21:04:16 -04:00
|
|
|
result.authenticator_name = "CAS"
|
2013-02-25 11:42:20 -05:00
|
|
|
|
2013-08-23 03:00:18 -04:00
|
|
|
assign(:data, result)
|
2013-02-25 23:28:32 -05:00
|
|
|
|
|
|
|
render
|
|
|
|
|
2013-08-25 21:04:16 -04:00
|
|
|
rendered_data["email"].should eq(result.email)
|
|
|
|
# TODO this is a bit weird, the upcasing is confusing,
|
|
|
|
# clean it up throughout
|
|
|
|
rendered_data["auth_provider"].should eq("Cas")
|
2013-02-25 23:28:32 -05:00
|
|
|
end
|
2013-02-27 12:09:22 -05:00
|
|
|
|
2013-02-13 02:15:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|