2022-08-09 18:54:33 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec.describe FoundUserSerializer do
|
2023-11-10 06:47:59 +08:00
|
|
|
fab!(:user)
|
2022-08-09 18:54:33 +08:00
|
|
|
let(:serializer) { described_class.new(user, root: false) }
|
|
|
|
|
2023-04-25 22:25:57 +08:00
|
|
|
describe "#id" do
|
|
|
|
it "returns user id" do
|
|
|
|
json = serializer.as_json
|
|
|
|
expect(json.keys).to include :id
|
|
|
|
expect(json[:id]).to eq(user.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-08-09 18:54:33 +08:00
|
|
|
describe "#name" do
|
|
|
|
it "returns name if enabled in site settings" do
|
|
|
|
SiteSetting.enable_names = true
|
|
|
|
json = serializer.as_json
|
|
|
|
expect(json.keys).to include :name
|
|
|
|
expect(json[:name]).to eq(user.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't return name if disabled in site settings" do
|
|
|
|
SiteSetting.enable_names = false
|
|
|
|
json = serializer.as_json
|
|
|
|
expect(json.keys).not_to include :name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|