aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/result_test.rb
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2018-09-19 23:10:36 -0400
committerGitHub <noreply@github.com>2018-09-19 23:10:36 -0400
commit4586b304fc61e3a5d756d005aa2c386a1b01b848 (patch)
tree1cdf574781e879bbd6825a2b1dc4efa584d28f41 /activerecord/test/cases/result_test.rb
parentd69b04de0ff33237209afea6f6cac3ab27934908 (diff)
parent16510d609c601aa7d466809f3073ec3313e08937 (diff)
downloadrails-4586b304fc61e3a5d756d005aa2c386a1b01b848.tar.gz
rails-4586b304fc61e3a5d756d005aa2c386a1b01b848.tar.bz2
rails-4586b304fc61e3a5d756d005aa2c386a1b01b848.zip
Merge pull request #33912 from gmcgibbon/ar_result_to_hash_deprecate
Deprecate ActiveRecord::Result#to_hash in favor of #to_a
Diffstat (limited to 'activerecord/test/cases/result_test.rb')
-rw-r--r--activerecord/test/cases/result_test.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/activerecord/test/cases/result_test.rb b/activerecord/test/cases/result_test.rb
index 68fcafb682..825aee2423 100644
--- a/activerecord/test/cases/result_test.rb
+++ b/activerecord/test/cases/result_test.rb
@@ -21,12 +21,22 @@ module ActiveRecord
assert_equal 3, result.length
end
- test "to_hash returns row_hashes" do
+ test "to_a returns row_hashes" do
assert_equal [
{ "col_1" => "row 1 col 1", "col_2" => "row 1 col 2" },
{ "col_1" => "row 2 col 1", "col_2" => "row 2 col 2" },
{ "col_1" => "row 3 col 1", "col_2" => "row 3 col 2" },
- ], result.to_hash
+ ], result.to_a
+ end
+
+ test "to_hash (deprecated) returns row_hashes" do
+ assert_deprecated do
+ assert_equal [
+ { "col_1" => "row 1 col 1", "col_2" => "row 1 col 2" },
+ { "col_1" => "row 2 col 1", "col_2" => "row 2 col 2" },
+ { "col_1" => "row 3 col 1", "col_2" => "row 3 col 2" },
+ ], result.to_hash
+ end
end
test "first returns first row as a hash" do