diff --git a/app/models/post.rb b/app/models/post.rb index 263d7eff1..ee2812e61 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -414,7 +414,7 @@ class Post < ActiveRecord::Base end def filter_metatags(tags) - metatags, tags = tags.partition {|x| x =~ /\A(?:pool|rating|fav):/} + metatags, tags = tags.partition {|x| x =~ /\A(?:pool|rating|fav|parent):/} apply_metatags(metatags) return tags end @@ -422,6 +422,9 @@ class Post < ActiveRecord::Base def apply_metatags(tags) tags.each do |tag| case tag + when /^parent:(\d+)$/ + self.parent_id = $1.to_i + when /^pool:(\d+)$/ pool = Pool.find_by_id($1.to_i) add_pool!(pool) if pool diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index f27b608eb..09399c799 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -215,6 +215,20 @@ class PostTest < ActiveSupport::TestCase end context "tagged with a metatag" do + context "for a parent" do + setup do + @parent = Factory.create(:post) + end + + should "update the parent relationships for both posts" do + @post.update_attributes(:tag_string => "aaa parent:#{@parent.id}") + @post.reload + @parent.reload + assert_equal(@parent.id, @post.parent_id) + assert(@parent.has_children?) + end + end + context "for a pool" do context "id" do setup do