Sha256: 1195397845196628785f8a1dd49a23d90011aded37564f9aa06d6d554bea6960

Contents?: true

Size: 1.64 KB

Versions: 22

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

22 entries across 22 versions & 1 rubygems

Version Path
blacklight-spotlight-3.4.0 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-3.3.0 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-3.2.0 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-3.1.0 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-3.0.3 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-3.0.2 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-3.0.1 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-3.0.0 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-3.0.0.rc6 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-3.0.0.rc5 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-3.0.0.rc4 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-3.0.0.rc3 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-3.0.0.rc2 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-3.0.0.rc1 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-3.0.0.alpha.10 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-3.0.0.alpha.9 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-3.0.0.alpha.8 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-3.0.0.alpha.7 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-3.0.0.alpha.6 spec/models/spotlight/custom_search_field_spec.rb
blacklight-spotlight-3.0.0.alpha.5 spec/models/spotlight/custom_search_field_spec.rb