[#501] Ugly patch to stop creating journals when only line endings change
This commit is contained in:
parent
66c4db8669
commit
32f92a5058
|
@ -280,6 +280,13 @@ class Issue < ActiveRecord::Base
|
|||
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
|
||||
end
|
||||
|
||||
|
|
|
@ -875,4 +875,22 @@ class IssueTest < ActiveSupport::TestCase
|
|||
assert issue.save
|
||||
assert_equal 0, ActionMailer::Base.deliveries.size
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue