mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
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:
@ -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
|
||||
|
Reference in New Issue
Block a user