<% if post.is_pending? %>
- This post is pending approval.
- (<%= link_to_wiki "learn more", "about:mod_queue" %>)
- <% else %>
+ This post is pending approval. (<%= link_to_wiki "learn more", "about:mod_queue" %>)
+ <% elsif post.is_flagged? %>
This post was flagged and is pending approval (<%= link_to_wiki "learn more", "about:mod_queue" %>)
+ <% elsif post.is_appealed? %>
+ This post was appealed and is pending approval (<%= link_to_wiki "learn more", "about:mod_queue" %>)
<% end %>
<%= render "post_disapprovals/counts", :disapprovals => post.disapprovals, :post => post %>
@@ -48,7 +49,8 @@
<% end %>
-<% if (post.is_flagged? || post.is_deleted?) && post.appeals.any? %>
+<% #XXX %>
+<% if post.is_deleted? && post.appeals.any? %>
This post was appealed:
<%= render "post_appeals/reasons", appeals: post.appeals %>
diff --git a/app/views/posts/partials/show/_options.html.erb b/app/views/posts/partials/show/_options.html.erb
index e55116e2f..d071f7bb6 100644
--- a/app/views/posts/partials/show/_options.html.erb
+++ b/app/views/posts/partials/show/_options.html.erb
@@ -51,25 +51,24 @@
<% if post.is_status_locked? %>
Status locked
<% else %>
- <% if (!post.is_deleted? && !post.is_pending? && !post.is_flagged?) && policy(PostFlag).create? %>
+ <% if post.is_active? && policy(PostFlag).create? %>
<%= link_to "Flag", new_post_flag_path(post_flag: { post_id: post.id }), remote: true %>
- <% elsif (post.is_flagged? || post.is_deleted?) && policy(PostAppeal).create? %>
+ <% elsif post.is_appealable? && policy(PostAppeal).create? %>
<%= link_to "Appeal", new_post_appeal_path(post_appeal: { post_id: post.id }), remote: true %>
<% end %>
<% if policy(PostApproval).create? %>
- <% if post.is_deleted? %>
-
<%= link_to "Undelete", post_approvals_path(post_id: post.id), remote: true, method: :post, "data-confirm": "Are you sure you want to undelete this post?" %>
- <% if policy(post).move_favorites? %>
-
<%= link_to "Move favorites", confirm_move_favorites_moderator_post_post_path(post_id: post.id) %>
- <% end %>
- <% elsif policy(post).delete? %>
-
<%= link_to "Delete", post, method: :delete, remote: true %>
+ <% if post.is_approvable? %>
+
<%= link_to (post.is_deleted? ? "Undelete" : "Approve"), post_approvals_path(post_id: post.id), remote: true, method: :post, "data-shortcut": "shift+o", "data-confirm": "Are you sure you want to approve this post?" %>
+
<%= link_to "Hide from queue", post_disapprovals_path(post_disapproval: { post_id: post.id, reason: "disinterest" }), remote: true, method: :post %>
<% end %>
- <% if post.is_approvable? && !post.is_deleted? %>
-
<%= link_to "Approve", post_approvals_path(post_id: post.id), remote: true, method: :post, id: "approve", "data-shortcut": "shift+o", "data-confirm": "Are you sure you want to approve this post?" %>
-
<%= link_to "Hide from queue", post_disapprovals_path(post_disapproval: { post_id: post.id, reason: "disinterest" }), remote: true, method: :post, id: "disapprove" %>
+ <% if post.is_deleted? && policy(post).move_favorites? %>
+
<%= link_to "Move favorites", confirm_move_favorites_moderator_post_post_path(post_id: post.id) %>
+ <% end %>
+
+ <% if !post.is_deleted? && policy(post).delete? %>
+
<%= link_to "Delete", post, method: :delete, remote: true %>
<% end %>
<% if policy(post).unban? %>
diff --git a/db/migrate/20200803022359_add_status_to_post_appeals_and_flags.rb b/db/migrate/20200803022359_add_status_to_post_appeals_and_flags.rb
new file mode 100644
index 000000000..fd2420b67
--- /dev/null
+++ b/db/migrate/20200803022359_add_status_to_post_appeals_and_flags.rb
@@ -0,0 +1,9 @@
+class AddStatusToPostAppealsAndFlags < ActiveRecord::Migration[6.0]
+ def change
+ add_column :post_appeals, :status, :integer, default: 0, null: false
+ add_index :post_appeals, :status
+
+ add_column :post_flags, :status, :integer, default: 0, null: false
+ add_index :post_flags, :status
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index c8e7ff934..e600fba4c 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -2584,7 +2584,8 @@ CREATE TABLE public.post_appeals (
creator_id integer NOT NULL,
reason text,
created_at timestamp without time zone NOT NULL,
- updated_at timestamp without time zone NOT NULL
+ updated_at timestamp without time zone NOT NULL,
+ status integer DEFAULT 0 NOT NULL
);
@@ -2684,7 +2685,8 @@ CREATE TABLE public.post_flags (
reason text,
is_resolved boolean DEFAULT false NOT NULL,
created_at timestamp without time zone NOT NULL,
- updated_at timestamp without time zone NOT NULL
+ updated_at timestamp without time zone NOT NULL,
+ status integer DEFAULT 0 NOT NULL
);
@@ -6622,6 +6624,13 @@ CREATE INDEX index_post_appeals_on_post_id ON public.post_appeals USING btree (p
CREATE INDEX index_post_appeals_on_reason_tsvector ON public.post_appeals USING gin (to_tsvector('english'::regconfig, reason));
+--
+-- Name: index_post_appeals_on_status; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_post_appeals_on_status ON public.post_appeals USING btree (status);
+
+
--
-- Name: index_post_approvals_on_post_id; Type: INDEX; Schema: public; Owner: -
--
@@ -6671,6 +6680,13 @@ CREATE INDEX index_post_flags_on_post_id ON public.post_flags USING btree (post_
CREATE INDEX index_post_flags_on_reason_tsvector ON public.post_flags USING gin (to_tsvector('english'::regconfig, reason));
+--
+-- Name: index_post_flags_on_status; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_post_flags_on_status ON public.post_flags USING btree (status);
+
+
--
-- Name: index_post_replacements_on_creator_id; Type: INDEX; Schema: public; Owner: -
--
@@ -7393,6 +7409,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20200325074859'),
('20200403210353'),
('20200406054838'),
-('20200427190519');
+('20200427190519'),
+('20200803022359');
diff --git a/script/fixes/066_initialize_appeal_and_flag_statuses.rb b/script/fixes/066_initialize_appeal_and_flag_statuses.rb
new file mode 100755
index 000000000..c48e7079a
--- /dev/null
+++ b/script/fixes/066_initialize_appeal_and_flag_statuses.rb
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+
+require_relative "../../config/environment"
+
+PostFlag.transaction do
+ # Mark all old flags and appeals as succeeded or rejected. Recent flags and
+ # appeals are left as pending. This is not strictly correct for posts that
+ # may have been flagged or appealed multiple times.
+ PostAppeal.expired.where(post: Post.undeleted).update_all(status: "succeeded")
+ PostAppeal.expired.where(post: Post.deleted).update_all(status: "rejected")
+ PostFlag.where(post: Post.undeleted).update_all(status: "rejected")
+ PostFlag.where(post: Post.deleted).update_all(status: "succeeded")
+
+ # Mark all unapproved in three days flags as successful.
+ PostFlag.category_matches("deleted").update_all(status: "succeeded")
+
+ # Mark all currently flagged posts as pending.
+ PostFlag.where(post: Post.flagged).update_all(status: "pending")
+
+ puts "Appeals pending: #{PostAppeal.pending.count}"
+ puts "Appeals succeeded: #{PostAppeal.succeeded.count}"
+ puts "Appeals rejected: #{PostAppeal.rejected.count}"
+ puts "Flags pending: #{PostFlag.pending.count}"
+ puts "Flags succeeded: #{PostFlag.succeeded.count}"
+ puts "Flags rejected: #{PostFlag.rejected.count}"
+end
diff --git a/test/factories/post_flag.rb b/test/factories/post_flag.rb
index ed7c3d942..baf373052 100644
--- a/test/factories/post_flag.rb
+++ b/test/factories/post_flag.rb
@@ -1,7 +1,7 @@
FactoryBot.define do
factory(:post_flag) do
creator
- post
+ post { build(:post, is_flagged: true) }
reason {"xxx"}
is_resolved {false}
end
diff --git a/test/functional/modqueue_controller_test.rb b/test/functional/modqueue_controller_test.rb
index 9ab23dc88..8312ea051 100644
--- a/test/functional/modqueue_controller_test.rb
+++ b/test/functional/modqueue_controller_test.rb
@@ -13,6 +13,14 @@ class ModqueueControllerTest < ActionDispatch::IntegrationTest
get_auth modqueue_index_path, @admin
assert_response :success
end
+
+ should "include appealed posts in the modqueue" do
+ @appeal = create(:post_appeal)
+ get_auth modqueue_index_path, @admin
+
+ assert_response :success
+ assert_select "#post-#{@appeal.post_id}"
+ end
end
end
end
diff --git a/test/functional/post_appeals_controller_test.rb b/test/functional/post_appeals_controller_test.rb
index faa5982de..a8dcc1607 100644
--- a/test/functional/post_appeals_controller_test.rb
+++ b/test/functional/post_appeals_controller_test.rb
@@ -48,14 +48,54 @@ class PostAppealsControllerTest < ActionDispatch::IntegrationTest
end
context "create action" do
- setup do
- @post = as(@user) { create(:post, is_deleted: true) }
+ context "appealing a deleted post" do
+ should "create a new appeal" do
+ @post = create(:post, is_deleted: true)
+
+ assert_difference("PostAppeal.count", 1) do
+ post_auth post_appeals_path, @user, params: { post_appeal: { post_id: @post.id, reason: "xxx" }}, as: :json
+ end
+
+ assert_response :success
+ end
end
- should "create a new appeal" do
- assert_difference("PostAppeal.count", 1) do
- post_auth post_appeals_path, @user, params: {:format => "js", :post_appeal => {:post_id => @post.id, :reason => "xxx"}}
- assert_response :success
+ context "appealing a flagged post" do
+ should "fail" do
+ @flag = create(:post_flag)
+
+ assert_no_difference("PostAppeal.count") do
+ post_auth post_appeals_path, @user, params: { post_appeal: { post_id: @flag.post.id, reason: "xxx" }}, as: :json
+ end
+
+ assert_response 422
+ assert_equal(["cannot be appealed"], response.parsed_body.dig("errors", "post"))
+ end
+ end
+
+ context "appealing a pending post" do
+ should "fail" do
+ @post = create(:post, is_pending: true)
+
+ assert_no_difference("PostAppeal.count") do
+ post_auth post_appeals_path, @user, params: { post_appeal: { post_id: @post.id, reason: "xxx" }}, as: :json
+ end
+
+ assert_response 422
+ assert_equal(["cannot be appealed"], response.parsed_body.dig("errors", "post"))
+ end
+ end
+
+ context "appealing an already appealed post" do
+ should "fail" do
+ @appeal = create(:post_appeal)
+
+ assert_no_difference("PostAppeal.count") do
+ post_auth post_appeals_path, @user, params: { post_appeal: { post_id: @appeal.post.id, reason: "xxx" }}, as: :json
+ end
+
+ assert_response 422
+ assert_equal(["cannot be appealed"], response.parsed_body.dig("errors", "post"))
end
end
end
diff --git a/test/functional/post_approvals_controller_test.rb b/test/functional/post_approvals_controller_test.rb
index e4b93c65f..813cf62ef 100644
--- a/test/functional/post_approvals_controller_test.rb
+++ b/test/functional/post_approvals_controller_test.rb
@@ -27,6 +27,29 @@ class PostApprovalsControllerTest < ActionDispatch::IntegrationTest
end
end
+ context "for an appealed post" do
+ should "undelete the post and mark the appeal as successful" do
+ @appeal = create(:post_appeal)
+ post_auth post_approvals_path(post_id: @appeal.post_id, format: :js), @approver
+
+ assert_response :success
+ assert_equal(false, @appeal.reload.post.is_deleted?)
+ assert_equal(true, @appeal.succeeded?)
+ end
+ end
+
+ context "for a flagged post" do
+ should "approve the post and mark the flag as rejected" do
+ @flag = create(:post_flag)
+ post_auth post_approvals_path(post_id: @flag.post_id, format: :js), @approver
+
+ assert_response :success
+ assert_equal(false, @flag.reload.post.is_deleted?)
+ assert_equal(false, @flag.post.is_flagged?)
+ assert_equal(true, @flag.rejected?)
+ end
+ end
+
should "not allow non-approvers to approve posts" do
@post = create(:post, is_pending: true)
post_auth post_approvals_path(post_id: @post.id, format: :js), create(:user)
diff --git a/test/functional/post_events_controller_test.rb b/test/functional/post_events_controller_test.rb
index af3f42b9b..623b9d2c1 100644
--- a/test/functional/post_events_controller_test.rb
+++ b/test/functional/post_events_controller_test.rb
@@ -10,6 +10,7 @@ class PostEventsControllerTest < ActionDispatch::IntegrationTest
as(@user) do
@post = create(:post)
@post.flag!("aaa")
+ @post.update(is_deleted: true)
create(:post_appeal, post: @post)
@post.approve!(@mod)
end
diff --git a/test/functional/posts_controller_test.rb b/test/functional/posts_controller_test.rb
index f3aeb2826..e70c2d358 100644
--- a/test/functional/posts_controller_test.rb
+++ b/test/functional/posts_controller_test.rb
@@ -483,7 +483,7 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
create(:note, post: @post)
create(:artist_commentary, post: @post)
create(:post_flag, post: @post, creator: @user)
- create(:post_appeal, post: @post, creator: @user)
+ #create(:post_appeal, post: @post, creator: @user)
create(:post_vote, post: @post, user: @user)
create(:favorite, post: @post, user: @user)
create(:moderation_report, model: @comment, creator: @builder)
@@ -667,7 +667,6 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
assert_response :success
assert_equal(false, @post.is_deleted?)
end
-
end
context "revert action" do
diff --git a/test/unit/post_appeal_test.rb b/test/unit/post_appeal_test.rb
index ef0b9c27f..a37906ce2 100644
--- a/test/unit/post_appeal_test.rb
+++ b/test/unit/post_appeal_test.rb
@@ -32,7 +32,7 @@ class PostAppealTest < ActiveSupport::TestCase
@post_appeal = build(:post_appeal, post: @post, creator: @alice)
assert_equal(false, @post_appeal.valid?)
- assert_equal(["Post is active"], @post_appeal.errors.full_messages)
+ assert_equal(["Post cannot be appealed"], @post_appeal.errors.full_messages)
end
end
end
diff --git a/test/unit/post_event_test.rb b/test/unit/post_event_test.rb
index 460414504..46072a443 100644
--- a/test/unit/post_event_test.rb
+++ b/test/unit/post_event_test.rb
@@ -5,6 +5,7 @@ class PostEventTest < ActiveSupport::TestCase
@user = create(:user, created_at: 2.weeks.ago)
@post = create(:post)
@post_flag = create(:post_flag, creator: @user, post: @post)
+ @post.update(is_deleted: true)
@post_appeal = create(:post_appeal, creator: @user, post: @post)
end
diff --git a/test/unit/post_flag_test.rb b/test/unit/post_flag_test.rb
index a59a0eb49..ced0cbc36 100644
--- a/test/unit/post_flag_test.rb
+++ b/test/unit/post_flag_test.rb
@@ -53,7 +53,7 @@ class PostFlagTest < ActiveSupport::TestCase
@post_flag = build(:post_flag, post: @post, creator: @bob)
@post_flag.save
- assert_equal(["Post is deleted"], @post_flag.errors.full_messages)
+ assert_equal(["Post is deleted and cannot be flagged"], @post_flag.errors.full_messages)
end
should "not be able to flag a pending post" do
diff --git a/test/unit/post_pruner_test.rb b/test/unit/post_pruner_test.rb
index 09e491fa7..dd288eca0 100644
--- a/test/unit/post_pruner_test.rb
+++ b/test/unit/post_pruner_test.rb
@@ -1,30 +1,108 @@
require 'test_helper'
class PostPrunerTest < ActiveSupport::TestCase
- def setup
- @old_post = FactoryBot.create(:post, :created_at => 5.days.ago, :is_pending => true)
- @unresolved_flagged_post = FactoryBot.create(:post, :is_flagged => true)
- @resolved_flagged_post = FactoryBot.create(:post, :is_flagged => true)
+ context "PostPruner" do
+ context "for a pending post" do
+ should "prune expired posts" do
+ @post = create(:post, created_at: 5.days.ago, is_pending: true)
+ PostPruner.prune!
- @flagger = create(:gold_user, created_at: 2.weeks.ago)
- @unresolved_post_flag = create(:post_flag, creator: @flagger, created_at: 5.days.ago, is_resolved: false, post: @unresolved_flagged_post)
- @resolved_post_flag = create(:post_flag, creator: @flagger, created_at: 5.days.ago, is_resolved: true, post: @resolved_flagged_post)
+ assert_equal(true, @post.reload.is_deleted?)
+ assert_equal(false, @post.is_pending?)
- PostPruner.new.prune!
- end
+ assert_equal(1, @post.flags.size)
+ assert_equal("Unapproved in three days", @post.flags.last.reason)
+ end
+ end
- should "prune old pending posts" do
- @old_post.reload
- assert(@old_post.is_deleted?)
- end
+ context "for a flagged post" do
+ should "prune expired flags" do
+ @post = create(:post, created_at: 4.weeks.ago, is_flagged: true)
+ @flag = create(:post_flag, post: @post, created_at: 5.days.ago)
+ PostPruner.prune!
- should "prune old flagged posts that are still unresolved" do
- @unresolved_flagged_post.reload
- assert(@unresolved_flagged_post.is_deleted?)
- end
+ assert_equal(true, @post.reload.is_deleted?)
+ assert_equal(false, @post.is_pending?)
+ assert_equal(false, @post.is_flagged?)
+ assert_equal(true, @flag.reload.succeeded?)
- should "not prune old flagged posts that are resolved" do
- @resolved_flagged_post.reload
- assert(!@resolved_flagged_post.is_deleted?)
+ assert_equal(2, @post.flags.size)
+ assert_equal("Unapproved in three days after returning to moderation queue", @post.flags.last.reason)
+ end
+
+ should "not prune unexpired flags" do
+ @post = create(:post, created_at: 4.weeks.ago, is_flagged: true)
+ @flag = create(:post_flag, post: @post, created_at: 1.day.ago)
+ PostPruner.prune!
+
+ assert_equal(false, @post.reload.is_deleted?)
+ assert_equal(false, @post.is_pending?)
+ assert_equal(true, @post.is_flagged?)
+ assert_equal(true, @flag.reload.pending?)
+
+ assert_equal(1, @post.flags.size)
+ end
+
+ should "leave the status of old flags unchanged" do
+ @post = create(:post, created_at: 4.weeks.ago, is_flagged: true)
+ @flag1 = create(:post_flag, post: @post, created_at: 3.weeks.ago, status: :succeeded)
+ @flag2 = create(:post_flag, post: @post, created_at: 2.weeks.ago, status: :rejected)
+ @flag3 = create(:post_flag, post: @post, created_at: 1.weeks.ago, status: :pending)
+ PostPruner.prune!
+
+ assert_equal(true, @post.reload.is_deleted?)
+ assert_equal(false, @post.is_pending?)
+ assert_equal(false, @post.is_flagged?)
+
+ assert_equal(true, @flag1.reload.succeeded?)
+ assert_equal(true, @flag2.reload.rejected?)
+ assert_equal(true, @flag3.reload.succeeded?)
+ end
+ end
+
+ context "for an appealed post" do
+ should "prune expired appeals" do
+ @post = create(:post, created_at: 4.weeks.ago, is_deleted: true)
+ @appeal = create(:post_appeal, post: @post, created_at: 5.days.ago)
+ PostPruner.prune!
+
+ assert_equal(false, @post.reload.is_pending?)
+ assert_equal(false, @post.is_flagged?)
+ assert_equal(true, @post.is_deleted?)
+ assert_equal(true, @appeal.reload.rejected?)
+
+ assert_equal(1, @post.flags.size)
+ assert_equal("Unapproved in three days after returning to moderation queue", @post.flags.last.reason)
+ end
+
+ should "not prune unexpired appeals" do
+ @post = create(:post, created_at: 4.weeks.ago, is_deleted: true)
+ @appeal = create(:post_appeal, post: @post, created_at: 1.day.ago)
+ PostPruner.prune!
+
+ assert_equal(false, @post.reload.is_pending?)
+ assert_equal(false, @post.is_flagged?)
+ assert_equal(true, @post.is_deleted?)
+ assert_equal(true, @appeal.reload.pending?)
+
+ assert_equal(0, @post.flags.size)
+ end
+
+ should "leave the status of old appeals unchanged" do
+ @post = create(:post, created_at: 4.weeks.ago, is_deleted: true)
+ @appeal1 = create(:post_appeal, post: @post, created_at: 3.weeks.ago, status: :succeeded)
+ @appeal2 = create(:post_appeal, post: @post, created_at: 2.weeks.ago, status: :rejected)
+ @appeal3 = create(:post_appeal, post: @post, created_at: 1.weeks.ago, status: :pending)
+ PostPruner.prune!
+
+ assert_equal(true, @post.reload.is_deleted?)
+ assert_equal(false, @post.is_pending?)
+ assert_equal(false, @post.is_flagged?)
+
+ assert_equal(true, @appeal1.reload.succeeded?)
+ assert_equal(true, @appeal2.reload.rejected?)
+ assert_equal(false, @appeal3.reload.pending?)
+ end
+ end
end
end
diff --git a/test/unit/post_query_builder_test.rb b/test/unit/post_query_builder_test.rb
index 54b8ca27f..5810a9b92 100644
--- a/test/unit/post_query_builder_test.rb
+++ b/test/unit/post_query_builder_test.rb
@@ -584,22 +584,26 @@ class PostQueryBuilderTest < ActiveSupport::TestCase
flagged = create(:post, is_flagged: true)
deleted = create(:post, is_deleted: true)
banned = create(:post, is_banned: true)
- all = [banned, deleted, flagged, pending]
+ appealed = create(:post, is_deleted: true)
+ appeal = create(:post_appeal, post: appealed)
+ all = [appealed, banned, deleted, flagged, pending]
- assert_tag_match([flagged, pending], "status:modqueue")
+ assert_tag_match([appealed, flagged, pending], "status:modqueue")
assert_tag_match([pending], "status:pending")
assert_tag_match([flagged], "status:flagged")
- assert_tag_match([deleted], "status:deleted")
+ assert_tag_match([appealed], "status:appealed")
+ assert_tag_match([appealed, deleted], "status:deleted")
assert_tag_match([banned], "status:banned")
assert_tag_match([banned], "status:active")
assert_tag_match([banned], "status:active status:banned")
assert_tag_match(all, "status:any")
assert_tag_match(all, "status:all")
- assert_tag_match(all - [flagged, pending], "-status:modqueue")
+ assert_tag_match(all - [flagged, pending, appealed], "-status:modqueue")
assert_tag_match(all - [pending], "-status:pending")
assert_tag_match(all - [flagged], "-status:flagged")
- assert_tag_match(all - [deleted], "-status:deleted")
+ assert_tag_match(all - [appealed], "-status:appealed")
+ assert_tag_match(all - [deleted, appealed], "-status:deleted")
assert_tag_match(all - [banned], "-status:banned")
assert_tag_match(all - [banned], "-status:active")
@@ -611,11 +615,13 @@ class PostQueryBuilderTest < ActiveSupport::TestCase
flagged = create(:post, is_flagged: true)
pending = create(:post, is_pending: true)
disapproved = create(:post, is_pending: true)
+ appealed = create(:post, is_deleted: true)
create(:post_flag, post: flagged, creator: create(:user, created_at: 2.weeks.ago))
+ create(:post_appeal, post: appealed)
create(:post_disapproval, user: CurrentUser.user, post: disapproved, reason: "disinterest")
- assert_tag_match([pending, flagged], "status:unmoderated")
+ assert_tag_match([appealed, pending, flagged], "status:unmoderated")
assert_tag_match([disapproved], "-status:unmoderated")
end
diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb
index c65956a32..c45d83bc3 100644
--- a/test/unit/post_test.rb
+++ b/test/unit/post_test.rb
@@ -513,24 +513,23 @@ class PostTest < ActiveSupport::TestCase
end
context "A status locked post" do
- setup do
- @post = FactoryBot.create(:post, is_status_locked: true)
- end
-
should "not allow new flags" do
assert_raises(PostFlag::Error) do
+ @post = create(:post, is_status_locked: true)
@post.flag!("wrong")
end
end
should "not allow new appeals" do
+ @post = create(:post, is_status_locked: true, is_deleted: true)
@appeal = build(:post_appeal, post: @post)
assert_equal(false, @appeal.valid?)
- assert_equal(["Post is active"], @appeal.errors.full_messages)
+ assert_equal(["Post cannot be appealed"], @appeal.errors.full_messages)
end
should "not allow approval" do
+ @post = create(:post, is_status_locked: true, is_pending: true)
approval = @post.approve!
assert_includes(approval.errors.full_messages, "Post is locked and cannot be approved")
end
diff --git a/test/unit/upload_limit_test.rb b/test/unit/upload_limit_test.rb
index f58c8c95a..06127b4fb 100644
--- a/test/unit/upload_limit_test.rb
+++ b/test/unit/upload_limit_test.rb
@@ -12,7 +12,7 @@ class UploadLimitTest < ActiveSupport::TestCase
@post = create(:post, uploader: @user, is_pending: true, created_at: 7.days.ago)
assert_equal(1000, @user.reload.upload_points)
- PostPruner.new.prune!
+ PostPruner.prune!
assert_equal(967, @user.reload.upload_points)
end
end