mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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.
This commit is contained in:
parent
03f6e235a3
commit
19537ecd0f
2 changed files with 7 additions and 22 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue