fix attachment_removal

This commit is contained in:
Tim Felgentreff 2010-09-15 10:38:07 +02:00
parent aaecab6d7f
commit 485335599a
2 changed files with 10 additions and 4 deletions

View File

@ -315,6 +315,13 @@ class Issue < ActiveRecord::Base
end
end
# Callback on attachment deletion
def attachment_removed(obj)
init_journal(User.current)
create_journal
last_journal.update_attribute(:changes, {obj.id => [obj.filename, nil]}.to_yaml)
end
# Return true if the issue is closed, otherwise false
def closed?
self.status.is_closed?

View File

@ -97,10 +97,9 @@ class AttachmentsControllerTest < ActionController::TestCase
# no referrer
assert_redirected_to 'projects/ecookbook'
assert_nil Attachment.find_by_id(1)
j = issue.journals.find(:first, :order => 'created_on DESC')
assert_equal 'attachment', j.details.first.property
assert_equal '1', j.details.first.prop_key
assert_equal 'error281.txt', j.details.first.old_value
j = issue.journals.find(:first, :order => 'created_at DESC')
assert_equal [1], j.details.keys
assert_equal 'error281.txt', j.details[1].first
end
def test_destroy_wiki_page_attachment