discourse/spec/views/omniauth_callbacks/complete.html.erb_spec.rb

42 lines
907 B
Ruby
Raw Normal View History

# frozen_string_literal: true
require "rails_helper"
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
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
assign(:auth_result, result)
2013-02-13 02:15:44 -05:00
render
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"
result.authenticator_name = "CAS"
2013-02-25 11:42:20 -05:00
assign(:auth_result, result)
render
expect(rendered_data["email"]).to eq(result.email)
expect(rendered_data["auth_provider"]).to eq("CAS")
end
2013-02-13 02:15:44 -05:00
end