mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 10:33:43 +08:00
Merge pull request #5510 from discourse/add-posts-count-to-web-hook-post-serializer
Feature: add topic posts count to webhook post serializer
This commit is contained in:
commit
80c41a0e59
|
@ -1,4 +1,7 @@
|
||||||
class WebHookPostSerializer < PostSerializer
|
class WebHookPostSerializer < PostSerializer
|
||||||
|
|
||||||
|
attributes :topic_posts_count
|
||||||
|
|
||||||
def include_topic_title?
|
def include_topic_title?
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
@ -14,4 +17,9 @@ class WebHookPostSerializer < PostSerializer
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def topic_posts_count
|
||||||
|
object.topic ? object.topic.posts_count : 0
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,7 @@ RSpec.describe WebHookPostSerializer do
|
||||||
|
|
||||||
it 'should only include the required keys' do
|
it 'should only include the required keys' do
|
||||||
count = serializer.as_json.keys.count
|
count = serializer.as_json.keys.count
|
||||||
difference = count - 40
|
difference = count - 41
|
||||||
|
|
||||||
expect(difference).to eq(0), lambda {
|
expect(difference).to eq(0), lambda {
|
||||||
message = ""
|
message = ""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user