Commit 1d3cdf1f authored by Felix Schäfer's avatar Felix Schäfer

Correct email sending on attachment to document #1008

parent 3e84c481
......@@ -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
......
......@@ -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
......
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