Skip to content

Commit ffb91aa

Browse files
committed
Support Rails 5.2 with #polymorphic_name
1 parent 90e5a56 commit ffb91aa

4 files changed

Lines changed: 9 additions & 3 deletions

File tree

lib/polymorphic_integer_type.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
require "polymorphic_integer_type/version"
44
require "polymorphic_integer_type/extensions"
55
require "polymorphic_integer_type/mapping"
6-
require "polymorphic_integer_type/belongs_to_polymorphic_association_extension"
76

87
if ACTIVE_RECORD_VERSION < Gem::Version.new("5")
98
require "polymorphic_integer_type/activerecord_4/predicate_builder_extension"
@@ -15,5 +14,8 @@
1514
require "polymorphic_integer_type/activerecord_5_0_0/association_query_handler_extension"
1615
end
1716

17+
if ACTIVE_RECORD_VERSION < Gem::Version.new("5.2.0")
18+
require "polymorphic_integer_type/activerecord_4/belongs_to_polymorphic_association_extension"
19+
end
1820

1921
module PolymorphicIntegerType; end

lib/polymorphic_integer_type/belongs_to_polymorphic_association_extension.rb renamed to lib/polymorphic_integer_type/activerecord_4/belongs_to_polymorphic_association_extension.rb

File renamed without changes.

spec/polymorphic_integer_type_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
end
2525
end
2626

27-
context "when the source is a class that modifies the sti_name" do
27+
context "when the source is a class that modifies the sti_name or polymorphic_name" do
2828
it "properly sets the source_type to the modified class name" do
2929
link = Link.new(source: Namespaced::Animal.new)
3030
expect(link.source_type).to eql "Animal"

spec/support/namespaced_animal.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@ class Animal < ActiveRecord::Base
33

44
self.store_full_sti_class = false
55
self.table_name = "animals"
6+
7+
def self.polymorphic_name
8+
"Animal"
9+
end
610
end
7-
end
11+
end

0 commit comments

Comments
 (0)