#2030: Fix regression that borked the -pool: metatag

This commit is contained in:
Toks
2013-11-26 23:27:40 -05:00
parent c37f949f17
commit f1455c1f77
2 changed files with 18 additions and 6 deletions

View File

@@ -353,11 +353,6 @@ class Post < ActiveRecord::Base
@tag_array_was ||= Tag.scan_tags(tag_string_was)
end
def create_tags
reset_tag_array_cache
set_tag_string(tag_array.map {|x| Tag.find_or_create_by_name(x).name}.uniq.sort.join(" "))
end
def increment_tag_post_counts
Tag.update_all("post_count = post_count + 1", {:name => tag_array}) if tag_array.any?
end
@@ -446,10 +441,10 @@ class Post < ActiveRecord::Base
end
def normalize_tags
create_tags
normalized_tags = Tag.scan_tags(tag_string)
normalized_tags = filter_metatags(normalized_tags)
normalized_tags = normalized_tags.map{|tag| tag.downcase}
normalized_tags = normalized_tags.map {|x| Tag.find_or_create_by_name(x).name}
normalized_tags = TagAlias.to_aliased(normalized_tags)
normalized_tags = TagImplication.with_descendants(normalized_tags)
normalized_tags = %w(tagme) if normalized_tags.empty?

View File

@@ -492,6 +492,23 @@ class PostTest < ActiveSupport::TestCase
end
end
context "negated" do
setup do
@pool = FactoryGirl.create(:pool)
@post = FactoryGirl.create(:post, :tag_string => "aaa")
@post.add_pool!(@pool)
@post.tag_string = "aaa -pool:#{@pool.id}"
@post.save
end
should "remove the post from the pool" do
@post.reload
@pool.reload
assert_equal("", @pool.post_ids)
assert_equal("", @post.pool_string)
end
end
context "id" do
setup do
@pool = FactoryGirl.create(:pool)