mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 02:33:37 +08:00
e219588142
* Introduced fab!, a helper that creates database state for a group It's almost identical to let_it_be, except: 1. It creates a new object for each test by default, 2. You can disable it using PREFABRICATION=0
28 lines
838 B
Ruby
28 lines
838 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe ReviewableFlaggedPostSerializer do
|
|
|
|
fab!(:admin) { Fabricate(:admin) }
|
|
|
|
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
|
|
expect(json[:cooked]).to eq(p0.cooked)
|
|
expect(json[:raw]).to eq(p0.raw)
|
|
expect(json[:topic_url]).to eq(p0.url)
|
|
end
|
|
|
|
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
|
|
|
|
end
|