mod reports: remove use of belongs_to_creator macro.

Remove use of belongs_to_creator macro as per b4ce2d83a.
This commit is contained in:
evazion
2020-01-21 00:23:45 -06:00
parent b5603f0d39
commit f2f236c23a
3 changed files with 7 additions and 8 deletions

View File

@@ -16,7 +16,7 @@ class ModerationReportsController < ApplicationController
def create def create
check_privilege check_privilege
@moderation_report = ModerationReport.create(moderation_report_params) @moderation_report = ModerationReport.create(moderation_report_params.merge(creator: CurrentUser.user))
respond_with(@moderation_report) respond_with(@moderation_report)
end end

View File

@@ -1,6 +1,6 @@
class ModerationReport < ApplicationRecord class ModerationReport < ApplicationRecord
belongs_to :model, polymorphic: true belongs_to :model, polymorphic: true
belongs_to_creator belongs_to :creator, class_name: "User"
validates :reason, presence: true validates :reason, presence: true
after_create :create_forum_post! after_create :create_forum_post!
@@ -21,8 +21,9 @@ class ModerationReport < ApplicationRecord
def forum_topic def forum_topic
topic = ForumTopic.find_by_title(forum_topic_title) topic = ForumTopic.find_by_title(forum_topic_title)
if topic.nil? if topic.nil?
topic = CurrentUser.as_system do CurrentUser.as_system do
ForumTopic.create(title: forum_topic_title, category_id: 0, min_level: User::Levels::MODERATOR, original_post_attributes: {body: forum_topic_body}) topic = ForumTopic.create!(creator: User.system, title: forum_topic_title, category_id: 0, min_level: User::Levels::MODERATOR)
forum_post = ForumPost.create!(creator: User.system, body: forum_topic_body, topic: topic)
end end
end end
topic topic

View File

@@ -10,7 +10,7 @@ class ModerationReportsControllerTest < ActionDispatch::IntegrationTest
end end
@user.as_current do @user.as_current do
@comment = create(:comment) @comment = create(:comment, creator: @user)
end end
end end
@@ -29,9 +29,7 @@ class ModerationReportsControllerTest < ActionDispatch::IntegrationTest
context "index action" do context "index action" do
setup do setup do
@builder.as_current do create(:moderation_report, model: @comment, creator: @builder)
create(:moderation_report, model: @comment)
end
end end
should "render the access denied page" do should "render the access denied page" do