##// END OF EJS Templates
Rails 3.1 compatibility....
Jean-Philippe Lang -
r8953:64d843a4d715
parent child
Show More
@@ -83,6 +83,9 class AttachmentsController < ApplicationController
83 83 end
84 84
85 85 def destroy
86 if @attachment.container.respond_to?(:init_journal)
87 @attachment.container.init_journal(User.current)
88 end
86 89 # Make sure association callbacks are called
87 90 @attachment.container.attachments.delete(@attachment)
88 91 redirect_to :back
@@ -953,11 +953,10 class Issue < ActiveRecord::Base
953 953
954 954 # Callback on attachment deletion
955 955 def attachment_removed(obj)
956 journal = init_journal(User.current)
957 journal.details << JournalDetail.new(:property => 'attachment',
958 :prop_key => obj.id,
959 :old_value => obj.filename)
960 journal.save
956 if @current_journal && !obj.new_record?
957 @current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => obj.id, :old_value => obj.filename)
958 @current_journal.save
959 end
961 960 end
962 961
963 962 # Default assignment based on category
@@ -264,15 +264,18 class AttachmentsControllerTest < ActionController::TestCase
264 264 @request.session[:user_id] = 2
265 265
266 266 assert_difference 'issue.attachments.count', -1 do
267 delete :destroy, :id => 1
267 assert_difference 'Journal.count' do
268 delete :destroy, :id => 1
269 assert_redirected_to '/projects/ecookbook'
270 end
268 271 end
269 # no referrer
270 assert_redirected_to '/projects/ecookbook'
271 272 assert_nil Attachment.find_by_id(1)
272 j = issue.journals.find(:first, :order => 'created_on DESC')
273 j = Journal.first(:order => 'id DESC')
274 assert_equal issue, j.journalized
273 275 assert_equal 'attachment', j.details.first.property
274 276 assert_equal '1', j.details.first.prop_key
275 277 assert_equal 'error281.txt', j.details.first.old_value
278 assert_equal User.find(2), j.user
276 279 end
277 280
278 281 def test_destroy_wiki_page_attachment
General Comments 0
You need to be logged in to leave comments. Login now