0001-Add-a-Version-keyword-to-receiving-email.-5622.patch

Correctly indented files, please remove the rest - Wael Nasreddine, 2010-06-05 12:55

Download (4.7 KB)

View differences:

app/models/mail_handler.rb
123 123
    assigned_to = (get_keyword(:assigned_to, :override => true) && find_user_from_keyword(get_keyword(:assigned_to, :override => true)))
124 124
    due_date = get_keyword(:due_date, :override => true)
125 125
    start_date = get_keyword(:start_date, :override => true)
126
    version = (get_keyword(:version, :override => true) && project.versions.find_by_name(get_keyword(:version)))
126 127

  
127 128
    # check permission
128 129
    unless @@handler_options[:no_permission_check]
129 130
      raise UnauthorizedAction unless user.allowed_to?(:add_issues, project)
130 131
    end
131 132

  
132
    issue = Issue.new(:author => user, :project => project, :tracker => tracker, :category => category, :priority => priority, :due_date => due_date, :start_date => start_date, :assigned_to => assigned_to)
133
    issue = Issue.new(:author => user, :project => project, :tracker => tracker, :category => category, :priority => priority, :due_date => due_date, :start_date => start_date, :assigned_to => assigned_to, :fixed_version => version)
133 134
    # check workflow
134 135
    if status && issue.new_statuses_allowed_to(user).include?(status)
135 136
      issue.status = status
......
165 166
  
166 167
  # Adds a note to an existing issue
167 168
  def receive_issue_reply(issue_id)
169
    project = target_project
168 170
    status =  (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status)))
169 171
    due_date = get_keyword(:due_date, :override => true)
170 172
    start_date = get_keyword(:start_date, :override => true)
171 173
    assigned_to = (get_keyword(:assigned_to, :override => true) && find_user_from_keyword(get_keyword(:assigned_to, :override => true)))
174
    version = (get_keyword(:version, :override => true) && project.versions.find_by_name(get_keyword(:version)))
172 175
    
173 176
    issue = Issue.find_by_id(issue_id)
174 177
    return unless issue
......
188 191
    issue.start_date = start_date if start_date
189 192
    issue.due_date = due_date if due_date
190 193
    issue.assigned_to = assigned_to if assigned_to
194
    issue.fixed_version = version if version
191 195
    
192 196
    issue.save!
193 197
    logger.info "MailHandler: issue ##{issue.id} updated by #{user}" if logger && logger.info
test/fixtures/mail_handler/ticket_on_given_project.eml
54 54
due date: 2010-12-31
55 55
Start Date:2010-01-01
56 56
Assigned to: John Smith
57

  
57
Version: Alpha
test/fixtures/mail_handler/ticket_reply_with_status.eml
29 29
due date: 2010-12-31
30 30
Start Date:2010-01-01
31 31
Assigned to: jsmith@somenet.foo
32
Version: 0.5
32 33

  
33 34
------=_NextPart_000_0067_01C8D3CE.711F9CC0
34 35
Content-Type: text/html;
test/unit/mail_handler_test.rb
58 58
    assert_equal '2010-01-01', issue.start_date.to_s
59 59
    assert_equal '2010-12-31', issue.due_date.to_s
60 60
    assert_equal User.find_by_login('jsmith'), issue.assigned_to
61
    assert_equal 'Alpha', issue.fixed_version.name
61 62
    # keywords should be removed from the email body
62 63
    assert !issue.description.match(/^Project:/i)
63 64
    assert !issue.description.match(/^Status:/i)
......
258 259
    assert_equal '2010-01-01', issue.start_date.to_s
259 260
    assert_equal '2010-12-31', issue.due_date.to_s
260 261
    assert_equal User.find_by_login('jsmith'), issue.assigned_to
262
    assert_equal '0.5', issue.fixed_version.name
261 263
  end
262 264

  
263 265
  def test_add_issue_note_should_send_email_notification
264
-