From c6294d5dfde48e2050dd97d0fcb76a72583d7b65 Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 21 Oct 2016 23:38:53 -0500 Subject: [PATCH] Resolve aliases when removing negated tags (fix #2730). --- app/models/post.rb | 1 + test/unit/post_test.rb | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/app/models/post.rb b/app/models/post.rb index c5c7099f0..076bbaebc 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -614,6 +614,7 @@ class Post < ActiveRecord::Base def remove_negated_tags(tags) negated_tags, tags = tags.partition {|x| x =~ /\A-/i} negated_tags = negated_tags.map {|x| x[1..-1]} + negated_tags = TagAlias.to_aliased(negated_tags) return tags - negated_tags end diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index d78c34ebc..1ce050ca8 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -668,6 +668,13 @@ class PostTest < ActiveSupport::TestCase @post.reload assert_equal("aaa ccc", @post.tag_string) end + + should "resolve aliases" do + FactoryGirl.create(:tag_alias, :antecedent_name => "/tr", :consequent_name => "translation_request") + @post.update(:tag_string => "aaa translation_request -/tr") + + assert_equal("aaa", @post.tag_string) + end end should "have an array representation of its tags" do