discourse/spec/serializers/reviewable_flagged_post_serializer_spec.rb
David Taylor c9dab6fd08
DEV: Automatically require 'rails_helper' in all specs (#16077)
It's very easy to forget to add `require 'rails_helper'` at the top of every core/plugin spec file, and omissions can cause some very confusing/sporadic errors.

By setting this flag in `.rspec`, we can remove the need for `require 'rails_helper'` entirely.
2022-03-01 17:50:50 +00:00

26 lines
836 B
Ruby

# frozen_string_literal: true
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[:target_url]).to eq(Discourse.base_url + 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