Commit c754e017 authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

Changeset comments are now stripped before being stored in the database (patch…

Changeset comments are now stripped before being stored in the database (patch by Nicholas Wieland).

git-svn-id: http://redmine.rubyforge.org/svn/trunk@657 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 138566de
......@@ -25,6 +25,10 @@ class Changeset < ActiveRecord::Base
validates_uniqueness_of :revision, :scope => :repository_id
validates_uniqueness_of :scmid, :scope => :repository_id, :allow_nil => true
def comments=(comment)
write_attribute(:comments, comment.strip)
end
def committed_on=(date)
self.commit_date = date
super
......
......@@ -53,4 +53,19 @@ class RepositoryTest < Test::Unit::TestCase
# ignoring commits referencing an issue of another project
assert_equal [], Issue.find(4).changesets
end
def test_for_changeset_comments_strip
repository = Repository::Mercurial.create( :project => Project.find( 4 ), :url => '/foo/bar/baz' )
comment = <<-COMMENT
This is a loooooooooooooooooooooooooooong comment
COMMENT
changeset = Changeset.new(
:comments => comment, :commit_date => Time.now, :revision => 0, :scmid => 'f39b7922fb3c',
:committer => 'foo <foo@example.com>', :committed_on => Time.now, :repository_id => repository )
assert( changeset.save )
assert_not_equal( comment, changeset.comments )
assert_equal( 'This is a loooooooooooooooooooooooooooong comment', changeset.comments )
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