Sha256: b96c0d974fed6245e42f4ea34f20d6d0cd64021f040be2eca5e862e79acf953c

Contents?: true

Size: 1.47 KB

Versions: 54

Compression:

Stored size: 1.47 KB

Contents

require 'spec_helper'

describe CurationConcernsHelper do
  let(:search_params) do
    ActionController::Parameters.new(q: 'Simon',
                                     search_field: 'publisher',
                                     controller: 'catalog')
  end
  describe 'render_constraints_query' do
    before do
      # Stub methods from Blacklight::SearchFields
      allow(helper).to receive(:default_search_field).and_return(CatalogController.blacklight_config.default_search_field)
      allow(helper).to receive(:label_for_search_field).and_return('Foo')
    end

    subject { helper.render_constraints_query(search_params) }

    it 'removes search_field' do
      node = Capybara::Node::Simple.new(subject)
      expect(node).to have_link 'Remove constraint Foo: Simon', href: search_catalog_path
    end

    it 'calls remove_constraint_url' do
      expect(helper).to receive(:remove_constraint_url).and_return('/hello')
      expect(subject).to include 'href="/hello"'
    end
  end

  describe 'remove_constraint_url' do
    subject { helper.remove_constraint_url(search_params) }
    it 'calls fields_to_exclude_from_constraint_element' do
      expect(helper).to receive(:fields_to_exclude_from_constraint_element).and_return([])
      expect(subject).to eq "/catalog?search_field=publisher"
    end
  end

  describe 'fields_to_exclude_from_constraint_element' do
    subject { helper.fields_to_exclude_from_constraint_element }
    it { is_expected.to eq [:search_field] }
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

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