diff --git a/app/serializers/web_hook_post_serializer.rb b/app/serializers/web_hook_post_serializer.rb index 5d79ef5f483..31e214cecc7 100644 --- a/app/serializers/web_hook_post_serializer.rb +++ b/app/serializers/web_hook_post_serializer.rb @@ -1,4 +1,7 @@ class WebHookPostSerializer < PostSerializer + + attributes :topic_posts_count + def include_topic_title? true end @@ -14,4 +17,9 @@ class WebHookPostSerializer < PostSerializer false end end + + def topic_posts_count + object.topic ? object.topic.posts_count : 0 + end + end diff --git a/spec/serializers/web_hook_post_serializer_spec.rb b/spec/serializers/web_hook_post_serializer_spec.rb index 2f1f4870603..6190f8e27ef 100644 --- a/spec/serializers/web_hook_post_serializer_spec.rb +++ b/spec/serializers/web_hook_post_serializer_spec.rb @@ -7,7 +7,7 @@ RSpec.describe WebHookPostSerializer do it 'should only include the required keys' do count = serializer.as_json.keys.count - difference = count - 40 + difference = count - 41 expect(difference).to eq(0), lambda { message = ""