Project

General

Profile

Feature #16098 » 16098_notified_events_relation.patch

Yuichi HARADA, 2019-09-25 09:11

View differences:

app/models/journal.rb
308 308
        (Setting.notified_events.include?('issue_note_added') && notes.present?) ||
309 309
        (Setting.notified_events.include?('issue_status_updated') && new_status.present?) ||
310 310
        (Setting.notified_events.include?('issue_assigned_to_updated') && detail_for_attribute('assigned_to_id').present?) ||
311
        (Setting.notified_events.include?('issue_priority_updated') && new_value_for('priority_id').present?)
311
        (Setting.notified_events.include?('issue_priority_updated') && new_value_for('priority_id').present?) ||
312
        (Setting.notified_events.include?('issue_relation_updated') && details.any?{|detail| detail.property == 'relation'})
312 313
      )
313 314
      Mailer.deliver_issue_edit(self)
314 315
    end
config/locales/en.yml
588 588
  label_issue_status_updated: Status updated
589 589
  label_issue_assigned_to_updated: Assignee updated
590 590
  label_issue_priority_updated: Priority updated
591
  label_issue_relation_updated: Relation updated
591 592
  label_document: Document
592 593
  label_document_new: New document
593 594
  label_document_plural: Documents
lib/redmine/notifiable.rb
16 16
      notifications << Notifiable.new('issue_status_updated', 'issue_updated')
17 17
      notifications << Notifiable.new('issue_assigned_to_updated', 'issue_updated')
18 18
      notifications << Notifiable.new('issue_priority_updated', 'issue_updated')
19
      notifications << Notifiable.new('issue_relation_updated', 'issue_updated')
19 20
      notifications << Notifiable.new('news_added')
20 21
      notifications << Notifiable.new('news_comment_added')
21 22
      notifications << Notifiable.new('document_added')
test/unit/journal_observer_test.rb
22 22
class JournalObserverTest < ActiveSupport::TestCase
23 23
  fixtures :issues, :issue_statuses, :journals, :journal_details, :projects,
24 24
           :projects_trackers, :trackers, :enabled_modules, :enumerations,
25
           :users, :email_addresses, :roles, :members, :member_roles
25
           :users, :email_addresses, :roles, :members, :member_roles,
26
           :issue_relations, :watchers
26 27

  
27 28
  def setup
28 29
    User.current = nil
29 30
    ActionMailer::Base.deliveries.clear
30
    @journal = Journal.find 1
31 31
  end
32 32

  
33 33
  # context: issue_updated notified_events
......
174 174
    end
175 175
    assert_equal 0, ActionMailer::Base.deliveries.size
176 176
  end
177

  
178
  def test_create_relation_should_send_email_notification_with_issue_relation_updated
179
    IssueRelation.delete_all
180
    Watcher.delete_all
181
    issue = Issue.generate!
182
    user = User.find_by_login('jsmith')
183

  
184
    ActionMailer::Base.deliveries.clear
185
    with_settings :notified_events => %w(issue_relation_updated) do
186
      relation = IssueRelation.new(:relation_type => IssueRelation::TYPE_RELATES, :issue_from_id => issue.id, :issue_to_id => 1)
187
      relation.init_journals(user)
188
      assert relation.save
189
    end
190
    assert_equal 2, ActionMailer::Base.deliveries.size
191

  
192
    ActionMailer::Base.deliveries.clear
193
    with_settings :notified_events => [] do
194
      relation = IssueRelation.new(:relation_type => IssueRelation::TYPE_DUPLICATES, :issue_from_id => issue.id, :issue_to_id => 2)
195
      relation.init_journals(user)
196
      assert relation.save
197
    end
198
    assert_equal 0, ActionMailer::Base.deliveries.size
199
  end
177 200
end
(2-2/6)