discourse/spec/serializers/user_status_serializer_spec.rb
Daniel Waterworth 6e161d3e75
DEV: Allow fab! without block (#24314)
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.
2023-11-09 16:47:59 -06:00

21 lines
531 B
Ruby

# frozen_string_literal: true
RSpec.describe UserStatusSerializer do
fab!(:user)
fab!(:user_status) do
Fabricate(
:user_status,
user: user,
set_at: Time.parse("2023-09-29T02:20:00Z"),
ends_at: Time.parse("2023-09-29T03:25:00Z"),
)
end
describe "#ends_at" do
it "is formatted as a ISO8601 timestamp" do
serialized = described_class.new(user_status, scope: Guardian.new(user), root: false).as_json
expect(serialized[:ends_at]).to eq("2023-09-29T03:25:00Z")
end
end
end