undeleting a post now records the approver
This commit is contained in:
@@ -755,7 +755,9 @@ class Post < ActiveRecord::Base
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
update_column(:is_deleted, false)
|
self.is_deleted = false
|
||||||
|
self.approver_id = CurrentUser.id
|
||||||
|
save
|
||||||
tag_array.each {|x| expire_cache(x)}
|
tag_array.each {|x| expire_cache(x)}
|
||||||
update_parent_on_save
|
update_parent_on_save
|
||||||
ModAction.create(:description => "undeleted post ##{id}")
|
ModAction.create(:description => "undeleted post ##{id}")
|
||||||
|
|||||||
@@ -182,6 +182,18 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "Undestroying a post with a parent" do
|
context "Undestroying a post with a parent" do
|
||||||
|
should "create a new approver" do
|
||||||
|
new_user = FactoryGirl.create(:moderator_user)
|
||||||
|
p1 = FactoryGirl.create(:post)
|
||||||
|
c1 = FactoryGirl.create(:post, :parent_id => p1.id)
|
||||||
|
c1.delete!
|
||||||
|
CurrentUser.scoped(new_user, "127.0.0.1") do
|
||||||
|
c1.undelete!
|
||||||
|
end
|
||||||
|
p1.reload
|
||||||
|
assert_equal(new_user.id, c1.approver_id)
|
||||||
|
end
|
||||||
|
|
||||||
should "not preserve the parent's has_children flag" do
|
should "not preserve the parent's has_children flag" do
|
||||||
p1 = FactoryGirl.create(:post)
|
p1 = FactoryGirl.create(:post)
|
||||||
c1 = FactoryGirl.create(:post, :parent_id => p1.id)
|
c1 = FactoryGirl.create(:post, :parent_id => p1.id)
|
||||||
|
|||||||
Reference in New Issue
Block a user