Commit 48533559 authored by Tim Felgentreff's avatar Tim Felgentreff

fix attachment_removal

parent aaecab6d
...@@ -315,6 +315,13 @@ class Issue < ActiveRecord::Base ...@@ -315,6 +315,13 @@ class Issue < ActiveRecord::Base
end end
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 # Return true if the issue is closed, otherwise false
def closed? def closed?
self.status.is_closed? self.status.is_closed?
......
...@@ -97,10 +97,9 @@ class AttachmentsControllerTest < ActionController::TestCase ...@@ -97,10 +97,9 @@ class AttachmentsControllerTest < ActionController::TestCase
# no referrer # no referrer
assert_redirected_to 'projects/ecookbook' assert_redirected_to 'projects/ecookbook'
assert_nil Attachment.find_by_id(1) assert_nil Attachment.find_by_id(1)
j = issue.journals.find(:first, :order => 'created_on DESC') j = issue.journals.find(:first, :order => 'created_at DESC')
assert_equal 'attachment', j.details.first.property assert_equal [1], j.details.keys
assert_equal '1', j.details.first.prop_key assert_equal 'error281.txt', j.details[1].first
assert_equal 'error281.txt', j.details.first.old_value
end end
def test_destroy_wiki_page_attachment def test_destroy_wiki_page_attachment
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment