mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 15:05:24 +08:00
4ea21fa2d0
This change both speeds up specs (less strings to allocate) and helps catch cases where methods in Discourse are mutating inputs. Overall we will be migrating everything to use #frozen_string_literal: true it will take a while, but this is the first and safest move in this direction
42 lines
907 B
Ruby
42 lines
907 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "rails_helper"
|
|
|
|
require "auth/authenticator"
|
|
require_dependency "auth/result"
|
|
|
|
describe "users/omniauth_callbacks/complete.html.erb" do
|
|
|
|
let :rendered_data do
|
|
JSON.parse(rendered.match(/data-auth-result="([^"]*)"/)[1].gsub('"', '"'))
|
|
end
|
|
|
|
it "renders auth info" do
|
|
result = Auth::Result.new
|
|
result.user = User.new
|
|
|
|
assign(:auth_result, result)
|
|
|
|
render
|
|
|
|
expect(rendered_data["authenticated"]).to eq(false)
|
|
expect(rendered_data["awaiting_activation"]).to eq(false)
|
|
expect(rendered_data["awaiting_approval"]).to eq(false)
|
|
end
|
|
|
|
it "renders cas data " do
|
|
result = Auth::Result.new
|
|
|
|
result.email = "xxx@xxx.com"
|
|
result.authenticator_name = "CAS"
|
|
|
|
assign(:auth_result, result)
|
|
|
|
render
|
|
|
|
expect(rendered_data["email"]).to eq(result.email)
|
|
expect(rendered_data["auth_provider"]).to eq("CAS")
|
|
end
|
|
|
|
end
|