git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5602 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
88a93d7e10
commit
fdb0151869
|
@ -188,7 +188,13 @@ class Issue < ActiveRecord::Base
|
||||||
issue.attributes = options[:attributes]
|
issue.attributes = options[:attributes]
|
||||||
end
|
end
|
||||||
if issue.save
|
if issue.save
|
||||||
unless options[:copy]
|
if options[:copy]
|
||||||
|
if current_journal && current_journal.notes.present?
|
||||||
|
issue.init_journal(current_journal.user, current_journal.notes)
|
||||||
|
issue.current_journal.notify = false
|
||||||
|
issue.save
|
||||||
|
end
|
||||||
|
else
|
||||||
# Manually update project_id on related time entries
|
# Manually update project_id on related time entries
|
||||||
TimeEntry.update_all("project_id = #{new_project.id}", {:issue_id => id})
|
TimeEntry.update_all("project_id = #{new_project.id}", {:issue_id => id})
|
||||||
|
|
||||||
|
|
|
@ -78,4 +78,12 @@ class Journal < ActiveRecord::Base
|
||||||
s << ' has-details' unless details.blank?
|
s << ' has-details' unless details.blank?
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def notify?
|
||||||
|
@notify != false
|
||||||
|
end
|
||||||
|
|
||||||
|
def notify=(arg)
|
||||||
|
@notify = arg
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
|
@ -17,10 +17,12 @@
|
||||||
|
|
||||||
class JournalObserver < ActiveRecord::Observer
|
class JournalObserver < ActiveRecord::Observer
|
||||||
def after_create(journal)
|
def after_create(journal)
|
||||||
if Setting.notified_events.include?('issue_updated') ||
|
if journal.notify? &&
|
||||||
(Setting.notified_events.include?('issue_note_added') && journal.notes.present?) ||
|
(Setting.notified_events.include?('issue_updated') ||
|
||||||
(Setting.notified_events.include?('issue_status_updated') && journal.new_status.present?) ||
|
(Setting.notified_events.include?('issue_note_added') && journal.notes.present?) ||
|
||||||
(Setting.notified_events.include?('issue_priority_updated') && journal.new_value_for('priority_id').present?)
|
(Setting.notified_events.include?('issue_status_updated') && journal.new_status.present?) ||
|
||||||
|
(Setting.notified_events.include?('issue_priority_updated') && journal.new_value_for('priority_id').present?)
|
||||||
|
)
|
||||||
Mailer.deliver_issue_edit(journal)
|
Mailer.deliver_issue_edit(journal)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -112,6 +112,19 @@ class IssueMovesControllerTest < ActionController::TestCase
|
||||||
assert_equal '2009-12-31', issue.due_date.to_s, "Due date is incorrect"
|
assert_equal '2009-12-31', issue.due_date.to_s, "Due date is incorrect"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "allow adding a note when copying" do
|
||||||
|
@request.session[:user_id] = 2
|
||||||
|
assert_difference 'Issue.count', 1 do
|
||||||
|
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'
|
||||||
|
end
|
||||||
|
|
||||||
|
issue = Issue.first(:order => 'id DESC')
|
||||||
|
assert_equal 1, issue.journals.size
|
||||||
|
journal = issue.journals.first
|
||||||
|
assert_equal 0, journal.details.size
|
||||||
|
assert_equal 'Copying one issue', journal.notes
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_copy_to_another_project_should_follow_when_needed
|
def test_copy_to_another_project_should_follow_when_needed
|
||||||
|
|
|
@ -522,6 +522,11 @@ class IssueTest < ActiveSupport::TestCase
|
||||||
@issue = Issue.find(1)
|
@issue = Issue.find(1)
|
||||||
@copy = nil
|
@copy = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "not create a journal" do
|
||||||
|
@copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:assigned_to_id => 3}})
|
||||||
|
assert_equal 0, @copy.reload.journals.size
|
||||||
|
end
|
||||||
|
|
||||||
should "allow assigned_to changes" do
|
should "allow assigned_to changes" do
|
||||||
@copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:assigned_to_id => 3}})
|
@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
|
||||||
|
|
||||||
assert_equal User.current, @copy.author
|
assert_equal User.current, @copy.author
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "keep journal notes" do
|
||||||
|
date = Date.today
|
||||||
|
notes = "Notes added when copying"
|
||||||
|
User.current = User.find(9)
|
||||||
|
@issue.init_journal(User.current, notes)
|
||||||
|
@copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:start_date => date}})
|
||||||
|
|
||||||
|
assert_equal 1, @copy.journals.size
|
||||||
|
journal = @copy.journals.first
|
||||||
|
assert_equal 0, journal.details.size
|
||||||
|
assert_equal notes, journal.notes
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2009 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
|
@ -35,6 +35,17 @@ class JournalObserverTest < ActiveSupport::TestCase
|
||||||
assert journal.save
|
assert journal.save
|
||||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_create_should_not_send_email_notification_with_notify_set_to_false
|
||||||
|
Setting.notified_events = ['issue_updated']
|
||||||
|
issue = Issue.find(:first)
|
||||||
|
user = User.find(:first)
|
||||||
|
journal = issue.init_journal(user, issue)
|
||||||
|
journal.notify = false
|
||||||
|
|
||||||
|
assert journal.save
|
||||||
|
assert_equal 0, ActionMailer::Base.deliveries.size
|
||||||
|
end
|
||||||
|
|
||||||
def test_create_should_not_send_email_notification_without_issue_updated
|
def test_create_should_not_send_email_notification_without_issue_updated
|
||||||
Setting.notified_events = []
|
Setting.notified_events = []
|
||||||
|
|
Loading…
Reference in New Issue