polymorphic_integer_type 3.2.1 → 3.3.0

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: ea9d51ebb89d80399f1ef17cc3e7163fe4923db10710d352e1f849cbeb81c782
4
+ data.tar.gz: '0910cded5f13a659aa01ba248353c6b2a23f81bb80dd447d54aa37f5a5a526b9'
5
5
  SHA512:
6
- metadata.gz: 801b9bf926c3a23237f0838013d8e425c902292f186f38f65ff41c0e80b94ac5df15152e8d8d108800650439e069c990342f2d6c4fdcfb79b4e4870403bc93f9
7
- data.tar.gz: c81b0af3ef8593d8f607c12db9ef0b685f91cd7b21b4e85f70289cd30fcfe839427e2eecc43cb2de01295ba454522e15dd04be101cfa001d86061c68403d1432
6
+ metadata.gz: 05e5887f356fd8d96352adc20ad4aae0d4dd8d8d42c7611b5bb83aabcdf03e7132e1366855ef4148b92e001afd9d10430525c43127ac34fe3b3dcc6e776cfbf8
7
+ data.tar.gz: 0da151ee5cd138ef7d677cdd5fb7040e674144cedfbcc06cff50dfb11c37a5b972717359e07a21ceac3c7aab03878a040002f2b4e41d309d5c90bf003def445f
data/.gitignore CHANGED
@@ -21,3 +21,6 @@ tmp
21
21
  polymorphic_integer_type_test
22
22
  gemfiles/*.lock
23
23
  .idea/
24
+ .ruby-version
25
+ mysql
26
+ polymorphic_integer_type_test-*
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### Changed
1
+ # Changelog
2
2
 
3
3
  ## v3.2.1 (2023-12-14)
4
4
 
@@ -10,4 +10,19 @@
10
10
 
11
11
  - Added .idea/ folder to .gitignore
12
12
 
13
- ### Changed
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
+
19
+ ## v3.3.0 (2024-10-29)
20
+
21
+ ### Changed
22
+
23
+ - Upgrade rails support version to be compatible with 7.2
24
+
25
+ ### Removed
26
+
27
+ - Remove unsupported rails versions(5.0, 5.2, 6.0) and ruby version(2.7)
28
+
@@ -5,3 +5,4 @@ source "https://rubygems.org"
5
5
  gemspec path: ".."
6
6
 
7
7
  gem "activerecord", github: "rails/rails", branch: "6-1-stable"
8
+ gem "sqlite3", "~> 1.4"
@@ -5,3 +5,4 @@ source "https://rubygems.org"
5
5
  gemspec path: ".."
6
6
 
7
7
  gem "activerecord", github: "rails/rails", branch: "7-0-stable"
8
+ gem "sqlite3", "~> 1.4"
@@ -4,4 +4,4 @@ source "https://rubygems.org"
4
4
 
5
5
  gemspec path: ".."
6
6
 
7
- gem "activerecord", github: "rails/rails", branch: "5-1-stable"
7
+ gem "activerecord", github: "rails/rails", branch: "7-2-stable"
@@ -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.3.0"
3
3
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "activerecord", "< 7.1"
21
+ spec.add_dependency "activerecord", "< 8"
22
22
  spec.add_development_dependency "bundler"
23
23
  spec.add_development_dependency "rake"
24
24
  spec.add_development_dependency "rspec"
@@ -175,7 +175,7 @@ describe PolymorphicIntegerType do
175
175
  before { link }
176
176
 
177
177
  it "should have the proper source" do
178
- expect(source.source_links[0].source).to eql source
178
+ expect(source.reload.source_links[0].source).to eql source
179
179
  end
180
180
  end
181
181
  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'
@@ -21,18 +23,14 @@ RSpec.configure do |config|
21
23
  active_record_version = Gem::Version.new(ActiveRecord::VERSION::STRING)
22
24
 
23
25
  ActiveRecord::Base.establish_connection(database_config)
24
-
25
- if active_record_version < Gem::Version.new("5.2")
26
- ActiveRecord::Migrator.migrate(migrations_path)
27
- end
28
-
29
- if active_record_version >= Gem::Version.new("5.2") && active_record_version < Gem::Version.new("6.0")
30
- ActiveRecord::MigrationContext.new(migrations_path).migrate
31
- end
32
26
 
33
- if active_record_version >= Gem::Version.new("6.0")
27
+ if active_record_version >= Gem::Version.new("6.1") && active_record_version < Gem::Version.new("7.0")
34
28
  ActiveRecord::MigrationContext.new(migrations_path, ActiveRecord::SchemaMigration).migrate
35
29
  end
30
+
31
+ if active_record_version >= Gem::Version.new("7.0")
32
+ ActiveRecord::MigrationContext.new(migrations_path).migrate
33
+ end
36
34
  end
37
35
 
38
36
  config.around do |example|
@@ -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.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle d'Oliveira
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-15 00:00:00.000000000 Z
11
+ date: 2025-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "<"
18
18
  - !ruby/object:Gem::Version
19
- version: '7.1'
19
+ version: '8'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "<"
25
25
  - !ruby/object:Gem::Version
26
- version: '7.1'
26
+ version: '8'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -109,12 +109,9 @@ files:
109
109
  - README.md
110
110
  - Rakefile
111
111
  - bin/setup
112
- - gemfiles/Gemfile.rails-5.0-stable
113
- - gemfiles/Gemfile.rails-5.1-stable
114
- - gemfiles/Gemfile.rails-5.2-stable
115
- - gemfiles/Gemfile.rails-6.0-stable
116
112
  - gemfiles/Gemfile.rails-6.1-stable
117
113
  - gemfiles/Gemfile.rails-7.0-stable
114
+ - gemfiles/Gemfile.rails-7.2-stable
118
115
  - lib/polymorphic_integer_type.rb
119
116
  - lib/polymorphic_integer_type/activerecord_5_0_0/association_query_handler_extension.rb
120
117
  - lib/polymorphic_integer_type/activerecord_5_0_0/polymorphic_array_value_extension.rb
@@ -141,15 +138,19 @@ files:
141
138
  - spec/support/migrations/5_create_drink_table.rb
142
139
  - spec/support/migrations/6_create_plant_table.rb
143
140
  - spec/support/migrations/7_create_activity_table.rb
141
+ - spec/support/migrations/8_create_profile_table.rb
142
+ - spec/support/migrations/9_create_profile_history_table.rb
144
143
  - spec/support/namespaced_activity.rb
145
144
  - spec/support/namespaced_animal.rb
146
145
  - spec/support/namespaced_plant.rb
147
146
  - spec/support/person.rb
147
+ - spec/support/profile.rb
148
+ - spec/support/profile_history.rb
148
149
  homepage: ''
149
150
  licenses:
150
151
  - MIT
151
152
  metadata: {}
152
- post_install_message:
153
+ post_install_message:
153
154
  rdoc_options: []
154
155
  require_paths:
155
156
  - lib
@@ -164,8 +165,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
165
  - !ruby/object:Gem::Version
165
166
  version: '0'
166
167
  requirements: []
167
- rubygems_version: 3.4.10
168
- signing_key:
168
+ rubygems_version: 3.3.27
169
+ signing_key:
169
170
  specification_version: 4
170
171
  summary: Use integers rather than strings for the _type field
171
172
  test_files:
@@ -185,7 +186,11 @@ test_files:
185
186
  - spec/support/migrations/5_create_drink_table.rb
186
187
  - spec/support/migrations/6_create_plant_table.rb
187
188
  - spec/support/migrations/7_create_activity_table.rb
189
+ - spec/support/migrations/8_create_profile_table.rb
190
+ - spec/support/migrations/9_create_profile_history_table.rb
188
191
  - spec/support/namespaced_activity.rb
189
192
  - spec/support/namespaced_animal.rb
190
193
  - spec/support/namespaced_plant.rb
191
194
  - spec/support/person.rb
195
+ - spec/support/profile.rb
196
+ - spec/support/profile_history.rb
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- gemspec path: ".."
6
-
7
- gem "activerecord", github: "rails/rails", branch: "5-0-stable"
8
- gem "sqlite3", "~> 1.3.6"
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- gemspec path: ".."
6
-
7
- gem "activerecord", github: "rails/rails", branch: "5-2-stable"
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- gemspec path: ".."
6
-
7
- gem "activerecord", github: "rails/rails", branch: "6-0-stable"