Rails3: model: replace deprecated 'before_destroy' method at WikiPage model

test_redirects_removed_when_deleting_page at unit wiki_redirect_test.rb has this test.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7437 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-09-22 00:53:53 +00:00
parent 2d541a7e1b
commit ec1b9f38f3
1 changed files with 2 additions and 1 deletions

View File

@ -43,6 +43,7 @@ class WikiPage < ActiveRecord::Base
validates_associated :content
validate :validate_parent_title
before_destroy :remove_redirects
# eager load information about last updates, without loading text
named_scope :with_updated_on, {
@ -86,7 +87,7 @@ class WikiPage < ActiveRecord::Base
end
end
def before_destroy
def remove_redirects
# Remove redirects to this page
wiki.redirects.find_all_by_redirects_to(title).each(&:destroy)
end