Sha256: faea85a3ccccc0a9c40e6c54aee8544a42b49b996a2292414888abfaaddbe94f

Contents?: true

Size: 1.04 KB

Versions: 11

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

module Polyamorous
  describe JoinAssociation do

    let(:join_dependency) { new_join_dependency Note, {} }
    let(:reflection) { Note.reflect_on_association(:notable) }
    let(:parent) { join_dependency.send(:join_root) }
    let(:join_association) {
      new_join_association(reflection, parent.children, Article)
    }

    subject { new_join_association(reflection, parent.children, Person) }

    it 'leaves the original reflection intact for thread safety' do
      reflection.instance_variable_set(:@klass, Article)
      join_association
      .swapping_reflection_klass(reflection, Person) do |new_reflection|
        expect(new_reflection.options).not_to equal reflection.options
        expect(new_reflection.options).not_to have_key(:polymorphic)
        expect(new_reflection.klass).to eq(Person)
        expect(reflection.klass).to eq(Article)
      end
    end

    it 'sets the polymorphic option to true after initializing' do
      expect(join_association.reflection.options[:polymorphic]).to be true
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ransack-4.2.1 spec/polyamorous/join_association_spec.rb
ransack-4.2.0 spec/polyamorous/join_association_spec.rb
ransack-4.1.1 spec/polyamorous/join_association_spec.rb
ransack-4.1.0 spec/polyamorous/join_association_spec.rb
ransack-4.0.0 spec/polyamorous/join_association_spec.rb
ransack-3.2.1 spec/polyamorous/join_association_spec.rb
ransack-3.2.0 spec/polyamorous/join_association_spec.rb
ransack-3.1.0 spec/polyamorous/join_association_spec.rb
ransack-3.0.1 spec/polyamorous/join_association_spec.rb
ransack-3.0.0 spec/polyamorous/join_association_spec.rb
ransack-2.6.0 spec/polyamorous/join_association_spec.rb