activerecord-deprecated_finders 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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)
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module DeprecatedFinders
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
@@ -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',
@@ -21,6 +21,8 @@ ActiveRecord::Schema.define do
21
21
  create_table :appointments do |t|
22
22
  t.integer :physician_id
23
23
  t.integer :patient_id
24
+ t.string :week_day
25
+ t.string :status
24
26
  end
25
27
 
26
28
  create_table :physicians do |t|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-deprecated_finders
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: