mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 15:05:24 +08:00
6e161d3e75
The most common thing that we do with fab! is: fab!(:thing) { Fabricate(:thing) } This commit adds a shorthand for this which is just simply: fab!(:thing) i.e. If you omit the block, then, by default, you'll get a `Fabricate`d object using the fabricator of the same name.
30 lines
752 B
Ruby
30 lines
752 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe FoundUserSerializer do
|
|
fab!(:user)
|
|
let(:serializer) { described_class.new(user, root: false) }
|
|
|
|
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
|
|
|
|
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
|