Sha256: c99549d4b9b00358def2b051ae49323fbca478493cc47197475496635414a113

Contents?: true

Size: 1.16 KB

Versions: 5

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'

describe BlacklightHelper do
  describe "document_partial_name" do
    let(:field_name) { 'has_model_s' }

    let(:config) do
      Blacklight::Configuration.new.configure do |config|
        config.show.display_type_field = field_name
      end
    end

    before do
      allow(helper).to receive(:blacklight_config).and_return(config)
      allow(helper).to receive(:blacklight_configuration_context).and_return(helper)
      allow(helper).to receive(:evaluate_if_unless_configuration).and_return(true)
    end

    it "changes camel case to underscored lowercase" do
      expect(helper.document_partial_name('has_model_s' => ["Presentation"])).to eq "presentation"
      expect(helper.document_partial_name('has_model_s' => ["GenericContent"])).to eq("generic_content")
    end

    context "with a single valued field" do
      let(:field_name) { 'has_model_s' }
      it "should support single valued fields" do
        expect(helper.document_partial_name('has_model_s' => "Chicken")).to eq "chicken"
      end
    end

    it "handles periods" do
      expect(helper.document_partial_name('has_model_s' => ["text.PDF"])).to eq "text_pdf"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hydra-core-13.0.0 spec/helpers/blacklight_helper_spec.rb
hydra-core-12.1.0 spec/helpers/blacklight_helper_spec.rb
hydra-core-12.0.2 spec/helpers/blacklight_helper_spec.rb
hydra-core-12.0.1 spec/helpers/blacklight_helper_spec.rb
hydra-core-12.0.0 spec/helpers/blacklight_helper_spec.rb