fixes #2048
This commit is contained in:
@@ -433,7 +433,7 @@ class Post < ActiveRecord::Base
|
|||||||
|
|
||||||
def filter_metatags(tags)
|
def filter_metatags(tags)
|
||||||
@pre_metatags, tags = tags.partition {|x| x =~ /\A(?:rating|parent):/i}
|
@pre_metatags, tags = tags.partition {|x| x =~ /\A(?:rating|parent):/i}
|
||||||
@post_metatags, tags = tags.partition {|x| x =~ /\A(?:-pool|pool|newpool|fav):/i}
|
@post_metatags, tags = tags.partition {|x| x =~ /\A(?:-pool|pool|newpool|fav|child):/i}
|
||||||
apply_pre_metatags
|
apply_pre_metatags
|
||||||
return tags
|
return tags
|
||||||
end
|
end
|
||||||
@@ -468,6 +468,11 @@ class Post < ActiveRecord::Base
|
|||||||
|
|
||||||
when /^fav:(.+)$/i
|
when /^fav:(.+)$/i
|
||||||
add_favorite!(CurrentUser.user)
|
add_favorite!(CurrentUser.user)
|
||||||
|
|
||||||
|
when /^child:(.+)$/i
|
||||||
|
child = Post.find($1)
|
||||||
|
child.parent_id = id
|
||||||
|
child.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -576,6 +576,20 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
assert_equal("fav:#{@user.id}", @post.fav_string)
|
assert_equal("fav:#{@user.id}", @post.fav_string)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "for a child" do
|
||||||
|
setup do
|
||||||
|
@child = FactoryGirl.create(:post)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "update the parent relationships for both posts" do
|
||||||
|
@post.update_attributes(:tag_string => "aaa child:#{@child.id}")
|
||||||
|
@post.reload
|
||||||
|
@child.reload
|
||||||
|
assert_equal(@post.id, @child.parent_id)
|
||||||
|
assert(@post.has_children?)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "tagged with a negated tag" do
|
context "tagged with a negated tag" do
|
||||||
|
|||||||
Reference in New Issue
Block a user