2015-10-11 04:41:23 -05:00
|
|
|
require "rails_helper"
|
2013-08-25 20:04:16 -05:00
|
|
|
|
|
|
|
require "auth/authenticator"
|
2013-08-23 02:00:18 -05:00
|
|
|
require_dependency "auth/result"
|
2013-02-13 01:15:44 -06:00
|
|
|
|
|
|
|
describe "users/omniauth_callbacks/complete.html.erb" do
|
|
|
|
|
2013-08-23 02:00:18 -05:00
|
|
|
let :rendered_data do
|
2016-06-10 10:32:32 -05:00
|
|
|
JSON.parse(rendered.match(/var authResult = (.*);/)[1])
|
2013-02-13 01:15:44 -06:00
|
|
|
end
|
|
|
|
|
2013-08-23 02:00:18 -05:00
|
|
|
it "renders auth info" do
|
|
|
|
result = Auth::Result.new
|
|
|
|
result.user = User.new
|
2013-05-23 15:40:50 -05:00
|
|
|
|
2015-06-24 11:12:43 -05:00
|
|
|
assign(:auth_result, result)
|
2013-02-13 01:15:44 -06:00
|
|
|
|
|
|
|
render
|
|
|
|
|
2014-12-31 08:55:03 -06: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 01:15:44 -06:00
|
|
|
end
|
|
|
|
|
2013-08-23 02:00:18 -05:00
|
|
|
it "renders cas data " do
|
|
|
|
result = Auth::Result.new
|
2013-02-13 01:15:44 -06:00
|
|
|
|
2013-08-23 02:00:18 -05:00
|
|
|
result.email = "xxx@xxx.com"
|
2013-08-25 20:04:16 -05:00
|
|
|
result.authenticator_name = "CAS"
|
2013-02-25 10:42:20 -06:00
|
|
|
|
2015-06-24 11:12:43 -05:00
|
|
|
assign(:auth_result, result)
|
2013-02-25 22:28:32 -06:00
|
|
|
|
|
|
|
render
|
|
|
|
|
2014-12-31 08:55:03 -06:00
|
|
|
expect(rendered_data["email"]).to eq(result.email)
|
2013-08-25 20:04:16 -05:00
|
|
|
# TODO this is a bit weird, the upcasing is confusing,
|
|
|
|
# clean it up throughout
|
2014-12-31 08:55:03 -06:00
|
|
|
expect(rendered_data["auth_provider"]).to eq("Cas")
|
2013-02-25 22:28:32 -06:00
|
|
|
end
|
2013-02-27 11:09:22 -06:00
|
|
|
|
2013-02-13 01:15:44 -06:00
|
|
|
end
|