mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 15:25:35 +08:00
6e161d3e75
The most common thing that we do with fab! is: fab!(:thing) { Fabricate(:thing) } This commit adds a shorthand for this which is just simply: fab!(:thing) i.e. If you omit the block, then, by default, you'll get a `Fabricate`d object using the fabricator of the same name.
59 lines
1.2 KiB
Ruby
59 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe WebHookTopicViewSerializer do
|
|
fab!(:admin)
|
|
fab!(:topic)
|
|
|
|
let(:serializer) do
|
|
WebHookTopicViewSerializer.new(TopicView.new(topic), scope: Guardian.new(admin), root: false)
|
|
end
|
|
|
|
before { SiteSetting.tagging_enabled = true }
|
|
|
|
it "should only include the keys that are sent out in the webhook" do
|
|
expected_keys = %i[
|
|
id
|
|
title
|
|
fancy_title
|
|
posts_count
|
|
created_at
|
|
views
|
|
reply_count
|
|
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
|
|
tags_descriptions
|
|
thumbnails
|
|
]
|
|
|
|
keys = serializer.as_json.keys
|
|
|
|
expect(serializer.as_json.keys).to contain_exactly(*expected_keys)
|
|
|
|
topic.external_id = "external_id"
|
|
expected_keys << :external_id
|
|
expect(serializer.as_json.keys).to contain_exactly(*expected_keys)
|
|
end
|
|
end
|