From e1bd57007be821a7efa0becb7b812449ac53b67f Mon Sep 17 00:00:00 2001 From: Mark VanLandingham Date: Wed, 20 May 2020 11:30:27 -0500 Subject: [PATCH] DEV: Specs for AboutController can_see_about_stats? impact (#9843) --- spec/requests/about_controller_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/requests/about_controller_spec.rb b/spec/requests/about_controller_spec.rb index 6c58284979f..a10b7663043 100644 --- a/spec/requests/about_controller_spec.rb +++ b/spec/requests/about_controller_spec.rb @@ -36,5 +36,21 @@ describe AboutController do expect(response.body).to include("About - Discourse") 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