Sha256: dfd471b500a8abe0080d03016d7c81b9339ef1a17fa7e1f656931fabfcfeb278

Contents?: true

Size: 1.61 KB

Versions: 75

Compression:

Stored size: 1.61 KB

Contents

require 'spec_helper'

describe "rdf associations" do
  context "when there is one relationship for the predicate" do
    before do
      class Foo < ActiveFedora::Base
      end
      class Library < ActiveFedora::Base
        has_and_belongs_to_many :foos, predicate: ::RDF::URI('http://example.com')
      end
    end
    after do
      Object.send(:remove_const, :Foo)
      Object.send(:remove_const, :Library)
    end

    let(:library) { Library.new }

    it "doesn't not bother to filter by class type" do
      expect(library.association(:foo_ids)).not_to receive(:filter_by_class)
      library.foos.to_a
    end

    describe "the id setter" do
      it "can handle nil" do
        library.foo_ids = nil
        expect(library.foo_ids).to eq []
      end

      it "can handle array with nils" do
        library.foo_ids = [nil, nil]
        expect(library.foo_ids).to eq []
      end
    end
  end

  context "when two relationships have the same predicate" do
    before do
      class Foo < ActiveFedora::Base
      end
      class Bar < ActiveFedora::Base
      end
      class Library < ActiveFedora::Base
        has_and_belongs_to_many :foos, predicate: ::RDF::URI('http://example.com')
        has_and_belongs_to_many :bars, predicate: ::RDF::URI('http://example.com')
      end
    end
    after do
      Object.send(:remove_const, :Foo)
      Object.send(:remove_const, :Bar)
      Object.send(:remove_const, :Library)
    end

    let(:library) { Library.new }

    it "filters by class type" do
      expect(library.association(:foo_ids)).to receive(:filter_by_class).and_call_original
      library.foos.to_a
    end
  end
end

Version data entries

75 entries across 75 versions & 1 rubygems

Version Path
active-fedora-11.0.0.rc6 spec/integration/associations/rdf_spec.rb
active-fedora-10.2.1 spec/integration/associations/rdf_spec.rb
active-fedora-11.0.0.rc5 spec/integration/associations/rdf_spec.rb
active-fedora-11.0.0.rc4 spec/integration/associations/rdf_spec.rb
active-fedora-10.2.0 spec/integration/associations/rdf_spec.rb
active-fedora-11.0.0.rc3 spec/integration/associations/rdf_spec.rb
active-fedora-11.0.0.rc2 spec/integration/associations/rdf_spec.rb
active-fedora-11.0.0.rc1 spec/integration/associations/rdf_spec.rb
active-fedora-10.1.0 spec/integration/associations/rdf_spec.rb
active-fedora-10.1.0.rc1 spec/integration/associations/rdf_spec.rb
active-fedora-9.7.2 spec/integration/associations/rdf_spec.rb
active-fedora-10.0.0 spec/integration/associations/rdf_spec.rb
active-fedora-10.0.0.beta4 spec/integration/associations/rdf_spec.rb
active-fedora-10.0.0.beta3 spec/integration/associations/rdf_spec.rb
active-fedora-10.0.0.beta2 spec/integration/associations/rdf_spec.rb
active-fedora-10.0.0.beta1 spec/integration/associations/rdf_spec.rb
active-fedora-9.13.0 spec/integration/associations/rdf_spec.rb
active-fedora-9.12.0 spec/integration/associations/rdf_spec.rb
active-fedora-9.11.0 spec/integration/associations/rdf_spec.rb
active-fedora-9.10.4 spec/integration/associations/rdf_spec.rb