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

@ -352,4 +352,25 @@ RSpec.describe CurrentUserSerializer do
expect(initial_count).to eq(final_count)
end
end
describe "#featured_topic" do
fab!(:featured_topic) { Fabricate(:topic) }
before { user.user_profile.update!(featured_topic_id: featured_topic.id) }
it "includes the featured topic" do
payload = serializer.as_json
expect(payload[:featured_topic]).to_not be_nil
expect(payload[:featured_topic][:id]).to eq(featured_topic.id)
expect(payload[:featured_topic][:title]).to eq(featured_topic.title)
expect(payload[:featured_topic].keys).to contain_exactly(
:id,
:title,
:fancy_title,
:slug,
:posts_count,
)
end
end
end