posts: remove unused appeal! method.
This commit is contained in:
@@ -276,18 +276,6 @@ class Post < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def appeal!(reason)
|
|
||||||
if is_status_locked?
|
|
||||||
raise PostAppeal::Error.new("Post is locked and cannot be appealed")
|
|
||||||
end
|
|
||||||
|
|
||||||
appeal = appeals.create(:reason => reason)
|
|
||||||
|
|
||||||
if appeal.errors.any?
|
|
||||||
raise PostAppeal::Error.new(appeal.errors.full_messages.join("; "))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def approve!(approver = CurrentUser.user)
|
def approve!(approver = CurrentUser.user)
|
||||||
approvals.create(user: approver)
|
approvals.create(user: approver)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -127,14 +127,10 @@ module Moderator
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "for appeals" do
|
context "for appeals" do
|
||||||
setup do
|
|
||||||
as(@user) do
|
|
||||||
@post = create(:post, :is_deleted => true)
|
|
||||||
@post.appeal!("blah")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
|
@post = create(:post, is_deleted: true)
|
||||||
|
@appeal = create(:post_appeal, post: @post)
|
||||||
|
|
||||||
get_auth moderator_dashboard_path, @admin
|
get_auth moderator_dashboard_path, @admin
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class PostEventsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
as_user do
|
as_user do
|
||||||
@post = create(:post)
|
@post = create(:post)
|
||||||
@post.flag!("aaa")
|
@post.flag!("aaa")
|
||||||
@post.appeal!("aaa")
|
create(:post_appeal, post: @post)
|
||||||
@post.approve!(@mod)
|
@post.approve!(@mod)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -482,9 +482,7 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "be appealed" do
|
should "be appealed" do
|
||||||
assert_difference("PostAppeal.count", 1) do
|
create(:post_appeal, post: @post)
|
||||||
@post.appeal!("xxx")
|
|
||||||
end
|
|
||||||
assert(@post.is_deleted?, "Post should still be deleted")
|
assert(@post.is_deleted?, "Post should still be deleted")
|
||||||
assert_equal(1, @post.appeals.count)
|
assert_equal(1, @post.appeals.count)
|
||||||
end
|
end
|
||||||
@@ -561,9 +559,10 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "not allow new appeals" do
|
should "not allow new appeals" do
|
||||||
assert_raises(PostAppeal::Error) do
|
@appeal = build(:post_appeal, post: @post)
|
||||||
@post.appeal!("wrong")
|
|
||||||
end
|
assert_equal(false, @appeal.valid?)
|
||||||
|
assert_equal(["Post is active"], @appeal.errors.full_messages)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not allow approval" do
|
should "not allow approval" do
|
||||||
|
|||||||
Reference in New Issue
Block a user