##// END OF EJS Templates
Merged r6147 and r6149 from trunk....
Jean-Philippe Lang -
r6040:8e87cd6f772a
parent child
Show More
@@ -228,6 +228,13 class Issue < ActiveRecord::Base
228 result
228 result
229 end
229 end
230
230
231 def description=(arg)
232 if arg.is_a?(String)
233 arg = arg.gsub(/(\r\n|\n|\r)/, "\r\n")
234 end
235 write_attribute(:description, arg)
236 end
237
231 # Overrides attributes= so that tracker_id gets assigned first
238 # Overrides attributes= so that tracker_id gets assigned first
232 def attributes_with_tracker_first=(new_attributes, *args)
239 def attributes_with_tracker_first=(new_attributes, *args)
233 return if new_attributes.nil?
240 return if new_attributes.nil?
@@ -870,10 +877,13 class Issue < ActiveRecord::Base
870 if @current_journal
877 if @current_journal
871 # attributes changes
878 # attributes changes
872 (Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on)).each {|c|
879 (Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on)).each {|c|
880 before = @issue_before_change.send(c)
881 after = send(c)
882 next if before == after || (before.blank? && after.blank?)
873 @current_journal.details << JournalDetail.new(:property => 'attr',
883 @current_journal.details << JournalDetail.new(:property => 'attr',
874 :prop_key => c,
884 :prop_key => c,
875 :old_value => @issue_before_change.send(c),
885 :old_value => @issue_before_change.send(c),
876 :value => send(c)) unless send(c)==@issue_before_change.send(c)
886 :value => send(c))
877 }
887 }
878 # custom fields changes
888 # custom fields changes
879 custom_values.each {|c|
889 custom_values.each {|c|
@@ -734,6 +734,27 class IssueTest < ActiveSupport::TestCase
734 assert_equal new_description, detail.value
734 assert_equal new_description, detail.value
735 end
735 end
736
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.find(1)
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
752
753 def test_description_eol_should_be_normalized
754 i = Issue.new(:description => "CR \r LF \n CRLF \r\n")
755 assert_equal "CR \r\n LF \r\n CRLF \r\n", i.description
756 end
757
737 def test_saving_twice_should_not_duplicate_journal_details
758 def test_saving_twice_should_not_duplicate_journal_details
738 i = Issue.find(:first)
759 i = Issue.find(:first)
739 i.init_journal(User.find(2), 'Some notes')
760 i.init_journal(User.find(2), 'Some notes')
General Comments 0
You need to be logged in to leave comments. Login now