##// END OF EJS Templates
Do not journalize blank description changes (#8712)....
Jean-Philippe Lang -
r6027:d0d807caf1ef
parent child
Show More
@@ -870,10 +870,13 class Issue < ActiveRecord::Base
870 if @current_journal
870 if @current_journal
871 # attributes changes
871 # attributes changes
872 (Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on)).each {|c|
872 (Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on)).each {|c|
873 before = @issue_before_change.send(c)
874 after = send(c)
875 next if before == after || (before.blank? && after.blank?)
873 @current_journal.details << JournalDetail.new(:property => 'attr',
876 @current_journal.details << JournalDetail.new(:property => 'attr',
874 :prop_key => c,
877 :prop_key => c,
875 :old_value => @issue_before_change.send(c),
878 :old_value => @issue_before_change.send(c),
876 :value => send(c)) unless send(c)==@issue_before_change.send(c)
879 :value => send(c))
877 }
880 }
878 # custom fields changes
881 # custom fields changes
879 custom_values.each {|c|
882 custom_values.each {|c|
@@ -733,6 +733,22 class IssueTest < ActiveSupport::TestCase
733 assert_equal old_description, detail.old_value
733 assert_equal old_description, detail.old_value
734 assert_equal new_description, detail.value
734 assert_equal new_description, detail.value
735 end
735 end
736
737 def test_blank_descriptions_should_not_be_journalized
738 IssueCustomField.delete_all
739 Issue.update_all("description = NULL", "id=1")
740
741 i = Issue.first
742 i.init_journal(User.find(2))
743 i.subject = "blank description"
744 i.description = "\r\n"
745
746 assert_difference 'Journal.count', 1 do
747 assert_difference 'JournalDetail.count', 1 do
748 i.save!
749 end
750 end
751 end
736
752
737 def test_saving_twice_should_not_duplicate_journal_details
753 def test_saving_twice_should_not_duplicate_journal_details
738 i = Issue.find(:first)
754 i = Issue.find(:first)
General Comments 0
You need to be logged in to leave comments. Login now