Sha256: b312f09ce6e87ff8f1fb58b32506228e04969b87b5a3f838fbe6d04bf48aba62

Contents?: true

Size: 1.84 KB

Versions: 22

Compression:

Stored size: 1.84 KB

Contents

# frozen_string_literal: true

describe SirTrevorRails::Blocks::SolrDocumentsBlock do
  subject { described_class.new({ type: '', data: block_data }, page) }

  let(:page) { FactoryBot.create(:feature_page) }
  let(:block_data) { {} }

  describe '#text' do
    it "is the block's text data" do
      block_data[:text] = 'abc'

      expect(subject.text).to eq 'abc'
    end

    it "squelches sir-trevor's placeholder values" do
      block_data[:text] = '<p><br></p>'
      expect(subject.text).to be_blank
    end
  end

  describe '#primary_caption?' do
    it 'is false if the primary caption field is not configured' do
      block_data['show-primary-caption'] = 'true'
      expect(subject.primary_caption?).to eq false
    end

    it 'is false if the field is configured not to show' do
      block_data['primary-caption-field'] = 'some_field'
      block_data['show-primary-caption'] = 'false'
      expect(subject.primary_caption?).to eq false
    end

    it 'is true if the field is configured to show' do
      block_data['primary-caption-field'] = 'some_field'
      block_data['show-primary-caption'] = 'true'
      expect(subject.primary_caption?).to eq true
    end
  end

  describe '#secondary_caption?' do
    it 'is false if the secondary caption field is not configured' do
      block_data['show-secondary-caption'] = 'true'
      expect(subject.secondary_caption?).to eq false
    end

    it 'is false if the field is configured not to show' do
      block_data['secondary-caption-field'] = 'some_field'
      block_data['show-secondary-caption'] = 'false'
      expect(subject.secondary_caption?).to eq false
    end

    it 'is true if the field is configured to show' do
      block_data['secondary-caption-field'] = 'some_field'
      block_data['show-secondary-caption'] = 'true'
      expect(subject.secondary_caption?).to eq true
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

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