FIX: Take `enable_names` setting into account (#240)

This commit is contained in:
Penar Musaraj 2023-06-05 09:54:25 -04:00 committed by GitHub
parent e0cd3d11c3
commit 7b90566b05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -464,7 +464,13 @@ SQL
nil
end
postInfo[3] = SiteSetting.display_name_on_posts ? postInfo[3] : nil
postInfo[3] = (
if SiteSetting.enable_names && SiteSetting.display_name_on_posts
postInfo[3]
else
nil
end
)
postInfo
end
end

View File

@ -76,6 +76,12 @@ RSpec.describe TopicsController do
expect(response.parsed_body["accepted_answer"]["name"]).to eq(p2.user.name)
expect(response.parsed_body["accepted_answer"]["username"]).to eq(p2.user.username)
# enable_names is default ON, this ensures disabling it also disables names here
SiteSetting.enable_names = false
get "/t/#{topic.slug}/#{topic.id}.json"
expect(response.parsed_body["accepted_answer"]["name"]).to eq(nil)
expect(response.parsed_body["accepted_answer"]["username"]).to eq(p2.user.username)
end
it "should not include user name when site setting is disabled" do