Sha256: 1885843d6fbcda652fd4eb60871bf5080215c23e98a029ec858a99667c6dd451

Contents?: true

Size: 1.23 KB

Versions: 13

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'

describe CurationConcern::LinkedResourceActor do
  let(:user) { FactoryGirl.create(:user) }
  let(:parent) { FactoryGirl.create(:generic_work, user: user) }
  let(:link) { LinkedResource.new.tap {|lr| lr.batch = parent } }
  let(:you_tube_link) { 'http://www.youtube.com/watch?v=oHg5SJYRHA0' }

  def reload_resource(resource)
    resource.class.find(resource.pid)
  end

  subject {
    CurationConcern::LinkedResourceActor.new(link, user, url: you_tube_link)
  }

  describe '#create' do
    describe 'success' do
      it 'adds a linked resource to the parent work' do
        parent.linked_resources.should == []
        subject.create
        reload_resource(parent).linked_resources.should == [link]
        reloaded_link = reload_resource(link)
        reloaded_link.batch.should == parent
        reloaded_link.url.should == you_tube_link
      end
    end

    describe 'failure' do
      it 'returns false' do
        link.stub(:valid?).and_return(false)
        return_value = 'some value'
        expect {
          return_value = subject.create
        }.to_not change { LinkedResource.count }
        reload_resource(parent).linked_resources.should == []
        return_value.should be_false
      end
    end
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
curate-0.6.6 spec/services/curation_concern/linked_resource_actor_spec.rb
curate-0.6.5 spec/services/curation_concern/linked_resource_actor_spec.rb
curate-0.6.4 spec/services/curation_concern/linked_resource_actor_spec.rb
curate-0.6.3 spec/services/curation_concern/linked_resource_actor_spec.rb
curate-0.6.1 spec/services/curation_concern/linked_resource_actor_spec.rb
curate-0.6.0 spec/services/curation_concern/linked_resource_actor_spec.rb
curate-0.5.6 spec/services/curation_concern/linked_resource_actor_spec.rb
curate-0.5.5 spec/services/curation_concern/linked_resource_actor_spec.rb
curate-0.5.4 spec/services/curation_concern/linked_resource_actor_spec.rb
curate-0.5.2 spec/services/curation_concern/linked_resource_actor_spec.rb
curate-0.5.1 spec/services/curation_concern/linked_resource_actor_spec.rb
curate-0.5.0 spec/services/curation_concern/linked_resource_actor_spec.rb
curate-0.4.2 spec/services/curation_concern/linked_resource_actor_spec.rb