aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-05-26 07:46:11 -0700
committerSean Griffin <sean@thoughtbot.com>2014-05-26 08:08:32 -0700
commita8afc6395b9ccbbe62c6deaa01294b4bd3aac758 (patch)
treeab66f2e5754fe496afae553520b52064c923edf7 /activerecord/test/cases
parentd075c84320fab51992a1ab7d020c62ff1bad0b4e (diff)
downloadrails-a8afc6395b9ccbbe62c6deaa01294b4bd3aac758.tar.gz
rails-a8afc6395b9ccbbe62c6deaa01294b4bd3aac758.tar.bz2
rails-a8afc6395b9ccbbe62c6deaa01294b4bd3aac758.zip
Add missing test case for quoting behavior
It appears that the only time that `quote` is called with a column, but without first calling `type_cast` is when where is called with an array. My previous pull request broke this behavior, without failing tests. This adds a test for the only case I can think of that exercises the `if column.type == :integer` branch of `quote` effectively.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/base_test.rb4
-rw-r--r--activerecord/test/cases/relations_test.rb7
2 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index c565daba65..1b3aa84a06 100644
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -518,6 +518,10 @@ class BasicsTest < ActiveRecord::TestCase
assert_equal Topic.find('1-meowmeow'), Topic.find(1)
end
+ def test_find_by_slug_with_array
+ assert_equal Topic.find(['1-meowmeow', '2-hello']), Topic.find([1, 2])
+ end
+
def test_equality_of_new_records
assert_not_equal Topic.new, Topic.new
assert_equal false, Topic.new == Topic.new
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index 4b146c11bc..61111b254a 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -750,6 +750,13 @@ class RelationTest < ActiveRecord::TestCase
assert_equal [], relation.to_a
end
+ def test_typecasting_where_with_array
+ ids = Author.pluck(:id)
+ slugs = ids.map { |id| "#{id}-as-a-slug" }
+
+ assert_equal Author.all.to_a, Author.where(id: slugs).to_a
+ end
+
def test_find_all_using_where_with_relation
david = authors(:david)
# switching the lines below would succeed in current rails