Sha256: e81fc4427510f69df2755c6985fa5b7be4ed0b2ad6772ed956ba09bf1bdfcfc4

Contents?: true

Size: 1.64 KB

Versions: 7

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

describe Spotlight::CustomSearchField, type: :model do
  describe '#label' do
    subject { described_class.new configuration: { 'label' => 'the configured label' }, slug: 'foo' }

    describe "when the exhibit doesn't have a config" do
      its(:label) { is_expected.to eq 'the configured label' }
    end

    describe 'when the exhibit has a config' do
      let(:exhibit) { FactoryBot.create(:exhibit) }
      before { subject.exhibit = exhibit }

      describe 'that overrides the label' do
        before do
          exhibit.blacklight_configuration.search_fields['foo'] = { 'label' => 'overridden' }
        end

        its(:label) { is_expected.to eq 'overridden' }
      end

      describe "that doesn't override the label" do
        its(:label) { is_expected.to eq 'the configured label' }
      end
    end
  end

  describe '#label=' do
    subject { described_class.new slug: 'foo' }

    describe "when the exhibit doesn't have a config" do
      before { subject.label = 'the configured label' }

      its(:configuration) { is_expected.to eq('label' => 'the configured label') }
    end

    describe 'when the exhibit has a config' do
      let(:exhibit) { FactoryBot.create(:exhibit) }
      before { subject.exhibit = exhibit }

      describe 'that overrides the label' do
        before do
          exhibit.blacklight_configuration.search_fields['foo'] = { 'label' => 'overridden' }
          subject.label = 'edited'
        end

        it 'has updated the exhibit' do
          expect(subject.exhibit.blacklight_configuration.search_fields['foo']['label']).to eq 'edited'
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
blacklight-spotlight-3.0.0.alpha.2 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-3.0.0.alpha.1 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-2.13.0 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-2.12.1 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-2.12.0 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-2.11.0 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-2.10.0 spec/models/spotlight/custom_search_field_spec.rb