[#501] Ugly patch to stop creating journals when only line endings change

This commit is contained in:
Eric Davis 2011-07-01 12:25:07 -07:00
parent 66c4db8669
commit 32f92a5058
2 changed files with 25 additions and 0 deletions

View File

@ -280,6 +280,13 @@ class Issue < ActiveRecord::Base
end end
end end
# Bug #501: browsers might swap the line endings causing a Journal.
if attrs.has_key?('description') && attrs['description'].present?
if attrs['description'].gsub(/\r\n?/,"\n") == self.description
attrs.delete('description')
end
end
self.attributes = attrs self.attributes = attrs
end end

View File

@ -875,4 +875,22 @@ class IssueTest < ActiveSupport::TestCase
assert issue.save assert issue.save
assert_equal 0, ActionMailer::Base.deliveries.size assert_equal 0, ActionMailer::Base.deliveries.size
end end
test 'changing the line endings in a description will not be recorded as a Journal' do
User.current = User.find(1)
issue = Issue.find(1)
issue.update_attribute(:description, "Description with newlines\n\nembedded")
issue.reload
assert issue.description.include?("\n")
assert_no_difference("Journal.count") do
issue.safe_attributes= {
'description' => "Description with newlines\r\n\r\nembedded"
}
assert issue.save
end
assert_equal "Description with newlines\n\nembedded", issue.reload.description
end
end end