[Tests] Fix pool related errors in tests

This commit is contained in:
Kira 2021-02-05 20:13:04 -08:00
parent 46fe5f1164
commit dbb5870d93
3 changed files with 12 additions and 18 deletions

View File

@ -225,19 +225,19 @@ module PostIndex
file_size: file_size,
parent: parent_id,
pools: options[:pools] || Pool.where("post_ids @> '{?}'", id).pluck(:id),
sets: options[:sets] || PostSet.where("post_ids @> '{?}'", id).pluck(:id),
commenters: options[:commenters] || Comment.undeleted.where(post_id: id).pluck(:creator_id),
noters: options[:noters] || Note.active.where(post_id: id).pluck(:creator_id),
faves: options[:faves] || Favorite.where(post_id: id).pluck(:user_id),
upvotes: options[:upvotes] || PostVote.where(post_id: id).where("score > 0").pluck(:user_id),
downvotes: options[:downvotes] || PostVote.where(post_id: id).where("score < 0").pluck(:user_id),
children: options[:children] || Post.where(parent_id: id).pluck(:id),
notes: options[:notes] || Note.active.where(post_id: id).pluck(:body),
pools: options[:pools] || ::Pool.where("post_ids @> '{?}'", id).pluck(:id),
sets: options[:sets] || ::PostSet.where("post_ids @> '{?}'", id).pluck(:id),
commenters: options[:commenters] || ::Comment.undeleted.where(post_id: id).pluck(:creator_id),
noters: options[:noters] || ::Note.active.where(post_id: id).pluck(:creator_id),
faves: options[:faves] || ::Favorite.where(post_id: id).pluck(:user_id),
upvotes: options[:upvotes] || ::PostVote.where(post_id: id).where("score > 0").pluck(:user_id),
downvotes: options[:downvotes] || ::PostVote.where(post_id: id).where("score < 0").pluck(:user_id),
children: options[:children] || ::Post.where(parent_id: id).pluck(:id),
notes: options[:notes] || ::Note.active.where(post_id: id).pluck(:body),
uploader: uploader_id,
approver: approver_id,
deleter: options[:deleter] || PostFlag.where(post_id: id, is_resolved: false, is_deletion: true).order(id: :desc).first&.creator_id,
del_reason: options[:del_reason] || PostFlag.where(post_id: id, is_resolved: false, is_deletion: true).order(id: :desc).first&.reason&.downcase,
deleter: options[:deleter] || ::PostFlag.where(post_id: id, is_resolved: false, is_deletion: true).order(id: :desc).first&.creator_id,
del_reason: options[:del_reason] || ::PostFlag.where(post_id: id, is_resolved: false, is_deletion: true).order(id: :desc).first&.reason&.downcase,
width: image_width,
height: image_height,
mpixels: image_width && image_height ? (image_width.to_f * image_height / 1_000_000).round(2) : 0.0,

View File

@ -393,7 +393,7 @@ class Pool < ApplicationRecord
errors[:name] << "cannot contain only digits"
when /,/
errors.add(:name, "cannot contain commas")
when /[_- ]{2}/
when /[_\- ]{2}/
errors.add(:name, "cannot contain consecutive underscores, hyphens or spaces")
end
end

View File

@ -15,7 +15,6 @@ class PostTest < ActiveSupport::TestCase
end
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
mock_pool_archive_service!
Post.__elasticsearch__.index_name = "posts_test"
Post.__elasticsearch__.create_index!
end
@ -774,7 +773,6 @@ class PostTest < ActiveSupport::TestCase
context "for a pool" do
setup do
mock_pool_archive_service!
start_pool_archive_transaction
end
@ -1603,10 +1601,6 @@ class PostTest < ActiveSupport::TestCase
end
context "Searching:" do
setup do
mock_pool_archive_service!
end
should "return posts for the age:<1minute tag" do
post = FactoryBot.create(:post)
assert_tag_match([post], "age:<1minute")