mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
FIX: do not serialize status when profile is hidden (#23946)
Users can decide to hide their profile and presence. It seems more correct to also not return the status in this case. Co-authored-by: Penar Musaraj <pmusaraj@gmail.com>
This commit is contained in:
@ -0,0 +1,40 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "rails_helper"
|
||||
|
||||
describe Chat::ChatablesSerializer do
|
||||
context "with status" do
|
||||
fab!(:user_1) { Fabricate(:user) }
|
||||
|
||||
before do
|
||||
SiteSetting.enable_user_status = true
|
||||
user_1.set_status!("test", ":cat:")
|
||||
end
|
||||
|
||||
it "includes status" do
|
||||
serializer =
|
||||
described_class.new(
|
||||
OpenStruct.new({ users: [user_1] }),
|
||||
scope: Guardian.new(Fabricate(:user)),
|
||||
root: false,
|
||||
)
|
||||
|
||||
expect(serializer.users[0]["model"][:status]).to be_present
|
||||
end
|
||||
|
||||
context "with hidden profile" do
|
||||
before { user_1.user_option.update!(hide_profile_and_presence: true) }
|
||||
|
||||
it "doesn’t include status" do
|
||||
serializer =
|
||||
described_class.new(
|
||||
OpenStruct.new({ users: [user_1] }),
|
||||
scope: Guardian.new(Fabricate(:user)),
|
||||
root: false,
|
||||
)
|
||||
|
||||
expect(serializer.users[0]["model"][:status]).to be_blank
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user