2011-06-06 14:17:44 -04:00
|
|
|
require "cases/helper"
|
2008-09-11 16:38:20 -04:00
|
|
|
require 'models/binary'
|
|
|
|
|
|
|
|
class SanitizeTest < ActiveRecord::TestCase
|
|
|
|
def setup
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_sanitize_sql_array_handles_string_interpolation
|
|
|
|
quoted_bambi = ActiveRecord::Base.connection.quote_string("Bambi")
|
|
|
|
assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=%s", "Bambi"])
|
2008-09-21 12:01:15 -04:00
|
|
|
assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=%s", "Bambi".mb_chars])
|
2008-09-11 16:38:20 -04:00
|
|
|
quoted_bambi_and_thumper = ActiveRecord::Base.connection.quote_string("Bambi\nand\nThumper")
|
|
|
|
assert_equal "name=#{quoted_bambi_and_thumper}",Binary.send(:sanitize_sql_array, ["name=%s", "Bambi\nand\nThumper"])
|
2008-09-21 12:01:15 -04:00
|
|
|
assert_equal "name=#{quoted_bambi_and_thumper}",Binary.send(:sanitize_sql_array, ["name=%s", "Bambi\nand\nThumper".mb_chars])
|
2008-09-11 16:38:20 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_sanitize_sql_array_handles_bind_variables
|
|
|
|
quoted_bambi = ActiveRecord::Base.connection.quote("Bambi")
|
|
|
|
assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=?", "Bambi"])
|
2008-09-21 12:01:15 -04:00
|
|
|
assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=?", "Bambi".mb_chars])
|
2008-09-11 16:38:20 -04:00
|
|
|
quoted_bambi_and_thumper = ActiveRecord::Base.connection.quote("Bambi\nand\nThumper")
|
|
|
|
assert_equal "name=#{quoted_bambi_and_thumper}", Binary.send(:sanitize_sql_array, ["name=?", "Bambi\nand\nThumper"])
|
2008-09-21 12:01:15 -04:00
|
|
|
assert_equal "name=#{quoted_bambi_and_thumper}", Binary.send(:sanitize_sql_array, ["name=?", "Bambi\nand\nThumper".mb_chars])
|
2008-09-11 16:38:20 -04:00
|
|
|
end
|
|
|
|
end
|