diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-01-01 10:00:08 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-01-01 10:00:08 -0700 |
commit | 19537ecd0fcc888842a49007187c371fcb454d11 (patch) | |
tree | 95cf901e0085bfe3f6fffd09bb95dacfae552546 /activerecord/test/cases | |
parent | 03f6e235a32b4ba540db11586b66416e780bc3d7 (diff) | |
download | rails-19537ecd0fcc888842a49007187c371fcb454d11.tar.gz rails-19537ecd0fcc888842a49007187c371fcb454d11.tar.bz2 rails-19537ecd0fcc888842a49007187c371fcb454d11.zip |
Stop relying on columns in sqlite quoting tests
The string encoding test wasn't using the types for anything. The
boolean casting test included logic that should be in the tests for the
types, and the string test was legitimately not testing anything useful.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/adapters/sqlite3/quoting_test.rb | 23 | ||||
-rw-r--r-- | activerecord/test/cases/type/integer_test.rb | 6 |
2 files changed, 7 insertions, 22 deletions
diff --git a/activerecord/test/cases/adapters/sqlite3/quoting_test.rb b/activerecord/test/cases/adapters/sqlite3/quoting_test.rb index ac8332e2fa..dd10995a1d 100644 --- a/activerecord/test/cases/adapters/sqlite3/quoting_test.rb +++ b/activerecord/test/cases/adapters/sqlite3/quoting_test.rb @@ -15,10 +15,9 @@ module ActiveRecord def test_type_cast_binary_encoding_without_logger @conn.extend(Module.new { def logger; end }) - column = Column.new(nil, nil, Type::String.new) binary = SecureRandom.hex expected = binary.dup.encode!(Encoding::UTF_8) - assert_equal expected, @conn.type_cast(binary, column) + assert_equal expected, @conn.type_cast(binary) end def test_type_cast_symbol @@ -47,31 +46,11 @@ module ActiveRecord end def test_type_cast_true - c = Column.new(nil, 1, Type::Integer.new) assert_equal 't', @conn.type_cast(true, nil) - assert_equal 1, @conn.type_cast(true, c) end def test_type_cast_false - c = Column.new(nil, 1, Type::Integer.new) assert_equal 'f', @conn.type_cast(false, nil) - assert_equal 0, @conn.type_cast(false, c) - end - - def test_type_cast_string - assert_equal '10', @conn.type_cast('10', nil) - - c = Column.new(nil, 1, Type::Integer.new) - assert_equal 10, @conn.type_cast('10', c) - - c = Column.new(nil, 1, Type::Float.new) - assert_equal 10.1, @conn.type_cast('10.1', c) - - c = Column.new(nil, 1, Type::Binary.new) - assert_equal '10.1', @conn.type_cast('10.1', c) - - c = Column.new(nil, 1, Type::Date.new) - assert_equal '10.1', @conn.type_cast('10.1', c) end def test_type_cast_bigdecimal diff --git a/activerecord/test/cases/type/integer_test.rb b/activerecord/test/cases/type/integer_test.rb index af4d0b4642..ff956b7680 100644 --- a/activerecord/test/cases/type/integer_test.rb +++ b/activerecord/test/cases/type/integer_test.rb @@ -41,6 +41,12 @@ module ActiveRecord assert_nil type.type_cast_from_user(1.0/0.0) end + test "casting booleans for database" do + type = Type::Integer.new + assert_equal 1, type.type_cast_for_database(true) + assert_equal 0, type.type_cast_for_database(false) + end + test "changed?" do type = Type::Integer.new |