]> source.dussan.org Git - redmine.git/commitdiff
Merged r14164 (#19538).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 25 Apr 2015 07:20:53 +0000 (07:20 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 25 Apr 2015 07:20:53 +0000 (07:20 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/2.6-stable@14200 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/changeset.rb
test/unit/changeset_test.rb

index 6ef98cdef539f3e0d1a8962c7accd36b625c3760..cd18dcf5f00d9b9f3b2a42d1dcbebd35bdc014b7 100644 (file)
@@ -240,8 +240,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
index c4087272a3973cb9045c6e95e59edb23b8a2aacd..bd58ea92a7976fe3af8ead4f25951e8eb16bc3d5 100644 (file)
@@ -162,6 +162,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'},