Sha256: d9e78a46628d219af78183dc0e372f393f0e011373ff30bb865aae7000ec2090

Contents?: true

Size: 1.33 KB

Versions: 17

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

describe ActiveFedora::Reflection::AssociationReflection do
  describe "#derive_foreign_key" do
    let(:name) { 'dummy' }
    let(:options) { { inverse_of: :default_permissions } }
    let(:active_fedora) { double }
    let(:instance) { described_class.new(macro, name, options, active_fedora) }
    subject { instance.send :derive_foreign_key }

    context "when a has_many" do
      let(:macro) { :has_many }

      context "and the inverse is a collection association" do
        let(:inverse) { double(collection?: true) }
        before { allow(instance).to receive(:inverse_of).and_return(inverse) }
        it { is_expected.to eq 'default_permission_ids' }
      end
    end
  end

  describe "#automatic_inverse_of" do
    before do
      class Dummy < ActiveFedora::Base
        belongs_to :foothing, predicate: ::RDF::DC.extent
      end
    end

    after { Object.send(:remove_const, :Dummy) }
    let(:name) { 'dummy' }
    let(:options) { { as: 'foothing' } }
    let(:active_fedora) { double }
    let(:instance) { described_class.new(macro, name, options, active_fedora) }
    subject { instance.send :automatic_inverse_of }

    context "when a has_many" do
      let(:macro) { :has_many }

      context "and the inverse is a collection association" do
        it { is_expected.to eq :foothing }
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
active-fedora-9.0.8 spec/unit/reflection_spec.rb
active-fedora-9.6.2 spec/unit/reflection_spec.rb
active-fedora-9.6.1 spec/unit/reflection_spec.rb
active-fedora-9.5.0 spec/unit/reflection_spec.rb
active-fedora-9.4.3 spec/unit/reflection_spec.rb
active-fedora-9.4.2 spec/unit/reflection_spec.rb
active-fedora-9.4.1 spec/unit/reflection_spec.rb
active-fedora-9.4.0 spec/unit/reflection_spec.rb
active-fedora-9.3.0 spec/unit/reflection_spec.rb
active-fedora-9.2.1 spec/unit/reflection_spec.rb
active-fedora-9.2.0 spec/unit/reflection_spec.rb
active-fedora-9.2.0.rc2 spec/unit/reflection_spec.rb
active-fedora-9.2.0.rc1 spec/unit/reflection_spec.rb
active-fedora-9.1.2 spec/unit/reflection_spec.rb
active-fedora-9.1.1 spec/unit/reflection_spec.rb
active-fedora-9.1.0 spec/unit/reflection_spec.rb
active-fedora-9.1.0.rc1 spec/unit/reflection_spec.rb