Commit 32f92a50 authored by Eric Davis's avatar Eric Davis

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

parent 66c4db86
...@@ -280,6 +280,13 @@ class Issue < ActiveRecord::Base ...@@ -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
......
...@@ -875,4 +875,22 @@ class IssueTest < ActiveSupport::TestCase ...@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment