blacklight 6.2.0 → 6.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/.solr_wrapper +5 -0
  4. data/.travis.yml +3 -5
  5. data/Gemfile +3 -3
  6. data/VERSION +1 -1
  7. data/app/assets/javascripts/blacklight/core.js +19 -5
  8. data/app/helpers/blacklight/blacklight_helper_behavior.rb +48 -20
  9. data/app/helpers/blacklight/configuration_helper_behavior.rb +1 -1
  10. data/app/helpers/blacklight/url_helper_behavior.rb +2 -1
  11. data/app/presenters/blacklight/document_presenter.rb +58 -150
  12. data/app/presenters/blacklight/field_presenter.rb +31 -0
  13. data/app/presenters/blacklight/index_presenter.rb +69 -0
  14. data/app/presenters/blacklight/link_alternate_presenter.rb +29 -0
  15. data/app/presenters/blacklight/rendering/abstract_step.rb +24 -0
  16. data/app/presenters/blacklight/rendering/helper_method.rb +23 -0
  17. data/app/presenters/blacklight/rendering/join.rb +16 -0
  18. data/app/presenters/blacklight/rendering/link_to_facet.rb +35 -0
  19. data/app/presenters/blacklight/rendering/microdata.rb +17 -0
  20. data/app/presenters/blacklight/rendering/pipeline.rb +32 -0
  21. data/app/presenters/blacklight/rendering/terminator.rb +9 -0
  22. data/app/presenters/blacklight/show_presenter.rb +93 -0
  23. data/app/services/blacklight/field_retriever.rb +58 -0
  24. data/app/views/catalog/_document_default.atom.builder +2 -3
  25. data/app/views/catalog/_document_default.rss.builder +2 -2
  26. data/app/views/kaminari/blacklight/_next_page.html.erb +9 -3
  27. data/app/views/kaminari/blacklight/_prev_page.html.erb +10 -3
  28. data/lib/blacklight/configuration.rb +15 -3
  29. data/lib/blacklight/configuration/null_field.rb +13 -0
  30. data/lib/blacklight/configuration/view_config.rb +6 -0
  31. data/lib/generators/blacklight/templates/catalog_controller.rb +1 -1
  32. data/lib/generators/blacklight/templates/config/blacklight.yml +1 -1
  33. data/lib/generators/blacklight/templates/config/jetty.yml +1 -1
  34. data/spec/controllers/alternate_controller_spec.rb +2 -2
  35. data/spec/controllers/application_controller_spec.rb +1 -1
  36. data/spec/controllers/blacklight/facet_spec.rb +3 -3
  37. data/spec/controllers/blacklight/search_fields_spec.rb +7 -7
  38. data/spec/controllers/blacklight/search_helper_spec.rb +44 -44
  39. data/spec/controllers/blacklight/suggest_search_spec.rb +1 -1
  40. data/spec/controllers/bookmarks_controller_spec.rb +6 -6
  41. data/spec/controllers/catalog_controller_spec.rb +125 -125
  42. data/spec/controllers/saved_searches_controller_spec.rb +4 -9
  43. data/spec/controllers/search_history_controller_spec.rb +3 -6
  44. data/spec/controllers/suggest_controller_spec.rb +2 -2
  45. data/spec/features/alternate_controller_spec.rb +3 -3
  46. data/spec/features/bookmarks_spec.rb +6 -6
  47. data/spec/features/did_you_mean_spec.rb +10 -10
  48. data/spec/features/facets_spec.rb +4 -4
  49. data/spec/features/record_view_spec.rb +4 -4
  50. data/spec/features/saved_searches_spec.rb +4 -4
  51. data/spec/features/search_context_spec.rb +4 -4
  52. data/spec/features/search_filters_spec.rb +10 -10
  53. data/spec/features/search_formats_spec.rb +2 -2
  54. data/spec/features/search_history_spec.rb +5 -5
  55. data/spec/features/search_pagination_spec.rb +4 -4
  56. data/spec/features/search_results_spec.rb +7 -7
  57. data/spec/features/search_sort_spec.rb +2 -2
  58. data/spec/features/search_spec.rb +6 -6
  59. data/spec/helpers/blacklight_helper_spec.rb +105 -65
  60. data/spec/helpers/catalog_helper_spec.rb +36 -36
  61. data/spec/helpers/configuration_helper_spec.rb +28 -28
  62. data/spec/helpers/facets_helper_spec.rb +39 -39
  63. data/spec/helpers/hash_as_hidden_fields_spec.rb +1 -1
  64. data/spec/helpers/render_constraints_helper_spec.rb +1 -1
  65. data/spec/helpers/search_history_constraints_helper_spec.rb +7 -7
  66. data/spec/helpers/url_helper_spec.rb +20 -17
  67. data/spec/lib/blacklight/search_state_spec.rb +2 -2
  68. data/spec/lib/blacklight/utils_spec.rb +15 -15
  69. data/spec/lib/blacklight_spec.rb +1 -1
  70. data/spec/lib/tasks/blacklight_task_spec.rb +1 -1
  71. data/spec/models/blacklight/configurable_spec.rb +3 -3
  72. data/spec/models/blacklight/configuration_spec.rb +52 -52
  73. data/spec/models/blacklight/document_spec.rb +10 -10
  74. data/spec/models/blacklight/facet_paginator_spec.rb +5 -5
  75. data/spec/models/blacklight/search_builder_spec.rb +34 -34
  76. data/spec/models/blacklight/user_spec.rb +4 -4
  77. data/spec/models/bookmark_spec.rb +5 -5
  78. data/spec/models/record_mailer_spec.rb +11 -11
  79. data/spec/models/search_spec.rb +1 -1
  80. data/spec/models/solr_document_spec.rb +4 -4
  81. data/spec/presenters/document_presenter_spec.rb +94 -50
  82. data/spec/presenters/index_presenter_spec.rb +147 -0
  83. data/spec/presenters/pipeline_spec.rb +28 -0
  84. data/spec/presenters/show_presenter_spec.rb +287 -0
  85. data/spec/routing/catalog_routing_spec.rb +11 -11
  86. data/spec/spec_helper.rb +10 -1
  87. data/spec/support/backport_test.rb +38 -0
  88. data/spec/test_app_templates/Gemfile.extra +2 -10
  89. data/spec/views/_user_util_links.html.erb_spec.rb +1 -1
  90. data/spec/views/catalog/_constraints.html.erb_spec.rb +3 -3
  91. data/spec/views/catalog/_constraints_element.html.erb_spec.rb +5 -5
  92. data/spec/views/catalog/_document.html.erb_spec.rb +2 -2
  93. data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -1
  94. data/spec/views/catalog/_facet_layout.html.erb_spec.rb +4 -4
  95. data/spec/views/catalog/_facets.html.erb_spec.rb +4 -4
  96. data/spec/views/catalog/_index_default.erb_spec.rb +5 -4
  97. data/spec/views/catalog/_index_header_default.html.erb_spec.rb +4 -3
  98. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +3 -3
  99. data/spec/views/catalog/_search_header.erb_spec.rb +1 -1
  100. data/spec/views/catalog/_show_default.erb_spec.rb +6 -5
  101. data/spec/views/catalog/_show_sidebar.erb_spec.rb +2 -1
  102. data/spec/views/catalog/_show_tools.html.erb_spec.rb +8 -8
  103. data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +2 -2
  104. data/spec/views/catalog/_thumbnail_default.erb_spec.rb +3 -2
  105. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +3 -3
  106. data/spec/views/catalog/facet.html.erb_spec.rb +3 -3
  107. data/spec/views/catalog/index.atom.builder_spec.rb +15 -14
  108. data/spec/views/catalog/index.html.erb_spec.rb +3 -3
  109. data/spec/views/catalog/opensearch.xml.builder_spec.rb +1 -1
  110. data/spec/views/catalog/show.html.erb_spec.rb +5 -4
  111. data/tasks/blacklight.rake +1 -1
  112. metadata +25 -4
  113. data/config/jetty.yml +0 -13
@@ -1,6 +1,5 @@
1
1
  xml.entry do
2
-
3
- xml.title presenter(document).render_document_index_label(document_show_link_field(document))
2
+ xml.title index_presenter(document).label(document_show_link_field(document))
4
3
 
5
4
  # updated is required, for now we'll just set it to now, sorry
6
5
  xml.updated Time.current.iso8601
@@ -8,7 +7,7 @@ xml.entry do
8
7
  xml.link "rel" => "alternate", "type" => "text/html", "href" => polymorphic_url(url_for_document(document))
9
8
  # add other doc-specific formats, atom only lets us have one per
10
9
  # content type, so the first one in the list wins.
11
- xml << render_link_rel_alternates(document, :unique => true)
10
+ xml << show_presenter(document).link_rel_alternates(unique: true)
12
11
 
13
12
  xml.id polymorphic_url(url_for_document(document))
14
13
 
@@ -1,5 +1,5 @@
1
1
  xml.item do
2
- xml.title(presenter(document).render_document_index_label(document_show_link_field(document)) || (document.to_semantic_values[:title].first if document.to_semantic_values.key?(:title)))
2
+ xml.title(index_presenter(document).label(document_show_link_field(document)) || (document.to_semantic_values[:title].first if document.to_semantic_values.key?(:title)))
3
3
  xml.link(polymorphic_url(url_for_document(document)))
4
4
  xml.author( document.to_semantic_values[:author].first ) if document.to_semantic_values.key? :author
5
- end
5
+ end
@@ -6,6 +6,12 @@
6
6
  per_page: number of items to fetch per page
7
7
  remote: data-remote
8
8
  -%>
9
- <li class="<%= 'disabled' if current_page.last? %>">
10
- <%= link_to raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote %>
11
- </li>
9
+ <% if current_page.last? %>
10
+ <li class="disabled">
11
+ <%= link_to raw(t 'views.pagination.next'), '#', :rel => 'next', :onclick=>'return false;' %>
12
+ </li>
13
+ <% else %>
14
+ <li>
15
+ <%= link_to raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote %>
16
+ </li>
17
+ <% end %>
@@ -6,6 +6,13 @@
6
6
  per_page: number of items to fetch per page
7
7
  remote: data-remote
8
8
  -%>
9
- <li class="<%= 'disabled' if current_page.first? %>">
10
- <%= link_to raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote %>
11
- </li>
9
+ <% if current_page.first? %>
10
+ <li class="disabled">
11
+ <%= link_to raw(t 'views.pagination.previous'), '#', :rel => 'prev', :onclick=>'return false;' %>
12
+ </li>
13
+ <% else %>
14
+ <li>
15
+ <%= link_to raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote %>
16
+ </li>
17
+ <% end %>
18
+
@@ -16,6 +16,7 @@ module Blacklight
16
16
  # XXX this isn't very pretty, but it works.
17
17
  require_dependency 'blacklight/configuration/fields'
18
18
  require_dependency 'blacklight/configuration/field'
19
+ require_dependency 'blacklight/configuration/null_field'
19
20
  require_dependency 'blacklight/configuration/search_field'
20
21
  require_dependency 'blacklight/configuration/facet_field'
21
22
  require_dependency 'blacklight/configuration/sort_field'
@@ -69,7 +70,7 @@ module Blacklight
69
70
  # the model to use for each response document
70
71
  document_model: nil,
71
72
  # document presenter class used by helpers and views
72
- document_presenter_class: nil,
73
+ document_presenter_class: nil, # deprecated
73
74
  # Class for paginating long lists of facet fields
74
75
  facet_paginator_class: nil,
75
76
  # repository connection configuration
@@ -80,6 +81,8 @@ module Blacklight
80
81
  navbar: OpenStructWithHashAccess.new(partials: { }),
81
82
  # General configuration for all views
82
83
  index: ViewConfig::Index.new(
84
+ # document presenter class used by helpers and views
85
+ document_presenter_class: nil,
83
86
  # solr field to use to render a document title
84
87
  title_field: nil,
85
88
  # solr field to use to render format-specific partials
@@ -95,6 +98,8 @@ module Blacklight
95
98
  ),
96
99
  # Additional configuration when displaying a single document
97
100
  show: ViewConfig::Show.new(
101
+ # document presenter class used by helpers and views
102
+ document_presenter_class: nil,
98
103
  # default route parameters for 'show' requests
99
104
  # set this to a hash with additional arguments to merge into
100
105
  # the route, or set `controller: :current` to route to the
@@ -186,13 +191,20 @@ module Blacklight
186
191
  super
187
192
  end
188
193
 
194
+ def response_model
195
+ super || Blacklight::Solr::Response
196
+ end
197
+
198
+ # @deprecated
189
199
  def document_presenter_class
190
200
  super || Blacklight::DocumentPresenter
191
201
  end
192
202
 
193
- def response_model
194
- super || Blacklight::Solr::Response
203
+ # @deprecated
204
+ def document_presenter_class=(klass)
205
+ super
195
206
  end
207
+ deprecation_deprecate :document_presenter_class= => "replaced by show.presenter_class and index.presenter_class"
196
208
 
197
209
  def response_model= *args
198
210
  super
@@ -0,0 +1,13 @@
1
+ module Blacklight
2
+ # Returned if no config is defined for the field in the Blacklight::Configuration
3
+ class Configuration::NullField < Blacklight::Configuration::Field
4
+ def initialize(field_or_hash = nil)
5
+ case field_or_hash
6
+ when String, Symbol
7
+ super(field: field_or_hash)
8
+ else
9
+ super
10
+ end
11
+ end
12
+ end
13
+ end
@@ -2,9 +2,15 @@
2
2
  class Blacklight::Configuration
3
3
  class ViewConfig < Blacklight::OpenStructWithHashAccess
4
4
  class Show < ViewConfig
5
+ def document_presenter_class
6
+ super || Blacklight::ShowPresenter
7
+ end
5
8
  end
6
9
 
7
10
  class Index < ViewConfig
11
+ def document_presenter_class
12
+ super || Blacklight::IndexPresenter
13
+ end
8
14
  end
9
15
  end
10
16
  end
@@ -31,7 +31,7 @@ class <%= controller_name.classify %>Controller < ApplicationController
31
31
  # qt: 'document',
32
32
  # ## These are hard-coded in the blacklight 'document' requestHandler
33
33
  # # fl: '*',
34
- # # rows: 1
34
+ # # rows: 1,
35
35
  # # q: '{!term f=id v=$id}'
36
36
  #}
37
37
 
@@ -15,7 +15,7 @@ development:
15
15
  url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:8983/solr/blacklight-core" %>
16
16
  test: &test
17
17
  adapter: solr
18
- url: <%= "http://127.0.0.1:#{ENV['TEST_JETTY_PORT'] || 8888}/solr/blacklight-core" %>
18
+ url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:#{ENV['TEST_JETTY_PORT'] || 8983}/solr/blacklight-core" %>
19
19
  production:
20
20
  adapter: solr
21
21
  url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:8983/solr/blacklight-core" %>
@@ -4,7 +4,7 @@ development:
4
4
  java_version: ">= 1.7"
5
5
  test:
6
6
  startup_wait: 60
7
- jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8888 %>
7
+ jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8983 %>
8
8
  <%= ENV['TEST_JETTY_PATH'] ? "jetty_home: " + ENV['TEST_JETTY_PATH'] : '' %>
9
9
  java_version: ">= 1.7"
10
10
  production:
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
 
4
4
  describe AlternateController do
5
5
  describe "the search results tools" do
6
- it "should inherit tools from CatalogController" do
6
+ it "inherits tools from CatalogController" do
7
7
  expect(AlternateController.blacklight_config.index.document_actions).to have_key(:bookmark)
8
8
  end
9
9
 
@@ -11,7 +11,7 @@ describe AlternateController do
11
11
  before do
12
12
  AlternateController.blacklight_config.index.document_actions.delete(:bookmark)
13
13
  end
14
- it "should not affect the CatalogController" do
14
+ it "does not affect the CatalogController" do
15
15
  expect(AlternateController.blacklight_config.index.document_actions).to be_empty
16
16
  expect(CatalogController.blacklight_config.index.document_actions).to have_key(:bookmark)
17
17
  end
@@ -5,7 +5,7 @@ describe ApplicationController do
5
5
 
6
6
  describe "#blacklight_config" do
7
7
 
8
- it "should provide a default blacklight_config everywhere" do
8
+ it "provides a default blacklight_config everywhere" do
9
9
  expect(controller.blacklight_config).to eq CatalogController.blacklight_config
10
10
  end
11
11
  end
@@ -16,17 +16,17 @@ describe Blacklight::Facet do
16
16
  let(:blacklight_config) { Blacklight::Configuration.new }
17
17
 
18
18
  describe "#facet_configuration_for_field" do
19
- it "should look up fields by key" do
19
+ it "looks up fields by key" do
20
20
  blacklight_config.add_facet_field 'a'
21
21
  expect(subject.facet_configuration_for_field('a')).to eq blacklight_config.facet_fields['a']
22
22
  end
23
23
 
24
- it "should look up fields by field name" do
24
+ it "looks up fields by field name" do
25
25
  blacklight_config.add_facet_field 'a', field: 'b'
26
26
  expect(subject.facet_configuration_for_field('b')).to eq blacklight_config.facet_fields['a']
27
27
  end
28
28
 
29
- it "should support both strings and symbols" do
29
+ it "supports both strings and symbols" do
30
30
  blacklight_config.add_facet_field 'a', field: :b
31
31
  expect(subject.facet_configuration_for_field('b')).to eq blacklight_config.facet_fields['a']
32
32
  end
@@ -24,25 +24,25 @@ describe Blacklight::SearchFields do
24
24
  allow(@search_field_obj).to receive(:blacklight_config).and_return(@config)
25
25
  end
26
26
 
27
- it "should return search field list with calculated :label when needed" do
27
+ it "returns search field list with calculated :label when needed" do
28
28
  @search_field_obj.search_field_list.each do |hash|
29
29
  expect(hash.label).not_to be_blank
30
30
  end
31
31
  end
32
32
 
33
- it "should fill in default qt where needed" do
33
+ it "fills in default qt where needed" do
34
34
  expect(@search_field_obj.search_field_def_for_key("all_fields").qt).to eq @config.default_solr_params[:qt]
35
35
  end
36
36
 
37
- it "should lookup field definitions by key" do
37
+ it "lookups field definitions by key" do
38
38
  expect(@search_field_obj.search_field_def_for_key("title").key).to eq "title"
39
39
  end
40
40
 
41
- it "should find label by key" do
41
+ it "finds label by key" do
42
42
  expect(@search_field_obj.label_for_search_field("title")).to eq "Title"
43
43
  end
44
44
 
45
- it "should supply default label for key not found" do
45
+ it "supplies default label for key not found" do
46
46
  expect(@search_field_obj.label_for_search_field("non_existent_key")).to eq "Keyword"
47
47
  end
48
48
 
@@ -50,7 +50,7 @@ describe Blacklight::SearchFields do
50
50
  before do
51
51
  @bad_config = MockConfig.new
52
52
  end
53
- it "should raise exception on #search_field_list" do
53
+ it "raises exception on #search_field_list" do
54
54
  expect { allow(@bad_config).to receive(:blacklight_config).and_return(Blacklight::Configuration.new { |config|
55
55
  config.add_search_field :label => 'All Fields', :qt => 'all_fields'
56
56
  config.add_search_field 'title', :qt => 'title_search'
@@ -62,7 +62,7 @@ describe Blacklight::SearchFields do
62
62
  before do
63
63
  @bad_config = MockConfig.new
64
64
  end
65
- it "should raise on #search_field_list" do
65
+ it "raises on #search_field_list" do
66
66
  expect { allow(@bad_config).to receive(:blacklight_config).and_return(Blacklight::Configuration.new { |config|
67
67
  config.add_search_field 'my_key', :label => 'All Fields'
68
68
  config.add_search_field 'my_key', :label => 'title'
@@ -59,7 +59,7 @@ describe Blacklight::SearchHelper do
59
59
  (@solr_response, @document_list) = subject.search_results(q: @all_docs_query)
60
60
  end
61
61
 
62
- it "should use the configured request handler " do
62
+ it "uses the configured request handler" do
63
63
  allow(blacklight_config).to receive(:default_solr_params).and_return({:qt => 'custom_request_handler'})
64
64
  allow(blacklight_solr).to receive(:send_and_receive) do |path, params|
65
65
  expect(path).to eq 'select'
@@ -70,11 +70,11 @@ describe Blacklight::SearchHelper do
70
70
  subject.search_results(q: @all_docs_query)
71
71
  end
72
72
 
73
- it 'should have a @response.docs list of the same size as @document_list' do
73
+ it 'has a @response.docs list of the same size as @document_list' do
74
74
  expect(@solr_response.docs).to have(@document_list.length).docs
75
75
  end
76
76
 
77
- it 'should have @response.docs list representing same documents as SolrDocuments in @document_list' do
77
+ it 'has @response.docs list representing same documents as SolrDocuments in @document_list' do
78
78
  @solr_response.docs.each_index do |index|
79
79
  mash = @solr_response.docs[index]
80
80
  solr_document = @document_list[index]
@@ -96,11 +96,11 @@ describe Blacklight::SearchHelper do
96
96
  (@solr_response, @document_list) = subject.search_results(q: @all_docs_query)
97
97
  end
98
98
 
99
- it "should have an empty document list" do
99
+ it "has an empty document list" do
100
100
  expect(@document_list).to be_empty
101
101
  end
102
102
 
103
- it "should return a grouped response" do
103
+ it "returns a grouped response" do
104
104
  expect(@solr_response).to be_a_kind_of Blacklight::Solr::Response::GroupResponse
105
105
 
106
106
  end
@@ -116,11 +116,11 @@ describe Blacklight::SearchHelper do
116
116
  (@solr_response, @document_list) = subject.search_results(q: @all_docs_query)
117
117
  end
118
118
 
119
- it "should have an empty document list" do
119
+ it "has an empty document list" do
120
120
  expect(@document_list).to be_empty
121
121
  end
122
122
 
123
- it "should return a grouped response" do
123
+ it "returns a grouped response" do
124
124
  expect(@solr_response).to be_a_kind_of Blacklight::Solr::Response::GroupResponse
125
125
  expect(@solr_response.group_field).to eq "title_sort"
126
126
  end
@@ -128,7 +128,7 @@ describe Blacklight::SearchHelper do
128
128
 
129
129
 
130
130
  describe "for All Docs Query and One Facet" do
131
- it 'should have results' do
131
+ it 'has results' do
132
132
  (solr_response, document_list) = subject.search_results(q: @all_docs_query, f: @single_facet)
133
133
  expect(solr_response.docs).to have(document_list.size).results
134
134
  expect(solr_response.docs).to have_at_least(1).result
@@ -138,7 +138,7 @@ describe Blacklight::SearchHelper do
138
138
  end
139
139
 
140
140
  describe "for Query Without Results and No Facet" do
141
- it 'should have no results and not raise error' do
141
+ it 'has no results and not raise error' do
142
142
  (solr_response, document_list) = subject.search_results(q: @no_docs_query)
143
143
  expect(document_list).to have(0).results
144
144
  expect(solr_response.docs).to have(0).results
@@ -146,7 +146,7 @@ describe Blacklight::SearchHelper do
146
146
  end
147
147
 
148
148
  describe "for Query Without Results and One Facet" do
149
- it 'should have no results and not raise error' do
149
+ it 'has no results and not raise error' do
150
150
  (solr_response, document_list) = subject.search_results(q: @no_docs_query, f: @single_facet)
151
151
  expect(document_list).to have(0).results
152
152
  expect(solr_response.docs).to have(0).results
@@ -154,7 +154,7 @@ describe Blacklight::SearchHelper do
154
154
  end
155
155
 
156
156
  describe "for All Docs Query and Bad Facet" do
157
- it 'should have no results and not raise error' do
157
+ it 'has no results and not raise error' do
158
158
  (solr_response, document_list) = subject.search_results(q: @all_docs_query, f: @bad_facet)
159
159
  expect(document_list).to have(0).results
160
160
  expect(solr_response.docs).to have(0).results
@@ -173,20 +173,20 @@ describe Blacklight::SearchHelper do
173
173
  @facets = solr_response.aggregations
174
174
  end
175
175
 
176
- it 'should have more than one facet' do
176
+ it 'has more than one facet' do
177
177
  expect(@facets).to have_at_least(1).facet
178
178
  end
179
- it 'should have all facets specified in initializer' do
179
+ it 'has all facets specified in initializer' do
180
180
  expect(@facets.keys).to include *blacklight_config.facet_fields.keys
181
181
  expect(@facets.none? { |k, v| v.nil? }).to eq true
182
182
  end
183
183
 
184
- it 'should have at least one value for each facet' do
184
+ it 'has at least one value for each facet' do
185
185
  @facets.each do |key, facet|
186
186
  expect(facet.items).to have_at_least(1).hit
187
187
  end
188
188
  end
189
- it 'should have multiple values for at least one facet' do
189
+ it 'has multiple values for at least one facet' do
190
190
  has_mult_values = false
191
191
  @facets.each do |key, facet|
192
192
  if facet.items.size > 1
@@ -196,7 +196,7 @@ describe Blacklight::SearchHelper do
196
196
  end
197
197
  expect(has_mult_values).to eq true
198
198
  end
199
- it 'should have all value counts > 0' do
199
+ it 'has all value counts > 0' do
200
200
  @facets.each do |key, facet|
201
201
  facet.items.each do |facet_vals|
202
202
  expect(facet_vals.hits).to be > 0
@@ -210,56 +210,56 @@ describe Blacklight::SearchHelper do
210
210
  describe 'Paging', :integration => true do
211
211
  let(:blacklight_config) { copy_of_catalog_config }
212
212
 
213
- it 'should start with first results by default' do
213
+ it 'starts with first results by default' do
214
214
  (solr_response, document_list) = subject.search_results(q: @all_docs_query)
215
215
  expect(solr_response.params[:start].to_i).to eq 0
216
216
  end
217
- it 'should have number of results (per page) set in initializer, by default' do
217
+ it 'has number of results (per page) set in initializer, by default' do
218
218
  (solr_response, document_list) = subject.search_results(q: @all_docs_query)
219
219
  expect(solr_response.docs).to have(blacklight_config[:default_solr_params][:rows]).items
220
220
  expect(document_list).to have(blacklight_config[:default_solr_params][:rows]).items
221
221
  end
222
222
 
223
- it 'should get number of results per page requested' do
223
+ it 'gets number of results per page requested' do
224
224
  num_results = 3 # non-default value
225
225
  (solr_response1, document_list1) = subject.search_results(q: @all_docs_query, per_page: num_results)
226
226
  expect(document_list1).to have(num_results).docs
227
227
  expect(solr_response1.docs).to have(num_results).docs
228
228
  end
229
229
 
230
- it 'should get number of rows requested' do
230
+ it 'gets number of rows requested' do
231
231
  num_results = 4 # non-default value
232
232
  (solr_response1, document_list1) = subject.search_results(q: @all_docs_query, rows: num_results)
233
233
  expect(document_list1).to have(num_results).docs
234
234
  expect(solr_response1.docs).to have(num_results).docs
235
235
  end
236
236
 
237
- it 'should skip appropriate number of results when requested - default per page' do
237
+ it 'skips appropriate number of results when requested - default per page' do
238
238
  page = 3
239
239
  (solr_response2, document_list2) = subject.search_results(q: @all_docs_query, page: page)
240
240
  expect(solr_response2.params[:start].to_i).to eq blacklight_config[:default_solr_params][:rows] * (page-1)
241
241
  end
242
- it 'should skip appropriate number of results when requested - non-default per page' do
242
+ it 'skips appropriate number of results when requested - non-default per page' do
243
243
  page = 3
244
244
  num_results = 3
245
245
  (solr_response2a, document_list2a) = subject.search_results(q: @all_docs_query, per_page: num_results, page: page)
246
246
  expect(solr_response2a.params[:start].to_i).to eq num_results * (page-1)
247
247
  end
248
248
 
249
- it 'should have no results when prompted for page after last result' do
249
+ it 'has no results when prompted for page after last result' do
250
250
  big = 5000
251
251
  (solr_response3, document_list3) = subject.search_results(q: @all_docs_query, rows: big, page: big)
252
252
  expect(document_list3).to have(0).docs
253
253
  expect(solr_response3.docs).to have(0).docs
254
254
  end
255
255
 
256
- it 'should show first results when prompted for page before first result' do
256
+ it 'shows first results when prompted for page before first result' do
257
257
  # FIXME: should it show first results, or should it throw an error for view to deal w?
258
258
  # Solr throws an error for a negative start value
259
259
  (solr_response4, document_list4) = subject.search_results(q: @all_docs_query, page: '-1')
260
260
  expect(solr_response4.params[:start].to_i).to eq 0
261
261
  end
262
- it 'should have results available when asked for more than are in response' do
262
+ it 'has results available when asked for more than are in response' do
263
263
  big = 5000
264
264
  (solr_response5, document_list5) = subject.search_results(q: @all_docs_query, rows: big, page: 1)
265
265
  expect(solr_response5.docs).to have(document_list5.length).docs
@@ -276,34 +276,34 @@ describe Blacklight::SearchHelper do
276
276
  @response2, @document = subject.fetch(@doc_id)
277
277
  end
278
278
 
279
- it "should raise Blacklight::RecordNotFound for an unknown id" do
279
+ it "raises Blacklight::RecordNotFound for an unknown id" do
280
280
  expect {
281
281
  subject.fetch(@bad_id)
282
282
  }.to raise_error(Blacklight::Exceptions::RecordNotFound)
283
283
  end
284
284
 
285
- it "should use a provided document request handler " do
285
+ it "uses a provided document request handler" do
286
286
  allow(blacklight_config).to receive_messages(:document_solr_request_handler => 'document')
287
287
  allow(blacklight_solr).to receive(:send_and_receive).with('select', kind_of(Hash)).and_return({'response'=>{'docs'=>[]}})
288
288
  expect { subject.fetch(@doc_id)}.to raise_error Blacklight::Exceptions::RecordNotFound
289
289
  end
290
290
 
291
- it "should use a provided document solr path " do
291
+ it "uses a provided document solr path" do
292
292
  allow(blacklight_config).to receive_messages(:document_solr_path => 'get')
293
293
  allow(blacklight_solr).to receive(:send_and_receive).with('get', kind_of(Hash)).and_return({'response'=>{'docs'=>[]}})
294
294
  expect { subject.fetch(@doc_id)}.to raise_error Blacklight::Exceptions::RecordNotFound
295
295
  end
296
296
 
297
- it "should have a non-nil result for a known id" do
297
+ it "has a non-nil result for a known id" do
298
298
  expect(@document).not_to be_nil
299
299
  end
300
- it "should have a single document in the response for a known id" do
300
+ it "has a single document in the response for a known id" do
301
301
  expect(@response2.docs.size).to eq 1
302
302
  end
303
- it 'should have the expected value in the id field' do
303
+ it 'has the expected value in the id field' do
304
304
  expect(@document.id).to eq @doc_id
305
305
  end
306
- it 'should have non-nil values for required fields set in initializer' do
306
+ it 'has non-nil values for required fields set in initializer' do
307
307
  expect(@document.fetch(blacklight_config.view_config(:show).display_type_field)).not_to be_nil
308
308
  end
309
309
  end
@@ -354,7 +354,7 @@ describe Blacklight::SearchHelper do
354
354
  describe "facet_limit_for" do
355
355
  let(:blacklight_config) { copy_of_catalog_config }
356
356
 
357
- it "should return specified value for facet_field specified" do
357
+ it "returns specified value for facet_field specified" do
358
358
  expect(subject.facet_limit_for("subject_topic_facet")).to eq blacklight_config.facet_fields["subject_topic_facet"].limit
359
359
  end
360
360
 
@@ -364,7 +364,7 @@ describe Blacklight::SearchHelper do
364
364
  expect(subject.facet_limit_hash).to eq blacklight_config[:facet][:limits]
365
365
  end
366
366
 
367
- it "should handle no facet_limits in config" do
367
+ it "handles no facet_limits in config" do
368
368
  blacklight_config.facet_fields = {}
369
369
  expect(subject.facet_limit_for("subject_topic_facet")).to be_nil
370
370
  end
@@ -375,23 +375,23 @@ describe Blacklight::SearchHelper do
375
375
  config.add_facet_field "language_facet", limit: true
376
376
  config
377
377
  end
378
- it "should return nil if no @response available" do
378
+ it "returns nil if no @response available" do
379
379
  expect(subject.facet_limit_for("some_unknown_field")).to be_nil
380
380
  end
381
- it "should get from @response facet.limit if available" do
381
+ it "gets from @response facet.limit if available" do
382
382
  @response = double()
383
383
  allow(@response).to receive(:aggregations).and_return("language_facet" => double(limit: nil))
384
384
  subject.instance_variable_set(:@response, @response)
385
385
  blacklight_config.facet_fields['language_facet'].limit = 10
386
386
  expect(subject.facet_limit_for("language_facet")).to eq 10
387
387
  end
388
- it "should get the limit from the facet field in @response" do
388
+ it "gets the limit from the facet field in @response" do
389
389
  @response = double()
390
390
  allow(@response).to receive(:aggregations).and_return("language_facet" => double(limit: 16))
391
391
  subject.instance_variable_set(:@response, @response)
392
392
  expect(subject.facet_limit_for("language_facet")).to eq 15
393
393
  end
394
- it "should default to 10" do
394
+ it "defaults to 10" do
395
395
  expect(subject.facet_limit_for("language_facet")).to eq 10
396
396
  end
397
397
  end
@@ -404,13 +404,13 @@ describe Blacklight::SearchHelper do
404
404
  # TODO: maybe eventually check other types of solr requests
405
405
  # more like this
406
406
  # nearby on shelf
407
- it "should raise a Blacklight exception if RSolr can't connect to the Solr instance" do
407
+ it "raises a Blacklight exception if RSolr can't connect to the Solr instance" do
408
408
  allow(blacklight_solr).to receive(:send_and_receive).and_raise(Errno::ECONNREFUSED)
409
409
  expect { subject.repository.search }.to raise_exception(/Unable to connect to Solr instance/)
410
410
  end
411
411
 
412
412
  describe "grouped_key_for_results" do
413
- it "should pull the grouped key out of the config" do
413
+ it "pulls the grouped key out of the config" do
414
414
  blacklight_config.index.group = 'xyz'
415
415
  expect(subject.grouped_key_for_results).to eq('xyz')
416
416
  end
@@ -422,27 +422,27 @@ describe Blacklight::SearchHelper do
422
422
  @full_response, @all_docs = pre_query.search_results(q: '', per_page: '100')
423
423
  end
424
424
 
425
- it "should return the previous and next documents for a search" do
425
+ it "returns the previous and next documents for a search" do
426
426
  response, docs = subject.get_previous_and_next_documents_for_search(4, :q => '')
427
427
 
428
428
  expect(docs.first.id).to eq @all_docs[3].id
429
429
  expect(docs.last.id).to eq @all_docs[5].id
430
430
  end
431
431
 
432
- it "should return only the next document if the counter is 0" do
432
+ it "returns only the next document if the counter is 0" do
433
433
  response, docs = subject.get_previous_and_next_documents_for_search(0, :q => '')
434
434
 
435
435
  expect(docs.first).to be_nil
436
436
  expect(docs.last.id).to eq @all_docs[1].id
437
437
  end
438
438
 
439
- it "should return only the previous document if the counter is the total number of documents" do
439
+ it "returns only the previous document if the counter is the total number of documents" do
440
440
  response, docs = subject.get_previous_and_next_documents_for_search(@full_response.total - 1, :q => '')
441
441
  expect(docs.first.id).to eq @all_docs.slice(-2).id
442
442
  expect(docs.last).to be_nil
443
443
  end
444
444
 
445
- it "should return an array of nil values if there is only one result" do
445
+ it "returns an array of nil values if there is only one result" do
446
446
  response, docs = subject.get_previous_and_next_documents_for_search(0, :q => 'id:2007020969')
447
447
  expect(docs.last).to be_nil
448
448
  expect(docs.first).to be_nil