Sha256: 3e1f043288f2fef9db6abd88e29b03c8e5724352a60f7350be0c8f53778caa71
Contents?: true
Size: 1.4 KB
Versions: 1
Compression:
Stored size: 1.4 KB
Contents
require 'spec_helper' module Polyamorous describe JoinAssociation do let(:join_dependency) { new_join_dependency Note, {} } let(:parent) { join_dependency.join_base } let(:reflection) { Note.reflect_on_association(:notable) } let(:join_association) { JoinAssociation.new(reflection, join_dependency, parent, Article) } subject { join_dependency.build_join_association_respecting_polymorphism( reflection, parent, Person ) } it 'respects polymorphism on equality test' do subject.should eq( join_dependency.build_join_association_respecting_polymorphism( reflection, parent, Person ) ) subject.should_not 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.swapping_reflection_klass(reflection, Person) do |new_reflection| new_reflection.options.should_not equal reflection.options new_reflection.options.should_not have_key(:polymorphic) new_reflection.klass.should == Person reflection.klass.should == Article end end it 'sets the polmorphic option to true after initializing' do join_association.options[:polymorphic].should be_true end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
polyamorous-0.6.4 | spec/polyamorous/join_association_spec.rb |