mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 23:48:44 +08:00
FEATURE: Hide user status when user is hiding public profile and presence (#24300)
Users can hide their public profile and presence information by checking
“Hide my public profile and presence features” on the
`u/{username}/preferences/interface` page. In that case, we also don't
want to return user status from the server.
This work has been started in https://github.com/discourse/discourse/pull/23946.
The current PR fixes all the remaining places in Core.
Note that the actual fix is quite simple – a5802f484d
.
But we had a fair amount of duplication in the code responsible for
the user status serialization, so I had to dry that up first. The refactoring
as well as adding some additional tests is the main part of this PR.
This commit is contained in:

committed by
GitHub

parent
41790f7739
commit
b3a1199493
17
spec/serializers/user_with_custom_fields_serializer_spec.rb
Normal file
17
spec/serializers/user_with_custom_fields_serializer_spec.rb
Normal file
@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
RSpec.describe UserWithCustomFieldsSerializer do
|
||||
describe "#status" do
|
||||
fab!(:user_status)
|
||||
fab!(:user) { Fabricate(:user, user_status: user_status) }
|
||||
|
||||
it "adds user status when enabled in site settings" do
|
||||
SiteSetting.enable_user_status = true
|
||||
|
||||
serializer =
|
||||
described_class.new(user, scope: Guardian.new(user), root: false, include_status: true)
|
||||
json = serializer.as_json
|
||||
|
||||
expect(json[:status]).to be_present
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user