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
  require 'spec_helper'
2
3
 
3
4
  describe SavedSearchesController do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe SearchHistoryController do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe SuggestController do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Alternate Controller Behaviors" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Bookmarks" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Did You Mean" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Facets" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Record View" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Saved Searches" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Search Results context", js: true do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Facets" do
@@ -12,7 +13,7 @@ describe "Facets" do
12
13
 
13
14
  expect(page).to have_selector(".blacklight-language_facet")
14
15
  expect(page).to have_selector(".blacklight-language_facet.facet_limit-active")
15
-
16
+
16
17
  within "#facet-language_facet" do
17
18
  expect(page).to have_selector("span.selected", :text => "Tibetan")
18
19
  expect(page).to have_selector("span.facet-count.selected", :text => "6")
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Search Formats" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Search History Page" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Search Pagination" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Search Results" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Search Sort" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Search Page" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  feature 'Sitelinks search box' do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe BlacklightHelper do
@@ -84,8 +85,8 @@ describe BlacklightHelper do
84
85
  end
85
86
 
86
87
  describe "render_nav_actions" do
87
- it "should render partials" do
88
- buff = ''
88
+ it "renders partials" do
89
+ buff = String.new
89
90
  helper.render_nav_actions { |config, item| buff << "<foo>#{item}</foo>" }
90
91
  expect(buff).to have_selector "foo a#bookmarks_nav[href=\"/bookmarks\"]"
91
92
  expect(buff).to have_selector "foo a span[data-role='bookmark-counter']", text: '0'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe CatalogHelper do
@@ -24,9 +25,6 @@ describe CatalogHelper do
24
25
 
25
26
 
26
27
  describe "page_entries_info" do
27
- before(:all) do
28
- end
29
-
30
28
  it "with no results" do
31
29
  @response = mock_response :total => 0
32
30
 
@@ -123,12 +121,13 @@ describe CatalogHelper do
123
121
  expect(html).to eq "<strong>1,001</strong> - <strong>1,010</strong> of <strong>5,000</strong>"
124
122
  end
125
123
 
126
- it "should work with an activerecord collection" do
127
- 50.times { b = Bookmark.new; b.user_id = 1; b.save! }
128
- html = helper.page_entries_info(Bookmark.page(1).per(25))
129
- expect(html).to eq "<strong>1</strong> - <strong>25</strong> of <strong>50</strong>"
130
- end
124
+ context "with an ActiveRecord collection" do
125
+ let(:user) { User.create! email: 'xyz@example.com', password: 'xyz12345' }
126
+ before { 50.times { Bookmark.create!(user: user) } }
127
+ subject { helper.page_entries_info(Bookmark.page(1).per(25)) }
131
128
 
129
+ it { is_expected.to eq "<strong>1</strong> - <strong>25</strong> of <strong>50</strong>" }
130
+ end
132
131
  end
133
132
 
134
133
  describe "should_autofocus_on_search_box?" do
@@ -360,14 +359,10 @@ describe CatalogHelper do
360
359
  allow(helper).to receive(:label_for_search_field).with(nil).and_return('')
361
360
  end
362
361
 
363
- let :blacklight_config do
364
- Blacklight::Configuration.new
365
- end
362
+ let(:blacklight_config) { Blacklight::Configuration.new }
363
+ let(:params) { ActionController::Parameters.new(q: 'foobar', f: { format: ["Book"] }) }
364
+ subject { helper.render_search_to_page_title(params) }
366
365
 
367
- let(:params) { {'q' => 'foobar', "f" => {"format" => ["Book"]}} }
368
-
369
- it "should render a page title" do
370
- expect(helper.render_search_to_page_title(params)).to eq "foobar / Format: Book"
371
- end
366
+ it { is_expected.to eq "foobar / Format: Book" }
372
367
  end
373
368
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe BlacklightConfigurationHelper do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::DeprecatedUrlHelperBehavior do
@@ -6,9 +7,10 @@ describe Blacklight::DeprecatedUrlHelperBehavior do
6
7
  test.call
7
8
  end
8
9
  end
9
-
10
+
11
+ let(:parameter_class) { ActionController::Parameters }
10
12
  let(:search_state) { Blacklight::SearchState.new(params, blacklight_config) }
11
- let(:params) { {} }
13
+ let(:params) { parameter_class.new }
12
14
  let(:blacklight_config) { Blacklight::Configuration.new }
13
15
 
14
16
  before do
@@ -27,7 +29,7 @@ describe Blacklight::DeprecatedUrlHelperBehavior do
27
29
  end
28
30
 
29
31
  it 'generates a search state for the source parameters' do
30
- expect(helper.params_for_search({ source: 1 }, { merge: 1 })).to include merge: 1, source: 1
32
+ expect(helper.params_for_search(parameter_class.new(source: 1), { merge: 1 })).to include merge: 1, source: 1
31
33
  end
32
34
  end
33
35
 
@@ -38,8 +40,9 @@ describe Blacklight::DeprecatedUrlHelperBehavior do
38
40
  end
39
41
 
40
42
  describe '#reset_search_params' do
43
+ let(:source_parameters) { parameter_class.new page: 1, counter: 10 }
41
44
  it 'resets the current page and counter' do
42
- expect(helper.reset_search_params(page: 1, counter: 10)).to be_blank
45
+ expect(helper.reset_search_params(source_parameters)).to be_blank
43
46
  end
44
47
  end
45
48
 
@@ -55,8 +58,11 @@ describe Blacklight::DeprecatedUrlHelperBehavior do
55
58
  expect(helper.add_facet_params(field, item)).to eq search_state.add_facet_params(field, item)
56
59
  end
57
60
 
58
- it 'generates a search state for the source parameters' do
59
- expect(helper.add_facet_params(field, item, source: 1)).to include source: 1
61
+ context "with source_parameters" do
62
+ let(:source_parameters) { parameter_class.new source: 1 }
63
+ it 'generates a search state for the source parameters' do
64
+ expect(helper.add_facet_params(field, item, source_parameters)).to include source: 1
65
+ end
60
66
  end
61
67
  end
62
68
 
@@ -85,8 +91,11 @@ describe Blacklight::DeprecatedUrlHelperBehavior do
85
91
  expect(helper.remove_facet_params(field, item)).to eq search_state.remove_facet_params(field, item)
86
92
  end
87
93
 
88
- it 'generates a search state for the source parameters' do
89
- expect(helper.remove_facet_params(field, item, source: 1)).to include source: 1
94
+ context "with source_parameters" do
95
+ let(:source_parameters) { parameter_class.new source: 1 }
96
+ it 'generates a search state for the source parameters' do
97
+ expect(helper.remove_facet_params(field, item, source_parameters)).to include source: 1
98
+ end
90
99
  end
91
100
  end
92
- end
101
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  require 'equivalent-xml'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe HashAsHiddenFieldsHelper do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe LayoutHelper do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe RenderConstraintsHelper do
@@ -18,12 +19,19 @@ describe RenderConstraintsHelper do
18
19
 
19
20
  describe '#render_constraints_query' do
20
21
  let(:my_engine) { double("Engine") }
21
- it "should have a link relative to the current url" do
22
- expect(helper.render_constraints_query(:q=>'foobar', :f=>{:type=>'journal'})).to have_selector "a[href='/?f%5Btype%5D=journal']"
22
+ let(:params) { ActionController::Parameters.new(q: 'foobar', f: { type: 'journal' }) }
23
+ subject { helper.render_constraints_query(params) }
24
+
25
+ it "has a link relative to the current url" do
26
+ expect(subject).to have_selector "a[href='/?f%5Btype%5D=journal']"
23
27
  end
24
- it "should accept an optional route set" do
25
- expect(my_engine).to receive(:url_for).and_return('/?f%5Btype%5D=journal')
26
- expect(helper.render_constraints_query(:q=>'foobar', :f=>{:type=>'journal'}, :route_set => my_engine)).to have_selector "a[href='/?f%5Btype%5D=journal']"
28
+
29
+ context "with a route_set" do
30
+ let(:params) { ActionController::Parameters.new(q: 'foobar', f: { type: 'journal' }, route_set: my_engine) }
31
+ it "accepts an optional route set" do
32
+ expect(my_engine).to receive(:url_for).and_return('/?f%5Btype%5D=journal')
33
+ expect(subject).to have_selector "a[href='/?f%5Btype%5D=journal']"
34
+ end
27
35
  end
28
36
  end
29
37
 
@@ -34,19 +42,21 @@ describe RenderConstraintsHelper do
34
42
  end
35
43
  subject { helper.render_filter_element('type', ['journal'], path) }
36
44
 
37
- let(:path) { Blacklight::SearchState.new({:q=>'biz'}, config) }
45
+ let(:params) { ActionController::Parameters.new q: 'biz' }
46
+ let(:path) { Blacklight::SearchState.new(params, config) }
38
47
 
39
- it "should have a link relative to the current url" do
48
+ it "has a link relative to the current url" do
40
49
  expect(subject).to have_link "Remove constraint Item Type: journal", href: "/catalog?q=biz"
41
50
  expect(subject).to have_selector ".filterName", text: 'Item Type'
42
51
  end
43
52
  end
44
53
 
45
54
  describe "#render_constraints_filters" do
55
+ let(:params) { ActionController::Parameters.new f: { 'type' => [''] } }
46
56
  before do
47
57
  allow(helper).to receive(:blacklight_config).and_return(config)
48
58
  end
49
- subject { helper.render_constraints_filters(:f=>{'type'=>['']}) }
59
+ subject { helper.render_constraints_filters(params) }
50
60
 
51
61
  it "should render nothing for empty facet limit param" do
52
62
  expect(subject).to be_blank
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe SearchHistoryConstraintsHelper do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe SuggestHelper do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe BlacklightUrlHelper do
@@ -9,6 +10,8 @@ describe BlacklightUrlHelper do
9
10
  end
10
11
  end
11
12
 
13
+ let(:parameter_class) { ActionController::Parameters }
14
+
12
15
  before do
13
16
  allow(helper).to receive(:search_action_path) do |*args|
14
17
  search_catalog_url *args
@@ -26,7 +29,7 @@ describe BlacklightUrlHelper do
26
29
  before do
27
30
  allow(helper).to receive_messages(controller: controller_class)
28
31
  allow(helper).to receive_messages(controller_name: controller_class.controller_name)
29
- allow(helper).to receive_messages(params: {})
32
+ allow(helper).to receive_messages(params: parameter_class.new)
30
33
  end
31
34
 
32
35
  it "should be a polymorphic routing-ready object" do
@@ -48,12 +51,14 @@ describe BlacklightUrlHelper do
48
51
 
49
52
  context "within an alternative catalog controller" do
50
53
  let(:controller_class) { ::AlternateController.new }
54
+
51
55
  before do
52
56
  helper.blacklight_config.show.route = { controller: :current }
53
- allow(helper).to receive(:params).and_return(controller: 'alternate')
57
+ allow(helper).to receive(:params).and_return(parameter_class.new controller: 'alternate')
54
58
  end
59
+
55
60
  it "should support the :current controller configuration" do
56
- expect(helper.url_for_document(doc)).to eq({controller: 'alternate', action: :show, id: doc})
61
+ expect(helper.url_for_document(doc)).to eq(controller: 'alternate', action: :show, id: doc)
57
62
  end
58
63
  end
59
64
 
@@ -94,7 +99,7 @@ describe BlacklightUrlHelper do
94
99
  expect(tag).to match /page=3/
95
100
  expect(tag).to match /per_page=15/
96
101
  end
97
-
102
+
98
103
  it "should omit per_page if the value is the same as the default" do
99
104
  allow(helper).to receive_messages(current_search_session: double(query_params: query_params))
100
105
  allow(helper).to receive_messages(search_session: { 'per_page' => 10, 'counter' => 31 })
@@ -106,7 +111,11 @@ describe BlacklightUrlHelper do
106
111
 
107
112
  context "without current search context" do
108
113
  before do
109
- controller.request.assign_parameters(Rails.application.routes, 'catalog', 'show', id: '123')
114
+ if Rails.version >= '5.0.0'
115
+ controller.request.assign_parameters(Rails.application.routes, 'catalog', 'show', { id: '123' }, '/catalog/123', [:controller, :action, :id])
116
+ else
117
+ controller.request.assign_parameters(Rails.application.routes, 'catalog', 'show', id: '123')
118
+ end
110
119
  allow(helper).to receive_messages(current_search_session: nil)
111
120
  end
112
121
 
@@ -131,31 +140,41 @@ describe BlacklightUrlHelper do
131
140
  end
132
141
  end
133
142
 
143
+ describe "link_to_previous_document" do
144
+ context "when the argument is nil" do
145
+ subject { helper.link_to_previous_document(nil) }
146
+ it { is_expected.to eq '<span class="previous">&laquo; Previous</span>' }
147
+ end
148
+ end
149
+
134
150
  describe "link_to_query" do
135
- it "should build a link tag to catalog using query string (no other params)" do
151
+ it "builds a link tag to catalog using query string (no other params)" do
136
152
  query = "brilliant"
137
- allow(helper).to receive_messages(params: {})
153
+ allow(helper).to receive_messages(params: parameter_class.new)
138
154
  tag = helper.link_to_query(query)
139
155
  expect(tag).to match /q=#{query}/
140
156
  expect(tag).to match />#{query}<\/a>/
141
157
  end
142
- it "should build a link tag to catalog using query string and other existing params" do
158
+
159
+ it "builds a link tag to catalog using query string and other existing params" do
143
160
  query = "wonderful"
144
- allow(helper).to receive_messages(params: {:qt => "title_search", :per_page => "50"})
161
+ allow(helper).to receive_messages(params: parameter_class.new(qt: "title_search", per_page: "50"))
145
162
  tag = helper.link_to_query(query)
146
163
  expect(tag).to match /qt=title_search/
147
164
  expect(tag).to match /per_page=50/
148
165
  end
149
- it "should ignore existing :page param" do
166
+
167
+ it "ignores existing :page param" do
150
168
  query = "yes"
151
- allow(helper).to receive_messages(params: {:page => "2", :qt => "author_search"})
169
+ allow(helper).to receive_messages(params: parameter_class.new(page: "2", qt: "author_search"))
152
170
  tag = helper.link_to_query(query)
153
171
  expect(tag).to match /qt=author_search/
154
172
  expect(tag).to_not match /page/
155
173
  end
156
- it "should be html_safe" do
174
+
175
+ it "is html_safe" do
157
176
  query = "brilliant"
158
- allow(helper).to receive_messages(params: {:page => "2", :qt => "author_search"})
177
+ allow(helper).to receive_messages(params: parameter_class.new(page: "2", qt: "author_search"))
159
178
  tag = helper.link_to_query(query)
160
179
  expect(tag).to be_html_safe
161
180
  end
@@ -176,91 +195,76 @@ describe BlacklightUrlHelper do
176
195
  end
177
196
 
178
197
  describe "link_to_document" do
179
- it "should consist of the document title wrapped in a <a>" do
180
- data = {'id'=>'123456','title_display'=>['654321'] }
181
- @document = SolrDocument.new(data)
182
- expect(helper.link_to_document(@document, :title_display)).to have_selector("a", :text => '654321', :count => 1)
183
- end
198
+ let(:title_display) { '654321' }
199
+ let(:id) { '123456' }
200
+ let(:data) { { 'id' => id, 'title_display' => [title_display] } }
201
+ let(:document) { SolrDocument.new(data) }
184
202
 
185
- it "should accept and return a string label" do
186
- data = {'id'=>'123456','title_display'=>['654321'] }
187
- @document = SolrDocument.new(data)
188
- expect(helper.link_to_document(@document, "title_display")).to have_selector("a", :text => 'title_display', :count => 1)
203
+ it "consists of the document title wrapped in a <a>" do
204
+ expect(helper.link_to_document(document, :title_display)).to have_selector("a", :text => '654321', :count => 1)
189
205
  end
190
206
 
191
- it "should accept and return a Proc" do
192
- data = {'id'=>'123456','title_display'=>['654321'] }
193
- @document = SolrDocument.new(data)
194
- expect(helper.link_to_document(@document, Proc.new { |doc, opts| doc[:id] + ": " + doc.first(:title_display) })).to have_selector("a", :text => '123456: 654321', :count => 1)
207
+ it "accepts and returns a string label" do
208
+ expect(helper.link_to_document(document, String.new('title_display'))).to have_selector("a", :text => 'title_display', :count => 1)
195
209
  end
196
210
 
197
- it "should return id when label is missing" do
198
- data = {'id'=>'123456'}
199
- @document = SolrDocument.new(data)
200
- expect(helper.link_to_document(@document, :title_display)).to have_selector("a", :text => '123456', :count => 1)
211
+ it "accepts and returns a Proc" do
212
+ expect(helper.link_to_document(document, Proc.new { |doc, opts| doc[:id] + ": " + doc.first(:title_display) })).to have_selector("a", :text => '123456: 654321', :count => 1)
201
213
  end
202
214
 
203
- it "should be html safe" do
204
- data = {'id'=>'123456'}
205
- @document = SolrDocument.new(data)
206
- expect(helper.link_to_document(@document, :title_display)).to be_html_safe
207
- end
215
+ context 'when label is missing' do
216
+ let(:data) { { 'id' => id } }
217
+ it "returns id" do
218
+ expect(helper.link_to_document(document, :title_display)).to have_selector("a", :text => '123456', :count => 1)
219
+ end
220
+
221
+ it "is html safe" do
222
+ expect(helper.link_to_document(document, :title_display)).to be_html_safe
223
+ end
208
224
 
209
- it "should convert the counter parameter into a data- attribute" do
210
- data = {'id'=>'123456','title_display'=>['654321']}
211
- @document = SolrDocument.new(data)
225
+ it "passes on the title attribute to the link_to_with_data method" do
226
+ expect(helper.link_to_document(document, "Some crazy long label...", title: "Some crazy longer label")).to match(/title=\"Some crazy longer label\"/)
227
+ end
228
+
229
+ it "doesn't add an erroneous title attribute if one isn't provided" do
230
+ expect(helper.link_to_document(document, "Some crazy long label...")).to_not match(/title=/)
231
+ end
232
+
233
+ context "with an integer id" do
234
+ let(:id) { 123456 }
235
+ it "works" do
236
+ expect(helper.link_to_document(document)).to have_selector("a")
237
+ end
238
+ end
239
+ end
212
240
 
241
+ it "converts the counter parameter into a data- attribute" do
213
242
  allow(helper).to receive(:track_test_path).with(hash_including(id: '123456', counter: 5)).and_return('tracking url')
214
243
 
215
- expect(helper.link_to_document(@document, :title_display, counter: 5)).to include 'data-context-href="tracking url"'
244
+ expect(helper.link_to_document(document, :title_display, counter: 5)).to include 'data-context-href="tracking url"'
216
245
  end
217
246
 
218
247
  it "includes the data- attributes from the options" do
219
- data = {'id'=>'123456','title_display'=>['654321']}
220
- @document = SolrDocument.new(data)
221
- link = helper.link_to_document @document, { data: { x: 1 } }
248
+ link = helper.link_to_document document, { data: { x: 1 } }
222
249
  expect(link).to have_selector '[data-x]'
223
250
  end
224
251
 
225
252
  it 'adds a controller-specific tracking attribute' do
226
- data = { 'id'=>'123456', 'title_display'=>['654321'] }
227
- @document = SolrDocument.new(data)
228
-
229
253
  expect(helper).to receive(:track_test_path).and_return('/asdf')
230
- link = helper.link_to_document @document, { data: { x: 1 } }
254
+ link = helper.link_to_document document, { data: { x: 1 } }
231
255
 
232
256
  expect(link).to have_selector '[data-context-href="/asdf"]'
233
257
  end
234
258
 
235
259
  it 'adds a global tracking attribute' do
236
- data = { 'id'=>'123456', 'title_display'=>['654321'] }
237
- @document = SolrDocument.new(data)
238
-
239
- link = helper.link_to_document @document, { data: { x: 1 } }
260
+ link = helper.link_to_document document, { data: { x: 1 } }
240
261
  expect(link).to have_selector '[data-context-href="/catalog/123456/track"]'
241
262
  end
242
-
243
- it "passes on the title attribute to the link_to_with_data method" do
244
- @document = SolrDocument.new('id'=>'123456')
245
- expect(helper.link_to_document(@document, "Some crazy long label...", title: "Some crazy longer label")).to match(/title=\"Some crazy longer label\"/)
246
- end
247
-
248
- it "doesn't add an erroneous title attribute if one isn't provided" do
249
- @document = SolrDocument.new('id'=>'123456')
250
- expect(helper.link_to_document(@document, "Some crazy long label...")).to_not match(/title=/)
251
- end
252
-
253
- it "should work with integer ids" do
254
- data = {'id'=> 123456 }
255
- @document = SolrDocument.new(data)
256
- expect(helper.link_to_document(@document)).to have_selector("a")
257
- end
258
-
259
263
  end
260
264
 
261
265
  describe "link_to_previous_search" do
266
+ let(:params) { {} }
262
267
  it "should link to the given search parameters" do
263
- params = {}
264
268
  allow(helper).to receive(:render_search_to_s).with(params).and_return "link text"
265
269
  expect(helper.link_to_previous_search({})).to eq helper.link_to("link text", helper.search_action_path)
266
270
  end