Sha256: 6e9c0a31b89e6654bcdf249b4b3d5349a2239739f9b80a7e52b16026a7da70d1

Contents?: true

Size: 1.95 KB

Versions: 7

Compression:

Stored size: 1.95 KB

Contents

require 'spec_helper'

describe CurationConcerns::CollectionsHelper do
  describe '#link_to_select_collection' do
    let(:collection) { double(id: '123') }
    let(:collectible) { double(id: '456', human_readable_type: 'Generic Work', to_param: '456') }
    before do
      assign(:collection, collection)
    end
    subject { helper.link_to_select_collection(collectible) }

    it 'has a link that pops up a modal' do
      expect(subject).to have_selector 'a[data-toggle=modal][data-target="#456-modal"]'
      expect(subject).to have_link 'Add to a Collection', href: '#'
    end
  end

  describe '#link_to_remove_from_collection' do
    let(:collection) { double(id: '123') }
    let(:collectible) { double(id: '456') }
    before do
      assign(:collection, collection)
    end
    subject { helper.link_to_remove_from_collection(collectible) }

    it 'has a form that routes to remove the collectible' do
      expect(subject).to have_selector 'a[data-method=put]'
      expect(subject).to have_link 'Remove From Collection',
                                   href: collections.collection_path('123', collection: { members: 'remove' },
                                                                            batch_document_ids: ['456'])
    end
  end

  describe '#collection_options_for_select' do
    before do
      allow(helper).to receive(:current_user).and_return(user)
    end
    let(:user) { FactoryGirl.create(:user) }
    let!(:collection1) { FactoryGirl.create(:collection, user: user, title: 'One') }
    let!(:collection2) { FactoryGirl.create(:collection, user: user, title: 'Two') }
    let!(:collection3) { FactoryGirl.create(:collection, user: user, title: 'Three') }
    subject { helper.collection_options_for_select(collection2) }

    it 'excludes the passed in collection' do
      expect(subject).to eq "<option value=\"#{collection1.id}\">#{collection1.title}</option>\n<option value=\"#{collection3.id}\">#{collection3.title}</option>"
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
curation_concerns-0.8.0 spec/helpers/curation_concerns/collections_helper_spec.rb
curation_concerns-0.7.0 spec/helpers/curation_concerns/collections_helper_spec.rb
curation_concerns-0.6.0 spec/helpers/curation_concerns/collections_helper_spec.rb
curation_concerns-0.5.0 spec/helpers/curation_concerns/collections_helper_spec.rb
curation_concerns-0.4.0 spec/helpers/curation_concerns/collections_helper_spec.rb
curation_concerns-0.3.0 spec/helpers/curation_concerns/collections_helper_spec.rb
curation_concerns-0.2.0 spec/helpers/curation_concerns/collections_helper_spec.rb