diff --git a/app/views/moderation_reports/new.html.erb b/app/views/moderation_reports/new.html.erb
new file mode 100644
index 000000000..70ebcbda7
--- /dev/null
+++ b/app/views/moderation_reports/new.html.erb
@@ -0,0 +1,5 @@
+
+
+ <%= render "moderation_reports/new", moderation_report: @moderation_report %>
+
+
diff --git a/test/factories/moderation_report.rb b/test/factories/moderation_report.rb
new file mode 100644
index 000000000..55cdbaa78
--- /dev/null
+++ b/test/factories/moderation_report.rb
@@ -0,0 +1,5 @@
+FactoryBot.define do
+ factory(:moderation_report) do
+ reason {"xxx"}
+ end
+end
diff --git a/test/functional/moderation_reports_controller_test.rb b/test/functional/moderation_reports_controller_test.rb
new file mode 100644
index 000000000..3d18bc445
--- /dev/null
+++ b/test/functional/moderation_reports_controller_test.rb
@@ -0,0 +1,66 @@
+require 'test_helper'
+
+class ModerationReportsControllerTest < ActionDispatch::IntegrationTest
+ context "The moderation reports controller" do
+ setup do
+ travel_to(2.weeks.ago) do
+ @user = create(:user)
+ @builder = create(:builder_user)
+ @mod = create(:moderator_user)
+ end
+
+ @user.as_current do
+ @comment = create(:comment)
+ end
+ end
+
+ context "new action" do
+ should "render the access denied page" do
+ get_auth new_moderation_report_path, @user
+ assert_response 403
+ assert_select "h1", /Access Denied/
+ end
+
+ should "render" do
+ get_auth new_moderation_report_path, @mod, params: {:moderation_report => {:model_id => @comment.id, :model_type => "Comment"}}
+ assert_response :success
+ end
+ end
+
+ context "index action" do
+ setup do
+ @builder.as_current do
+ create(:moderation_report, model: @comment)
+ end
+ end
+
+ should "render the access denied page" do
+ get_auth moderation_reports_path, @builder
+ assert_response 403
+ assert_select "h1", /Access Denied/
+ end
+
+ should "render" do
+ get_auth moderation_reports_path, @mod
+ assert_response :success
+ end
+
+ context "with search parameters" do
+ should "render" do
+ get_auth moderation_reports_path, @mod, params: {:search => {:model_id => @comment.id}}
+ assert_response :success
+ end
+ end
+
+ context "create action" do
+ should "create a new moderation report" do
+ assert_difference("ModerationReport.count", 1) do
+ assert_difference("ModerationReport.count") do
+ post_auth moderation_reports_path, @builder, params: {:format => "js", :moderation_report => {:model_id => @comment.id, :model_type => "Comment", :reason => "xxx"}}
+ end
+ end
+ end
+ end
+ end
+ end
+end