aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-10-11 17:40:36 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-10-11 17:52:10 -0700
commit2610bcbd94760bf7d601dae9477ae112a0a1147b (patch)
treef4813edf048a65fee8d102d5df55e50bb26926a8
parentb9d4341bd00280f2bd33a9d55a82d8a28c1efd02 (diff)
downloadrails-2610bcbd94760bf7d601dae9477ae112a0a1147b.tar.gz
rails-2610bcbd94760bf7d601dae9477ae112a0a1147b.tar.bz2
rails-2610bcbd94760bf7d601dae9477ae112a0a1147b.zip
getting quoted_time under more specific tests
-rw-r--r--activerecord/test/cases/quoting_test.rb65
1 files changed, 65 insertions, 0 deletions
diff --git a/activerecord/test/cases/quoting_test.rb b/activerecord/test/cases/quoting_test.rb
index bfb287749c..bd4b174b12 100644
--- a/activerecord/test/cases/quoting_test.rb
+++ b/activerecord/test/cases/quoting_test.rb
@@ -19,12 +19,77 @@ module ActiveRecord
assert_equal "foo", @quoter.quote_column_name('foo')
end
+ def test_quote_table_name
+ assert_equal "foo", @quoter.quote_table_name('foo')
+ end
+
+ 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
+
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
+
+ def test_quoted_date
+ t = Date.today
+ assert_equal t.to_s(:db), @quoter.quoted_date(t)
+ end
+
+ def test_quoted_time_utc
+ before = ActiveRecord::Base.default_timezone
+ ActiveRecord::Base.default_timezone = :utc
+ t = Time.now
+ assert_equal t.getutc.to_s(:db), @quoter.quoted_date(t)
+ ensure
+ ActiveRecord::Base.default_timezone = before
+ end
+
+ def test_quoted_time_local
+ before = ActiveRecord::Base.default_timezone
+ ActiveRecord::Base.default_timezone = :local
+ t = Time.now
+ assert_equal t.getlocal.to_s(:db), @quoter.quoted_date(t)
+ ensure
+ ActiveRecord::Base.default_timezone = before
+ end
+
+ def test_quoted_time_crazy
+ before = ActiveRecord::Base.default_timezone
+ ActiveRecord::Base.default_timezone = :asdfasdf
+ t = Time.now
+ assert_equal t.getlocal.to_s(:db), @quoter.quoted_date(t)
+ ensure
+ ActiveRecord::Base.default_timezone = before
+ end
+
+ def test_quoted_datetime_utc
+ before = ActiveRecord::Base.default_timezone
+ ActiveRecord::Base.default_timezone = :utc
+ t = DateTime.now
+ assert_equal t.getutc.to_s(:db), @quoter.quoted_date(t)
+ ensure
+ ActiveRecord::Base.default_timezone = before
+ end
+
+ ###
+ # DateTime doesn't define getlocal, so make sure it does nothing
+ def test_quoted_datetime_local
+ before = ActiveRecord::Base.default_timezone
+ ActiveRecord::Base.default_timezone = :local
+ t = DateTime.now
+ assert_equal t.to_s(:db), @quoter.quoted_date(t)
+ ensure
+ ActiveRecord::Base.default_timezone = before
+ end
end
end
end