fixes #1472
This commit is contained in:
@@ -25,7 +25,7 @@ class TagImplication < ActiveRecord::Base
|
|||||||
|
|
||||||
until children.empty?
|
until children.empty?
|
||||||
all.concat(children)
|
all.concat(children)
|
||||||
children = self.class.where(["antecedent_name IN (?)", children]).all.map(&:consequent_name)
|
children = TagImplication.where("antecedent_name IN (?) and status = ?", children, "active").all.map(&:consequent_name)
|
||||||
end
|
end
|
||||||
end.sort.uniq
|
end.sort.uniq
|
||||||
end
|
end
|
||||||
@@ -40,6 +40,7 @@ class TagImplication < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_descendant_names!
|
def update_descendant_names!
|
||||||
|
clear_descendants_cache
|
||||||
update_descendant_names
|
update_descendant_names
|
||||||
update_column(:descendant_names, descendant_names)
|
update_column(:descendant_names, descendant_names)
|
||||||
end
|
end
|
||||||
@@ -104,9 +105,9 @@ class TagImplication < ActiveRecord::Base
|
|||||||
|
|
||||||
def process!
|
def process!
|
||||||
update_column(:status, "processing")
|
update_column(:status, "processing")
|
||||||
update_descendant_names_for_parent
|
|
||||||
update_posts
|
update_posts
|
||||||
update_column(:status, "active")
|
update_column(:status, "active")
|
||||||
|
update_descendant_names_for_parent
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
update_column(:status, "error: #{e}")
|
update_column(:status, "error: #{e}")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,6 +15,14 @@ class TagImplicationTest < ActiveSupport::TestCase
|
|||||||
CurrentUser.ip_addr = nil
|
CurrentUser.ip_addr = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "ignore pending implications when building descendant names" do
|
||||||
|
ti2 = FactoryGirl.build(:tag_implication, :antecedent_name => "b", :consequent_name => "c")
|
||||||
|
ti2.save
|
||||||
|
ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "a", :consequent_name => "b")
|
||||||
|
ti1.reload
|
||||||
|
assert_equal("b", ti1.descendant_names)
|
||||||
|
end
|
||||||
|
|
||||||
should "populate the creator information" do
|
should "populate the creator information" do
|
||||||
ti = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb")
|
ti = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb")
|
||||||
assert_equal(CurrentUser.user.id, ti.creator_id)
|
assert_equal(CurrentUser.user.id, ti.creator_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user