Sha256: 3f828ae7899ff5744d3829c671dd02f3c21fa87e4033eb69a75a1ebbe7b0728a

Contents?: true

Size: 1007 Bytes

Versions: 1

Compression:

Stored size: 1007 Bytes

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
    subject { @collection.bytes }
    context "with no items" do
      before { @collection.save }
      it { is_expected.to eq 0 }
    end

    context "with two 50 byte files" do
      let(:bitstream) { double("content", size: "50")}
      let(:file) { mock_model GenericFile, content: bitstream }
      before { allow(@collection).to receive(:members).and_return([file, file]) }
      it { is_expected.to eq 100 }
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sufia-6.0.0 spec/models/collection_spec.rb