aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/deprecated_dynamic_methods_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases/deprecated_dynamic_methods_test.rb')
-rw-r--r--activerecord/test/cases/deprecated_dynamic_methods_test.rb18
1 files changed, 9 insertions, 9 deletions
diff --git a/activerecord/test/cases/deprecated_dynamic_methods_test.rb b/activerecord/test/cases/deprecated_dynamic_methods_test.rb
index 8e842d8758..cfc5c5d292 100644
--- a/activerecord/test/cases/deprecated_dynamic_methods_test.rb
+++ b/activerecord/test/cases/deprecated_dynamic_methods_test.rb
@@ -403,9 +403,9 @@ class DeprecatedDynamicMethodsTest < ActiveRecord::TestCase
post = Post.first
assert_equal [], person.readers
- assert_nil person.readers.find_by_post_id(post.id)
+ assert_nil person.readers.find_by(post_id: post.id)
- person.readers.find_or_create_by_post_id(post.id)
+ person.readers.find_or_create_by(post_id: post.id)
assert_equal 1, person.readers.count
assert_equal 1, person.readers.length
@@ -513,34 +513,34 @@ class DeprecatedDynamicMethodsTest < ActiveRecord::TestCase
def test_finder_block
t = Topic.first
found = nil
- Topic.find_by_id(t.id) { |f| found = f }
+ Topic.find_by(id: t.id) { |f| found = f }
assert_equal t, found
end
def test_finder_block_nothing_found
bad_id = Topic.maximum(:id) + 1
- assert_nil Topic.find_by_id(bad_id) { |f| raise }
+ assert_nil Topic.find_by(id: bad_id) { |f| raise }
end
def test_find_returns_block_value
t = Topic.first
- x = Topic.find_by_id(t.id) { |f| "hi mom!" }
+ x = Topic.find_by(id:t.id) { |f| "hi mom!" }
assert_equal "hi mom!", x
end
def test_dynamic_finder_with_invalid_params
- assert_raise(ArgumentError) { Topic.find_by_title 'No Title', :join => "It should be `joins'" }
+ assert_raise(ArgumentError) { Topic.find_by title: 'No Title', :join => "It should be `joins'" }
end
def test_find_by_one_attribute_with_order_option
- assert_equal accounts(:signals37), Account.find_by_credit_limit(50, :order => 'id')
- assert_equal accounts(:rails_core_account), Account.find_by_credit_limit(50, :order => 'id DESC')
+ assert_equal accounts(:signals37), Account.find_by(credit_limit: 50, :order => 'id')
+ assert_equal accounts(:rails_core_account), Account.find_by(credit_limit: 50, :order => 'id DESC')
end
def test_dynamic_find_by_attributes_should_yield_found_object
david = authors(:david)
yielded_value = nil
- Author.find_by_name(david.name) do |author|
+ Author.find_by(name: david.name) do |author|
yielded_value = author
end
assert_equal david, yielded_value