polymorphic_integer_type 3.2.1 → 3.2.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eeec5115208f7fee02b00a10f05e660a46550b2c0815999133a1fe541950c1dc
4
- data.tar.gz: 8268bfe5dd15c0cb9f3c6cc240989ad89cc112dff8ac9723ed64e6de8e7ddc61
3
+ metadata.gz: cfa2f9c68364a27168180b5dfeaae71b6ea2a9e74c313a8f42658b6e3a562dcd
4
+ data.tar.gz: b4f0b2225be4e6d8270f1e4d1755a15d791aec80a3f20afd3cd2c6d9f4923603
5
5
  SHA512:
6
- metadata.gz: 801b9bf926c3a23237f0838013d8e425c902292f186f38f65ff41c0e80b94ac5df15152e8d8d108800650439e069c990342f2d6c4fdcfb79b4e4870403bc93f9
7
- data.tar.gz: c81b0af3ef8593d8f607c12db9ef0b685f91cd7b21b4e85f70289cd30fcfe839427e2eecc43cb2de01295ba454522e15dd04be101cfa001d86061c68403d1432
6
+ metadata.gz: 12fa770fcb992eb05270b971a8f1ff88d881318d09bccc9f3e7d139e01396054873a68f1083238db0af4d7dc32bf3a715a51d848df2d9432e060580a6b524cf8
7
+ data.tar.gz: ca0d6e461f1543b2f47476d53e679d24de1420e60acaa8c51119f1bfa05ac962f5ac189912d9a7ae12e63f9568af91e6e0550dbc448efc3b2e75c6f655a8e0c5
data/CHANGELOG.md CHANGED
@@ -10,4 +10,10 @@
10
10
 
11
11
  - Added .idea/ folder to .gitignore
12
12
 
13
+ ## v3.2.2 (2023-12-21)
14
+
15
+ ### Fixed
16
+
17
+ - Fixed polymorphic_foreign_association_extension.rb to be compatible with other reflection than `has_many` and `has_one`.
18
+
13
19
  ### Changed
@@ -3,7 +3,7 @@ module PolymorphicIntegerType
3
3
 
4
4
  def set_owner_attributes(record)
5
5
  super
6
- if reflection.foreign_integer_type && reflection.integer_type
6
+ if reflection.try(:foreign_integer_type) && reflection.try(:integer_type)
7
7
  record._write_attribute(reflection.foreign_integer_type, reflection.integer_type)
8
8
  end
9
9
  end
@@ -1,3 +1,3 @@
1
1
  module PolymorphicIntegerType
2
- VERSION = "3.2.1"
2
+ VERSION = "3.2.2"
3
3
  end
@@ -371,4 +371,13 @@ describe PolymorphicIntegerType do
371
371
  expect(link.normal_target_type).to eq("InlineDrink2")
372
372
  end
373
373
  end
374
+
375
+ context "when using other reflection" do
376
+ it "owner able to association ActiveRecord::Reflection::ThroughReflection successfully" do
377
+ profile_history = ProfileHistory.new
378
+ owner.profile_histories << profile_history
379
+
380
+ expect(owner.profile_histories).to eq([profile_history])
381
+ end
382
+ end
374
383
  end
data/spec/spec_helper.rb CHANGED
@@ -10,6 +10,8 @@ require 'support/dog'
10
10
  require 'support/person'
11
11
  require 'support/food'
12
12
  require 'support/drink'
13
+ require 'support/profile'
14
+ require 'support/profile_history'
13
15
  require 'support/namespaced_activity'
14
16
  require 'byebug'
15
17
  require 'pry'
@@ -0,0 +1,16 @@
1
+ class CreateProfileTable < ActiveRecord::Migration[5.0]
2
+
3
+ def up
4
+ create_table :profiles do |t|
5
+ t.integer :person_id
6
+ t.integer :profile_history_id
7
+ end
8
+ end
9
+
10
+ def down
11
+ drop_table :profiles
12
+ end
13
+
14
+ end
15
+
16
+
@@ -0,0 +1,14 @@
1
+ class CreateProfileHistoryTable < ActiveRecord::Migration[5.0]
2
+
3
+ def up
4
+ create_table :profile_histories do |t|
5
+ end
6
+ end
7
+
8
+ def down
9
+ drop_table :profile_histories
10
+ end
11
+
12
+ end
13
+
14
+
@@ -5,4 +5,6 @@ class Person < ActiveRecord::Base
5
5
  has_many :source_links, as: :source, integer_type: true, class_name: "Link"
6
6
 
7
7
  has_many :pet_source_links, class_name: "Link", through: :pets, source: :source_links
8
+ has_many :profiles
9
+ has_many :profile_histories, class_name: "ProfileHistory", through: :profiles
8
10
  end
@@ -0,0 +1,4 @@
1
+ class Profile < ActiveRecord::Base
2
+ belongs_to :person
3
+ belongs_to :profile_history
4
+ end
@@ -0,0 +1,3 @@
1
+ class ProfileHistory < ActiveRecord::Base
2
+ has_many :profiles
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polymorphic_integer_type
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle d'Oliveira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-15 00:00:00.000000000 Z
11
+ date: 2023-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -141,10 +141,14 @@ files:
141
141
  - spec/support/migrations/5_create_drink_table.rb
142
142
  - spec/support/migrations/6_create_plant_table.rb
143
143
  - spec/support/migrations/7_create_activity_table.rb
144
+ - spec/support/migrations/8_create_profile_table.rb
145
+ - spec/support/migrations/9_create_profile_history_table.rb
144
146
  - spec/support/namespaced_activity.rb
145
147
  - spec/support/namespaced_animal.rb
146
148
  - spec/support/namespaced_plant.rb
147
149
  - spec/support/person.rb
150
+ - spec/support/profile.rb
151
+ - spec/support/profile_history.rb
148
152
  homepage: ''
149
153
  licenses:
150
154
  - MIT
@@ -185,7 +189,11 @@ test_files:
185
189
  - spec/support/migrations/5_create_drink_table.rb
186
190
  - spec/support/migrations/6_create_plant_table.rb
187
191
  - spec/support/migrations/7_create_activity_table.rb
192
+ - spec/support/migrations/8_create_profile_table.rb
193
+ - spec/support/migrations/9_create_profile_history_table.rb
188
194
  - spec/support/namespaced_activity.rb
189
195
  - spec/support/namespaced_animal.rb
190
196
  - spec/support/namespaced_plant.rb
191
197
  - spec/support/person.rb
198
+ - spec/support/profile.rb
199
+ - spec/support/profile_history.rb