Rails 3.1 compatibility.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9073 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
858e317e6e
commit
64d843a4d7
|
@ -83,6 +83,9 @@ class AttachmentsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
if @attachment.container.respond_to?(:init_journal)
|
||||||
|
@attachment.container.init_journal(User.current)
|
||||||
|
end
|
||||||
# Make sure association callbacks are called
|
# Make sure association callbacks are called
|
||||||
@attachment.container.attachments.delete(@attachment)
|
@attachment.container.attachments.delete(@attachment)
|
||||||
redirect_to :back
|
redirect_to :back
|
||||||
|
|
|
@ -953,11 +953,10 @@ class Issue < ActiveRecord::Base
|
||||||
|
|
||||||
# Callback on attachment deletion
|
# Callback on attachment deletion
|
||||||
def attachment_removed(obj)
|
def attachment_removed(obj)
|
||||||
journal = init_journal(User.current)
|
if @current_journal && !obj.new_record?
|
||||||
journal.details << JournalDetail.new(:property => 'attachment',
|
@current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => obj.id, :old_value => obj.filename)
|
||||||
:prop_key => obj.id,
|
@current_journal.save
|
||||||
:old_value => obj.filename)
|
end
|
||||||
journal.save
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Default assignment based on category
|
# Default assignment based on category
|
||||||
|
|
|
@ -264,15 +264,18 @@ class AttachmentsControllerTest < ActionController::TestCase
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
assert_difference 'issue.attachments.count', -1 do
|
assert_difference 'issue.attachments.count', -1 do
|
||||||
delete :destroy, :id => 1
|
assert_difference 'Journal.count' do
|
||||||
|
delete :destroy, :id => 1
|
||||||
|
assert_redirected_to '/projects/ecookbook'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
# no referrer
|
|
||||||
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 = Journal.first(:order => 'id DESC')
|
||||||
|
assert_equal issue, j.journalized
|
||||||
assert_equal 'attachment', j.details.first.property
|
assert_equal 'attachment', j.details.first.property
|
||||||
assert_equal '1', j.details.first.prop_key
|
assert_equal '1', j.details.first.prop_key
|
||||||
assert_equal 'error281.txt', j.details.first.old_value
|
assert_equal 'error281.txt', j.details.first.old_value
|
||||||
|
assert_equal User.find(2), j.user
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy_wiki_page_attachment
|
def test_destroy_wiki_page_attachment
|
||||||
|
|
Loading…
Reference in New Issue