undeleting a post now records the approver

This commit is contained in:
albert
2013-02-26 22:38:46 -08:00
parent ace8ee12f1
commit 155974210b
2 changed files with 15 additions and 1 deletions

View File

@@ -755,7 +755,9 @@ class Post < ActiveRecord::Base
return false
end
update_column(:is_deleted, false)
self.is_deleted = false
self.approver_id = CurrentUser.id
save
tag_array.each {|x| expire_cache(x)}
update_parent_on_save
ModAction.create(:description => "undeleted post ##{id}")

View File

@@ -182,6 +182,18 @@ class PostTest < ActiveSupport::TestCase
end
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
p1 = FactoryGirl.create(:post)
c1 = FactoryGirl.create(:post, :parent_id => p1.id)