#2030: Fix regression that borked the -pool: metatag
This commit is contained in:
@@ -353,11 +353,6 @@ class Post < ActiveRecord::Base
|
|||||||
@tag_array_was ||= Tag.scan_tags(tag_string_was)
|
@tag_array_was ||= Tag.scan_tags(tag_string_was)
|
||||||
end
|
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
|
def increment_tag_post_counts
|
||||||
Tag.update_all("post_count = post_count + 1", {:name => tag_array}) if tag_array.any?
|
Tag.update_all("post_count = post_count + 1", {:name => tag_array}) if tag_array.any?
|
||||||
end
|
end
|
||||||
@@ -446,10 +441,10 @@ class Post < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def normalize_tags
|
def normalize_tags
|
||||||
create_tags
|
|
||||||
normalized_tags = Tag.scan_tags(tag_string)
|
normalized_tags = Tag.scan_tags(tag_string)
|
||||||
normalized_tags = filter_metatags(normalized_tags)
|
normalized_tags = filter_metatags(normalized_tags)
|
||||||
normalized_tags = normalized_tags.map{|tag| tag.downcase}
|
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 = TagAlias.to_aliased(normalized_tags)
|
||||||
normalized_tags = TagImplication.with_descendants(normalized_tags)
|
normalized_tags = TagImplication.with_descendants(normalized_tags)
|
||||||
normalized_tags = %w(tagme) if normalized_tags.empty?
|
normalized_tags = %w(tagme) if normalized_tags.empty?
|
||||||
|
|||||||
@@ -492,6 +492,23 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
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
|
context "id" do
|
||||||
setup do
|
setup do
|
||||||
@pool = FactoryGirl.create(:pool)
|
@pool = FactoryGirl.create(:pool)
|
||||||
|
|||||||
Reference in New Issue
Block a user