@@ -188,7 +188,13 class Issue < ActiveRecord::Base | |||
|
188 | 188 | issue.attributes = options[:attributes] |
|
189 | 189 | end |
|
190 | 190 | if issue.save |
|
191 |
|
|
|
191 | if options[:copy] | |
|
192 | if current_journal && current_journal.notes.present? | |
|
193 | issue.init_journal(current_journal.user, current_journal.notes) | |
|
194 | issue.current_journal.notify = false | |
|
195 | issue.save | |
|
196 | end | |
|
197 | else | |
|
192 | 198 | # Manually update project_id on related time entries |
|
193 | 199 | TimeEntry.update_all("project_id = #{new_project.id}", {:issue_id => id}) |
|
194 | 200 |
@@ -78,4 +78,12 class Journal < ActiveRecord::Base | |||
|
78 | 78 | s << ' has-details' unless details.blank? |
|
79 | 79 | s |
|
80 | 80 | end |
|
81 | ||
|
82 | def notify? | |
|
83 | @notify != false | |
|
84 | end | |
|
85 | ||
|
86 | def notify=(arg) | |
|
87 | @notify = arg | |
|
88 | end | |
|
81 | 89 | end |
@@ -1,5 +1,5 | |||
|
1 |
# |
|
|
2 |
# Copyright (C) 2006-20 |
|
|
1 | # Redmine - project management software | |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
@@ -17,10 +17,12 | |||
|
17 | 17 | |
|
18 | 18 | class JournalObserver < ActiveRecord::Observer |
|
19 | 19 | def after_create(journal) |
|
20 | if Setting.notified_events.include?('issue_updated') || | |
|
21 |
(Setting.notified_events.include?('issue_ |
|
|
22 |
(Setting.notified_events.include?('issue_ |
|
|
23 |
(Setting.notified_events.include?('issue_ |
|
|
20 | if journal.notify? && | |
|
21 | (Setting.notified_events.include?('issue_updated') || | |
|
22 | (Setting.notified_events.include?('issue_note_added') && journal.notes.present?) || | |
|
23 | (Setting.notified_events.include?('issue_status_updated') && journal.new_status.present?) || | |
|
24 | (Setting.notified_events.include?('issue_priority_updated') && journal.new_value_for('priority_id').present?) | |
|
25 | ) | |
|
24 | 26 | Mailer.deliver_issue_edit(journal) |
|
25 | 27 | end |
|
26 | 28 | end |
@@ -112,6 +112,19 class IssueMovesControllerTest < ActionController::TestCase | |||
|
112 | 112 | assert_equal '2009-12-31', issue.due_date.to_s, "Due date is incorrect" |
|
113 | 113 | end |
|
114 | 114 | end |
|
115 | ||
|
116 | should "allow adding a note when copying" do | |
|
117 | @request.session[:user_id] = 2 | |
|
118 | assert_difference 'Issue.count', 1 do | |
|
119 | post :create, :ids => [1], :copy_options => {:copy => '1'}, :notes => 'Copying one issue', :new_tracker_id => '', :assigned_to_id => 4, :status_id => 3, :start_date => '2009-12-01', :due_date => '2009-12-31' | |
|
120 | end | |
|
121 | ||
|
122 | issue = Issue.first(:order => 'id DESC') | |
|
123 | assert_equal 1, issue.journals.size | |
|
124 | journal = issue.journals.first | |
|
125 | assert_equal 0, journal.details.size | |
|
126 | assert_equal 'Copying one issue', journal.notes | |
|
127 | end | |
|
115 | 128 | end |
|
116 | 129 | |
|
117 | 130 | def test_copy_to_another_project_should_follow_when_needed |
@@ -522,6 +522,11 class IssueTest < ActiveSupport::TestCase | |||
|
522 | 522 | @issue = Issue.find(1) |
|
523 | 523 | @copy = nil |
|
524 | 524 | end |
|
525 | ||
|
526 | should "not create a journal" do | |
|
527 | @copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:assigned_to_id => 3}}) | |
|
528 | assert_equal 0, @copy.reload.journals.size | |
|
529 | end | |
|
525 | 530 | |
|
526 | 531 | should "allow assigned_to changes" do |
|
527 | 532 | @copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:assigned_to_id => 3}}) |
@@ -552,6 +557,19 class IssueTest < ActiveSupport::TestCase | |||
|
552 | 557 | |
|
553 | 558 | assert_equal User.current, @copy.author |
|
554 | 559 | end |
|
560 | ||
|
561 | should "keep journal notes" do | |
|
562 | date = Date.today | |
|
563 | notes = "Notes added when copying" | |
|
564 | User.current = User.find(9) | |
|
565 | @issue.init_journal(User.current, notes) | |
|
566 | @copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:start_date => date}}) | |
|
567 | ||
|
568 | assert_equal 1, @copy.journals.size | |
|
569 | journal = @copy.journals.first | |
|
570 | assert_equal 0, journal.details.size | |
|
571 | assert_equal notes, journal.notes | |
|
572 | end | |
|
555 | 573 | end |
|
556 | 574 | end |
|
557 | 575 |
@@ -1,5 +1,5 | |||
|
1 |
# |
|
|
2 |
# Copyright (C) 2006-20 |
|
|
1 | # Redmine - project management software | |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
@@ -35,6 +35,17 class JournalObserverTest < ActiveSupport::TestCase | |||
|
35 | 35 | assert journal.save |
|
36 | 36 | assert_equal 1, ActionMailer::Base.deliveries.size |
|
37 | 37 | end |
|
38 | ||
|
39 | def test_create_should_not_send_email_notification_with_notify_set_to_false | |
|
40 | Setting.notified_events = ['issue_updated'] | |
|
41 | issue = Issue.find(:first) | |
|
42 | user = User.find(:first) | |
|
43 | journal = issue.init_journal(user, issue) | |
|
44 | journal.notify = false | |
|
45 | ||
|
46 | assert journal.save | |
|
47 | assert_equal 0, ActionMailer::Base.deliveries.size | |
|
48 | end | |
|
38 | 49 | |
|
39 | 50 | def test_create_should_not_send_email_notification_without_issue_updated |
|
40 | 51 | Setting.notified_events = [] |
General Comments 0
You need to be logged in to leave comments.
Login now