mirror of
https://github.com/discourse/discourse.git
synced 2025-03-31 18:55:58 +08:00
DEV: Improve specs to provide a better error message.
This commit is contained in:
parent
9bfc939692
commit
65faff5832
@ -11,20 +11,47 @@ RSpec.describe WebHookTopicViewSerializer do
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should only include the required keys' do
|
before do
|
||||||
count = serializer.as_json.keys.count
|
SiteSetting.tagging_enabled = true
|
||||||
difference = count - 30
|
end
|
||||||
|
|
||||||
expect(difference).to eq(0), lambda {
|
it 'should only include the keys that are sent out in the webhook' do
|
||||||
message = ""
|
expected_keys = %i{
|
||||||
|
id
|
||||||
if difference < 0
|
title
|
||||||
message << "#{difference * -1} key(s) have been removed from this serializer."
|
fancy_title
|
||||||
else
|
posts_count
|
||||||
message << "#{difference} key(s) have been added to this serializer."
|
created_at
|
||||||
end
|
views
|
||||||
|
reply_count
|
||||||
message << "\nPlease verify if those key(s) are required as part of the web hook's payload."
|
like_count
|
||||||
|
last_posted_at
|
||||||
|
visible
|
||||||
|
closed
|
||||||
|
archived
|
||||||
|
archetype
|
||||||
|
slug
|
||||||
|
category_id
|
||||||
|
word_count
|
||||||
|
deleted_at
|
||||||
|
user_id
|
||||||
|
featured_link
|
||||||
|
pinned_globally
|
||||||
|
pinned_at
|
||||||
|
pinned_until
|
||||||
|
unpinned
|
||||||
|
pinned
|
||||||
|
highest_post_number
|
||||||
|
deleted_by
|
||||||
|
bookmarked
|
||||||
|
participant_count
|
||||||
|
created_by
|
||||||
|
last_poster
|
||||||
|
tags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
keys = serializer.as_json.keys
|
||||||
|
|
||||||
|
expect(serializer.as_json.keys).to contain_exactly(*expected_keys)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user