Sha256: 05684a0d5be245d5b6940240a7f2e2fe9c780aa94e4d33acee114ec6831aa1c2

Contents?: true

Size: 1.48 KB

Versions: 27

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

describe Spotlight::PageConfigurations, type: :model do
  let(:view_context) do
    double(
      'ViewContext',
      available_view_fields: [],
      current_exhibit: exhibit,
      blacklight_config: exhibit.blacklight_config,
      document_show_link_field: 'document_show_link_field',
      index_field_label: 'index_field_label',
      index_fields: [],
      spotlight: spotlight,
      t: 'translated-content'
    )
  end

  let(:exhibit) { FactoryBot.create(:exhibit) }
  let(:page) { FactoryBot.create(:feature_page, exhibit: exhibit) }
  subject(:page_config) { described_class.new(context: view_context, page: page) }

  describe '#as_json' do
    it 'is a json-able object (hash)' do
      expect(page_config.as_json).to be_a Hash
    end
  end

  describe 'downstream configured_params' do
    it 'merges the supplied hash into the configs' do
      expect(page_config).to receive_messages(configured_params: { 'hello': 'goodbye' })

      expect(page_config.as_json).to include('hello': 'goodbye')
    end

    it 'sends the #call method to the value if it can respond (e.g. a lamda)' do
      expect(view_context).to receive_messages(my_custom_plugin_path: 'my_custom_plugin/data.json')
      expect(page_config).to receive_messages(
        configured_params: { 'my-custom-plugin-path': ->(config) { config.context.my_custom_plugin_path } }
      )

      expect(page_config.as_json).to include('my-custom-plugin-path': 'my_custom_plugin/data.json')
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
blacklight-spotlight-3.0.0.alpha.2 spec/models/spotlight/page_configurations_spec.rb
blacklight-spotlight-3.0.0.alpha.1 spec/models/spotlight/page_configurations_spec.rb
blacklight-spotlight-2.13.0 spec/models/spotlight/page_configurations_spec.rb
blacklight-spotlight-2.12.1 spec/models/spotlight/page_configurations_spec.rb
blacklight-spotlight-2.12.0 spec/models/spotlight/page_configurations_spec.rb
blacklight-spotlight-2.11.0 spec/models/spotlight/page_configurations_spec.rb
blacklight-spotlight-2.10.0 spec/models/spotlight/page_configurations_spec.rb
blacklight-spotlight-2.9.0 spec/models/spotlight/page_configurations_spec.rb
blacklight-spotlight-2.8.0 spec/models/spotlight/page_configurations_spec.rb
blacklight-spotlight-2.7.2 spec/models/spotlight/page_configurations_spec.rb
blacklight-spotlight-2.7.1 spec/models/spotlight/page_configurations_spec.rb
blacklight-spotlight-2.7.0 spec/models/spotlight/page_configurations_spec.rb
blacklight-spotlight-2.6.1.1 spec/models/spotlight/page_configurations_spec.rb
blacklight-spotlight-2.6.1 spec/models/spotlight/page_configurations_spec.rb
blacklight-spotlight-2.6.0 spec/models/spotlight/page_configurations_spec.rb
blacklight-spotlight-2.5.2 spec/models/spotlight/page_configurations_spec.rb
blacklight-spotlight-2.5.1 spec/models/spotlight/page_configurations_spec.rb
blacklight-spotlight-2.5.0 spec/models/spotlight/page_configurations_spec.rb
blacklight-spotlight-2.4.1 spec/models/spotlight/page_configurations_spec.rb
blacklight-spotlight-2.4.0 spec/models/spotlight/page_configurations_spec.rb