Sha256: 3c88232a5aa4b33fec2f288dfba61c3410cf68ffebcf6f916a5d00af0fb4d285
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
require 'spec_helper' RSpec.describe Collection, type: :model do it_behaves_like "a DDR model" 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.build(type: "Curator", agent: user.agent, scope: "resource"), Ddr::Auth::Roles::Role.build(type: "Curator", agent: user.agent, scope: "policy")]) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ddr-models-3.0.0.alpha.4 | spec/models/collection_spec.rb |
ddr-models-3.0.0.alpha.3 | spec/models/collection_spec.rb |