Sha256: 3d3f651cce0aae5c932528efc548b0c4603f42eac56ab6a4dba517a0bae35d02

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

describe Collection 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

3 entries across 3 versions & 1 rubygems

Version Path
sufia-4.0.1 spec/models/collection_spec.rb
sufia-4.0.0 spec/models/collection_spec.rb
sufia-4.0.0.rc2 spec/models/collection_spec.rb