Correct email sending on attachment to document #1008

This commit is contained in:
Felix Schäfer 2012-05-18 22:45:52 +02:00
parent 3e84c4817b
commit 1d3cdf1fa9
2 changed files with 23 additions and 1 deletions

View File

@ -85,7 +85,7 @@ class DocumentsController < ApplicationController
if attachments.present? && attachments[:files].present? && Setting.notified_events.include?('document_added')
# TODO: refactor
attachments.first.container.recipients.each do |recipient|
@document.recipients.each do |recipient|
Mailer.deliver_attachments_added(attachments[:files], recipient)
end
end

View File

@ -147,6 +147,28 @@ LOREM
end
end
context "#add_attachment" do
setup do
@request.session[:user_id] = 2
set_tmp_attachments_directory
@document = Document.generate!(:project => Project.find('ecookbook'),
:title => 'Test')
end
should "send a notification mail" do
ActionMailer::Base.deliveries.clear
Setting.notified_events = Setting.notified_events.dup << 'document_added'
post :add_attachment,
:id => @document.id,
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
@document.reload
assert_not_nil @document
assert_equal 2, ActionMailer::Base.deliveries.size
end
end
def test_destroy
@request.session[:user_id] = 2
post :destroy, :id => 1