Sha256: 0788421bc96132437603c640c5c25c7eacb7d6dcb0c50761569f4f962b7316d8

Contents?: true

Size: 1.35 KB

Versions: 26

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

RSpec.describe Collection, type: :model do

  it_behaves_like "a DDR model"
  it_behaves_like "a publishable object"

  describe "#components_from_solr" do
    subject { Collection.new(id: 'test-1') }
    before do
      allow_any_instance_of(Component).to receive(:collection_id).and_return(subject.id)
    end
    it "should return the correct component(s)" do
      component = Component.create
      docs = subject.components_from_solr
      expect(docs.size).to eq(1)
      expect(docs.first.id).to eq(component.id)
    end
  end

  describe "validation" do
    it "should require a title" do
      expect(subject).to_not be_valid
      expect(subject.errors.messages).to have_key(:dc_title)
    end
  end

  describe "creation" do
    subject { Collection.create(dc_title: [ "Test Collection" ]) }
    it "should be governed by itself" do
      expect(subject.admin_policy).to eq(subject)
    end
  end

  describe "roles granted to creator" do
    let(:user) { FactoryGirl.build(:user) }
    before { subject.grant_roles_to_creator(user) }
    it "should include Curator roles in both resource abd policy scopes" do
      expect(subject.roles.to_a).to eq([Ddr::Auth::Roles::Role.new(role_type: "Curator", agent: user.agent, scope: "resource"), Ddr::Auth::Roles::Role.new(role_type: "Curator", agent: user.agent, scope: "policy")])
    end
  end

end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
ddr-models-3.0.8 spec/models/collection_spec.rb
ddr-models-3.0.7 spec/models/collection_spec.rb
ddr-models-3.0.6 spec/models/collection_spec.rb
ddr-models-3.0.5 spec/models/collection_spec.rb
ddr-models-3.0.4 spec/models/collection_spec.rb
ddr-models-3.0.3 spec/models/collection_spec.rb
ddr-models-3.0.2 spec/models/collection_spec.rb
ddr-models-3.0.1 spec/models/collection_spec.rb
ddr-models-3.0.0 spec/models/collection_spec.rb
ddr-models-3.0.0.rc6 spec/models/collection_spec.rb
ddr-models-3.0.0.rc5 spec/models/collection_spec.rb
ddr-models-3.0.0.rc4 spec/models/collection_spec.rb
ddr-models-3.0.0.rc3 spec/models/collection_spec.rb
ddr-models-3.0.0.rc2 spec/models/collection_spec.rb
ddr-models-3.0.0.rc1 spec/models/collection_spec.rb
ddr-models-3.0.0.beta.22 spec/models/collection_spec.rb
ddr-models-3.0.0.beta.21 spec/models/collection_spec.rb
ddr-models-3.0.0.beta.20 spec/models/collection_spec.rb
ddr-models-3.0.0.beta.18 spec/models/collection_spec.rb
ddr-models-3.0.0.beta.17 spec/models/collection_spec.rb