Sha256: d2d71d8fe7182e3f5967701ada9793f568f4fd4807a6c644cce592a1d8d69d57

Contents?: true

Size: 890 Bytes

Versions: 5

Compression:

Stored size: 890 Bytes

Contents

# frozen_string_literal: true
require 'spec_helper'

describe SavedSearchesController do
  routes { Blacklight::Engine.routes }

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

  before(:each) do
    @user = User.create! :email => 'test@example.com', :password => 'abcd12345', :password_confirmation => 'abcd12345'
    sign_in @user  
  end

  describe "save" do
    it "should let you save a search" do

      request.env["HTTP_REFERER"] = "where_i_came_from"
      session[:history] = [@one.id]
      post :save, :id => @one.id
      expect(response).to redirect_to "where_i_came_from"
    end

    it "should not let you save a search that isn't in your search history" do
      session[:history] = [@one.id]
      expect {
        post :save, :id => @two.id
      }.to raise_error ActiveRecord::RecordNotFound
    end

  end



end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
blacklight-6.2.0 spec/controllers/saved_searches_controller_spec.rb
blacklight-6.1.0 spec/controllers/saved_searches_controller_spec.rb
blacklight-6.0.2 spec/controllers/saved_searches_controller_spec.rb
blacklight-6.0.1 spec/controllers/saved_searches_controller_spec.rb
blacklight-6.0.0 spec/controllers/saved_searches_controller_spec.rb