mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #21726 from yui-knk/test/named_bind_arity
Add tests for sanitize named bind arity
This commit is contained in:
commit
eb52c8979b
1 changed files with 9 additions and 3 deletions
|
@ -701,12 +701,12 @@ class FinderTest < ActiveRecord::TestCase
|
|||
end
|
||||
|
||||
def test_bind_arity
|
||||
assert_nothing_raised { bind '' }
|
||||
assert_nothing_raised { bind '' }
|
||||
assert_raise(ActiveRecord::PreparedStatementInvalid) { bind '', 1 }
|
||||
|
||||
assert_raise(ActiveRecord::PreparedStatementInvalid) { bind '?' }
|
||||
assert_nothing_raised { bind '?', 1 }
|
||||
assert_raise(ActiveRecord::PreparedStatementInvalid) { bind '?', 1, 1 }
|
||||
assert_nothing_raised { bind '?', 1 }
|
||||
assert_raise(ActiveRecord::PreparedStatementInvalid) { bind '?', 1, 1 }
|
||||
end
|
||||
|
||||
def test_named_bind_variables
|
||||
|
@ -721,6 +721,12 @@ class FinderTest < ActiveRecord::TestCase
|
|||
assert_kind_of Time, Topic.where(["id = :id", { id: 1 }]).first.written_on
|
||||
end
|
||||
|
||||
def test_named_bind_arity
|
||||
assert_nothing_raised { bind "name = :name", { name: "37signals" } }
|
||||
assert_nothing_raised { bind "name = :name", { name: "37signals", id: 1 } }
|
||||
assert_raise(ActiveRecord::PreparedStatementInvalid) { bind "name = :name", { id: 1 } }
|
||||
end
|
||||
|
||||
class SimpleEnumerable
|
||||
include Enumerable
|
||||
|
||||
|
|
Loading…
Reference in a new issue