Feature #16006 » 16006_forum_notification_include_attachments_v2.patch
app/controllers/messages_controller.rb | ||
---|---|---|
77 | 77 |
@reply.author = User.current |
78 | 78 |
@reply.board = @board |
79 | 79 |
@reply.safe_attributes = params[:reply] |
80 |
@reply.save_attachments(params[:attachments]) |
|
80 | 81 |
@topic.children << @reply |
81 | 82 |
if !@reply.new_record? |
82 | 83 |
call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply}) |
83 |
attachments = Attachment.attach_files(@reply, params[:attachments]) |
|
84 | 84 |
render_attachment_warning_if_needed(@reply) |
85 | 85 |
end |
86 | 86 |
flash[:notice] = l(:notice_successful_update) |
... | ... | |
91 | 91 |
def edit |
92 | 92 |
(render_403; return false) unless @message.editable_by?(User.current) |
93 | 93 |
@message.safe_attributes = params[:message] |
94 |
if request.post? && @message.save |
|
95 |
attachments = Attachment.attach_files(@message, params[:attachments]) |
|
96 |
render_attachment_warning_if_needed(@message) |
|
97 |
flash[:notice] = l(:notice_successful_update) |
|
98 |
@message.reload |
|
99 |
redirect_to board_message_path(@message.board, @message.root, :r => (@message.parent_id && @message.id)) |
|
94 |
if request.post? |
|
95 |
@message.save_attachments(params[:attachments]) |
|
96 |
if @message.save |
|
97 |
render_attachment_warning_if_needed(@message) |
|
98 |
flash[:notice] = l(:notice_successful_update) |
|
99 |
@message.reload |
|
100 |
redirect_to board_message_path(@message.board, @message.root, :r => (@message.parent_id && @message.id)) |
|
101 |
end |
|
100 | 102 |
end |
101 | 103 |
end |
102 | 104 |
app/views/mailer/message_posted.html.erb | ||
---|---|---|
2 | 2 |
<em><%= @message.author %></em> |
3 | 3 | |
4 | 4 |
<%= textilizable(@message, :content, :only_path => false) %> |
5 | ||
6 |
<% if @message.attachments.any? -%> |
|
7 |
<fieldset class="attachments"><legend><%= l(:label_attachment_plural) %></legend> |
|
8 |
<% @message.attachments.each do |attachment| -%> |
|
9 |
<%= link_to_attachment attachment, :download => true, :only_path => false %> (<%= number_to_human_size(attachment.filesize) %>)<br /> |
|
10 |
<% end -%> |
|
11 |
</fieldset> |
|
12 |
<% end -%> |
app/views/mailer/message_posted.text.erb | ||
---|---|---|
2 | 2 |
<%= @message.author %> |
3 | 3 | |
4 | 4 |
<%= @message.content %> |
5 | ||
6 |
<% if @message.attachments.any? -%> |
|
7 |
---<%= l(:label_attachment_plural).ljust(37, '-') %> |
|
8 |
<% @message.attachments.each do |attachment| -%> |
|
9 |
<%= attachment.filename %> (<%= number_to_human_size(attachment.filesize) %>) |
|
10 |
<% end -%> |
|
11 |
<% end -%> |
test/unit/mailer_test.rb | ||
---|---|---|
334 | 334 | |
335 | 335 |
def test_message_posted_message_id |
336 | 336 |
message = Message.find(1) |
337 |
attachment = message.attachments.first |
|
337 | 338 |
Mailer.deliver_message_posted(message) |
338 | 339 |
mail = last_email |
339 | 340 |
uid = destination_user(mail).id |
... | ... | |
344 | 345 |
assert_select "a[href=?]", |
345 | 346 |
"http://localhost:3000/boards/#{message.board.id}/topics/#{message.id}", |
346 | 347 |
:text => message.subject |
348 |
# link to the attachments download |
|
349 |
assert_select 'fieldset.attachments' do |
|
350 |
assert_select 'a[href=?]', |
|
351 |
"http://localhost:3000/attachments/download/#{attachment.id}/#{attachment.filename}", |
|
352 |
:text => attachment.filename |
|
353 |
end |
|
347 | 354 |
end |
348 | 355 |
end |
349 | 356 | |
350 | 357 |
def test_reply_posted_message_id |
358 |
set_tmp_attachments_directory |
|
351 | 359 |
message = Message.find(3) |
360 |
attachment = Attachment.generate!( |
|
361 |
:container => message, |
|
362 |
:file => uploaded_test_file('testfile.txt', 'text/plain') |
|
363 |
) |
|
352 | 364 |
Mailer.deliver_message_posted(message) |
353 | 365 |
mail = last_email |
354 | 366 |
uid = destination_user(mail).id |
... | ... | |
359 | 371 |
assert_select "a[href=?]", |
360 | 372 |
"http://localhost:3000/boards/#{message.board.id}/topics/#{message.root.id}?r=#{message.id}#message-#{message.id}", |
361 | 373 |
:text => message.subject |
374 |
# link to the attachments download |
|
375 |
assert_select 'fieldset.attachments' do |
|
376 |
assert_select 'a[href=?]', |
|
377 |
"http://localhost:3000/attachments/download/#{attachment.id}/testfile.txt", |
|
378 |
:text => 'testfile.txt' |
|
379 |
end |
|
362 | 380 |
end |
363 | 381 |
end |
364 | 382 |
- « Previous
- 1
- …
- 4
- 5
- 6
- Next »