Sha256: a531f725865f74e9eb81d24f0960e09d1d037c0c81d235a0a29a67d8cae8e985

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

describe Collection, :type => :model do
  before do
    @user = FactoryGirl.create(:user)
    @collection = Collection.new(title: "test collection").tap do |c|
      c.apply_depositor_metadata(@user.user_key)
    end
  end

  after do
    @collection.delete
    @user.destroy
  end

  it "should have open visibility" do
    @collection.save
    expect(@collection.read_groups).to eq ['public']
  end

  it "should not allow a collection to be saved without a title" do
     @collection.title = nil
     expect{ @collection.save! }.to raise_error(ActiveFedora::RecordInvalid)
  end

  describe "::bytes" do

    context "with no items" do
      specify "is zero" do
        @collection.save
        expect(@collection.bytes).to eq 0
      end
    end

    context "with characterized GenericFiles" do
      let(:file) { mock_model GenericFile, file_size: ["50"] }
      before do
        allow(@collection).to receive(:members).and_return([file, file])
      end
      specify "is the sum of the files' sizes" do
        expect(@collection.bytes).to eq 100
      end
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sufia-5.0.0 spec/models/collection_spec.rb
sufia-5.0.0.rc1 spec/models/collection_spec.rb
sufia-4.3.1 spec/models/collection_spec.rb
sufia-4.2.0 spec/models/collection_spec.rb
sufia-4.1.0 spec/models/collection_spec.rb