polymorphic_integer_type 2.2.1 → 2.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
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 167cd58ce2ec474eea9268af532e07815e3c1a0c
|
4
|
+
data.tar.gz: a523c263e4822806d3ce02543417658f4904c0a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1913d6fea43ec6707438afbec0c60c8525e015e75062f8115afb7d4176143bb4efe8d79364dfd465d6551c8bb131815933fca85aa1df98813e62541ca8cca4d
|
7
|
+
data.tar.gz: d4adcee63eeb967d4e4ecb17a53ec72cae5d23937c52a8e3030f4d27da9cf771b6a136583e9e0c2bf5a75ff31ab94895b2bcb2a7232ae140714a35961292242d
|
@@ -31,7 +31,10 @@ module PolymorphicIntegerType
|
|
31
31
|
|
32
32
|
define_method "#{foreign_type}=" do |klass|
|
33
33
|
enum = mapping.key(klass.to_s)
|
34
|
-
|
34
|
+
if klass.kind_of?(Class) && klass <= ActiveRecord::Base
|
35
|
+
enum ||= mapping.key(klass.base_class.to_s)
|
36
|
+
enum ||= mapping.key(klass.base_class.sti_name)
|
37
|
+
end
|
35
38
|
enum ||= klass if klass != NilClass
|
36
39
|
super(enum)
|
37
40
|
end
|
@@ -24,6 +24,13 @@ describe PolymorphicIntegerType do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
context "when the source is a class that modifies the sti_name" do
|
28
|
+
it "properly sets the source_type to the modified class name" do
|
29
|
+
link = Link.new(source: Namespaced::Animal.new)
|
30
|
+
expect(link.source_type).to eql "Animal"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
27
34
|
context "when querying the associations" do
|
28
35
|
let(:source) { cat }
|
29
36
|
let(:target) { nil }
|
data/spec/spec_helper.rb
CHANGED
data/spec/support/animal.rb
CHANGED
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: 2.2.
|
4
|
+
version: 2.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: 2019-
|
11
|
+
date: 2019-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- spec/support/migrations/3_create_person_table.rb
|
130
130
|
- spec/support/migrations/4_create_food_table.rb
|
131
131
|
- spec/support/migrations/5_create_drink_table.rb
|
132
|
+
- spec/support/namespaced_animal.rb
|
132
133
|
- spec/support/person.rb
|
133
134
|
homepage: ''
|
134
135
|
licenses:
|
@@ -149,7 +150,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
150
|
- !ruby/object:Gem::Version
|
150
151
|
version: '0'
|
151
152
|
requirements: []
|
152
|
-
|
153
|
+
rubyforge_project:
|
154
|
+
rubygems_version: 2.6.14
|
153
155
|
signing_key:
|
154
156
|
specification_version: 4
|
155
157
|
summary: Use integers rather than strings for the _type field
|
@@ -168,4 +170,5 @@ test_files:
|
|
168
170
|
- spec/support/migrations/3_create_person_table.rb
|
169
171
|
- spec/support/migrations/4_create_food_table.rb
|
170
172
|
- spec/support/migrations/5_create_drink_table.rb
|
173
|
+
- spec/support/namespaced_animal.rb
|
171
174
|
- spec/support/person.rb
|