Sha256: d2aac8cf28e247bf5d5d439c06c17351a54e0120ad99be4af5639b7431730b9a

Contents?: true

Size: 1.99 KB

Versions: 54

Compression:

Stored size: 1.99 KB

Contents

require 'spec_helper'

describe 'shared/_add_content.html.erb' do
  before do
    allow(view).to receive(:current_user).and_return(user)
  end

  context 'for people who can create Works and Collections' do
    let(:user) { create(:admin) }
    before do
      allow(view).to receive(:can?).and_return(true)
      render
    end

    it 'has links to create works and collections' do
      CurationConcerns.config.curation_concerns.each do |curation_concern_type|
        expect(rendered).to have_link("New #{curation_concern_type.human_readable_type}", href: new_polymorphic_path(curation_concern_type))
      end
      expect(rendered).to have_link('Add a Collection', href: new_collection_path)
    end
  end

  context 'for people who can only create Collections' do
    let(:user) { create(:admin) }
    before do
      allow(view).to receive(:can?).and_return(true)
      allow(view).to receive(:can_ever_create_works?).and_return(false)
      render
    end

    it 'has links to add collections but not to add works' do
      CurationConcerns.config.curation_concerns.each do |curation_concern_type|
        expect(rendered).not_to have_link("New #{curation_concern_type.human_readable_type}", href: new_polymorphic_path(curation_concern_type))
      end
      expect(rendered).to have_link('Add a Collection', href: new_collection_path)
    end
  end

  context 'for people who cannot create anything' do
    let(:user) { create(:user) }
    before do
      allow(view).to receive(:can?).and_return(false)
      render
    end

    it 'does not have links to add works or collections' do
      expect(rendered).not_to have_text('Add')
      expect(rendered).not_to have_text('Admin')
      CurationConcerns.config.curation_concerns.each do |curation_concern_type|
        expect(rendered).not_to have_link("New #{curation_concern_type.human_readable_type}", href: new_polymorphic_path(curation_concern_type))
      end
      expect(rendered).not_to have_link('Add a Collection', href: new_collection_path)
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
curation_concerns-1.7.8 spec/views/shared/_add_content.html.erb_spec.rb
curation_concerns-1.7.7 spec/views/shared/_add_content.html.erb_spec.rb
curation_concerns-2.0.0 spec/views/shared/_add_content.html.erb_spec.rb
curation_concerns-2.0.0.rc2 spec/views/shared/_add_content.html.erb_spec.rb
curation_concerns-1.7.6 spec/views/shared/_add_content.html.erb_spec.rb
curation_concerns-1.7.5 spec/views/shared/_add_content.html.erb_spec.rb
curation_concerns-1.7.4 spec/views/shared/_add_content.html.erb_spec.rb
curation_concerns-1.7.3 spec/views/shared/_add_content.html.erb_spec.rb
curation_concerns-1.7.2 spec/views/shared/_add_content.html.erb_spec.rb
curation_concerns-2.0.0.rc1 spec/views/shared/_add_content.html.erb_spec.rb
curation_concerns-1.7.1 spec/views/shared/_add_content.html.erb_spec.rb
curation_concerns-1.7.0 spec/views/shared/_add_content.html.erb_spec.rb
curation_concerns-1.7.0.beta1 spec/views/shared/_add_content.html.erb_spec.rb
curation_concerns-1.6.3 spec/views/shared/_add_content.html.erb_spec.rb
curation_concerns-1.6.2 spec/views/shared/_add_content.html.erb_spec.rb
curation_concerns-1.6.1 spec/views/shared/_add_content.html.erb_spec.rb
curation_concerns-1.6.0 spec/views/shared/_add_content.html.erb_spec.rb
curation_concerns-1.5.0 spec/views/shared/_add_content.html.erb_spec.rb
curation_concerns-1.4.0 spec/views/shared/_add_content.html.erb_spec.rb
curation_concerns-1.3.3 spec/views/shared/_add_content.html.erb_spec.rb