test: fix broken tests.
This commit is contained in:
@@ -63,6 +63,6 @@ module TagRelationshipRetirementService
|
||||
end
|
||||
|
||||
def is_unused?(name)
|
||||
return !Post.tag_match("status:any #{name}").where("created_at > ?", THRESHOLD.ago).exists?
|
||||
!Post.raw_tag_match(name).where("created_at > ?", THRESHOLD.ago).exists?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -37,7 +37,7 @@ class IpBan < ApplicationRecord
|
||||
|
||||
def create_mod_action
|
||||
if new_record?
|
||||
ModAction.log("#{CurrentUser.user.name} created ip ban for #{ip_addr}", :ip_ban_create)
|
||||
ModAction.log("#{creator.name} created ip ban for #{ip_addr}", :ip_ban_create)
|
||||
elsif is_deleted? == true && is_deleted_was == false
|
||||
ModAction.log("#{CurrentUser.user.name} deleted ip ban for #{ip_addr}", :ip_ban_delete)
|
||||
elsif is_deleted? == false && is_deleted_was == true
|
||||
|
||||
@@ -17,7 +17,7 @@ class IpBanTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
context "validation" do
|
||||
setup { create(:ip_ban: ip_addr: "5.6.7.8") }
|
||||
setup { create(:ip_ban, ip_addr: "5.6.7.8") }
|
||||
subject { build(:ip_ban) }
|
||||
|
||||
should allow_value("1.2.3.4").for(:ip_addr)
|
||||
|
||||
@@ -20,7 +20,7 @@ class PostDisapprovalTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "not allow blank messages" do
|
||||
@post_disapproval = create(:post_disapproval, message: "")
|
||||
@post_disapproval = create(:post_disapproval, post: @post_1, message: "")
|
||||
assert_equal(nil, @post_disapproval.message)
|
||||
end
|
||||
|
||||
@@ -55,7 +55,7 @@ class PostDisapprovalTest < ActiveSupport::TestCase
|
||||
|
||||
context "for a post that has been approved" do
|
||||
setup do
|
||||
@post = FactoryBot.create(:post)
|
||||
@post = FactoryBot.create(:post, is_pending: true)
|
||||
@user = FactoryBot.create(:user)
|
||||
@disapproval = create(:post_disapproval, user: @user, post: @post, created_at: 2.months.ago)
|
||||
end
|
||||
@@ -74,7 +74,7 @@ class PostDisapprovalTest < ActiveSupport::TestCase
|
||||
|
||||
# 2 uploaders, with 2 uploads each, and 2 disapprovals on each upload.
|
||||
@uploaders.each do |uploader|
|
||||
FactoryBot.create_list(:post, 2, uploader: uploader).each do |post|
|
||||
FactoryBot.create_list(:post, 2, is_pending: true, uploader: uploader).each do |post|
|
||||
FactoryBot.create(:post_disapproval, post: post, user: @disapprovers[0])
|
||||
FactoryBot.create(:post_disapproval, post: post, user: @disapprovers[1])
|
||||
end
|
||||
|
||||
@@ -1448,7 +1448,7 @@ class PostTest < ActiveSupport::TestCase
|
||||
|
||||
# final should be <aaa>, <bbb>, <ddd>, <eee>
|
||||
final_post = Post.find(post.id)
|
||||
assert_equal(%w(aaa bbb ddd eee), PostQueryBuilder.scan_query(final_post.tag_string).sort)
|
||||
assert_equal("aaa bbb ddd eee", final_post.tag_string)
|
||||
end
|
||||
|
||||
should "merge any tag changes that were made after loading the initial set of tags part 2" do
|
||||
@@ -1471,7 +1471,7 @@ class PostTest < ActiveSupport::TestCase
|
||||
|
||||
# final should be <aaa>, <bbb>, <ddd>, <eee>
|
||||
final_post = Post.find(post.id)
|
||||
assert_equal(%w(aaa bbb ddd eee), PostQueryBuilder.scan_query(final_post.tag_string).sort)
|
||||
assert_equal("aaa bbb ddd eee", final_post.tag_string)
|
||||
end
|
||||
|
||||
should "merge any parent, source, and rating changes that were made after loading the initial set" do
|
||||
@@ -2033,8 +2033,6 @@ class PostTest < ActiveSupport::TestCase
|
||||
post1 = FactoryBot.create(:post, tag_string: "aaa bbb rating:s")
|
||||
post2 = FactoryBot.create(:post, tag_string: "aaa bbb rating:e")
|
||||
|
||||
Danbooru.config.expects(:is_unlimited_tag?).with("rating:s").once.returns(true)
|
||||
Danbooru.config.expects(:is_unlimited_tag?).with(anything).twice.returns(false)
|
||||
assert_equal(1, Post.fast_count("aaa bbb"))
|
||||
end
|
||||
|
||||
|
||||
@@ -93,13 +93,13 @@ class TagTest < ActiveSupport::TestCase
|
||||
|
||||
context "A tag parser" do
|
||||
should "scan a query" do
|
||||
assert_equal(%w(aaa bbb), PostQueryBuilder.scan_query("aaa bbb"))
|
||||
assert_equal(%w(~AAa -BBB* -bbb*), PostQueryBuilder.scan_query("~AAa -BBB* -bbb*"))
|
||||
assert_equal(%w(aaa bbb), PostQueryBuilder.split_query("aaa bbb"))
|
||||
assert_equal(%w(~aaa -bbb* -bbb*), PostQueryBuilder.split_query("~AAa -BBB* -bbb*"))
|
||||
end
|
||||
|
||||
should "not strip out valid characters when scanning" do
|
||||
assert_equal(%w(aaa bbb), PostQueryBuilder.scan_query("aaa bbb"))
|
||||
assert_equal(%w(favgroup:yondemasu_yo,_azazel-san. pool:ichigo_100%), PostQueryBuilder.scan_query("favgroup:yondemasu_yo,_azazel-san. pool:ichigo_100%"))
|
||||
assert_equal(%w(aaa bbb), PostQueryBuilder.split_query("aaa bbb"))
|
||||
assert_equal(%w(favgroup:yondemasu_yo,_azazel-san. pool:ichigo_100%), PostQueryBuilder.split_query("favgroup:yondemasu_yo,_azazel-san. pool:ichigo_100%"))
|
||||
end
|
||||
|
||||
should "cast values" do
|
||||
@@ -110,21 +110,6 @@ class TagTest < ActiveSupport::TestCase
|
||||
assert_nothing_raised {PostQueryBuilder.parse_cast("1234.56", :float)}
|
||||
end
|
||||
|
||||
should "parse a query" do
|
||||
tag1 = FactoryBot.create(:tag, :name => "abc")
|
||||
tag2 = FactoryBot.create(:tag, :name => "acb")
|
||||
|
||||
assert_equal(["abc"], PostQueryBuilder.parse_query("md5:abc")[:md5])
|
||||
assert_equal([:between, 1, 2], PostQueryBuilder.parse_query("id:1..2")[:post_id])
|
||||
assert_equal([:gte, 1], PostQueryBuilder.parse_query("id:1..")[:post_id])
|
||||
assert_equal([:lte, 2], PostQueryBuilder.parse_query("id:..2")[:post_id])
|
||||
assert_equal([:gt, 2], PostQueryBuilder.parse_query("id:>2")[:post_id])
|
||||
assert_equal([:lt, 3], PostQueryBuilder.parse_query("id:<3")[:post_id])
|
||||
assert_equal([:lt, 3], PostQueryBuilder.parse_query("ID:<3")[:post_id])
|
||||
|
||||
assert_equal(["~no_matches~"], PostQueryBuilder.parse_query("a*b")[:tags][:include])
|
||||
end
|
||||
|
||||
should "parse single tags correctly" do
|
||||
assert_equal(true, Tag.is_single_tag?("foo"))
|
||||
assert_equal(true, Tag.is_single_tag?("-foo"))
|
||||
|
||||
Reference in New Issue
Block a user