mirror of
https://github.com/github/rails.git
synced 2026-01-10 07:07:54 -05:00
Fixtures: correct escaping of \n and \r. Closes #5859.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4811 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Fixtures: correct escaping of \n and \r. #5859 [evgeny.zislis@gmail.com]
|
||||
|
||||
* Migrations: gracefully handle missing migration files. #5857 [eli.gordon@gmail.com]
|
||||
|
||||
* MySQL: update test schema for MySQL 5 strict mode. #5861 [Tom Ward]
|
||||
|
||||
@@ -396,7 +396,7 @@ class Fixture #:nodoc:
|
||||
|
||||
list = @fixture.inject([]) do |fixtures, (key, value)|
|
||||
col = klass.columns_hash[key] if klass.kind_of?(ActiveRecord::Base)
|
||||
fixtures << ActiveRecord::Base.connection.quote(value, col).gsub('\\n', "\n").gsub('\\r', "\r")
|
||||
fixtures << ActiveRecord::Base.connection.quote(value, col).gsub('[^\]\\n', "\n").gsub('[^\]\\r', "\r")
|
||||
end
|
||||
list * ', '
|
||||
end
|
||||
|
||||
10
activerecord/test/fixtures/funny_jokes.yml
vendored
10
activerecord/test/fixtures/funny_jokes.yml
vendored
@@ -4,11 +4,7 @@ a_joke:
|
||||
|
||||
another_joke:
|
||||
id: 2
|
||||
name: The Aristocrats
|
||||
a_joke:
|
||||
id: 1
|
||||
name: Knock knock
|
||||
name: |
|
||||
The \n Aristocrats
|
||||
Ate the candy
|
||||
|
||||
another_joke:
|
||||
id: 2
|
||||
name: The Aristocrats
|
||||
@@ -344,6 +344,15 @@ class InvalidTableNameFixturesTest < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
class CheckEscapedYamlFixturesTest < Test::Unit::TestCase
|
||||
set_fixture_class :funny_jokes => 'Joke'
|
||||
fixtures :funny_jokes
|
||||
|
||||
def test_proper_escaped_fixture
|
||||
assert_equal "The \\n Aristocrats\nAte the candy\n", funny_jokes(:another_joke).name
|
||||
end
|
||||
end
|
||||
|
||||
class DevelopersProject; end;
|
||||
|
||||
class ManyToManyFixturesWithClassDefined < Test::Unit::TestCase
|
||||
|
||||
Reference in New Issue
Block a user