2019-04-29 19:27:42 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-27 21:27:38 -05:00
|
|
|
RSpec.describe AboutController do
|
2023-01-09 05:18:21 -06:00
|
|
|
describe "#index" do
|
2017-03-08 01:42:24 -06:00
|
|
|
it "should display the about page for anonymous user when login_required is false" do
|
|
|
|
SiteSetting.login_required = false
|
2018-05-21 22:40:50 -05:00
|
|
|
get "/about"
|
2017-08-30 23:06:56 -05:00
|
|
|
|
2018-06-07 03:11:09 -05:00
|
|
|
expect(response.status).to eq(200)
|
2018-11-27 20:36:14 -06:00
|
|
|
expect(response.body).to include("<title>About - Discourse</title>")
|
2017-03-08 01:42:24 -06:00
|
|
|
end
|
|
|
|
|
2023-01-09 05:18:21 -06:00
|
|
|
it "should redirect to login page for anonymous user when login_required is true" do
|
2017-03-08 01:42:24 -06:00
|
|
|
SiteSetting.login_required = true
|
2018-05-21 22:40:50 -05:00
|
|
|
get "/about"
|
2017-08-30 23:06:56 -05:00
|
|
|
|
2023-01-09 05:18:21 -06:00
|
|
|
expect(response).to redirect_to "/login"
|
2017-03-08 01:42:24 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should display the about page for logged in user when login_required is true" do
|
|
|
|
SiteSetting.login_required = true
|
2018-05-21 22:40:50 -05:00
|
|
|
sign_in(Fabricate(:user))
|
|
|
|
get "/about"
|
2017-08-30 23:06:56 -05:00
|
|
|
|
2018-06-07 03:11:09 -05:00
|
|
|
expect(response.status).to eq(200)
|
2017-03-08 01:42:24 -06:00
|
|
|
end
|
2018-11-27 20:36:14 -06:00
|
|
|
|
2022-07-27 11:14:14 -05:00
|
|
|
context "with crawler view" do
|
2018-11-27 20:36:14 -06:00
|
|
|
it "should include correct title" do
|
2023-01-09 05:18:21 -06:00
|
|
|
get "/about", headers: { "HTTP_USER_AGENT" => "Googlebot" }
|
2018-11-27 20:36:14 -06:00
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(response.body).to include("<title>About - Discourse</title>")
|
|
|
|
end
|
2020-07-14 10:09:27 -05:00
|
|
|
|
|
|
|
it "should include correct user URLs" do
|
|
|
|
Fabricate(:admin, username: "anAdminUser")
|
2023-01-09 05:18:21 -06:00
|
|
|
get "/about", headers: { "HTTP_USER_AGENT" => "Googlebot" }
|
2020-07-14 10:09:27 -05:00
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(response.body).to include("/u/anadminuser")
|
|
|
|
end
|
2018-11-27 20:36:14 -06:00
|
|
|
end
|
2020-05-22 23:56:13 -05:00
|
|
|
|
|
|
|
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
|
2017-03-08 01:42:24 -06:00
|
|
|
end
|
|
|
|
end
|