Sha256: ae47f616e2c989eef60c97dc3611259e9c03a3138af80660359dba251efab737

Contents?: true

Size: 1.99 KB

Versions: 19

Compression:

Stored size: 1.99 KB

Contents

require 'spec_helper'

describe Spotlight::Controller do
  class MockController < ActionController::Base
    include Spotlight::Controller
  end

  subject { MockController.new }

  before do
    allow(subject).to receive_messages(params: { action: 'show' })
  end

  describe '#current_exhibit' do
    it 'is nil by default' do
      expect(subject.current_exhibit).to be_nil
    end
  end

  describe '#exhibit_masthead?' do
    let(:masthead) { double('masthead', display?: true) }

    before do
      allow(subject).to receive_messages(current_exhibit: nil, current_masthead: nil)
    end

    it 'is true if there is no exhibit' do
      expect(subject.exhibit_masthead?).to eq true
    end

    it 'is true if there is no custom exhibit masthead' do
      allow(subject).to receive_messages(current_exhibit: double, current_masthead: nil)
      expect(subject.exhibit_masthead?).to eq true
    end

    it 'is false if the current masthead is not the exhibit masthead' do
      allow(subject).to receive_messages(current_exhibit: double(masthead: double), current_masthead: masthead)
      expect(subject.exhibit_masthead?).to eq false
    end
  end
  describe '#current_masthead' do
    let(:search_masthead) { double('search-masthead', display?: true) }
    let(:no_display_search_masthead) { double('no-display-search-masthead', display?: false) }
    let(:exhibit_masthead) { double('exhibit-masthead', display?: true) }
    let(:exhibit) { FactoryGirl.create(:exhibit) }
    let(:search) { FactoryGirl.create(:search) }
    it 'is nil by default' do
      expect(subject.current_masthead).to be_nil
    end
    it 'returns the exhibit masthead if available' do
      allow(exhibit).to receive_messages(masthead: exhibit_masthead)
      subject.instance_variable_set(:@exhibit, exhibit)
      expect(subject.current_masthead).to eq exhibit_masthead
    end
    it 'allows the masthead to be set' do
      subject.current_masthead = search_masthead
      expect(subject.current_masthead).to eq search_masthead
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
blacklight-spotlight-0.13.0 spec/lib/spotlight/controller_spec.rb
blacklight-spotlight-0.12.1 spec/lib/spotlight/controller_spec.rb
blacklight-spotlight-0.12.0 spec/lib/spotlight/controller_spec.rb
blacklight-spotlight-0.11.0 spec/lib/spotlight/controller_spec.rb
blacklight-spotlight-0.10.3 spec/lib/spotlight/controller_spec.rb
blacklight-spotlight-0.10.2 spec/lib/spotlight/controller_spec.rb
blacklight-spotlight-0.10.1 spec/lib/spotlight/controller_spec.rb
blacklight-spotlight-0.10.0 spec/lib/spotlight/controller_spec.rb
blacklight-spotlight-0.9.2 spec/lib/spotlight/controller_spec.rb
blacklight-spotlight-0.9.1 spec/lib/spotlight/controller_spec.rb
blacklight-spotlight-0.9.0 spec/lib/spotlight/controller_spec.rb
blacklight-spotlight-0.8.2 spec/lib/spotlight/controller_spec.rb
blacklight-spotlight-0.8.1 spec/lib/spotlight/controller_spec.rb
blacklight-spotlight-0.8.0 spec/lib/spotlight/controller_spec.rb
blacklight-spotlight-0.7.2 spec/lib/spotlight/controller_spec.rb
blacklight-spotlight-0.7.1 spec/lib/spotlight/controller_spec.rb
blacklight-spotlight-0.7.0 spec/lib/spotlight/controller_spec.rb
blacklight-spotlight-0.6.0 spec/lib/spotlight/controller_spec.rb
blacklight-spotlight-0.5.0 spec/lib/spotlight/controller_spec.rb