2019-04-30 08:27:42 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-10-11 17:41:23 +08:00
|
|
|
require "rails_helper"
|
2013-08-26 09:04:16 +08:00
|
|
|
|
|
|
|
require "auth/authenticator"
|
2013-08-23 15:00:18 +08:00
|
|
|
require_dependency "auth/result"
|
2013-02-13 15:15:44 +08:00
|
|
|
|
|
|
|
describe "users/omniauth_callbacks/complete.html.erb" do
|
|
|
|
|
2013-08-23 15:00:18 +08:00
|
|
|
let :rendered_data do
|
2018-10-25 21:52:01 +08:00
|
|
|
JSON.parse(rendered.match(/data-auth-result="([^"]*)"/)[1].gsub('"', '"'))
|
2013-02-13 15:15:44 +08:00
|
|
|
end
|
|
|
|
|
2013-08-23 15:00:18 +08:00
|
|
|
it "renders auth info" do
|
|
|
|
result = Auth::Result.new
|
|
|
|
result.user = User.new
|
2013-05-24 04:40:50 +08:00
|
|
|
|
2015-06-25 00:12:43 +08:00
|
|
|
assign(:auth_result, result)
|
2013-02-13 15:15:44 +08:00
|
|
|
|
|
|
|
render
|
|
|
|
|
2014-12-31 22:55:03 +08: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 15:00:18 +08:00
|
|
|
it "renders cas data " do
|
|
|
|
result = Auth::Result.new
|
2013-02-13 15:15:44 +08:00
|
|
|
|
2013-08-23 15:00:18 +08:00
|
|
|
result.email = "xxx@xxx.com"
|
2013-08-26 09:04:16 +08:00
|
|
|
result.authenticator_name = "CAS"
|
2013-02-26 00:42:20 +08:00
|
|
|
|
2015-06-25 00:12:43 +08:00
|
|
|
assign(:auth_result, result)
|
2013-02-26 12:28:32 +08:00
|
|
|
|
|
|
|
render
|
|
|
|
|
2014-12-31 22:55:03 +08:00
|
|
|
expect(rendered_data["email"]).to eq(result.email)
|
2018-11-23 03:12:04 +08:00
|
|
|
expect(rendered_data["auth_provider"]).to eq("CAS")
|
2013-02-26 12:28:32 +08:00
|
|
|
end
|
2013-02-28 01:09:22 +08:00
|
|
|
|
2013-02-13 15:15:44 +08:00
|
|
|
end
|