2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-10-11 05:41:23 -04:00
|
|
|
require "rails_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
|
2018-10-25 09:52:01 -04:00
|
|
|
JSON.parse(rendered.match(/data-auth-result="([^"]*)"/)[1].gsub('"', '"'))
|
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
|
|
|
|
2015-06-24 12:12:43 -04:00
|
|
|
assign(:auth_result, result)
|
2013-02-13 02:15:44 -05:00
|
|
|
|
|
|
|
render
|
|
|
|
|
2014-12-31 09:55:03 -05: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 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
|
|
|
|
2015-06-24 12:12:43 -04:00
|
|
|
assign(:auth_result, result)
|
2013-02-25 23:28:32 -05:00
|
|
|
|
|
|
|
render
|
|
|
|
|
2014-12-31 09:55:03 -05:00
|
|
|
expect(rendered_data["email"]).to eq(result.email)
|
2018-11-22 14:12:04 -05:00
|
|
|
expect(rendered_data["auth_provider"]).to 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
|