Sha256: f8c697b3df329c3098226ab142fc13364bfda5b36308a82b34bae59176b62464

Contents?: true

Size: 1.18 KB

Versions: 20

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'

describe ActiveFedora::Base do
  before :all do
    class Library < ActiveFedora::Base 
      has_many :books, property: :has_member
    end
    class Book < ActiveFedora::Base; end
  end
  after :all do
    Library.delete_all
    Object.send(:remove_const, :Library)
    Object.send(:remove_const, :Book)
  end

  subject { Library.all } 
  its(:class) {should eq ActiveFedora::Relation }

  before :all do
    Library.create
    @library = Library.create
  end

  let(:library1) { @library }

  describe "is cached" do
    before do
      subject.to_a # trigger initial load
    end

    it "should be loaded" do
      expect(subject).to be_loaded
    end
    it "shouldn't reload" do
      ActiveFedora::Relation.any_instance.should_not_receive :find_each
      subject[0]
    end
  end

  describe "#find" do
    it "should find one of them" do
      expect(subject.find(library1.id)).to eq library1
    end
    it "should find with a block" do
      expect(subject.find { |l| l.id == library1.id}).to eq library1
    end
  end

  describe "#select" do
    it "should find with a block" do
      expect(subject.select { |l| l.id == library1.id}).to eq [library1]
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
active-fedora-7.3.1 spec/integration/relation_spec.rb
active-fedora-7.3.0 spec/integration/relation_spec.rb
active-fedora-8.2.1 spec/integration/relation_spec.rb
active-fedora-8.2.0 spec/integration/relation_spec.rb
active-fedora-7.2.0 spec/integration/relation_spec.rb
active-fedora-8.1.0 spec/integration/relation_spec.rb
active-fedora-8.0.1 spec/integration/relation_spec.rb
active-fedora-8.0.0 spec/integration/relation_spec.rb
active-fedora-8.0.0.rc3 spec/integration/relation_spec.rb
active-fedora-8.0.0.rc2 spec/integration/relation_spec.rb
active-fedora-8.0.0.rc1 spec/integration/relation_spec.rb
active-fedora-7.1.2 spec/integration/relation_spec.rb
active-fedora-7.1.1 spec/integration/relation_spec.rb
active-fedora-7.1.0 spec/integration/relation_spec.rb
active-fedora-7.0.4 spec/integration/relation_spec.rb
active-fedora-7.0.3 spec/integration/relation_spec.rb
active-fedora-7.0.2 spec/integration/relation_spec.rb
active-fedora-7.0.1 spec/integration/relation_spec.rb
active-fedora-7.0.0 spec/integration/relation_spec.rb
active-fedora-7.0.0.rc3 spec/integration/relation_spec.rb