DEV: Use serializers for user_notification_schedule and featured_topic (#27719)

Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
This commit is contained in:
Jan Cernik
2024-07-05 00:00:24 -03:00
committed by GitHub
parent 906da0f3d1
commit 33c68b28b6
7 changed files with 87 additions and 3 deletions

View File

@ -126,4 +126,27 @@ RSpec.describe UserCardSerializer do
expect(json.keys).not_to include :status
end
end
describe "#featured_topic" do
fab!(:user)
fab!(:featured_topic) { Fabricate(:topic) }
before { user.user_profile.update(featured_topic_id: featured_topic.id) }
it "includes the featured topic" do
serializer = described_class.new(user, scope: Guardian.new(user), root: false)
json = serializer.as_json
expect(json[:featured_topic]).to_not be_nil
expect(json[:featured_topic][:id]).to eq(featured_topic.id)
expect(json[:featured_topic][:title]).to eq(featured_topic.title)
expect(json[:featured_topic].keys).to contain_exactly(
:id,
:title,
:fancy_title,
:slug,
:posts_count,
)
end
end
end