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-8.6.1 spec/controllers/search_history_controller_spec.rb
blacklight-7.40.0 spec/controllers/search_history_controller_spec.rb
blacklight-8.6.0 spec/controllers/search_history_controller_spec.rb
blacklight-8.5.1 spec/controllers/search_history_controller_spec.rb
blacklight-8.5.0 spec/controllers/search_history_controller_spec.rb
blacklight-7.39.0 spec/controllers/search_history_controller_spec.rb
blacklight-8.4.0 spec/controllers/search_history_controller_spec.rb
blacklight-7.38.0 spec/controllers/search_history_controller_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/spec/controllers/search_history_controller_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/spec/controllers/search_history_controller_spec.rb
blacklight-8.3.0 spec/controllers/search_history_controller_spec.rb
blacklight-8.2.2 spec/controllers/search_history_controller_spec.rb
blacklight-8.2.1 spec/controllers/search_history_controller_spec.rb
blacklight-8.2.0 spec/controllers/search_history_controller_spec.rb
blacklight-7.37.0 spec/controllers/search_history_controller_spec.rb
blacklight-7.36.2 spec/controllers/search_history_controller_spec.rb
blacklight-7.36.1 spec/controllers/search_history_controller_spec.rb
blacklight-7.36.0 spec/controllers/search_history_controller_spec.rb
blacklight-7.35.0 spec/controllers/search_history_controller_spec.rb
blacklight-8.1.0 spec/controllers/search_history_controller_spec.rb