mirror of
https://github.com/discourse/discourse.git
synced 2025-07-14 01:10:53 +08:00

There is a bug that when `SiteSetting.enable_names` is disabled, the admin can click the pencil next to the user and successfully update the name. However, the change is not saved as the action is blocked by the guardian. Meta: https://meta.discourse.org/t/disabling-enable-names-makes-admin-act-strange/291912
18 lines
579 B
Ruby
18 lines
579 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe AdminDetailedUserSerializer do
|
|
fab!(:user) { Fabricate(:user, trust_level: 0) }
|
|
fab!(:admin)
|
|
fab!(:moderator)
|
|
|
|
it "serializes name for admin even if enable_names setting is false" do
|
|
serializer = AdminDetailedUserSerializer.new(user, scope: Guardian.new(admin), root: false)
|
|
json = serializer.as_json
|
|
expect(json[:name]).to eq(user.name)
|
|
|
|
serializer = AdminDetailedUserSerializer.new(user, scope: Guardian.new(moderator), root: false)
|
|
json = serializer.as_json
|
|
expect(json[:name]).to be_nil
|
|
end
|
|
end
|