Sha256: 9f1f3bf4812e6ab902f307faf32fd46e69f68ace9ebf93ae24c231f00659bffd

Contents?: true

Size: 1.1 KB

Versions: 12

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

describe "persisting objects" do
  describe "#create!" do
    before do
      class MockAFBaseRelationship < ActiveFedora::Base
        has_metadata type: ActiveFedora::SimpleDatastream, name: "foo" do |m|
          m.field "name", :string
        end
        property :name, delegate_to: 'foo', multiple: false
        validates :name, presence: true
      end
    end

    after do
      Object.send(:remove_const, :MockAFBaseRelationship)
    end

    it "validates" do
      expect { MockAFBaseRelationship.create! }.to raise_error ActiveFedora::RecordInvalid, "Validation failed: Name can't be blank"
    end
  end

  describe "#save" do
    context "With undefined contains associations" do
      let(:f1) { ActiveFedora::Base.create }
      let!(:f2) { ActiveFedora::Base.create(id: "#{f1.id}/part2") }

      before do
        f1.reload # so it learns about f2
      end

      it "doesn't load the children" do
        allow(f1).to receive(:update_index) # solrizing can load the attached files.
        expect(ActiveFedora::File).not_to receive(:new)
        f1.save
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
active-fedora-9.7.3 spec/integration/persistence_spec.rb
active-fedora-9.7.2 spec/integration/persistence_spec.rb
active-fedora-9.10.0.pre1 spec/integration/persistence_spec.rb
active-fedora-9.9.1 spec/integration/persistence_spec.rb
active-fedora-9.9.0 spec/integration/persistence_spec.rb
active-fedora-9.8.2 spec/integration/persistence_spec.rb
active-fedora-9.8.1 spec/integration/persistence_spec.rb
active-fedora-9.8.0 spec/integration/persistence_spec.rb
active-fedora-9.7.1 spec/integration/persistence_spec.rb
active-fedora-9.7.0 spec/integration/persistence_spec.rb
active-fedora-9.6.2 spec/integration/persistence_spec.rb
active-fedora-9.6.1 spec/integration/persistence_spec.rb