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 Blacklight::Parameters do
@@ -5,7 +6,7 @@ describe Blacklight::Parameters do
5
6
  subject { described_class.sanitize(params) }
6
7
 
7
8
  context "with nil values" do
8
- let(:params) { { a: nil, b: 1 } }
9
+ let(:params) { ActionController::Parameters.new a: nil, b: 1 }
9
10
  it "removes them" do
10
11
  expect(subject).to_not have_key(:a)
11
12
  expect(subject[:b]).to eq 1
@@ -13,7 +14,7 @@ describe Blacklight::Parameters do
13
14
  end
14
15
 
15
16
  context "with blacklisted keys" do
16
- let(:params) { { action: true, controller: true, id: true, commit: true, utf8: true } }
17
+ let(:params) { ActionController::Parameters.new action: true, controller: true, id: true, commit: true, utf8: true }
17
18
  it "removes them" do
18
19
  expect(subject).to be_empty
19
20
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::SearchState do
@@ -8,11 +9,12 @@ describe Blacklight::SearchState do
8
9
  end
9
10
  end
10
11
 
12
+ let(:parameter_class) { ActionController::Parameters }
11
13
  let(:helper) { described_class.new(params, blacklight_config) }
12
- let(:params) { {} }
14
+ let(:params) { parameter_class.new }
13
15
 
14
16
  describe "params_for_search" do
15
- let(:params) { { 'default' => 'params' } }
17
+ let(:params) { parameter_class.new 'default' => 'params' }
16
18
 
17
19
  it "takes original params" do
18
20
  result = helper.params_for_search
@@ -22,11 +24,11 @@ describe Blacklight::SearchState do
22
24
 
23
25
  it "accepts params to merge into the controller's params" do
24
26
  result = helper.params_for_search(q: 'query')
25
- expect(result).to include(:q => 'query', 'default' => 'params')
27
+ expect(result).to eq('q' => 'query', 'default' => 'params')
26
28
  end
27
29
 
28
30
  context "when params have blacklisted keys" do
29
- let(:params) { { action: 'action', controller: 'controller', id: "id", commit: 'commit' } }
31
+ let(:params) { parameter_class.new action: 'action', controller: 'controller', id: "id", commit: 'commit' }
30
32
  it "removes them" do
31
33
  result = helper.params_for_search
32
34
  expect(result.keys).to_not include(:action, :controller, :commit, :id)
@@ -35,7 +37,7 @@ describe Blacklight::SearchState do
35
37
 
36
38
  context "when params has page" do
37
39
  context "and per_page changed" do
38
- let(:params) { { per_page: 20, page: 5 } }
40
+ let(:params) { parameter_class.new per_page: 20, page: 5 }
39
41
  it "adjusts the current page" do
40
42
  result = helper.params_for_search(per_page: 100)
41
43
  expect(result[:page]).to eq 1
@@ -43,7 +45,7 @@ describe Blacklight::SearchState do
43
45
  end
44
46
 
45
47
  context "and per_page didn't change" do
46
- let(:params) { { per_page: 20, page: 5 } }
48
+ let(:params) { parameter_class.new per_page: 20, page: 5 }
47
49
  it "doesn't change the current page" do
48
50
  result = helper.params_for_search(per_page: 20)
49
51
  expect(result[:page]).to eq 5
@@ -51,7 +53,7 @@ describe Blacklight::SearchState do
51
53
  end
52
54
 
53
55
  context "and the sort changes" do
54
- let(:params) { { sort: 'field_a', page: 5 } }
56
+ let(:params) { parameter_class.new sort: 'field_a', page: 5 }
55
57
  it "adjusts the current page" do
56
58
  result = helper.params_for_search(sort: 'field_b')
57
59
  expect(result[:page]).to eq 1
@@ -59,7 +61,7 @@ describe Blacklight::SearchState do
59
61
  end
60
62
 
61
63
  context "and the sort didn't change" do
62
- let(:params) { { sort: 'field_a', page: 5 } }
64
+ let(:params) { parameter_class.new sort: 'field_a', page: 5 }
63
65
  it "doesn't change the current page" do
64
66
  result = helper.params_for_search(sort: 'field_a')
65
67
  expect(result[:page]).to eq 5
@@ -68,10 +70,10 @@ describe Blacklight::SearchState do
68
70
  end
69
71
 
70
72
  context "with a block" do
71
- let(:params) { { a: 1, b: 2 } }
73
+ let(:params) { parameter_class.new a: 1, b: 2 }
72
74
  it "should evalute the block and allow it to add or remove keys" do
73
75
  result = helper.params_for_search(c: 3) do |params|
74
- params.except! :a, :b
76
+ params.extract! :a, :b
75
77
  params[:d] = 'd'
76
78
  end
77
79
 
@@ -83,14 +85,24 @@ describe Blacklight::SearchState do
83
85
  end
84
86
 
85
87
  describe "add_facet_params" do
86
- let(:params_no_existing_facet) { { q: "query", search_field: "search_field", per_page: "50" } }
87
- let(:params_existing_facets) { { q: "query", search_field: "search_field", per_page: "50", f: { "facet_field_1" => ["value1"], "facet_field_2" => ["value2", "value2a"] } } }
88
+ let(:params_no_existing_facet) do
89
+ parameter_class.new q: "query",
90
+ search_field: "search_field",
91
+ per_page: "50"
92
+ end
93
+ let(:params_existing_facets) do
94
+ parameter_class.new q: "query",
95
+ search_field: "search_field",
96
+ per_page: "50",
97
+ f: { "facet_field_1" => ["value1"],
98
+ "facet_field_2" => ["value2", "value2a"] }
99
+ end
88
100
 
89
101
  context "when there are no pre-existing facets" do
90
102
  let(:params) { params_no_existing_facet }
91
103
  it "adds facet value" do
92
104
  result_params = helper.add_facet_params("facet_field", "facet_value")
93
- expect(result_params[:f]).to be_a_kind_of(Hash)
105
+ expect(result_params[:f]).to be_a Hash
94
106
  expect(result_params[:f]["facet_field"]).to be_a_kind_of(Array)
95
107
  expect(result_params[:f]["facet_field"]).to eq ["facet_value"]
96
108
  end
@@ -119,7 +131,7 @@ describe Blacklight::SearchState do
119
131
  it "adds a facet param to existing facet constraints" do
120
132
  result_params = helper.add_facet_params("facet_field_2", "new_facet_value")
121
133
 
122
- expect(result_params[:f]).to be_a_kind_of(Hash)
134
+ expect(result_params[:f]).to be_a Hash
123
135
 
124
136
  params_existing_facets[:f].each_pair do |facet_field, value_list|
125
137
  expect(result_params[:f][facet_field]).to be_a_kind_of(Array)
@@ -135,14 +147,14 @@ describe Blacklight::SearchState do
135
147
  result_params = helper.add_facet_params("facet_field_2", "new_facet_value")
136
148
 
137
149
  params.each_pair do |key, value|
138
- next if key == :f
150
+ next if key == 'f'
139
151
  expect(result_params[key]).to eq params[key]
140
152
  end
141
153
  end
142
154
  end
143
155
 
144
156
  context "with a facet selected in the params" do
145
- let(:params) { { f: { 'single_value_facet_field' => 'other_value' } } }
157
+ let(:params) { parameter_class.new f: { 'single_value_facet_field' => 'other_value' } }
146
158
  it "replaces facets configured as single" do
147
159
  allow(helper).to receive(:facet_configuration_for_field).with('single_value_facet_field').and_return(double(single: true, key: "single_value_facet_field"))
148
160
  result_params = helper.add_facet_params('single_value_facet_field', 'my_value')
@@ -174,15 +186,15 @@ describe Blacklight::SearchState do
174
186
  end
175
187
 
176
188
  describe "add_facet_params_and_redirect" do
177
- let(:params) { { q: "query",
178
- :search_field => "search_field",
179
- :per_page => "50",
180
- :page => "5",
181
- :f => {"facet_field_1" => ["value1"], "facet_field_2" => ["value2", "value2a"]},
182
- Blacklight::Solr::FacetPaginator.request_keys[:page] => "100",
183
- Blacklight::Solr::FacetPaginator.request_keys[:sort] => "index",
184
- :id => 'facet_field_name'
185
- }
189
+ let(:params) { parameter_class.new(
190
+ q: "query",
191
+ search_field: "search_field",
192
+ per_page: "50",
193
+ page: "5",
194
+ f: { "facet_field_1" => ["value1"], "facet_field_2" => ["value2", "value2a"] },
195
+ Blacklight::Solr::FacetPaginator.request_keys[:page] => "100",
196
+ Blacklight::Solr::FacetPaginator.request_keys[:sort] => "index",
197
+ id: 'facet_field_name')
186
198
  }
187
199
 
188
200
  it "does not include request parameters used by the facet paginator" do
@@ -196,10 +208,10 @@ describe Blacklight::SearchState do
196
208
 
197
209
  it 'removes :page request key' do
198
210
  params = helper.add_facet_params_and_redirect("facet_field_2", "facet_value")
199
- expect(params.keys).to_not include(:page)
211
+ expect(params).to_not have_key(:page)
200
212
  end
201
213
 
202
- it "should otherwise do the same thing as add_facet_params" do
214
+ it "otherwise does the same thing as add_facet_params" do
203
215
  added_facet_params = helper.add_facet_params("facet_field_2", "facet_value")
204
216
  added_facet_params_from_facet_action = helper.add_facet_params_and_redirect("facet_field_2", "facet_value")
205
217
 
@@ -208,7 +220,7 @@ describe Blacklight::SearchState do
208
220
  end
209
221
 
210
222
  describe "#remove_facet_params" do
211
- let(:params) { { f: facet_params }}
223
+ let(:params) { parameter_class.new 'f' => facet_params }
212
224
  let(:facet_params) { { } }
213
225
  context "when the facet has multiple values" do
214
226
  let(:facet_params) { { 'some_field' => ['some_value', 'another_value'] } }
@@ -234,21 +246,21 @@ describe Blacklight::SearchState do
234
246
  end
235
247
  end
236
248
 
237
- it "should remove the facet entirely when the last facet value is removed" do
249
+ it "removes the facet entirely when the last facet value is removed" do
238
250
  facet_params['another_field'] = ['some_value']
239
251
  facet_params['some_field'] = ['some_value']
240
252
 
241
253
  params = helper.remove_facet_params('some_field', 'some_value')
242
254
 
243
- expect(params[:f]).not_to include 'some_field'
255
+ expect(params[:f]).not_to have_key 'some_field'
244
256
  end
245
257
 
246
- it "should remove the 'f' parameter entirely when no facets remain" do
258
+ it "removes the 'f' parameter entirely when no facets remain" do
247
259
  facet_params['some_field'] = ['some_value']
248
260
 
249
261
  params = helper.remove_facet_params('some_field', 'some_value')
250
262
 
251
- expect(params).not_to include :f
263
+ expect(params).not_to have_key :f
252
264
  end
253
265
  end
254
266
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe 'Blacklight::Utils' do
@@ -1,15 +1,13 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight do
4
-
5
5
  context 'root' do
6
-
7
6
  let(:blroot) { File.expand_path(File.join(__FILE__, '..', '..', '..' )) }
8
7
 
9
8
  it 'should return the full path to the BL plugin' do
10
9
  expect(Blacklight.root).to eq blroot
11
10
  end
12
-
13
11
  end
14
12
 
15
13
  describe '.default_index' do
@@ -25,6 +23,16 @@ describe Blacklight do
25
23
  end
26
24
 
27
25
  describe '.repository_class' do
26
+ context 'when the adapter key is missing' do
27
+ before do
28
+ allow(Blacklight).to receive(:connection_config).and_return({})
29
+ end
30
+
31
+ it 'raises an error' do
32
+ expect { Blacklight.repository_class }.to raise_error RuntimeError, 'The value for :adapter was not found in the blacklight.yml config'
33
+ end
34
+ end
35
+
28
36
  context 'for a solr index' do
29
37
  before do
30
38
  allow(Blacklight).to receive(:connection_config).and_return(adapter: 'solr')
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
  require 'rake'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Blacklight::Configurable" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::Configuration::Context do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Blacklight::Configuration" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe 'Blacklight::Document::ActiveModelShim' do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::Document::CacheKey do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Blacklight::Document::DublinCore" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Blacklight::Document::Email" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Blacklight::Document::Email" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::Document do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::FacetPaginator do
@@ -62,8 +63,8 @@ describe Blacklight::FacetPaginator do
62
63
 
63
64
  it 'should know a manually set sort, and produce proper sort url' do
64
65
  expect(subject.sort).to eq 'index'
65
-
66
- click_params = subject.params_for_resort_url('count', {})
66
+
67
+ click_params = subject.params_for_resort_url('count', {}.with_indifferent_access)
67
68
 
68
69
  expect(click_params[ sort_key ]).to eq 'count'
69
70
  expect(click_params[ page_key ]).to be_nil
@@ -71,23 +72,35 @@ describe Blacklight::FacetPaginator do
71
72
 
72
73
  context 'when sorting by "count"' do
73
74
  subject { described_class.new([]) }
75
+ let(:params) { HashWithIndifferentAccess.new :'facet.prefix' => 'A' }
74
76
 
75
77
  it 'includes the prefix filter for "index" sorting' do
76
- expect(subject.params_for_resort_url('index', :'facet.prefix' => 'A')).to include :'facet.prefix' => 'A'
78
+ expect(subject.params_for_resort_url('index', params)).to include :'facet.prefix' => 'A'
77
79
  end
78
80
 
79
81
  it 'removes the prefix filter' do
80
- expect(subject.params_for_resort_url('count', :'facet.prefix' => 'A')).not_to include :'facet.prefix' => 'A'
82
+ expect(subject.params_for_resort_url('count', params)).not_to include :'facet.prefix' => 'A'
81
83
  end
82
84
  end
83
85
  end
84
86
 
85
87
  context "for a nil :limit" do
86
- subject { described_class.new(seven_facet_values, offset: 0, limit: nil) }
87
- it "should return all the items" do
88
- expect(subject.items).to eq seven_facet_values
88
+ let(:paginator) { described_class.new(seven_facet_values, offset: 0, limit: nil) }
89
+
90
+ describe "#items" do
91
+ subject { paginator.items }
92
+ it { is_expected.to eq seven_facet_values }
93
+ end
94
+
95
+ describe "#last_page?" do
96
+ subject { paginator.last_page? }
97
+ it { is_expected.to be true }
98
+ end
99
+
100
+ describe "#current_page" do
101
+ subject { paginator.current_page }
102
+ it { is_expected.to eq 1 }
89
103
  end
90
- it { should be_last_page }
91
104
  end
92
105
 
93
106
  describe "#as_json" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::SearchBuilder do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::Solr::Document::MoreLikeThis do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Blacklight::Solr::Document" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::Solr::FacetPaginator do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::Solr::Repository do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::Solr::Request do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::Solr::Response::Facets do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "spec_helper"
2
3
 
3
4
  describe Blacklight::Solr::Response::GroupResponse do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "spec_helper"
2
3
 
3
4
  describe Blacklight::Solr::Response::Group do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::Solr::Response do