Sha256: 248054d127ac08debbecabf512d2943d6357b6a4ab4f7e2779d66624339eaf6c

Contents?: true

Size: 1.83 KB

Versions: 35

Compression:

Stored size: 1.83 KB

Contents

require 'spec_helper'

describe RenderConstraintsHelper do

  let(:config) do
    Blacklight::Configuration.new do |config|
      config.add_facet_field 'type'
    end
  end

  before do
    # the helper methods below infer paths from the current route
    controller.request.path_parameters[:controller] = 'catalog'
    allow(helper).to receive(:search_action_path) do |*args|
      catalog_index_path *args
    end
  end

  describe '#render_constraints_query' do
    let(:my_engine) { double("Engine") }
    it "should have a link relative to the current url" do
      expect(helper.render_constraints_query(:q=>'foobar', :f=>{:type=>'journal'})).to have_selector "a[href='/?f%5Btype%5D=journal']"
    end
    it "should accept an optional route set" do
      expect(my_engine).to receive(:url_for).and_return('/?f%5Btype%5D=journal')
      expect(helper.render_constraints_query(:q=>'foobar', :f=>{:type=>'journal'}, :route_set => my_engine)).to have_selector "a[href='/?f%5Btype%5D=journal']"
    end
  end

  describe '#render_filter_element' do
    before do
      allow(helper).to receive(:blacklight_config).and_return(config)
      expect(helper).to receive(:facet_field_label).with('type').and_return("Item Type")
    end
    subject { helper.render_filter_element('type', ['journal'], {:q=>'biz'}) }

    it "should have a link relative to the current url" do
      expect(subject).to have_link "Remove constraint Item Type: journal", href: "/catalog?q=biz"
      expect(subject).to have_selector ".filterName", text: 'Item Type'
    end
  end

  describe "#render_constraints_filters" do
    before do
      allow(helper).to receive(:blacklight_config).and_return(config)
    end
    subject { helper.render_constraints_filters(:f=>{'type'=>['']}) }

    it "should render nothing for empty facet limit param" do
      expect(subject).to be_blank
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
blacklight-5.9.4 spec/helpers/render_constraints_helper_spec.rb
blacklight-5.11.2 spec/helpers/render_constraints_helper_spec.rb
blacklight-5.11.1 spec/helpers/render_constraints_helper_spec.rb
blacklight-5.11.0 spec/helpers/render_constraints_helper_spec.rb
blacklight-5.10.2 spec/helpers/render_constraints_helper_spec.rb
blacklight-5.10.1 spec/helpers/render_constraints_helper_spec.rb
blacklight-5.10.0 spec/helpers/render_constraints_helper_spec.rb
blacklight-5.9.3 spec/helpers/render_constraints_helper_spec.rb
blacklight-5.9.2 spec/helpers/render_constraints_helper_spec.rb
blacklight-5.9.1 spec/helpers/render_constraints_helper_spec.rb
blacklight-5.9.0 spec/helpers/render_constraints_helper_spec.rb
blacklight-5.8.2 spec/helpers/render_constraints_helper_spec.rb
blacklight-5.8.1 spec/helpers/render_constraints_helper_spec.rb
blacklight-5.8.0 spec/helpers/render_constraints_helper_spec.rb
blacklight-5.7.2 spec/helpers/render_constraints_helper_spec.rb