This commit is contained in:
r888888888
2013-05-21 17:58:09 -07:00
parent 03e7d08830
commit cb2e1e9f57
2 changed files with 5 additions and 3 deletions

View File

@@ -117,7 +117,7 @@ class TagAlias < ActiveRecord::Base
end
def ensure_category_consistency
if antecedent_tag.category != consequent_tag.category
if antecedent_tag.category != consequent_tag.category && antecedent_tag.category != Tag.categories.general
consequent_tag.update_attribute(:category, antecedent_tag.category)
consequent_tag.update_category_cache_for_all
end

View File

@@ -62,9 +62,11 @@ class TagAliasTest < ActiveSupport::TestCase
end
end
should "not push the antecedent's category to the consequent if the antecedent is general"
should "push the antecedent's category to the consequent" do
tag1 = FactoryGirl.create(:tag, :name => "aaa", :category => 1)
tag2 = FactoryGirl.create(:tag, :name => "bbb")
tag1 = FactoryGirl.create(:tag, :name => "aaa")
tag2 = FactoryGirl.create(:tag, :name => "bbb", :category => 1)
ta = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb")
tag2.reload
assert_equal(1, tag2.category)