spec/services/curation_concern_spec.rb in curate-0.3.2 vs spec/services/curation_concern_spec.rb in curate-0.4.2

- old
+ new

@@ -22,13 +22,27 @@ 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(:mock_curation_concern, user) } + 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! + 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