discourse/spec/serializers/poster_serializer_spec.rb
Penar Musaraj 3abc542e63
FIX: Include group flair in homepage category topic lists (#21268)
Followup to c03f83bbea.

The `flair_group_id` parameter is now required to show the flair, and this serializer was missing that detail. 

This also fixes a typo in the `include_flair_group_name?` method.
2023-04-27 10:18:16 +08:00

41 lines
922 B
Ruby

# frozen_string_literal: true
RSpec.describe PosterSerializer do
let(:poster) { Fabricate(:user, admin: false, moderator: false) }
it "serializes the correct attributes" do
expect(PosterSerializer.new(poster).attributes.keys).to contain_exactly(
:trust_level,
:avatar_template,
:id,
:name,
:username,
)
end
it "includes group flair attributes when appropriate" do
group =
Fabricate(
:group,
name: "Groupster",
flair_bg_color: "#111111",
flair_color: "#999999",
flair_icon: "icon",
)
groupie = Fabricate(:user, flair_group: group)
expect(PosterSerializer.new(groupie).attributes.keys).to contain_exactly(
:trust_level,
:avatar_template,
:id,
:name,
:username,
:flair_bg_color,
:flair_color,
:flair_group_id,
:flair_name,
:flair_url,
)
end
end