diff --git a/app/models/post.rb b/app/models/post.rb index 9ad7162c8..cf541cd6e 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -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? diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index 8903b57f1..3dad74be9 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -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)