class ActiveRecord::ConnectionAdapters::QuotingTest
Public Instance Methods
setup()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 8 def setup @quoter = Class.new { include Quoting }.new end
test_crazy_object()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 146 def test_crazy_object crazy = Object.new e = assert_raises(TypeError) do @quoter.quote(crazy) end assert_equal "can't quote Object", e.message end
test_dates_and_times()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 135 def test_dates_and_times @quoter.extend(Module.new { def quoted_date(value) "lol" end }) assert_equal "'lol'", @quoter.quote(Date.today) assert_equal "'lol'", @quoter.quote(Time.now) assert_equal "'lol'", @quoter.quote(DateTime.now) end
test_quote_as_mb_chars_no_column()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 158 def test_quote_as_mb_chars_no_column string = ActiveSupport::Multibyte::Chars.new('lo\l') assert_equal "'lo\\\\l'", @quoter.quote(string) end
test_quote_bigdecimal()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 130 def test_quote_bigdecimal bigdec = BigDecimal.new((1 << 100).to_s) assert_equal bigdec.to_s("F"), @quoter.quote(bigdec) end
test_quote_bignum()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 125 def test_quote_bignum bignum = 1 << 100 assert_equal bignum.to_s, @quoter.quote(bignum) end
test_quote_column_name()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 20 def test_quote_column_name assert_equal "foo", @quoter.quote_column_name("foo") end
test_quote_duration()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 163 def test_quote_duration assert_equal "1800", @quoter.quote(30.minutes) end
test_quote_false()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 111 def test_quote_false assert_equal @quoter.quoted_false, @quoter.quote(false) end
test_quote_float()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 115 def test_quote_float float = 1.2 assert_equal float.to_s, @quoter.quote(float) end
test_quote_integer()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 120 def test_quote_integer integer = 1 assert_equal integer.to_s, @quoter.quote(integer) end
test_quote_nil()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 103 def test_quote_nil assert_equal "NULL", @quoter.quote(nil) end
test_quote_string()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 37 def test_quote_string assert_equal "''", @quoter.quote_string("'") assert_equal "\\\\", @quoter.quote_string("\\") assert_equal "hi''i", @quoter.quote_string("hi'i") assert_equal "hi\\\\i", @quoter.quote_string("hi\\i") end
test_quote_string_no_column()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 154 def test_quote_string_no_column assert_equal "'lo\\\\l'", @quoter.quote('lo\l') end
test_quote_table_name()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 24 def test_quote_table_name assert_equal "foo", @quoter.quote_table_name("foo") end
test_quote_table_name_calls_quote_column_name()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 28 def test_quote_table_name_calls_quote_column_name @quoter.extend(Module.new { def quote_column_name(string) "lol" end }) assert_equal "lol", @quoter.quote_table_name("foo") end
test_quote_true()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 107 def test_quote_true assert_equal @quoter.quoted_true, @quoter.quote(true) end
test_quote_with_quoted_id()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 93 def test_quote_with_quoted_id assert_deprecated(/defined on \S+::QuotedOne at .*quoting_test\.rb:[0-9]/) do assert_equal 1, @quoter.quote(QuotedOne.new) end assert_deprecated(/defined on \S+::SubQuotedOne\(\S+::QuotedOne\) at .*quoting_test\.rb:[0-9]/) do assert_equal 1, @quoter.quote(SubQuotedOne.new) end end
test_quoted_date()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 44 def test_quoted_date t = Date.today assert_equal t.to_s(:db), @quoter.quoted_date(t) end
test_quoted_datetime_local()
click to toggle source
DateTime
doesn't define getlocal, so make sure it does nothing
# File activerecord/test/cases/quoting_test.rb, line 79 def test_quoted_datetime_local with_timezone_config default: :local do t = Time.now.change(usec: 0).to_datetime assert_equal t.to_s(:db), @quoter.quoted_date(t) end end
test_quoted_datetime_utc()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 70 def test_quoted_datetime_utc with_timezone_config default: :utc do t = Time.now.change(usec: 0).to_datetime assert_equal t.getutc.to_s(:db), @quoter.quoted_date(t) end end
test_quoted_false()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 16 def test_quoted_false assert_equal "FALSE", @quoter.quoted_false end
test_quoted_time_crazy()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 63 def test_quoted_time_crazy with_timezone_config default: :asdfasdf do t = Time.now.change(usec: 0) assert_equal t.getlocal.to_s(:db), @quoter.quoted_date(t) end end
test_quoted_time_local()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 56 def test_quoted_time_local with_timezone_config default: :local do t = Time.now.change(usec: 0) assert_equal t.getlocal.to_s(:db), @quoter.quoted_date(t) end end
test_quoted_time_utc()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 49 def test_quoted_time_utc with_timezone_config default: :utc do t = Time.now.change(usec: 0) assert_equal t.getutc.to_s(:db), @quoter.quoted_date(t) end end
test_quoted_true()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 12 def test_quoted_true assert_equal "TRUE", @quoter.quoted_true end
test_quoting_classes()
click to toggle source
# File activerecord/test/cases/quoting_test.rb, line 142 def test_quoting_classes assert_equal "'Object'", @quoter.quote(Object) end