Sha256: e5e73d82814c1a93beaff3227c937bea5f2f1fa39632c9c2ed793ee03ea352d8

Contents?: true

Size: 1008 Bytes

Versions: 10

Compression:

Stored size: 1008 Bytes

Contents

require 'spec_helper'

describe Document do
  subject {  FactoryGirl.build(:document) }

  it { should have_unique_field(:title) }
  it { should have_unique_field(:type) }

  it_behaves_like 'is_a_curation_concern_model'
  it_behaves_like 'with_access_rights'
  it_behaves_like 'with_related_works'
  it_behaves_like 'is_embargoable'
  it_behaves_like 'has_dc_metadata'
  it_behaves_like 'has_common_solr_fields'
  it_behaves_like 'it has linked contributors'

  describe 'valid types: ' do
    let(:doc) { FactoryGirl.build(:document) }

    Document.valid_types.each do |type|
      it "type '#{type}' is valid" do
        doc.type = type
        doc.valid?
        expect(doc.errors[:type]).to_not be_present
      end
    end

    it 'non-whitelist types are not valid' do
      doc.type = 'Invalid document type'
      doc.valid?
      expect(doc.errors[:type]).to be_present
    end

    it 'type can be nil' do
      doc.type = nil
      expect(doc.errors[:type]).to_not be_present
    end
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
curate-0.6.6 spec/repository_models/document_spec.rb
curate-0.6.5 spec/repository_models/document_spec.rb
curate-0.6.4 spec/repository_models/document_spec.rb
curate-0.6.3 spec/repository_models/document_spec.rb
curate-0.6.1 spec/repository_models/document_spec.rb
curate-0.6.0 spec/repository_models/document_spec.rb
curate-0.5.6 spec/repository_models/document_spec.rb
curate-0.5.5 spec/repository_models/document_spec.rb
curate-0.5.4 spec/repository_models/document_spec.rb
curate-0.5.2 spec/repository_models/document_spec.rb