diff --git a/app/models/reviewable_queued_post.rb b/app/models/reviewable_queued_post.rb index 46292405ab1..a36e9f61738 100644 --- a/app/models/reviewable_queued_post.rb +++ b/app/models/reviewable_queued_post.rb @@ -173,7 +173,7 @@ class ReviewableQueuedPost < Reviewable original_post: self.payload["raw"], site_name: SiteSetting.title, } - SystemMessage.create_from_system_user( + SystemMessage.create( self.target_created_by, ( if self.topic.blank? diff --git a/spec/models/reviewable_queued_post_spec.rb b/spec/models/reviewable_queued_post_spec.rb index 5f1183055a8..bd929c0baa2 100644 --- a/spec/models/reviewable_queued_post_spec.rb +++ b/spec/models/reviewable_queued_post_spec.rb @@ -126,6 +126,14 @@ RSpec.describe ReviewableQueuedPost, type: :model do end context "with revise_and_reject_post" do + fab!(:contact_group) { Fabricate(:group) } + fab!(:contact_user) { Fabricate(:user) } + + before do + SiteSetting.site_contact_group_name = contact_group.name + SiteSetting.site_contact_username = contact_user.username + end + it "doesn't create the post the user intended" do post_count = Post.public_posts.count result = reviewable.perform(moderator, :revise_and_reject_post) @@ -156,6 +164,8 @@ RSpec.describe ReviewableQueuedPost, type: :model do original_post: reviewable.payload["raw"], site_name: SiteSetting.title, } + expect(topic.topic_allowed_users.pluck(:user_id)).to include(contact_user.id) + expect(topic.topic_allowed_groups.pluck(:group_id)).to include(contact_group.id) expect(topic.first_post.raw.chomp).to eq( I18n.t( "system_messages.reviewable_queued_post_revise_and_reject.text_body_template", @@ -175,6 +185,8 @@ RSpec.describe ReviewableQueuedPost, type: :model do } topic = Topic.where(archetype: Archetype.private_message).last + expect(topic.topic_allowed_users.pluck(:user_id)).to include(contact_user.id) + expect(topic.topic_allowed_groups.pluck(:group_id)).to include(contact_group.id) expect(topic.first_post.raw).not_to include("Other...") expect(topic.first_post.raw).to include("Boring") end diff --git a/spec/system/reviewables_spec.rb b/spec/system/reviewables_spec.rb index 203dcb74b99..af01733b90c 100644 --- a/spec/system/reviewables_spec.rb +++ b/spec/system/reviewables_spec.rb @@ -130,6 +130,14 @@ describe "Reviewables", type: :system do end context "when performing a review action from the show route" do + fab!(:contact_group) { Fabricate(:group) } + fab!(:contact_user) { Fabricate(:user) } + + before do + SiteSetting.site_contact_group_name = contact_group.name + SiteSetting.site_contact_username = contact_user.username + end + context "with a ReviewableQueuedPost" do fab!(:queued_post_reviewable) { Fabricate(:reviewable_queued_post) } @@ -170,7 +178,11 @@ describe "Reviewables", type: :system do expect(review_page).to have_reviewable_with_rejected_status(queued_post_reviewable) expect(queued_post_reviewable.reload).to be_rejected - expect(Topic.where(archetype: Archetype.private_message).last.title).to eq( + + topic = Topic.where(archetype: Archetype.private_message).last + expect(topic.topic_allowed_users.pluck(:user_id)).to include(contact_user.id) + expect(topic.topic_allowed_groups.pluck(:group_id)).to include(contact_group.id) + expect(topic.title).to eq( I18n.t( "system_messages.reviewable_queued_post_revise_and_reject.subject_template", topic_title: queued_post_reviewable.topic.title,