Sha256: 89d3f580a1f5eef3dfdc9291268284c33d016d8dd05ea7fdf643543d08b1c629

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 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

  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-6.0.0.rc4 spec/models/collection_spec.rb
sufia-6.0.0.rc3 spec/models/collection_spec.rb
sufia-6.0.0.rc2 spec/models/collection_spec.rb
sufia-6.0.0.rc1 spec/models/collection_spec.rb
sufia-6.0.0.beta1 spec/models/collection_spec.rb