blacklight 6.0.0.pre5 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (242) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +8 -8
  3. data/Gemfile +11 -2
  4. data/VERSION +1 -1
  5. data/app/assets/stylesheets/blacklight/_facets.scss +1 -10
  6. data/app/controllers/bookmarks_controller.rb +1 -0
  7. data/app/controllers/catalog_controller.rb +1 -0
  8. data/app/controllers/concerns/blacklight/base.rb +1 -0
  9. data/app/controllers/concerns/blacklight/bookmarks.rb +13 -1
  10. data/app/controllers/concerns/blacklight/catalog.rb +7 -1
  11. data/app/controllers/concerns/blacklight/controller.rb +7 -6
  12. data/app/controllers/concerns/blacklight/default_component_configuration.rb +1 -0
  13. data/app/controllers/concerns/blacklight/facet.rb +1 -0
  14. data/app/controllers/concerns/blacklight/request_builders.rb +1 -0
  15. data/app/controllers/concerns/blacklight/search_context.rb +8 -12
  16. data/app/controllers/concerns/blacklight/search_fields.rb +1 -0
  17. data/app/controllers/concerns/blacklight/search_helper.rb +2 -1
  18. data/app/controllers/concerns/blacklight/search_history.rb +32 -0
  19. data/app/controllers/concerns/blacklight/suggest.rb +1 -0
  20. data/app/controllers/concerns/blacklight/suggest_search.rb +1 -0
  21. data/app/controllers/concerns/blacklight/token_based_user.rb +1 -0
  22. data/app/controllers/saved_searches_controller.rb +20 -9
  23. data/app/controllers/search_history_controller.rb +2 -18
  24. data/app/controllers/suggest_controller.rb +1 -0
  25. data/app/helpers/blacklight/blacklight_helper_behavior.rb +1 -0
  26. data/app/helpers/blacklight/catalog_helper_behavior.rb +15 -1
  27. data/app/helpers/blacklight/component_helper_behavior.rb +1 -0
  28. data/app/helpers/blacklight/configuration_helper_behavior.rb +1 -0
  29. data/app/helpers/blacklight/deprecated_url_helper_behavior.rb +1 -0
  30. data/app/helpers/blacklight/facets_helper_behavior.rb +1 -0
  31. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +1 -0
  32. data/app/helpers/blacklight/layout_helper_behavior.rb +1 -0
  33. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +9 -6
  34. data/app/helpers/blacklight/render_partials_helper.rb +15 -4
  35. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -0
  36. data/app/helpers/blacklight/suggest_helper_behavior.rb +1 -0
  37. data/app/helpers/blacklight/url_helper_behavior.rb +6 -6
  38. data/app/helpers/blacklight_configuration_helper.rb +1 -0
  39. data/app/helpers/blacklight_helper.rb +1 -0
  40. data/app/helpers/blacklight_url_helper.rb +1 -0
  41. data/app/helpers/catalog_helper.rb +1 -0
  42. data/app/helpers/component_helper.rb +1 -0
  43. data/app/helpers/facets_helper.rb +1 -0
  44. data/app/helpers/hash_as_hidden_fields_helper.rb +1 -0
  45. data/app/helpers/layout_helper.rb +1 -0
  46. data/app/helpers/render_constraints_helper.rb +1 -0
  47. data/app/helpers/search_history_constraints_helper.rb +1 -0
  48. data/app/helpers/suggest_helper.rb +1 -0
  49. data/app/models/blacklight/facet_paginator.rb +6 -2
  50. data/app/models/blacklight/solr/facet_paginator.rb +1 -0
  51. data/app/models/bookmark.rb +1 -0
  52. data/app/models/concerns/blacklight/configurable.rb +1 -0
  53. data/app/models/concerns/blacklight/document.rb +1 -0
  54. data/app/models/concerns/blacklight/document/active_model_shim.rb +1 -0
  55. data/app/models/concerns/blacklight/document/cache_key.rb +1 -0
  56. data/app/models/concerns/blacklight/document/dublin_core.rb +1 -0
  57. data/app/models/concerns/blacklight/document/email.rb +1 -0
  58. data/app/models/concerns/blacklight/document/export.rb +1 -0
  59. data/app/models/concerns/blacklight/document/extensions.rb +1 -0
  60. data/app/models/concerns/blacklight/document/schema_org.rb +1 -0
  61. data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -0
  62. data/app/models/concerns/blacklight/document/sms.rb +1 -0
  63. data/app/models/concerns/blacklight/solr/document.rb +1 -0
  64. data/app/models/concerns/blacklight/solr/document/more_like_this.rb +1 -0
  65. data/app/models/concerns/blacklight/suggest/response.rb +1 -0
  66. data/app/models/concerns/blacklight/user.rb +1 -0
  67. data/app/models/record_mailer.rb +1 -0
  68. data/app/models/search.rb +4 -1
  69. data/app/models/solr_document.rb +1 -0
  70. data/app/presenters/blacklight/document_presenter.rb +17 -1
  71. data/app/presenters/blacklight/json_presenter.rb +1 -0
  72. data/app/views/bookmarks/_tools.html.erb +1 -1
  73. data/app/views/catalog/_facet_index_navigation.html.erb +2 -2
  74. data/app/views/catalog/_facet_pagination.html.erb +4 -4
  75. data/app/views/catalog/_search_results.html.erb +3 -5
  76. data/app/views/catalog/_view_type_group.html.erb +1 -1
  77. data/app/views/catalog/index.atom.builder +7 -7
  78. data/app/views/catalog/index.json.jbuilder +0 -1
  79. data/app/views/catalog/index.rss.builder +1 -4
  80. data/config/locales/blacklight.de.yml +0 -2
  81. data/config/locales/blacklight.es.yml +0 -2
  82. data/config/locales/blacklight.it.yml +0 -2
  83. data/config/locales/blacklight.pt-BR.yml +0 -6
  84. data/config/routes.rb +1 -0
  85. data/db/migrate/20140202020201_create_searches.rb +1 -0
  86. data/db/migrate/20140202020202_create_bookmarks.rb +1 -0
  87. data/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +1 -0
  88. data/lib/blacklight.rb +3 -1
  89. data/lib/blacklight/abstract_repository.rb +1 -0
  90. data/lib/blacklight/configuration.rb +1 -0
  91. data/lib/blacklight/configuration/context.rb +1 -0
  92. data/lib/blacklight/configuration/facet_field.rb +1 -0
  93. data/lib/blacklight/configuration/field.rb +1 -0
  94. data/lib/blacklight/configuration/fields.rb +1 -0
  95. data/lib/blacklight/configuration/search_field.rb +1 -0
  96. data/lib/blacklight/configuration/sort_field.rb +1 -0
  97. data/lib/blacklight/configuration/tool_config.rb +1 -0
  98. data/lib/blacklight/configuration/view_config.rb +1 -0
  99. data/lib/blacklight/engine.rb +1 -0
  100. data/lib/blacklight/exceptions.rb +1 -0
  101. data/lib/blacklight/parameters.rb +4 -4
  102. data/lib/blacklight/routes.rb +1 -0
  103. data/lib/blacklight/routes/exportable.rb +1 -0
  104. data/lib/blacklight/routes/searchable.rb +1 -0
  105. data/lib/blacklight/search_builder.rb +1 -0
  106. data/lib/blacklight/search_state.rb +22 -5
  107. data/lib/blacklight/solr.rb +1 -0
  108. data/lib/blacklight/solr/repository.rb +1 -0
  109. data/lib/blacklight/solr/request.rb +1 -0
  110. data/lib/blacklight/solr/response.rb +7 -1
  111. data/lib/blacklight/solr/response/facets.rb +1 -0
  112. data/lib/blacklight/solr/response/group.rb +1 -0
  113. data/lib/blacklight/solr/response/group_response.rb +1 -0
  114. data/lib/blacklight/solr/response/more_like_this.rb +1 -0
  115. data/lib/blacklight/solr/response/pagination_methods.rb +1 -0
  116. data/lib/blacklight/solr/response/response.rb +1 -0
  117. data/lib/blacklight/solr/response/spelling.rb +1 -0
  118. data/lib/blacklight/solr/search_builder_behavior.rb +19 -14
  119. data/lib/blacklight/utils.rb +1 -0
  120. data/lib/blacklight/version.rb +1 -0
  121. data/lib/generators/blacklight/assets_generator.rb +1 -0
  122. data/lib/generators/blacklight/controller_generator.rb +1 -0
  123. data/lib/generators/blacklight/document_generator.rb +1 -0
  124. data/lib/generators/blacklight/install_generator.rb +1 -0
  125. data/lib/generators/blacklight/models_generator.rb +1 -0
  126. data/lib/generators/blacklight/search_builder_generator.rb +1 -0
  127. data/lib/generators/blacklight/solr4_generator.rb +1 -0
  128. data/lib/generators/blacklight/solr5_generator.rb +2 -2
  129. data/lib/generators/blacklight/templates/alternate_controller.rb +1 -0
  130. data/lib/generators/blacklight/templates/catalog_controller.rb +1 -0
  131. data/lib/generators/blacklight/templates/search_builder.rb +1 -0
  132. data/lib/generators/blacklight/templates/solr_document.rb +1 -0
  133. data/lib/generators/blacklight/test_support_generator.rb +1 -0
  134. data/lib/generators/blacklight/user_generator.rb +10 -6
  135. data/lib/railties/blacklight.rake +3 -3
  136. data/spec/controllers/alternate_controller_spec.rb +1 -0
  137. data/spec/controllers/application_controller_spec.rb +1 -0
  138. data/spec/controllers/blacklight/base_spec.rb +5 -3
  139. data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +1 -0
  140. data/spec/controllers/blacklight/facet_spec.rb +1 -0
  141. data/spec/controllers/blacklight/search_fields_spec.rb +1 -0
  142. data/spec/controllers/blacklight/search_helper_spec.rb +1 -0
  143. data/spec/controllers/blacklight/suggest_search_spec.rb +1 -0
  144. data/spec/controllers/bookmarks_controller_spec.rb +1 -0
  145. data/spec/controllers/catalog_controller_spec.rb +17 -14
  146. data/spec/controllers/saved_searches_controller_spec.rb +1 -0
  147. data/spec/controllers/search_history_controller_spec.rb +1 -0
  148. data/spec/controllers/suggest_controller_spec.rb +1 -0
  149. data/spec/features/alternate_controller_spec.rb +1 -0
  150. data/spec/features/bookmarks_spec.rb +1 -0
  151. data/spec/features/did_you_mean_spec.rb +1 -0
  152. data/spec/features/facets_spec.rb +1 -0
  153. data/spec/features/record_view_spec.rb +1 -0
  154. data/spec/features/saved_searches_spec.rb +1 -0
  155. data/spec/features/search_context_spec.rb +1 -0
  156. data/spec/features/search_filters_spec.rb +2 -1
  157. data/spec/features/search_formats_spec.rb +1 -0
  158. data/spec/features/search_history_spec.rb +1 -0
  159. data/spec/features/search_pagination_spec.rb +1 -0
  160. data/spec/features/search_results_spec.rb +1 -0
  161. data/spec/features/search_sort_spec.rb +1 -0
  162. data/spec/features/search_spec.rb +1 -0
  163. data/spec/features/sitelinks_search_box.rb +1 -0
  164. data/spec/helpers/blacklight_helper_spec.rb +3 -2
  165. data/spec/helpers/catalog_helper_spec.rb +11 -16
  166. data/spec/helpers/configuration_helper_spec.rb +1 -0
  167. data/spec/helpers/deprecated_url_helper_behavior_spec.rb +18 -9
  168. data/spec/helpers/facets_helper_spec.rb +1 -0
  169. data/spec/helpers/hash_as_hidden_fields_spec.rb +1 -0
  170. data/spec/helpers/layout_helper_spec.rb +1 -0
  171. data/spec/helpers/render_constraints_helper_spec.rb +18 -8
  172. data/spec/helpers/search_history_constraints_helper_spec.rb +1 -0
  173. data/spec/helpers/suggest_helper_spec.rb +1 -0
  174. data/spec/helpers/url_helper_spec.rb +72 -68
  175. data/spec/lib/blacklight/parameters_spec.rb +3 -2
  176. data/spec/lib/blacklight/search_state_spec.rb +44 -32
  177. data/spec/lib/blacklight/utils_spec.rb +1 -0
  178. data/spec/lib/blacklight_spec.rb +11 -3
  179. data/spec/lib/tasks/blacklight_task_spec.rb +1 -0
  180. data/spec/models/blacklight/configurable_spec.rb +1 -0
  181. data/spec/models/blacklight/configuration/context_spec.rb +1 -0
  182. data/spec/models/blacklight/configuration_spec.rb +1 -0
  183. data/spec/models/blacklight/document/active_model_shim_spec.rb +1 -0
  184. data/spec/models/blacklight/document/cache_key_spec.rb +1 -0
  185. data/spec/models/blacklight/document/dublin_core_spec.rb +1 -0
  186. data/spec/models/blacklight/document/email_spec.rb +1 -0
  187. data/spec/models/blacklight/document/sms_spec.rb +1 -0
  188. data/spec/models/blacklight/document_spec.rb +1 -0
  189. data/spec/models/blacklight/facet_paginator_spec.rb +21 -8
  190. data/spec/models/blacklight/search_builder_spec.rb +1 -0
  191. data/spec/models/blacklight/solr/document/more_like_this_spec.rb +1 -0
  192. data/spec/models/blacklight/solr/document_spec.rb +1 -0
  193. data/spec/models/blacklight/solr/facet_paginator_spec.rb +1 -0
  194. data/spec/models/blacklight/solr/repository_spec.rb +1 -0
  195. data/spec/models/blacklight/solr/request_spec.rb +1 -0
  196. data/spec/models/blacklight/solr/response/facets_spec.rb +1 -0
  197. data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -0
  198. data/spec/models/blacklight/solr/response/group_spec.rb +1 -0
  199. data/spec/models/blacklight/solr/response_spec.rb +1 -0
  200. data/spec/models/blacklight/solr/search_builder_spec.rb +21 -30
  201. data/spec/models/blacklight/suggest/response_spec.rb +1 -0
  202. data/spec/models/blacklight/user_spec.rb +1 -0
  203. data/spec/models/bookmark_spec.rb +4 -3
  204. data/spec/models/record_mailer_spec.rb +1 -0
  205. data/spec/models/search_spec.rb +22 -38
  206. data/spec/models/solr_document_spec.rb +1 -0
  207. data/spec/presenters/document_presenter_spec.rb +7 -3
  208. data/spec/routing/catalog_routing_spec.rb +1 -0
  209. data/spec/spec_helper.rb +1 -0
  210. data/spec/support/controller_level_helpers.rb +2 -1
  211. data/spec/support/features.rb +1 -0
  212. data/spec/support/features/session_helpers.rb +1 -0
  213. data/spec/test_app_templates/Gemfile.extra +14 -0
  214. data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -0
  215. data/spec/views/_user_util_links.html.erb_spec.rb +1 -0
  216. data/spec/views/catalog/_constraints.html.erb_spec.rb +1 -0
  217. data/spec/views/catalog/_constraints_element.html.erb_spec.rb +1 -0
  218. data/spec/views/catalog/_document.html.erb_spec.rb +1 -0
  219. data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -0
  220. data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +4 -1
  221. data/spec/views/catalog/_facet_layout.html.erb_spec.rb +1 -0
  222. data/spec/views/catalog/_facets.html.erb_spec.rb +1 -0
  223. data/spec/views/catalog/_index_default.erb_spec.rb +1 -0
  224. data/spec/views/catalog/_index_header_default.html.erb_spec.rb +1 -0
  225. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +1 -0
  226. data/spec/views/catalog/_search_header.erb_spec.rb +1 -0
  227. data/spec/views/catalog/_show_default.erb_spec.rb +1 -0
  228. data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -0
  229. data/spec/views/catalog/_show_tools.html.erb_spec.rb +1 -0
  230. data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +1 -0
  231. data/spec/views/catalog/_thumbnail_default.erb_spec.rb +1 -0
  232. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +1 -0
  233. data/spec/views/catalog/facet.html.erb_spec.rb +1 -0
  234. data/spec/views/catalog/facet.json.jbuilder_spec.rb +1 -0
  235. data/spec/views/catalog/index.atom.builder_spec.rb +19 -27
  236. data/spec/views/catalog/index.html.erb_spec.rb +1 -0
  237. data/spec/views/catalog/index.json.jbuilder_spec.rb +1 -0
  238. data/spec/views/catalog/opensearch.xml.builder_spec.rb +1 -0
  239. data/spec/views/catalog/show.html.erb_spec.rb +1 -0
  240. data/template.demo.rb +1 -0
  241. metadata +7 -5
  242. data/app/views/catalog/show.refworks.erb +0 -1
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  module Solr
3
4
  autoload :Repository, 'blacklight/solr/repository'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight::Solr
2
3
  class Repository < Blacklight::AbstractRepository
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class Blacklight::Solr::InvalidParameter < ArgumentError; end
2
3
 
3
4
  class Blacklight::Solr::Request < ActiveSupport::HashWithIndifferentAccess
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class Blacklight::Solr::Response < ActiveSupport::HashWithIndifferentAccess
2
3
  extend Deprecation
3
4
 
@@ -91,7 +92,12 @@ class Blacklight::Solr::Response < ActiveSupport::HashWithIndifferentAccess
91
92
  when Array
92
93
  value.each { |v| force_to_utf8(v) }
93
94
  when String
94
- value.force_encoding("utf-8") if value.respond_to?(:force_encoding)
95
+ if value.encoding != Encoding::UTF_8
96
+ Rails.logger.warn "Found a non utf-8 value in Blacklight::Solr::Response. \"#{value}\" Encoding is #{value.encoding}"
97
+ value.dup.force_encoding('UTF-8')
98
+ else
99
+ value
100
+ end
95
101
  end
96
102
  value
97
103
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'ostruct'
2
3
 
3
4
  module Blacklight::Solr::Response::Facets
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class Blacklight::Solr::Response::Group
2
3
 
3
4
  include Blacklight::Solr::Response::PaginationMethods
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class Blacklight::Solr::Response::GroupResponse
2
3
 
3
4
  include Blacklight::Solr::Response::PaginationMethods
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight::Solr::Response::MoreLikeThis
2
3
  def more_like document
3
4
  mlt = more_like_this[document.id]
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight::Solr::Response::PaginationMethods
2
3
 
3
4
  include Kaminari::PageScopeMethods
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight::Solr::Response::Response
2
3
  def response
3
4
  self[:response] || {}
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # A mixin for making access to the spellcheck component data easy.
2
3
  #
3
4
  # response.spelling.words
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight::Solr
2
3
  module SearchBuilderBehavior
3
4
  extend ActiveSupport::Concern
@@ -107,16 +108,6 @@ module Blacklight::Solr
107
108
  # taking account of our facet paging/'more'. This is not
108
109
  # about solr 'fq', this is about solr facet.* params.
109
110
  def add_facetting_to_solr(solr_parameters)
110
- # While not used by BL core behavior, legacy behavior seemed to be
111
- # to accept incoming params as "facet.field" or "facets", and add them
112
- # on to any existing facet.field sent to Solr. Legacy behavior seemed
113
- # to be accepting these incoming params as arrays (in Rails URL with []
114
- # on end), or single values. At least one of these is used by
115
- # Stanford for "faux hieararchial facets".
116
- if blacklight_params.has_key?("facet.field") || blacklight_params.has_key?("facets")
117
- solr_parameters[:"facet.field"].concat( [blacklight_params["facet.field"], blacklight_params["facets"]].flatten.compact ).uniq!
118
- end
119
-
120
111
  facet_fields_to_include_in_request.each do |field_name, facet|
121
112
  solr_parameters[:facet] ||= true
122
113
 
@@ -139,10 +130,8 @@ module Blacklight::Solr
139
130
  end
140
131
  end
141
132
 
142
- # Support facet paging and 'more'
143
- # links, by sending a facet.limit one more than what we
144
- # want to page at, according to configured facet limits.
145
- solr_parameters[:"f.#{facet.field}.facet.limit"] = (facet_limit_for(field_name) + 1) if facet_limit_for(field_name)
133
+ limit = facet_limit_with_pagination(field_name)
134
+ solr_parameters[:"f.#{facet.field}.facet.limit"] = limit if limit
146
135
  end
147
136
  end
148
137
 
@@ -254,6 +243,22 @@ module Blacklight::Solr
254
243
  end
255
244
  end
256
245
 
246
+ # Support facet paging and 'more'
247
+ # links, by sending a facet.limit one more than what we
248
+ # want to page at, according to configured facet limits.
249
+ def facet_limit_with_pagination(field_name)
250
+ limit = facet_limit_for(field_name)
251
+
252
+ return if limit.nil?
253
+
254
+ if limit > 0
255
+ limit + 1
256
+ else
257
+ limit
258
+ end
259
+ end
260
+
261
+
257
262
  ##
258
263
  # A helper method used for generating solr LocalParams, put quotes
259
264
  # around the term unless it's a bare-word. Escape internal quotes
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'ostruct'
2
3
  module Blacklight
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  unless Blacklight.const_defined? :VERSION
3
4
  def self.version
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  class Assets < Rails::Generators::Base
3
4
  source_root File.expand_path('../templates', __FILE__)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  class ControllerGenerator < Rails::Generators::Base
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rails/generators'
2
3
 
3
4
  module Blacklight
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  class Install < Rails::Generators::Base
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rails/generators'
2
3
  require 'rails/generators/migration'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rails/generators'
2
3
 
3
4
  module Blacklight
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rails/generators'
2
3
 
3
4
  module Blacklight
@@ -9,8 +9,8 @@ module Blacklight
9
9
  EOF
10
10
 
11
11
  def install_solrwrapper
12
- gem 'solr_wrapper', '>= 0.3'
13
-
12
+ gem 'solr_wrapper', '>= 0.3'
13
+
14
14
  append_to_file "Rakefile", "\nrequire 'solr_wrapper/rake_task'\n"
15
15
  end
16
16
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class AlternateController < CatalogController
2
3
  configure_blacklight do |config|
3
4
  config.index.thumbnail_method = :xyz
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class <%= controller_name.classify %>Controller < ApplicationController
2
3
 
3
4
  include Blacklight::Catalog
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class SearchBuilder < Blacklight::SearchBuilder
2
3
  include Blacklight::Solr::SearchBuilderBehavior
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class <%= model_name.classify %>
2
3
 
3
4
  include Blacklight::Solr::Document
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Copy Blacklight test support material in place
2
3
 
3
4
 
@@ -18,7 +18,11 @@ This generator makes the following changes to your application:
18
18
  # Install Devise?
19
19
  def generate_devise_assets
20
20
  if options[:devise]
21
- gem "devise"
21
+ if ENV['RAILS_VERSION'] =~ /^5\.0/ || ENV['RAILS_VERSION'] == 'edge'
22
+ gem 'devise', github: 'plataformatec/devise' # Need > 3.5.3
23
+ else
24
+ gem "devise"
25
+ end
22
26
  gem "devise-guests", "~> 0.3"
23
27
 
24
28
  Bundler.with_clean_env do
@@ -31,11 +35,11 @@ This generator makes the following changes to your application:
31
35
 
32
36
  # add the #to_s to the model.
33
37
  insert_into_file("app/models/#{model_name}.rb", before: /end(\n| )*$/) do
34
- "\n # Method added by Blacklight; Blacklight uses #to_s on your\n" +
35
- " # user class to get a user-displayable login/identifier for\n" +
36
- " # the account.\n" +
37
- " def to_s\n" +
38
- " email\n" +
38
+ "\n # Method added by Blacklight; Blacklight uses #to_s on your\n" \
39
+ " # user class to get a user-displayable login/identifier for\n" \
40
+ " # the account.\n" \
41
+ " def to_s\n" \
42
+ " email\n" \
39
43
  " end\n"
40
44
  end
41
45
  gsub_file("config/initializers/devise.rb", "config.sign_out_via = :delete", "config.sign_out_via = :get")
@@ -73,10 +73,10 @@ namespace :blacklight do
73
73
  puts e.to_s
74
74
  end
75
75
 
76
- print " - get_search_results: "
77
-
76
+ print " - search_results: "
77
+
78
78
  begin
79
- response, docs = controller.get_search_results({}, q: '{!lucene}*:*')
79
+ response, docs = controller.search_results(q: '{!lucene}*:*')
80
80
 
81
81
  if response.header['status'] == 0 and docs.length > 0
82
82
  puts "OK"
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe AlternateController do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe ApplicationController do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::Base do
@@ -5,13 +6,14 @@ describe Blacklight::Base do
5
6
  subject { controller}
6
7
 
7
8
  describe "#search_state" do
8
- let(:params) { { a: 1 } }
9
+ let(:raw_params) { HashWithIndifferentAccess.new a: 1 }
10
+ let(:params) { ActionController::Parameters.new raw_params }
9
11
  before { allow(controller).to receive_messages(params: params) }
10
12
  subject { controller.send(:search_state) }
11
13
 
12
14
  it "creates a path object" do
13
15
  expect(subject).to be_kind_of Blacklight::SearchState
14
- expect(subject.params).to be params
16
+ expect(subject.params).to eq raw_params
15
17
  end
16
18
  end
17
- end
19
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::DefaultComponentConfiguration do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::Facet do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::SearchFields do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  # check the methods that do solr requests. Note that we are not testing if
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::SuggestSearch do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe BookmarksController do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe CatalogController do
@@ -6,8 +7,8 @@ describe CatalogController do
6
7
  describe "with format :html" do
7
8
  let(:user_query) { 'history' } # query that will get results
8
9
 
9
- it "should have no search history if no search criteria" do
10
- allow(controller).to receive(:get_search_results)
10
+ it "has no search history if no search criteria" do
11
+ allow(controller).to receive(:search_results)
11
12
  session[:history] = []
12
13
  get :index
13
14
  expect(session[:history]).to be_empty
@@ -74,13 +75,13 @@ describe CatalogController do
74
75
 
75
76
  describe "session" do
76
77
  before do
77
- allow(controller).to receive(:get_search_results)
78
+ allow(controller).to receive(:search_results)
78
79
  end
79
- it "should include search hash with key :q" do
80
+ it "includes search hash with key :q" do
80
81
  get :index, q: user_query
81
82
  expect(session[:search]).to_not be_nil
82
83
  expect(session[:search].keys).to include 'id'
83
-
84
+
84
85
  search = Search.find(session[:search]['id'])
85
86
  expect(search.query_params['q']).to eq user_query
86
87
  end
@@ -98,8 +99,8 @@ describe CatalogController do
98
99
  end
99
100
  end
100
101
 
101
- it "should render index.html.erb" do
102
- allow(controller).to receive(:get_search_results)
102
+ it "renders index.html.erb" do
103
+ allow(controller).to receive(:search_results)
103
104
  get :index
104
105
  expect(response).to render_template(:index)
105
106
  end
@@ -162,7 +163,7 @@ describe CatalogController do
162
163
 
163
164
  before :each do
164
165
  allow(@controller).to receive_messages blacklight_config: blacklight_config
165
- allow(@controller).to receive_messages get_search_results: [double, double]
166
+ allow(@controller).to receive_messages search_results: [double, double]
166
167
  end
167
168
 
168
169
  it "should not render when the config is false" do
@@ -170,7 +171,7 @@ describe CatalogController do
170
171
  expect { get :index, format: 'yaml' }.to raise_error ActionController::RoutingError
171
172
  end
172
173
 
173
- it "should render the default when the config is true" do
174
+ it "renders the default when the config is true" do
174
175
  # TODO: this should really stub a template and see if it gets rendered,
175
176
  # but how to do that is non-obvious..
176
177
  blacklight_config.index.respond_to.yaml = true
@@ -524,7 +525,7 @@ describe CatalogController do
524
525
 
525
526
  it "should return status 500 if the catalog path is raising an exception" do
526
527
  fake_error = Blacklight::Exceptions::InvalidRequest.new
527
- allow(controller).to receive(:get_search_results) { |*args| raise fake_error }
528
+ allow(controller).to receive(:search_results) { |*args| raise fake_error }
528
529
  allow(controller.flash).to receive(:sweep)
529
530
  allow(controller).to receive(:flash).and_return(:notice => I18n.t('blacklight.search.errors.request_error'))
530
531
  expect { get :index, q: "+" }.to raise_error Blacklight::Exceptions::InvalidRequest
@@ -598,16 +599,18 @@ describe CatalogController do
598
599
  end
599
600
 
600
601
  describe "current_search_session" do
602
+ let(:parameter_class) { ActionController::Parameters }
603
+
601
604
  it "should create a session if we're on an search action" do
602
605
  allow(controller).to receive_messages(:action_name => "index")
603
- allow(controller).to receive_messages(:params => { :q => "x", :page => 5})
606
+ allow(controller).to receive_messages(params: parameter_class.new(q: "x", page: 5))
604
607
  session = controller.send(:current_search_session)
605
608
  expect(session.query_params).to include(:q => "x")
606
609
  expect(session.query_params).to_not include(:page => 5)
607
610
  end
608
611
 
609
612
  it "should create a session if a search context was provided" do
610
- allow(controller).to receive_messages(:params => { :search_context => JSON.dump(:q => "x")})
613
+ allow(controller).to receive_messages(params: parameter_class.new(search_context: JSON.dump(:q => "x")))
611
614
  session = controller.send(:current_search_session)
612
615
  expect(session.query_params).to include("q" => "x")
613
616
  end
@@ -616,7 +619,7 @@ describe CatalogController do
616
619
  s = Search.create(:query_params => { :q => "x" })
617
620
  session[:history] ||= []
618
621
  session[:history] << s.id
619
- allow(controller).to receive_messages(:params => { :search_id => s.id})
622
+ allow(controller).to receive_messages(params: parameter_class.new(search_id: s.id))
620
623
  session = controller.send(:current_search_session)
621
624
  expect(session.query_params).to include(:q => "x")
622
625
  expect(session).to eq(s)
@@ -660,7 +663,7 @@ describe CatalogController do
660
663
  get 'catalog/like', as: :catalog_like
661
664
  end
662
665
  end
663
-
666
+
664
667
  after do
665
668
  CatalogController.blacklight_config.show.document_actions.delete(:like)
666
669
  Rails.application.reload_routes!