mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 15:25:35 +08:00
DEV: Set topic list filter name in serializer for children (#29291)
This commit is contained in:
parent
1a66556f1a
commit
201c174b43
|
@ -14,6 +14,11 @@ class TopicListSerializer < ApplicationSerializer
|
|||
has_many :tags, serializer: TagSerializer, embed: :objects
|
||||
has_many :categories, serializer: CategoryBadgeSerializer, embed: :objects
|
||||
|
||||
def initialize(object, options = {})
|
||||
super
|
||||
options[:filter] = object.filter
|
||||
end
|
||||
|
||||
def can_create_topic
|
||||
scope.can_create?(Topic)
|
||||
end
|
||||
|
|
|
@ -14,4 +14,13 @@ RSpec.describe TopicListSerializer do
|
|||
expect(serialized[:primary_groups]).to eq([])
|
||||
expect(serialized[:topic_list][:topics].first[:id]).to eq(topic.id)
|
||||
end
|
||||
|
||||
it "adds filter name to the options hash so childrens can access it" do
|
||||
filter = :hot
|
||||
topic_list = TopicList.new(filter, user, [topic])
|
||||
|
||||
serializer = described_class.new(topic_list, scope: Guardian.new(user))
|
||||
|
||||
expect(serializer.options[:filter]).to eq(filter)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user