Remove internal methods which are no longer used
`{find,build}_join_association_respecting_polymorphism` are no longer used since existed them for Active Record 3.2 and 4.0.
This commit is contained in:
parent
4ecf7541e1
commit
7282f2becb
|
@ -30,24 +30,6 @@ module Polyamorous
|
|||
end
|
||||
end
|
||||
|
||||
def find_join_association_respecting_polymorphism(reflection, parent, klass)
|
||||
if association = parent.children.find { |j| j.reflection == reflection }
|
||||
unless reflection.polymorphic?
|
||||
association
|
||||
else
|
||||
association if association.base_klass == klass
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def build_join_association_respecting_polymorphism(reflection, parent, klass)
|
||||
if reflection.polymorphic? && klass
|
||||
JoinAssociation.new(reflection, self, klass)
|
||||
else
|
||||
JoinAssociation.new(reflection, self)
|
||||
end
|
||||
end
|
||||
|
||||
# Replaces ActiveRecord::Associations::JoinDependency#join_constraints
|
||||
#
|
||||
# This internal method was changed in Rails 5.0 by commit
|
||||
|
|
|
@ -30,24 +30,6 @@ module Polyamorous
|
|||
end
|
||||
end
|
||||
|
||||
def find_join_association_respecting_polymorphism(reflection, parent, klass)
|
||||
if association = parent.children.find { |j| j.reflection == reflection }
|
||||
unless reflection.polymorphic?
|
||||
association
|
||||
else
|
||||
association if association.base_klass == klass
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def build_join_association_respecting_polymorphism(reflection, parent, klass)
|
||||
if reflection.polymorphic? && klass
|
||||
JoinAssociation.new(reflection, self, alias_tracker, klass)
|
||||
else
|
||||
JoinAssociation.new(reflection, self, alias_tracker)
|
||||
end
|
||||
end
|
||||
|
||||
# Replaces ActiveRecord::Associations::JoinDependency#join_constraints
|
||||
#
|
||||
# This internal method was changed in Rails 5.0 by commit
|
||||
|
|
|
@ -30,24 +30,6 @@ module Polyamorous
|
|||
end
|
||||
end
|
||||
|
||||
def find_join_association_respecting_polymorphism(reflection, parent, klass)
|
||||
if association = parent.children.find { |j| j.reflection == reflection }
|
||||
unless reflection.polymorphic?
|
||||
association
|
||||
else
|
||||
association if association.base_klass == klass
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def build_join_association_respecting_polymorphism(reflection, parent, klass)
|
||||
if reflection.polymorphic? && klass
|
||||
JoinAssociation.new(reflection, self, klass)
|
||||
else
|
||||
JoinAssociation.new(reflection, self)
|
||||
end
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
# Prepended before ActiveRecord::Associations::JoinDependency#walk_tree
|
||||
#
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||
module Polyamorous
|
||||
describe JoinAssociation do
|
||||
|
||||
join_base, join_association_args, polymorphic = [:join_root, 'parent.children', 'reflection.options[:polymorphic]']
|
||||
join_base, join_association_args, polymorphic = :join_root, 'parent.children', 'reflection.options[:polymorphic]'
|
||||
|
||||
let(:join_dependency) { new_join_dependency Note, {} }
|
||||
let(:reflection) { Note.reflect_on_association(:notable) }
|
||||
|
@ -12,25 +12,6 @@ module Polyamorous
|
|||
eval("new_join_association(reflection, #{join_association_args}, Article)")
|
||||
}
|
||||
|
||||
subject {
|
||||
join_dependency.build_join_association_respecting_polymorphism(
|
||||
reflection, parent, Person
|
||||
)
|
||||
}
|
||||
|
||||
it 'respects polymorphism on equality test' do
|
||||
expect(subject).to eq(
|
||||
join_dependency.build_join_association_respecting_polymorphism(
|
||||
reflection, parent, Person
|
||||
)
|
||||
)
|
||||
expect(subject).not_to eq(
|
||||
join_dependency.build_join_association_respecting_polymorphism(
|
||||
reflection, parent, Article
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
it 'leaves the orginal reflection intact for thread safety' do
|
||||
reflection.instance_variable_set(:@klass, Article)
|
||||
join_association
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||
module Polyamorous
|
||||
describe JoinDependency do
|
||||
|
||||
method, join_associations, join_base = :instance_eval, 'join_root.drop(1)', :join_root
|
||||
method, join_associations = :instance_eval, 'join_root.drop(1)'
|
||||
|
||||
context 'with symbol joins' do
|
||||
subject { new_join_dependency Person, articles: :comments }
|
||||
|
@ -53,15 +53,6 @@ module Polyamorous
|
|||
.to eq Polyamorous::InnerJoin }
|
||||
specify { expect(subject.send(method, join_associations).first.table_name)
|
||||
.to eq 'people' }
|
||||
|
||||
it 'finds a join association respecting polymorphism' do
|
||||
parent = subject.send(join_base)
|
||||
reflection = Note.reflect_on_association(:notable)
|
||||
|
||||
expect(subject.find_join_association_respecting_polymorphism(
|
||||
reflection, parent, Person))
|
||||
.to eq subject.send(method, join_associations).first
|
||||
end
|
||||
end
|
||||
|
||||
context 'with polymorphic belongs_to join and nested symbol join' do
|
||||
|
|
Loading…
Reference in New Issue