2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-02-26 22:28:31 -05:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe WebHookTopicViewSerializer do
|
|
|
|
let(:admin) { Fabricate(:admin) }
|
|
|
|
let(:topic) { Fabricate(:topic) }
|
|
|
|
|
|
|
|
let(:serializer) do
|
|
|
|
WebHookTopicViewSerializer.new(TopicView.new(topic),
|
|
|
|
scope: Guardian.new(admin),
|
|
|
|
root: false
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2018-10-19 02:31:17 -04:00
|
|
|
before do
|
|
|
|
SiteSetting.tagging_enabled = true
|
|
|
|
end
|
2018-02-26 22:28:31 -05:00
|
|
|
|
2018-10-19 02:31:17 -04:00
|
|
|
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
|
|
|
|
}
|
2018-02-26 22:28:31 -05:00
|
|
|
|
2018-10-19 02:31:17 -04:00
|
|
|
keys = serializer.as_json.keys
|
2018-02-26 22:28:31 -05:00
|
|
|
|
2018-10-19 02:31:17 -04:00
|
|
|
expect(serializer.as_json.keys).to contain_exactly(*expected_keys)
|
2018-02-26 22:28:31 -05:00
|
|
|
end
|
|
|
|
end
|