Merge pull request #3701 from evazion/fix-3579
Fix #3579: Add post approval index
This commit is contained in:
6
test/factories/post_approval.rb
Normal file
6
test/factories/post_approval.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
FactoryBot.define do
|
||||
factory(:post_approval) do
|
||||
user factory: :moderator_user
|
||||
post factory: :post, is_pending: true
|
||||
end
|
||||
end
|
||||
16
test/functional/post_approvals_controller_test.rb
Normal file
16
test/functional/post_approvals_controller_test.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
require 'test_helper'
|
||||
|
||||
class PostApprovalsControllerTest < ActionDispatch::IntegrationTest
|
||||
context "The post approvals controller" do
|
||||
setup do
|
||||
@approval = FactoryBot.create(:post_approval)
|
||||
end
|
||||
|
||||
context "index action" do
|
||||
should "render" do
|
||||
get post_approvals_path
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -9,15 +9,16 @@ class PostEventsControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
as_user do
|
||||
@post = create(:post)
|
||||
@post_flag = PostFlag.create(:post => @post, :reason => "aaa", :is_resolved => false)
|
||||
@post_appeal = PostAppeal.create(:post => @post, :reason => "aaa")
|
||||
@post.flag!("aaa")
|
||||
@post.appeal!("aaa")
|
||||
@post.approve!(@mod)
|
||||
end
|
||||
end
|
||||
|
||||
context "get /posts/:post_id/events" do
|
||||
should "render" do
|
||||
get_auth post_events_path(post_id: @post.id), @user
|
||||
assert_response :ok
|
||||
assert_response :ok
|
||||
end
|
||||
|
||||
should "render for mods" do
|
||||
|
||||
@@ -7,7 +7,7 @@ class PostApprovalTest < ActiveSupport::TestCase
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
|
||||
@post = FactoryBot.create(:post, uploader_id: @user.id, is_pending: true)
|
||||
@post = FactoryBot.create(:post, uploader_id: @user.id, tag_string: "touhou", is_pending: true)
|
||||
|
||||
@approver = FactoryBot.create(:user)
|
||||
@approver.can_approve_posts = true
|
||||
@@ -58,5 +58,14 @@ class PostApprovalTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "#search method" do
|
||||
should "work" do
|
||||
@approval = @post.approve!(@approver)
|
||||
@approvals = PostApproval.search(user_name: @approver.name, post_tags_match: "touhou", post_id: @post.id)
|
||||
|
||||
assert_equal([@approval.id], @approvals.map(&:id))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user