summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-04-25 07:20:44 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-04-25 07:20:44 +0000
commit737cbcc2e909affdbad1869a40e40cf37f2dd907 (patch)
tree7c8e0d510b190ebb96a46e28d4c6af13b7aa381f
parentd904292635b1479766f6eb3d503213f8c3c10ec0 (diff)
downloadredmine-737cbcc2e909affdbad1869a40e40cf37f2dd907.tar.gz
redmine-737cbcc2e909affdbad1869a40e40cf37f2dd907.zip
Merged r14164 (#19538).
git-svn-id: http://svn.redmine.org/redmine/branches/3.0-stable@14199 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/changeset.rb7
-rw-r--r--test/unit/changeset_test.rb24
2 files changed, 29 insertions, 2 deletions
diff --git a/app/models/changeset.rb b/app/models/changeset.rb
index 499191070..13213f3ab 100644
--- a/app/models/changeset.rb
+++ b/app/models/changeset.rb
@@ -242,8 +242,11 @@ class Changeset < ActiveRecord::Base
end
Redmine::Hook.call_hook(:model_changeset_scan_commit_for_issue_ids_pre_issue_update,
{ :changeset => self, :issue => issue, :action => action })
- unless issue.save
- logger.warn("Issue ##{issue.id} could not be saved by changeset #{id}: #{issue.errors.full_messages}") if logger
+
+ if issue.changes.any?
+ unless issue.save
+ logger.warn("Issue ##{issue.id} could not be saved by changeset #{id}: #{issue.errors.full_messages}") if logger
+ end
end
issue
end
diff --git a/test/unit/changeset_test.rb b/test/unit/changeset_test.rb
index 7cbc33f11..8c0611e45 100644
--- a/test/unit/changeset_test.rb
+++ b/test/unit/changeset_test.rb
@@ -163,6 +163,30 @@ class ChangesetTest < ActiveSupport::TestCase
assert_equal [1,2,3], c.issue_ids.sort
end
+ def test_update_keywords_with_changes_should_create_journal
+ issue = Issue.generate!(:project_id => 1, :status_id => 1)
+
+ with_settings :commit_update_keywords => [{'keywords' => 'fixes', 'status_id' => '3'}] do
+ assert_difference 'Journal.count' do
+ c = Changeset.generate!(:repository => Project.find(1).repository,:comments => "Fixes ##{issue.id}")
+ assert_include c.id, issue.reload.changeset_ids
+ journal = Journal.order('id DESC').first
+ assert_equal 1, journal.details.count
+ end
+ end
+ end
+
+ def test_update_keywords_without_change_should_not_create_journal
+ issue = Issue.generate!(:project_id => 1, :status_id => 3)
+
+ with_settings :commit_update_keywords => [{'keywords' => 'fixes', 'status_id' => '3'}] do
+ assert_no_difference 'Journal.count' do
+ c = Changeset.generate!(:repository => Project.find(1).repository,:comments => "Fixes ##{issue.id}")
+ assert_include c.id, issue.reload.changeset_ids
+ end
+ end
+ end
+
def test_update_keywords_with_multiple_rules
with_settings :commit_update_keywords => [
{'keywords' => 'fixes, closes', 'status_id' => '5'},