Project

General

Profile

Patch #2014 » add_user_name_when_document_added.patch

Yuki Shida, 2008-10-09 07:50

View differences:

test/unit/mailer_test.rb (リビジョン 23)
58 58
  
59 59
  def test_document_added
60 60
    document = Document.find(1)
61
    user = User.find(1)
61 62
    GLoc.valid_languages.each do |lang|
62 63
      Setting.default_language = lang.to_s
63
      assert Mailer.deliver_document_added(document)
64
      result = Mailer.deliver_document_added(document, user)
65
      assert result
66
      assert_match(/#{user.login}/, result.body)
64 67
    end
65 68
  end
66 69
  
app/models/mailer.rb (リビジョン 23)
60 60
         :issues_url => url_for(:controller => 'issues', :action => 'index', :set_filter => 1, :assigned_to_id => user.id, :sort_key => 'issues.due_date', :sort_order => 'asc')
61 61
  end
62 62
  
63
  def document_added(document)
63
  def document_added(document, user)
64 64
    redmine_headers 'Project' => document.project.identifier
65 65
    recipients document.project.recipients
66 66
    subject "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}"
67 67
    body :document => document,
68
         :document_url => url_for(:controller => 'documents', :action => 'show', :id => document)
68
         :document_url => url_for(:controller => 'documents', :action => 'show', :id => document),
69
         :user => user
69 70
  end
70 71
  
71 72
  def attachments_added(attachments)
app/controllers/documents_controller.rb (リビジョン 23)
47 47
    if request.post? and @document.save	
48 48
      attach_files(@document, params[:attachments])
49 49
      flash[:notice] = l(:notice_successful_create)
50
      Mailer.deliver_document_added(@document) if Setting.notified_events.include?('document_added')
50
      Mailer.deliver_document_added(@document, User.current) if Setting.notified_events.include?('document_added')
51 51
      redirect_to :action => 'index', :project_id => @project
52 52
    end
53 53
  end
app/views/mailer/document_added.text.plain.rhtml (リビジョン 23)
1
(by <%= @user.login %>)
2

  
1 3
<%= @document.title %> (<%= @document.category.name %>)
2 4
<%= @document_url %>
3 5

  
app/views/mailer/document_added.text.html.rhtml (リビジョン 23)
1
<p>(by <%= @user.login %>)</p>
2

  
1 3
<%= link_to @document.title, @document_url %> (<%= @document.category.name %>)<br />
2 4
<br />
3 5
<%= textilizable(@document, :description, :only_path => false) %>
    (1-1/1)