Sha256: 6c66d6620472254ff72d614f76310da5d92ee6ab69d14973e0e1bad935b82476

Contents?: true

Size: 1.43 KB

Versions: 78

Compression:

Stored size: 1.43 KB

Contents

require "cases/helper"
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"])
    assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=%s", "Bambi".mb_chars])
    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"])
    assert_equal "name=#{quoted_bambi_and_thumper}",Binary.send(:sanitize_sql_array, ["name=%s", "Bambi\nand\nThumper".mb_chars])
  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"])
    assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=?", "Bambi".mb_chars])
    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"])
    assert_equal "name=#{quoted_bambi_and_thumper}", Binary.send(:sanitize_sql_array, ["name=?", "Bambi\nand\nThumper".mb_chars])
  end
end

Version data entries

78 entries across 75 versions & 17 rubygems

Version Path
radiant-1.0.0.rc1 vendor/rails/activerecord/test/cases/sanitize_test.rb
webroar-0.5.0 src/admin_panel/vendor/rails/activerecord/test/cases/sanitize_test.rb
activerecord-2.3.11 test/cases/sanitize_test.rb
radiantcms-couchrest_model-0.2.4 vendor/rails/activerecord/test/cases/sanitize_test.rb
radiantcms-couchrest_model-0.2.2 vendor/rails/activerecord/test/cases/sanitize_test.rb
radiantcms-couchrest_model-0.2.1 vendor/rails/activerecord/test/cases/sanitize_test.rb
radiantcms-couchrest_model-0.2 vendor/rails/activerecord/test/cases/sanitize_test.rb
radiantcms-couchrest_model-0.1.9 vendor/rails/activerecord/test/cases/sanitize_test.rb
radiantcms-couchrest_model-0.1.8 vendor/rails/activerecord/test/cases/sanitize_test.rb
radiantcms-couchrest_model-0.1.7 vendor/rails/activerecord/test/cases/sanitize_test.rb
radiantcms-couchrest_model-0.1.6 vendor/rails/activerecord/test/cases/sanitize_test.rb
radiantcms-couchrest_model-0.1.5 vendor/rails/activerecord/test/cases/sanitize_test.rb
radiantcms-couchrest_model-0.1.4 vendor/rails/activerecord/test/cases/sanitize_test.rb
radiantcms-couchrest_model-0.1.3 vendor/rails/activerecord/test/cases/sanitize_test.rb
radiantcms-couchrest_model-0.1.2 vendor/rails/activerecord/test/cases/sanitize_test.rb
radiantcms-couchrest_model-0.1.1 vendor/rails/activerecord/test/cases/sanitize_test.rb
radiantcms-couchrest_model-0.1 vendor/rails/activerecord/test/cases/sanitize_test.rb
activerecord-2.3.10 test/cases/sanitize_test.rb
activerecord-2.3.9 test/cases/sanitize_test.rb
activerecord-2.3.9.pre test/cases/sanitize_test.rb