activerecord-deprecated_finders 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@ module ActiveRecord
|
|
6
6
|
match = DynamicMatchers::Method.match(klass, method)
|
7
7
|
sanitized_method = match.class.prefix + match.class.suffix if match
|
8
8
|
|
9
|
-
if match && self.respond_to?(sanitized_method)
|
9
|
+
if match && self.respond_to?(sanitized_method) && proxy_association.reflection.options[:through].present?
|
10
10
|
self.send(sanitized_method, Hash[match.attribute_names.zip(args)])
|
11
11
|
|
12
12
|
elsif match && match.is_a?(DynamicMatchers::Instantiator)
|
data/test/associations_test.rb
CHANGED
@@ -5,6 +5,7 @@ describe 'associations' do
|
|
5
5
|
@klass = Class.new(ActiveRecord::Base)
|
6
6
|
def @klass.name; 'Post'; end
|
7
7
|
@klass.table_name = 'posts'
|
8
|
+
Appointment.delete_all
|
8
9
|
end
|
9
10
|
|
10
11
|
it 'find_or_create_by on has_many through should work' do
|
@@ -15,6 +16,14 @@ describe 'associations' do
|
|
15
16
|
assert_equal 1, Appointment.count
|
16
17
|
end
|
17
18
|
|
19
|
+
it 'find_or_create_by on has_many should work' do
|
20
|
+
physician = Physician.create!
|
21
|
+
ActiveSupport::Deprecation.silence do
|
22
|
+
appointment = physician.appointments.find_or_create_by_status(status: 'active', week_day: 'sunday')
|
23
|
+
assert_equal appointment, physician.appointments.find_or_create_by_status(status: 'active', week_day: 'sunday')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
18
27
|
it 'translates hash scope options into scopes' do
|
19
28
|
assert_deprecated do
|
20
29
|
@klass.has_many :comments, readonly: 'a', order: 'b', limit: 'c', group: 'd', having: 'e',
|
data/test/helper.rb
CHANGED