Sha256: e9ce080538e0fa8a67c87f274e685cba5fb739690e2c81572d4f25fb72d37b8e

Contents?: true

Size: 1.51 KB

Versions: 2

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'

describe CurationConcern do
  subject {CurationConcern}
  it 'can mint_a_pid' do
    subject.should respond_to(:mint_a_pid)
  end

  describe '.actor' do
    it 'finds an actor by for a GenericFile' do
      subject.actor(GenericFile.new, User.new, {}).should(
        be_kind_of(CurationConcern::GenericFileActor)
      )
    end

    it 'raise an exception if there is no actor' do
      expect {
        subject.actor("", User.new, {})
      }.to raise_error(NameError)
    end
  end

  describe '.attach_file' do
    let(:file) { Rack::Test::UploadedFile.new(__FILE__, 'text/plain', false) }
    let(:user) { FactoryGirl.create(:user) }
    let(:generic_file) { GenericFile.new }
    let(:curation_concern) { FactoryGirl.create_curation_concern(:generic_work, user) }

    it 'works with a string' do
      actor = CurationConcern.actor(generic_file, user, {batch_id: curation_concern.pid, file: file})
      actor.create
      generic_file.content.content.should == file.read
    end

    it 'success returns true' do
      actor = CurationConcern.actor(generic_file, user, {batch_id: curation_concern.pid, file: file})
      actor.create.should be_true
    end

    context 'failure' do
      it 'returns false' do
        Sufia::GenericFile::Actions.should_receive(:create_content).and_raise(ActiveFedora::RecordInvalid.new(ActiveFedora::Base.new))
        actor = CurationConcern.actor(generic_file, user, {batch_id: curation_concern.pid, file: file})
        actor.create.should be_false
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
curate-0.5.0 spec/services/curation_concern_spec.rb
curate-0.4.2 spec/services/curation_concern_spec.rb