Sha256: 6b33fe26636abb763709eae835e9e826de7701904ac606091ad897a390415eb5

Contents?: true

Size: 1.72 KB

Versions: 6

Compression:

Stored size: 1.72 KB

Contents

require 'spec_helper'

describe Worthwhile::CatalogHelper do
  before do
    helper.params[:controller] = 'catalog'
    allow(helper).to receive(:blacklight_config).and_return(CatalogController.blacklight_config)
    allow(helper).to receive(:search_action_path) do |*args|
      catalog_index_path *args
    end
  end

  describe "all_type_tab" do
    subject { helper.all_type_tab('All') }

    context "when it is the active tab" do
      it { should eq "<li class=\"active\"><a href=\"#\">All</a></li>" }
    end

    context "when it is not the active tab" do
      before do
        helper.params[:f] = { 'generic_type_sim' => ['Work'] }
      end
      it { should eq "<li><a href=\"/catalog\">All</a></li>" }
    end

    context "when other parameters are present" do
      before do
        helper.params[:f] = { 'generic_type_sim' => ['Work'] }
        helper.params[:page] = 4
      end
      it("should clear them") { should eq "<li><a href=\"/catalog\">All</a></li>" }
    end
  end

  describe "type_tab" do
    subject { helper.type_tab('Works', 'Work') }

    context "when it is the active tab" do
      before do
        helper.params[:f] = { 'generic_type_sim' => ['Work'] }
      end
      it { should eq "<li class=\"active\"><a href=\"#\">Works</a></li>" }
    end

    context "when it is not the active tab" do
      it { should eq "<li><a href=\"/catalog?f%5Bgeneric_type_sim%5D%5B%5D=Work\">Works</a></li>" }
    end

    context "when other parameters are present" do
      before do
        helper.params[:f] = { 'generic_type_sim' => ['Collection'] }
        helper.params[:page] = 4
      end
      it("should clear them") { should eq "<li><a href=\"/catalog?f%5Bgeneric_type_sim%5D%5B%5D=Work\">Works</a></li>" }
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
worthwhile-0.1.2 spec/helpers/catalog_helper_spec.rb
worthwhile-0.1.1 spec/helpers/catalog_helper_spec.rb
worthwhile-0.1.0 spec/helpers/catalog_helper_spec.rb
worthwhile-0.0.3 spec/helpers/catalog_helper_spec.rb
worthwhile-0.0.2 spec/helpers/catalog_helper_spec.rb
worthwhile-0.0.1 spec/helpers/catalog_helper_spec.rb