mirror of
https://github.com/discourse/discourse.git
synced 2024-12-13 21:34:23 +08:00
d9a02d1336
This reverts commit20780a1eee
. * SECURITY: re-adds accidentally reverted commit: 03d26cd6: ensure embed_url contains valid http(s) uri * when the merge commite62a85cf
was reverted, git chose the2660c2e2
parent to land on instead of the03d26cd6
parent (which contains security fixes)
57 lines
1.7 KiB
Ruby
57 lines
1.7 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe AboutController do
|
|
|
|
context '.index' do
|
|
|
|
it "should display the about page for anonymous user when login_required is false" do
|
|
SiteSetting.login_required = false
|
|
get "/about"
|
|
|
|
expect(response.status).to eq(200)
|
|
expect(response.body).to include("<title>About - Discourse</title>")
|
|
end
|
|
|
|
it 'should redirect to login page for anonymous user when login_required is true' do
|
|
SiteSetting.login_required = true
|
|
get "/about"
|
|
|
|
expect(response).to redirect_to '/login'
|
|
end
|
|
|
|
it "should display the about page for logged in user when login_required is true" do
|
|
SiteSetting.login_required = true
|
|
sign_in(Fabricate(:user))
|
|
get "/about"
|
|
|
|
expect(response.status).to eq(200)
|
|
end
|
|
|
|
context "crawler view" do
|
|
it "should include correct title" do
|
|
get '/about', headers: { 'HTTP_USER_AGENT' => 'Googlebot' }
|
|
expect(response.status).to eq(200)
|
|
expect(response.body).to include("<title>About - Discourse</title>")
|
|
end
|
|
end
|
|
|
|
it "serializes stats when 'Guardian#can_see_about_stats?' is true" do
|
|
Guardian.any_instance.stubs(:can_see_about_stats?).returns(true)
|
|
get "/about.json"
|
|
|
|
expect(response.status).to eq(200)
|
|
expect(response.parsed_body["about"].keys).to include("stats")
|
|
end
|
|
|
|
it "does not serialize stats when 'Guardian#can_see_about_stats?' is false" do
|
|
Guardian.any_instance.stubs(:can_see_about_stats?).returns(false)
|
|
get "/about.json"
|
|
|
|
expect(response.status).to eq(200)
|
|
expect(response.parsed_body["about"].keys).not_to include("stats")
|
|
end
|
|
end
|
|
end
|