Sha256: a6279dcf100ffb160d9c0a01412b802a8858915bea66cc2e2066754a04f64697

Contents?: true

Size: 1019 Bytes

Versions: 55

Compression:

Stored size: 1019 Bytes

Contents

require 'spec_helper'

describe "persisting objects" do
  describe "#create!" do
    before do
      class MockAFBaseRelationship < ActiveFedora::Base
        property :name, predicate: ::RDF::Vocab::DC.title, 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

55 entries across 55 versions & 1 rubygems

Version Path
active-fedora-12.2.4 spec/integration/persistence_spec.rb
active-fedora-12.2.3 spec/integration/persistence_spec.rb
active-fedora-11.5.6 spec/integration/persistence_spec.rb
active-fedora-12.2.2 spec/integration/persistence_spec.rb
active-fedora-11.2.1 spec/integration/persistence_spec.rb
active-fedora-12.2.1 spec/integration/persistence_spec.rb
active-fedora-12.0.3 spec/integration/persistence_spec.rb
active-fedora-11.5.5 spec/integration/persistence_spec.rb
active-fedora-13.1.2 spec/integration/persistence_spec.rb
active-fedora-13.1.1 spec/integration/persistence_spec.rb
active-fedora-13.1.0 spec/integration/persistence_spec.rb
active-fedora-13.0.0 spec/integration/persistence_spec.rb
active-fedora-12.1.1 spec/integration/persistence_spec.rb
active-fedora-12.1.0 spec/integration/persistence_spec.rb
active-fedora-11.5.4 spec/integration/persistence_spec.rb
active-fedora-11.5.3 spec/integration/persistence_spec.rb
active-fedora-12.0.2 spec/integration/persistence_spec.rb
active-fedora-12.0.1 spec/integration/persistence_spec.rb
active-fedora-11.5.2 spec/integration/persistence_spec.rb
active-fedora-12.0.0 spec/integration/persistence_spec.rb