FIX: Topic title should be included in post webhook payload.

This commit is contained in:
Guo Xiang Tan 2017-04-21 10:04:21 +08:00
parent aec73d4003
commit 8b2e3bf5f1
2 changed files with 36 additions and 12 deletions

View File

@ -1,17 +1,17 @@
class WebHookPostSerializer < PostSerializer
def include_can_edit?
false
def include_topic_title?
true
end
def can_delete
false
end
def can_recover
false
end
def can_wiki
false
%i{
can_view
can_edit
can_delete
can_recover
can_wiki
}.each do |attr|
define_method("include_#{attr}?") do
false
end
end
end

View File

@ -0,0 +1,24 @@
require 'rails_helper'
RSpec.describe WebHookPostSerializer do
let(:admin) { Fabricate(:admin) }
let(:post) { Fabricate(:post) }
let(:serializer) { WebHookPostSerializer.new(post, scope: Guardian.new(admin), root: false) }
it 'should only include the required keys' do
count = serializer.as_json.keys.count
difference = count - 40
expect(difference).to eq(0), lambda {
message = ""
if difference < 0
message << "#{difference * -1} key(s) have been removed from this serializer."
else
message << "#{difference} key(s) have been added to this serializer."
end
message << "\nPlease verify if those key(s) are required as part of the web hook's payload."
}
end
end