aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-05-26 14:27:16 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-05-26 14:27:16 -0300
commitabd28f67e191a10147c0ad4f56d22b6e558869d2 (patch)
treeab66f2e5754fe496afae553520b52064c923edf7
parentd075c84320fab51992a1ab7d020c62ff1bad0b4e (diff)
parenta8afc6395b9ccbbe62c6deaa01294b4bd3aac758 (diff)
downloadrails-abd28f67e191a10147c0ad4f56d22b6e558869d2.tar.gz
rails-abd28f67e191a10147c0ad4f56d22b6e558869d2.tar.bz2
rails-abd28f67e191a10147c0ad4f56d22b6e558869d2.zip
Merge pull request #15335 from sgrif/sg-missing-test-case
Add missing test case for quoting behavior
-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