mirror of
https://github.com/meineerde/redmine.git
synced 2026-02-01 03:57:15 +00:00
Include attachments in news post notifications (#33002).
Patch by Yuichi HARADA. git-svn-id: http://svn.redmine.org/redmine/trunk@19528 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
3c45dfaad7
commit
6095186e97
@ -2,3 +2,11 @@
|
||||
<em><%= @news.author.name %></em>
|
||||
|
||||
<%= textilizable(@news, :description, :only_path => false) %>
|
||||
|
||||
<% if @news.attachments.any? -%>
|
||||
<fieldset class="attachments"><legend><%= l(:label_attachment_plural) %></legend>
|
||||
<% @news.attachments.each do |attachment| -%>
|
||||
<%= link_to_attachment attachment, :download => true, :only_path => false %> (<%= number_to_human_size(attachment.filesize) %>)<br />
|
||||
<% end -%>
|
||||
</fieldset>
|
||||
<% end -%>
|
||||
@ -3,3 +3,10 @@
|
||||
<%= @news.author.name %>
|
||||
|
||||
<%= @news.description %>
|
||||
|
||||
<% if @news.attachments.any? -%>
|
||||
---<%= l(:label_attachment_plural).ljust(37, '-') %>
|
||||
<% @news.attachments.each do |attachment| -%>
|
||||
<%= attachment.filename %> (<%= number_to_human_size(attachment.filesize) %>)
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
@ -123,29 +123,40 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_post_create_with_attachment
|
||||
set_tmp_attachments_directory
|
||||
ActionMailer::Base.deliveries.clear
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'News.count' do
|
||||
assert_difference 'Attachment.count' do
|
||||
post(
|
||||
:create,
|
||||
:params => {
|
||||
:project_id => 1,
|
||||
:news => {
|
||||
:title => 'Test',
|
||||
:description => 'This is the description'
|
||||
},
|
||||
:attachments => {
|
||||
'1' => {
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')
|
||||
with_settings :notified_events => %w(news_added) do
|
||||
post(
|
||||
:create,
|
||||
:params => {
|
||||
:project_id => 1,
|
||||
:news => {
|
||||
:title => 'Test',
|
||||
:description => 'This is the description'
|
||||
},
|
||||
:attachments => {
|
||||
'1' => {
|
||||
'file' => uploaded_test_file('testfile.txt', 'text/plain')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
attachment = Attachment.order('id DESC').first
|
||||
news = News.order('id DESC').first
|
||||
assert_equal news, attachment.container
|
||||
assert_select_email do
|
||||
# link to the attachments download
|
||||
assert_select 'fieldset.attachments' do
|
||||
assert_select 'a[href=?]',
|
||||
"http://localhost:3000/attachments/download/#{attachment.id}/testfile.txt",
|
||||
:text => 'testfile.txt'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_post_create_with_validation_failure
|
||||
|
||||
@ -613,14 +613,27 @@ class MailerTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
def test_news_added_should_notify_project_news_watchers
|
||||
set_tmp_attachments_directory
|
||||
user1 = User.generate!
|
||||
user2 = User.generate!
|
||||
news = News.find(1)
|
||||
news.project.enabled_module('news').add_watcher(user1)
|
||||
attachment = Attachment.generate!(
|
||||
:container => news,
|
||||
:file => uploaded_test_file('testfile.txt', 'text/plain')
|
||||
)
|
||||
|
||||
Mailer.deliver_news_added(news)
|
||||
assert_include user1.mail, recipients
|
||||
assert_not_include user2.mail, recipients
|
||||
assert_select_email do
|
||||
# link to the attachments download
|
||||
assert_select 'fieldset.attachments' do
|
||||
assert_select 'a[href=?]',
|
||||
"http://localhost:3000/attachments/download/#{attachment.id}/testfile.txt",
|
||||
:text => 'testfile.txt'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_wiki_content_added
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user