]> source.dussan.org Git - redmine.git/commitdiff
Do not journalize blank description changes (#8712).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 2 Jul 2011 11:05:27 +0000 (11:05 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 2 Jul 2011 11:05:27 +0000 (11:05 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6147 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue.rb
test/unit/issue_test.rb

index ea18e03ebfe58f75789d3a1e3cdfaaad404be3b1..5fe0d0517b6581a8c52c7e50ce4637bf50f2c833 100644 (file)
@@ -870,10 +870,13 @@ class Issue < ActiveRecord::Base
     if @current_journal
       # attributes changes
       (Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on)).each {|c|
+        before = @issue_before_change.send(c)
+        after = send(c)
+        next if before == after || (before.blank? && after.blank?)
         @current_journal.details << JournalDetail.new(:property => 'attr',
                                                       :prop_key => c,
                                                       :old_value => @issue_before_change.send(c),
-                                                      :value => send(c)) unless send(c)==@issue_before_change.send(c)
+                                                      :value => send(c))
       }
       # custom fields changes
       custom_values.each {|c|
index eee84ce2621ca9c9d13a0f6415fe70c4fcbf2e25..92f604e52364f1ccea3584f0766b9572aa3818d5 100644 (file)
@@ -733,6 +733,22 @@ class IssueTest < ActiveSupport::TestCase
     assert_equal old_description, detail.old_value
     assert_equal new_description, detail.value
   end
+  
+  def test_blank_descriptions_should_not_be_journalized
+    IssueCustomField.delete_all
+    Issue.update_all("description = NULL", "id=1")
+    
+    i = Issue.first
+    i.init_journal(User.find(2))
+    i.subject = "blank description"
+    i.description = "\r\n"
+    
+    assert_difference 'Journal.count', 1 do
+      assert_difference 'JournalDetail.count', 1 do
+        i.save!
+      end
+    end
+  end
 
   def test_saving_twice_should_not_duplicate_journal_details
     i = Issue.find(:first)