blacklight 6.0.0.pre3 → 6.0.0.pre4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/VERSION +1 -1
  4. data/app/controllers/bookmarks_controller.rb +0 -1
  5. data/app/controllers/catalog_controller.rb +0 -1
  6. data/app/controllers/concerns/blacklight/base.rb +0 -1
  7. data/app/controllers/concerns/blacklight/bookmarks.rb +0 -1
  8. data/app/controllers/concerns/blacklight/catalog.rb +6 -38
  9. data/app/controllers/concerns/blacklight/controller.rb +0 -2
  10. data/app/controllers/concerns/blacklight/search_fields.rb +0 -1
  11. data/app/controllers/concerns/blacklight/search_helper.rb +0 -5
  12. data/app/{models → controllers}/concerns/blacklight/token_based_user.rb +6 -10
  13. data/app/controllers/saved_searches_controller.rb +0 -1
  14. data/app/controllers/search_history_controller.rb +0 -1
  15. data/app/helpers/blacklight/blacklight_helper_behavior.rb +0 -4
  16. data/app/helpers/blacklight/catalog_helper_behavior.rb +3 -2
  17. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +0 -1
  18. data/app/helpers/blacklight/layout_helper_behavior.rb +8 -0
  19. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +0 -1
  20. data/app/helpers/blacklight/render_partials_helper.rb +1 -6
  21. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +0 -1
  22. data/app/helpers/blacklight/url_helper_behavior.rb +1 -6
  23. data/app/models/blacklight/solr/facet_paginator.rb +0 -1
  24. data/app/models/bookmark.rb +0 -1
  25. data/app/models/concerns/blacklight/configurable.rb +0 -1
  26. data/app/models/concerns/blacklight/document/cache_key.rb +0 -1
  27. data/app/models/concerns/blacklight/document/email.rb +0 -1
  28. data/app/models/concerns/blacklight/document/sms.rb +0 -1
  29. data/app/models/concerns/blacklight/solr/document.rb +0 -7
  30. data/app/models/concerns/blacklight/user.rb +0 -1
  31. data/app/models/record_mailer.rb +0 -1
  32. data/app/models/search.rb +0 -6
  33. data/app/presenters/blacklight/document_presenter.rb +3 -17
  34. data/app/presenters/blacklight/json_presenter.rb +41 -0
  35. data/app/views/catalog/_document.html.erb +1 -1
  36. data/app/views/catalog/_document_default.atom.builder +2 -4
  37. data/app/views/catalog/facet.json.jbuilder +3 -0
  38. data/app/views/catalog/index.atom.builder +1 -1
  39. data/app/views/catalog/index.json.jbuilder +6 -0
  40. data/app/views/layouts/blacklight.html.erb +1 -1
  41. data/app/views/shared/_header_navbar.html.erb +2 -2
  42. data/blacklight.gemspec +9 -4
  43. data/db/migrate/20140202020201_create_searches.rb +1 -2
  44. data/db/migrate/20140202020202_create_bookmarks.rb +1 -2
  45. data/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +0 -1
  46. data/lib/blacklight.rb +0 -10
  47. data/lib/blacklight/configuration.rb +0 -1
  48. data/lib/blacklight/engine.rb +0 -8
  49. data/lib/blacklight/exceptions.rb +0 -1
  50. data/lib/blacklight/routes.rb +0 -1
  51. data/lib/blacklight/version.rb +0 -1
  52. data/lib/generators/blacklight/assets_generator.rb +0 -1
  53. data/lib/generators/blacklight/install_generator.rb +8 -14
  54. data/lib/generators/blacklight/solr4_generator.rb +27 -0
  55. data/lib/generators/blacklight/solr5_generator.rb +21 -0
  56. data/lib/generators/blacklight/templates/alternate_controller.rb +0 -1
  57. data/lib/generators/blacklight/templates/catalog_controller.rb +3 -4
  58. data/lib/generators/blacklight/templates/solr_document.rb +0 -1
  59. data/lib/generators/blacklight/test_support_generator.rb +0 -1
  60. data/lib/railties/blacklight.rake +0 -7
  61. data/provision.sh +11 -1
  62. data/spec/controllers/blacklight/search_helper_spec.rb +0 -1
  63. data/spec/controllers/bookmarks_controller_spec.rb +26 -1
  64. data/spec/controllers/catalog_controller_spec.rb +8 -35
  65. data/spec/features/facets_spec.rb +0 -1
  66. data/spec/features/record_view_spec.rb +0 -1
  67. data/spec/features/search_context_spec.rb +0 -2
  68. data/spec/features/search_formats_spec.rb +0 -2
  69. data/spec/features/search_pagination_spec.rb +0 -2
  70. data/spec/features/search_results_spec.rb +0 -2
  71. data/spec/features/search_spec.rb +0 -2
  72. data/spec/helpers/blacklight_helper_spec.rb +3 -12
  73. data/spec/helpers/catalog_helper_spec.rb +8 -0
  74. data/spec/helpers/layout_helper_spec.rb +7 -0
  75. data/spec/helpers/url_helper_spec.rb +0 -7
  76. data/spec/lib/tasks/blacklight_task_spec.rb +0 -1
  77. data/spec/models/record_mailer_spec.rb +1 -3
  78. data/spec/models/search_spec.rb +1 -2
  79. data/spec/models/solr_document_spec.rb +22 -24
  80. data/spec/presenters/document_presenter_spec.rb +28 -6
  81. data/spec/spec_helper.rb +0 -1
  82. data/spec/views/catalog/_document.html.erb_spec.rb +20 -3
  83. data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +2 -2
  84. data/spec/views/catalog/facet.json.jbuilder_spec.rb +9 -0
  85. data/spec/views/catalog/index.json.jbuilder_spec.rb +30 -0
  86. metadata +15 -15
  87. data/app/models/concerns/blacklight/solr/document/dublin_core.rb +0 -7
  88. data/app/models/concerns/blacklight/solr/document/email.rb +0 -7
  89. data/app/models/concerns/blacklight/solr/document/export.rb +0 -7
  90. data/app/models/concerns/blacklight/solr/document/extensions.rb +0 -8
  91. data/app/models/concerns/blacklight/solr/document/schema_org.rb +0 -7
  92. data/app/models/concerns/blacklight/solr/document/sms.rb +0 -7
  93. data/app/views/catalog/email_sent.html.erb +0 -2
  94. data/app/views/catalog/sms_sent.html.erb +0 -2
  95. data/lib/blacklight/configuration/solr_field.rb +0 -7
@@ -1,4 +1,4 @@
1
1
  <% # container for a single doc -%>
2
- <div class="document <%= render_document_class document %>" itemscope itemtype="<%= document.itemtype %>">
2
+ <div class="document <%= render_document_class document %> document-position-<%= document_counter%> " data-document-counter="<%= document_counter %>" itemscope itemtype="<%= document.itemtype %>">
3
3
  <%= render_document_partials document, blacklight_config.view_config(document_index_view_type).partials, :document_counter => document_counter %>
4
4
  </div>
@@ -3,7 +3,7 @@ xml.entry do
3
3
  xml.title presenter(document).render_document_index_label(document_show_link_field(document))
4
4
 
5
5
  # updated is required, for now we'll just set it to now, sorry
6
- xml.updated Time.now.strftime("%Y-%m-%dT%H:%M:%SZ")
6
+ xml.updated Time.current.iso8601
7
7
 
8
8
  xml.link "rel" => "alternate", "type" => "text/html", "href" => polymorphic_url(url_for_document(document))
9
9
  # add other doc-specific formats, atom only lets us have one per
@@ -50,6 +50,4 @@ xml.entry do
50
50
  end
51
51
 
52
52
  end
53
-
54
-
55
- end
53
+ end
@@ -0,0 +1,3 @@
1
+ json.response do
2
+ json.facets @pagination
3
+ end
@@ -43,7 +43,7 @@ xml.feed("xmlns" => "http://www.w3.org/2005/Atom",
43
43
 
44
44
 
45
45
  # updated is required, for now we'll just set it to now, sorry
46
- xml.updated Time.now.strftime("%Y-%m-%dT%H:%M:%SZ")
46
+ xml.updated Time.current.iso8601
47
47
 
48
48
  @document_list.each_with_index do |document, document_counter|
49
49
  xml << Nokogiri::XML.fragment(render_document_partials(document, blacklight_config.view_config(:atom).partials, document_counter: document_counter))
@@ -0,0 +1,6 @@
1
+ json.response do
2
+ json.docs @presenter.documents
3
+ json.facets @presenter.search_facets_as_json
4
+ json.pages @presenter.pagination_info
5
+ end
6
+
@@ -35,7 +35,7 @@
35
35
 
36
36
  <%= render partial: 'shared/ajax_modal' %>
37
37
 
38
- <div id="main-container" class="container">
38
+ <div id="main-container" class="<%= container_classes %>">
39
39
  <%= content_tag :h1, application_name, class: 'sr-only application-heading' %>
40
40
 
41
41
  <%= render :partial=>'/flash_msg', layout: 'shared/flash_messages' %>
@@ -1,5 +1,5 @@
1
1
  <div id="header-navbar" class="navbar navbar-inverse navbar-static-top" role="navigation">
2
- <div class="container">
2
+ <div class="<%= container_classes %>">
3
3
  <div class="navbar-header">
4
4
  <button type="button" class="navbar-toggle btn collapsed" data-toggle="collapse" data-target="#user-util-collapse">
5
5
  <span class="sr-only">Toggle navigation</span>
@@ -17,7 +17,7 @@
17
17
  </div>
18
18
 
19
19
  <div id="search-navbar" class="navbar navbar-default navbar-static-top" role="navigation">
20
- <div class="container">
20
+ <div class="<%= container_classes %>">
21
21
  <%= render_search_bar %>
22
22
  </div>
23
23
  </div>
data/blacklight.gemspec CHANGED
@@ -1,5 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
- require File.join(File.dirname(__FILE__), "lib/blacklight/version")
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'blacklight/version'
3
5
 
4
6
  Gem::Specification.new do |s|
5
7
  s.name = "blacklight"
@@ -12,11 +14,14 @@ Gem::Specification.new do |s|
12
14
  s.description = %{Blacklight is an open source Solr user interface discovery platform. You can use Blacklight to enable searching and browsing of your collections. Blacklight uses the Apache Solr search engine to search full text and/or metadata.}
13
15
  s.license = "Apache 2.0"
14
16
 
15
- s.files = `git ls-files`.split("\n")
16
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.files = `git ls-files -z`.split("\x0")
18
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
19
+ s.bindir = 'exe'
20
+ s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
21
  s.require_paths = ["lib"]
19
22
 
23
+ s.required_ruby_version = '~> 2.0'
24
+
20
25
  s.add_dependency "rails", ">= 4.1", "< 5"
21
26
  s.add_dependency "globalid"
22
27
  s.add_dependency "nokogiri", "~>1.6" # XML Parser
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class CreateSearches < ActiveRecord::Migration
3
2
  def self.up
4
3
  create_table :searches do |t|
@@ -6,7 +5,7 @@ class CreateSearches < ActiveRecord::Migration
6
5
  t.integer :user_id
7
6
  t.string :user_type
8
7
 
9
- t.timestamps
8
+ t.timestamps null: false
10
9
  end
11
10
 
12
11
  add_index :searches, :user_id
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class CreateBookmarks < ActiveRecord::Migration
3
2
  def self.up
4
3
  create_table :bookmarks do |t|
@@ -6,7 +5,7 @@ class CreateBookmarks < ActiveRecord::Migration
6
5
  t.string :user_type
7
6
  t.string :document_id
8
7
  t.string :title
9
- t.timestamps
8
+ t.timestamps null: false
10
9
  end
11
10
  end
12
11
 
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class AddPolymorphicTypeToBookmarks < ActiveRecord::Migration
3
2
  def change
4
3
  add_column(:bookmarks, :document_type, :string)
data/lib/blacklight.rb CHANGED
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'kaminari'
3
2
  require 'deprecation'
4
3
  require 'blacklight/utils'
@@ -17,15 +16,6 @@ module Blacklight
17
16
 
18
17
  require 'blacklight/version'
19
18
  require 'blacklight/engine' if defined?(Rails)
20
-
21
- class << self
22
- attr_accessor :solr, :solr_config
23
- end
24
-
25
- # Secret key used to share session information with
26
- # other services (e.g. refworks callback urls)
27
- mattr_accessor :secret_key
28
- @@secret_key = nil
29
19
 
30
20
  def self.blacklight_config_file
31
21
  "#{::Rails.root}/config/blacklight.yml"
@@ -15,7 +15,6 @@ module Blacklight
15
15
  # XXX this isn't very pretty, but it works.
16
16
  require_dependency 'blacklight/configuration/fields'
17
17
  require_dependency 'blacklight/configuration/field'
18
- require_dependency 'blacklight/configuration/solr_field'
19
18
  require_dependency 'blacklight/configuration/search_field'
20
19
  require_dependency 'blacklight/configuration/facet_field'
21
20
  require_dependency 'blacklight/configuration/sort_field'
@@ -25,14 +25,6 @@ module Blacklight
25
25
  end
26
26
  end
27
27
  end
28
-
29
- initializer "blacklight.secret_key" do |app|
30
- if app.respond_to?(:secrets)
31
- Blacklight.secret_key ||= app.secrets.secret_key_base
32
- elsif app.config.respond_to?(:secret_key_base)
33
- Blacklight.secret_key ||= app.config.secret_key_base
34
- end
35
- end
36
28
 
37
29
  Blacklight::Engine.config.sms_mappings = {
38
30
  'Virgin' => 'vmobl.com',
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Blacklight
3
2
  module Exceptions
4
3
 
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Blacklight
3
2
  module Routes
4
3
  require 'blacklight/routes/exportable'
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Blacklight
3
2
  unless Blacklight.const_defined? :VERSION
4
3
  def self.version
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Blacklight
3
2
  class Assets < Rails::Generators::Base
4
3
  source_root File.expand_path('../templates', __FILE__)
@@ -7,6 +7,7 @@ module Blacklight
7
7
  argument :controller_name, type: :string , default: "catalog"
8
8
  argument :document_name, type: :string , default: "solr_document"
9
9
  argument :search_builder_name, type: :string , default: "search_builder"
10
+ argument :solr_version, type: :string , default: "latest"
10
11
 
11
12
  class_option :devise , type: :boolean, default: false, aliases: "-d", desc: "Use Devise as authentication logic."
12
13
  class_option :jettywrapper, type: :boolean, default: false, desc: "Use jettywrapper to download and control Jetty"
@@ -15,7 +16,7 @@ module Blacklight
15
16
  desc """
16
17
  This generator makes the following changes to your application:
17
18
  1. Generates blacklight:models
18
- 2. Adds rsolr to the Gemfile
19
+ 2. Generates utilities for working with solr
19
20
  3. Adds globalid to the Gemfile
20
21
  4. Creates a number of public assets, including images, stylesheets, and javascript
21
22
  5. Injects behavior into your user application_controller.rb
@@ -25,19 +26,12 @@ module Blacklight
25
26
  Thank you for Installing Blacklight.
26
27
  """
27
28
 
28
- def install_jettywrapper
29
- return unless options[:jettywrapper]
30
- gem "jettywrapper", ">= 2.0"
31
-
32
- copy_file "config/jetty.yml"
33
-
34
- append_to_file "Rakefile",
35
- "\nZIP_URL = \"https://github.com/projectblacklight/blacklight-jetty/archive/v4.10.3.zip\"\n" +
36
- "require 'jettywrapper'\n"
37
- end
38
-
39
- def add_rsolr_gem
40
- gem "rsolr", "~> 1.0.6"
29
+ def add_solr_wrapper
30
+ if solr_version == 'latest'
31
+ generate 'blacklight:solr5'
32
+ else
33
+ generate "blacklight:solr#{solr_version}"
34
+ end
41
35
  end
42
36
 
43
37
  def add_globalid_gem
@@ -0,0 +1,27 @@
1
+ require 'rails/generators'
2
+
3
+ module Blacklight
4
+ class Solr4Generator < Rails::Generators::Base
5
+ desc """
6
+ This generator makes the following changes to your application:
7
+ 1. Installs jettywrapper into your application
8
+ 2. Adds rsolr to your Gemfile
9
+ """
10
+
11
+ def install_jettywrapper
12
+ return unless options[:jettywrapper]
13
+ gem "jettywrapper", ">= 2.0"
14
+
15
+ copy_file "config/jetty.yml"
16
+
17
+ append_to_file "Rakefile",
18
+ "\nZIP_URL = \"https://github.com/projectblacklight/blacklight-jetty/archive/v4.10.4.zip\"\n" +
19
+ "require 'jettywrapper'\n"
20
+ end
21
+
22
+ def add_rsolr_gem
23
+ gem "rsolr", "~> 1.0.6"
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,21 @@
1
+ require 'rails/generators'
2
+
3
+ module Blacklight
4
+ class Solr5Generator < Rails::Generators::Base
5
+ desc <<-EOF
6
+ This generator makes the following changes to your application:
7
+ 1. Installs solr_wrapper into your application
8
+ 2. Adds rsolr to your Gemfile
9
+ EOF
10
+
11
+ def install_solrwrapper
12
+ gem 'solr_wrapper', '>= 0.3'
13
+
14
+ append_to_file "Rakefile", "\nrequire 'solr_wrapper/rake_task'\n"
15
+ end
16
+
17
+ def add_rsolr_gem
18
+ gem 'rsolr', '~> 1.0.6'
19
+ end
20
+ end
21
+ end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class AlternateController < CatalogController
3
2
  configure_blacklight do |config|
4
3
  config.index.thumbnail_method = :xyz
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class <%= controller_name.classify %>Controller < ApplicationController
3
2
 
4
3
  include Blacklight::Catalog
@@ -69,9 +68,9 @@ class <%= controller_name.classify %>Controller < ApplicationController
69
68
  config.add_facet_field 'example_pivot_field', label: 'Pivot Field', :pivot => ['format', 'language_facet']
70
69
 
71
70
  config.add_facet_field 'example_query_facet_field', label: 'Publish Date', :query => {
72
- :years_5 => { label: 'within 5 Years', fq: "pub_date:[#{Time.now.year - 5 } TO *]" },
73
- :years_10 => { label: 'within 10 Years', fq: "pub_date:[#{Time.now.year - 10 } TO *]" },
74
- :years_25 => { label: 'within 25 Years', fq: "pub_date:[#{Time.now.year - 25 } TO *]" }
71
+ :years_5 => { label: 'within 5 Years', fq: "pub_date:[#{Time.zone.now.year - 5 } TO *]" },
72
+ :years_10 => { label: 'within 10 Years', fq: "pub_date:[#{Time.zone.now.year - 10 } TO *]" },
73
+ :years_25 => { label: 'within 25 Years', fq: "pub_date:[#{Time.zone.now.year - 25 } TO *]" }
75
74
  }
76
75
 
77
76
 
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class <%= model_name.classify %>
3
2
 
4
3
  include Blacklight::Solr::Document
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  # Copy Blacklight test support material in place
3
2
 
4
3
 
@@ -22,13 +22,6 @@ namespace :blacklight do
22
22
  end
23
23
  end
24
24
 
25
- namespace :solr do
26
- task :seed do
27
- Deprecation.warn Blacklight, "blacklight:solr:seed is deprecated; use blacklight:index:seed instead"
28
- Rake::Task['blacklight:index:seed'].invoke
29
- end
30
- end
31
-
32
25
  namespace :check do
33
26
  desc "Check the Solr connection and controller configuration"
34
27
  task :solr, [:controller_name] => [:environment] do |_, args|
data/provision.sh CHANGED
@@ -1,14 +1,24 @@
1
1
  #!/usr/bin/env bash
2
+
3
+ # This script is used by the Vagrant file to provision the box
4
+
5
+ # Install server dependencies
2
6
  sudo yum install -y epel-release
3
- sudo yum install -y curl git java-1.7.0-openjdk-devel nodejs yum-utils gcc bzip2 kernel-devel dkms
7
+ sudo yum install -y curl git java-1.8.0-openjdk-devel nodejs yum-utils gcc bzip2 kernel-devel dkms
4
8
 
9
+ # Install RVM and Ruby
5
10
  su - vagrant -c 'gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3'
6
11
  su - vagrant -c 'curl -sSL https://get.rvm.io | bash -s stable'
7
12
  su - vagrant -c 'rvm 2.2.3 --install --default'
13
+
14
+ # Install bundler gem and bundle install
8
15
  su - vagrant -c 'gem install bundler'
9
16
  su - vagrant -c 'cd /home/vagrant/sync && bundle install'
17
+
18
+ # Create the test application
10
19
  su - vagrant -c 'cd /home/vagrant/sync && rake engine_cart:generate'
11
20
 
21
+ # Output some instructions on what to do next
12
22
  echo "
13
23
  Now to start Solr and Blacklight run the following from within the Blacklight directory:
14
24
 
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'spec_helper'
3
2
 
4
3
  # check the methods that do solr requests. Note that we are not testing if
@@ -43,5 +43,30 @@ describe BookmarksController do
43
43
  expect(response.code).to eq "500"
44
44
  end
45
45
  end
46
-
46
+
47
+ describe 'token based users' do
48
+ let(:user) { User.find_or_create_by(email: 'user1@example.com') { |u| u.password = 'password' } }
49
+ let(:current_time) { nil }
50
+ let(:token) { controller.send(:encrypt_user_id, user.id, current_time) }
51
+
52
+ before do
53
+ allow(controller).to receive(:fetch).and_return([])
54
+ end
55
+
56
+ it 'finds the user from the encrypted token' do
57
+ get :index, encrypted_user_id: token
58
+ expect(controller.send(:token_user).id).to eq user.id
59
+ end
60
+
61
+ context 'created over an hour ago' do
62
+ let(:current_time) { Time.zone.now - 2.hours }
63
+
64
+ it 'is expired' do
65
+ get :index, encrypted_user_id: token
66
+ expect do
67
+ controller.send(:token_user)
68
+ end.to raise_error(Blacklight::Exceptions::ExpiredSessionToken)
69
+ end
70
+ end
71
+ end
47
72
  end
@@ -119,6 +119,7 @@ describe CatalogController do
119
119
  end
120
120
 
121
121
  describe "with format :json" do
122
+ render_views
122
123
  before do
123
124
  get :index, :format => 'json'
124
125
  expect(response).to be_success
@@ -128,18 +129,18 @@ describe CatalogController do
128
129
  let(:docs) { json["docs"] }
129
130
  let(:facets) { json["facets"] }
130
131
 
131
- it "should get the pages" do
132
- expect(pages["total_count"]).to eq 30
132
+ it "gets the pages" do
133
+ expect(pages["total_count"]).to eq 30
133
134
  expect(pages["current_page"]).to eq 1
134
135
  expect(pages["total_pages"]).to eq 3
135
136
  end
136
137
 
137
- it "should get the documents" do
138
+ it "gets the documents" do
138
139
  expect(docs).to have(10).documents
139
140
  expect(docs.first.keys).to match_array(["published_display", "author_display", "lc_callnum_display", "pub_date", "subtitle_display", "format", "material_type_display", "title_display", "id", "subject_topic_facet", "language_facet", "score"])
140
141
  end
141
142
 
142
- it "should get the facets" do
143
+ it "gets the facets" do
143
144
  expect(facets).to have(9).facets
144
145
  expect(facets.first).to eq({"name"=>"format", "label" => "Format", "items"=>[{"value"=>"Book", "hits"=>30, "label"=>"Book"}]})
145
146
  end
@@ -147,7 +148,7 @@ describe CatalogController do
147
148
  describe "facets" do
148
149
  let(:query_facet_items) { facets.last['items'] }
149
150
  let(:regular_facet_items) { facets.first['items'] }
150
- it "should have items with labels and values" do
151
+ it "has items with labels and values" do
151
152
  expect(query_facet_items.first['label']).to eq 'within 10 Years'
152
153
  expect(query_facet_items.first['value']).to eq 'years_10'
153
154
  expect(regular_facet_items.first['label']).to eq "Book"
@@ -562,7 +563,8 @@ describe CatalogController do
562
563
  end
563
564
  end
564
565
  describe "requesting json" do
565
- it "should be successful" do
566
+ render_views
567
+ it "is successful" do
566
568
  get :facet, id: 'format', format: 'json'
567
569
  expect(response).to be_successful
568
570
  json = JSON.parse(response.body)
@@ -571,35 +573,6 @@ describe CatalogController do
571
573
  end
572
574
  end
573
575
 
574
- describe 'render_search_results_as_json' do
575
- before do
576
- controller.instance_variable_set :@document_list, [{id: '123', title_t: 'Book1'}, {id: '456', title_t: 'Book2'}]
577
- allow(controller).to receive(:pagination_info).and_return({current_page: 1, next_page: 2, prev_page: nil})
578
- allow(controller).to receive(:search_facets_as_json).and_return(
579
- [{name: "format", label: "Format", items: [{value: 'Book', hits: 30, label: 'Book'}]}])
580
- end
581
-
582
- it "should be a hash" do
583
- expect(controller.send(:render_search_results_as_json)).to eq (
584
- {response: {docs: [{id: '123', title_t: 'Book1'}, {id: '456', title_t: 'Book2'}],
585
- facets: [{name: "format", label: "Format", items: [{value: 'Book', hits: 30, label: 'Book'}]}],
586
- pages: {current_page: 1, next_page: 2, prev_page: nil}}}
587
- )
588
- end
589
- end
590
-
591
- describe 'render_facet_list_as_json' do
592
- before do
593
- controller.instance_variable_set :@pagination, {items: [{value: 'Book'}]}
594
- end
595
-
596
- it "should be a hash" do
597
- expect(controller.send(:render_facet_list_as_json)).to eq (
598
- {response: {facets: {items: [{value: 'Book'}]}}}
599
- )
600
- end
601
- end
602
-
603
576
  describe "#add_to_search_history" do
604
577
  it "should prepend the current search to the list" do
605
578
  session[:history] = []