Resolve aliases when removing negated tags (fix #2730).

This commit is contained in:
evazion
2016-10-21 23:38:53 -05:00
parent 080eecb6b9
commit c6294d5dfd
2 changed files with 8 additions and 0 deletions

View File

@@ -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

View File

@@ -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