mirror of
https://github.com/discourse/discourse.git
synced 2024-12-06 07:33:39 +08:00
234133bd3b
It splits the hide_profile_and_presence user option and the default_hide_profile_and_presence site setting for more granular control. It keeps the option to hide the profile under /u/username/preferences/interface and adds the presence toggle in the quick user menu. Co-authored-by: Régis Hanol <regis@hanol.fr>
44 lines
1.3 KiB
Ruby
44 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe UserStatusMixin do
|
|
fab!(:user_status)
|
|
fab!(:user) { Fabricate(:user, user_status: user_status) }
|
|
|
|
class DummySerializer < ApplicationSerializer
|
|
include UserStatusMixin
|
|
end
|
|
|
|
context "when user status is disabled" do
|
|
before { SiteSetting.enable_user_status = false }
|
|
|
|
it "doesn't include status" do
|
|
serializer = DummySerializer.new(user, root: false, include_status: true)
|
|
json = serializer.as_json
|
|
expect(json[:status]).to be_nil
|
|
end
|
|
end
|
|
|
|
context "when user status is enabled" do
|
|
before { SiteSetting.enable_user_status = true }
|
|
|
|
it "doesn't include status by default" do
|
|
serializer = DummySerializer.new(user, root: false)
|
|
json = serializer.as_json
|
|
expect(json[:status]).to be_nil
|
|
end
|
|
|
|
it "includes status when include_status option is passed" do
|
|
serializer = DummySerializer.new(user, root: false, include_status: true)
|
|
json = serializer.as_json
|
|
expect(json[:status]).to be_present
|
|
end
|
|
|
|
it "doesn't include status if user hid profile and presence" do
|
|
user.user_option.hide_profile = true
|
|
serializer = DummySerializer.new(user, root: false, include_status: true)
|
|
json = serializer.as_json
|
|
expect(json[:status]).to be_nil
|
|
end
|
|
end
|
|
end
|