2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-04-01 14:28:57 -04:00
|
|
|
describe ReviewableFlaggedPostSerializer do
|
|
|
|
|
2019-05-06 23:12:20 -04:00
|
|
|
fab!(:admin) { Fabricate(:admin) }
|
2019-04-01 14:28:57 -04:00
|
|
|
|
|
|
|
it "includes the user fields for review" do
|
|
|
|
p0 = Fabricate(:post)
|
|
|
|
reviewable = PostActionCreator.spam(Fabricate(:user), p0).reviewable
|
|
|
|
json = ReviewableFlaggedPostSerializer.new(reviewable, scope: Guardian.new(admin), root: nil).as_json
|
2019-04-01 19:43:13 -04:00
|
|
|
expect(json[:cooked]).to eq(p0.cooked)
|
|
|
|
expect(json[:raw]).to eq(p0.raw)
|
2019-11-14 19:20:45 -05:00
|
|
|
expect(json[:target_url]).to eq(Discourse.base_url + p0.url)
|
2019-04-01 14:28:57 -04:00
|
|
|
end
|
|
|
|
|
2019-04-02 09:36:25 -04:00
|
|
|
it "works when the topic is deleted" do
|
|
|
|
reviewable = Fabricate(:reviewable_queued_post)
|
|
|
|
reviewable.topic.update(deleted_at: Time.now)
|
|
|
|
reviewable.reload
|
|
|
|
|
|
|
|
json = ReviewableQueuedPostSerializer.new(reviewable, scope: Guardian.new(admin), root: nil).as_json
|
|
|
|
expect(json[:id]).to be_present
|
|
|
|
end
|
|
|
|
|
2019-04-01 14:28:57 -04:00
|
|
|
end
|