2019-04-30 08:27:42 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-28 10:27:38 +08:00
|
|
|
RSpec.describe ReviewableFlaggedPostSerializer do
|
2023-11-10 06:47:59 +08:00
|
|
|
fab!(:admin)
|
2019-04-02 02:28:57 +08:00
|
|
|
|
|
|
|
it "includes the user fields for review" do
|
|
|
|
p0 = Fabricate(:post)
|
2023-12-13 17:18:42 +08:00
|
|
|
reviewable = PostActionCreator.spam(Fabricate(:user, refresh_auto_groups: true), p0).reviewable
|
2019-04-02 02:28:57 +08:00
|
|
|
json =
|
|
|
|
ReviewableFlaggedPostSerializer.new(reviewable, scope: Guardian.new(admin), root: nil).as_json
|
2019-04-02 07:43:13 +08:00
|
|
|
expect(json[:cooked]).to eq(p0.cooked)
|
|
|
|
expect(json[:raw]).to eq(p0.raw)
|
2019-11-15 08:20:45 +08:00
|
|
|
expect(json[:target_url]).to eq(Discourse.base_url + p0.url)
|
2023-09-05 10:11:39 +08:00
|
|
|
expect(json[:created_from_flag]).to eq(true)
|
2019-04-02 02:28:57 +08:00
|
|
|
end
|
|
|
|
|
2019-04-02 21:36:25 +08: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-02 02:28:57 +08:00
|
|
|
end
|