Sha256: 0541ada39d618668e970d7dff80ddd41399ad72bced9c7c5b9ebabf7c22905e2

Contents?: true

Size: 1.05 KB

Versions: 95

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

RSpec.describe SearchHistoryController do
  routes { Blacklight::Engine.routes }

  describe "index" do
    before(:all) do
      @one = Search.create
      @two = Search.create
      @three = Search.create
    end

    it "only fetches searches with ids in the session" do
      session[:history] = [@one.id, @three.id]
      get :index
      @searches = assigns(:searches)
      expect(@searches).to have(2).searches
      expect(@searches).to include(@one)
      expect(@searches).to include(@three)
      expect(@searches).not_to include(@two)
    end

    it "tolerates bad ids in session" do
      session[:history] = [@one.id, @three.id, "NOT_IN_DB"]
      get :index
      @searches = assigns(:searches)
      expect(@searches).to have(2).searches
      expect(@searches).to include(@one)
      expect(@searches).to include(@three)
    end

    it "does not fetch any searches if there is no history" do
      session[:history] = []
      get :index
      @searches = assigns(:searches)
      expect(@searches).to be_empty
    end
  end
end

Version data entries

95 entries across 94 versions & 2 rubygems

Version Path
blacklight-7.8.0 spec/controllers/search_history_controller_spec.rb
blacklight-7.7.0 spec/controllers/search_history_controller_spec.rb
blacklight-7.6.0 spec/controllers/search_history_controller_spec.rb
blacklight-7.5.1 spec/controllers/search_history_controller_spec.rb
blacklight-7.5.0 spec/controllers/search_history_controller_spec.rb
blacklight-7.4.2 spec/controllers/search_history_controller_spec.rb
blacklight-7.4.1 spec/controllers/search_history_controller_spec.rb
blacklight-7.4.0 spec/controllers/search_history_controller_spec.rb
blacklight-7.3.0 spec/controllers/search_history_controller_spec.rb
blacklight-7.2.0 spec/controllers/search_history_controller_spec.rb
blacklight-7.1.0 spec/controllers/search_history_controller_spec.rb
blacklight-7.1.0.alpha spec/controllers/search_history_controller_spec.rb
blacklight-7.0.1 spec/controllers/search_history_controller_spec.rb
blacklight-7.0.0 spec/controllers/search_history_controller_spec.rb
blacklight-7.0.0.rc2 spec/controllers/search_history_controller_spec.rb