Project

General

Profile

Feature #16006 » 16006_forum_notification_include_attachments.patch

Yuichi HARADA, 2019-10-29 06:35

View differences:

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

  
(3-3/6)