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