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
p8-castronaut-0.6.1.1 vendor/activerecord/test/cases/sanitize_test.rb
relevance-castronaut-0.6.0 vendor/activerecord/test/cases/sanitize_test.rb
relevance-castronaut-0.6.1 vendor/activerecord/test/cases/sanitize_test.rb
relevance-castronaut-0.7.4 vendor/activerecord/test/cases/sanitize_test.rb
relevance-castronaut-0.7.5 vendor/activerecord/test/cases/sanitize_test.rb
activerecord-nuodb-adapter-2.0.3 test/cases/sanitize_test.rb
activerecord-nuodb-adapter-2.0 test/cases/sanitize_test.rb
activerecord-2.3.18 test/cases/sanitize_test.rb
activerecord_csi-2.3.5.p8 test/cases/sanitize_test.rb
activerecord-2.3.17 test/cases/sanitize_test.rb
activerecord_csi-2.3.5.p7 test/cases/sanitize_test.rb
activerecord_csi-2.3.5.p6 test/cases/sanitize_test.rb
activerecord-2.3.16 test/cases/sanitize_test.rb
activerecord-2.3.15 test/cases/sanitize_test.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/activerecord-2.3.14/test/cases/sanitize_test.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/activerecord-2.3.12/test/cases/sanitize_test.rb
activerecord-2.3.14 test/cases/sanitize_test.rb
kajam-1.0.3.rc2 vendor/rails/activerecord/test/cases/sanitize_test.rb
activerecord-2.3.12 test/cases/sanitize_test.rb
radiant-1.0.0.rc2 vendor/rails/activerecord/test/cases/sanitize_test.rb