blacklight 4.9.0 → 5.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (260) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.travis.yml +22 -12
  4. data/Gemfile +3 -40
  5. data/LICENSE +1 -2
  6. data/README.md +1 -2
  7. data/Rakefile +0 -4
  8. data/VERSION +1 -1
  9. data/app/assets/images/blacklight/logo.png +0 -0
  10. data/app/assets/javascripts/blacklight/ajax_modal.js +190 -0
  11. data/app/assets/javascripts/blacklight/blacklight.js +7 -17
  12. data/app/assets/javascripts/blacklight/checkbox_submit.js +1 -1
  13. data/app/assets/stylesheets/blacklight/{_blacklight_base.scss → _blacklight_base.css.scss} +0 -21
  14. data/app/assets/stylesheets/blacklight/_bookmark.css.scss +4 -0
  15. data/app/assets/stylesheets/blacklight/_catalog.css.scss +192 -0
  16. data/app/assets/stylesheets/blacklight/_facets.css.scss +141 -0
  17. data/app/assets/stylesheets/blacklight/{_group.scss → _group.css.scss} +1 -1
  18. data/app/assets/stylesheets/blacklight/_header.css.scss +44 -0
  19. data/app/assets/stylesheets/blacklight/_layout.css.scss +5 -0
  20. data/app/assets/stylesheets/blacklight/{_modal.scss → _modal.css.scss} +7 -7
  21. data/app/assets/stylesheets/blacklight/_search_history.css.scss +20 -0
  22. data/app/assets/stylesheets/blacklight/{blacklight.scss → blacklight.css.scss} +0 -0
  23. data/app/assets/stylesheets/blacklight/blacklight_defaults.css.scss +14 -0
  24. data/app/controllers/bookmarks_controller.rb +0 -4
  25. data/app/controllers/feedback_controller.rb +0 -4
  26. data/app/helpers/blacklight/blacklight_helper_behavior.rb +45 -155
  27. data/app/helpers/blacklight/catalog_helper_behavior.rb +8 -41
  28. data/app/helpers/blacklight/facets_helper_behavior.rb +20 -43
  29. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +2 -9
  30. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +9 -14
  31. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +6 -6
  32. data/app/views/_flash_msg.html.erb +9 -2
  33. data/app/views/_user_util_links.html.erb +29 -15
  34. data/app/views/bookmarks/_tools.html.erb +4 -7
  35. data/app/views/bookmarks/index.html.erb +3 -2
  36. data/app/views/catalog/_citation.html.erb +1 -1
  37. data/app/views/catalog/_constraints.html.erb +1 -1
  38. data/app/views/catalog/_constraints_element.html.erb +12 -8
  39. data/app/views/catalog/_did_you_mean.html.erb +2 -2
  40. data/app/views/catalog/_document_header.html.erb +3 -3
  41. data/app/views/catalog/_email_form.html.erb +10 -10
  42. data/app/views/catalog/_facet_layout.html.erb +11 -3
  43. data/app/views/catalog/_facet_limit.html.erb +7 -7
  44. data/app/views/catalog/_facet_pagination.html.erb +8 -7
  45. data/app/views/catalog/_facet_pivot.html.erb +3 -1
  46. data/app/views/catalog/_facets.html.erb +12 -9
  47. data/app/views/catalog/_paginate_compact.html.erb +1 -7
  48. data/app/views/catalog/_per_page_widget.html.erb +5 -8
  49. data/app/views/catalog/_previous_next_doc.html.erb +11 -9
  50. data/app/views/catalog/_refworks_form.html.erb +3 -4
  51. data/app/views/catalog/_results_pagination.html.erb +1 -1
  52. data/app/views/catalog/_search_form.html.erb +16 -14
  53. data/app/views/catalog/_show_sidebar.html.erb +7 -9
  54. data/app/views/catalog/_show_tools.html.erb +13 -7
  55. data/app/views/catalog/_sms_form.html.erb +8 -8
  56. data/app/views/catalog/_sort_and_per_page.html.erb +4 -6
  57. data/app/views/catalog/_sort_widget.html.erb +5 -6
  58. data/app/views/catalog/email.html.erb +1 -1
  59. data/app/views/catalog/facet.html.erb +2 -8
  60. data/app/views/catalog/index.html.erb +11 -6
  61. data/app/views/catalog/show.html.erb +5 -5
  62. data/app/views/catalog/sms.html.erb +1 -1
  63. data/app/views/catalog/sms_sent.html.erb +1 -1
  64. data/app/views/feedback/complete.html.erb +2 -2
  65. data/app/views/feedback/show.html.erb +1 -1
  66. data/app/views/kaminari/blacklight/_paginator.html.erb +1 -1
  67. data/app/views/kaminari/blacklight_compact/_paginator.html.erb +25 -5
  68. data/app/views/layouts/blacklight.html.erb +23 -23
  69. data/app/views/saved_searches/index.html.erb +2 -2
  70. data/app/views/search_history/index.html.erb +5 -7
  71. data/app/views/shared/_header_navbar.html.erb +23 -23
  72. data/blacklight.gemspec +10 -13
  73. data/config/locales/blacklight.en.yml +1 -12
  74. data/config/locales/blacklight.fr.yml +1 -12
  75. data/gemfiles/rails3.gemfile +21 -0
  76. data/gemfiles/rails4.gemfile +20 -0
  77. data/lib/blacklight.rb +0 -8
  78. data/lib/blacklight/base.rb +0 -2
  79. data/lib/blacklight/catalog.rb +6 -32
  80. data/lib/blacklight/catalog/search_context.rb +8 -48
  81. data/lib/blacklight/configurable.rb +2 -1
  82. data/lib/blacklight/configuration.rb +1 -2
  83. data/lib/blacklight/configuration/facet_field.rb +0 -2
  84. data/lib/blacklight/engine.rb +3 -3
  85. data/lib/blacklight/legacy_controller_methods.rb +1 -64
  86. data/lib/blacklight/rails/routes.rb +17 -0
  87. data/lib/blacklight/routes.rb +46 -40
  88. data/lib/blacklight/solr.rb +1 -0
  89. data/lib/blacklight/solr/document.rb +21 -42
  90. data/lib/blacklight/solr/facet_paginator.rb +30 -54
  91. data/lib/blacklight/solr/request.rb +45 -0
  92. data/lib/blacklight/solr_helper.rb +16 -53
  93. data/lib/blacklight/solr_response.rb +0 -6
  94. data/lib/blacklight/user.rb +2 -7
  95. data/lib/blacklight/utils.rb +1 -9
  96. data/lib/generators/blacklight/assets_generator.rb +0 -14
  97. data/lib/generators/blacklight/blacklight_generator.rb +17 -14
  98. data/lib/generators/blacklight/templates/blacklight.css.scss +3 -0
  99. data/lib/generators/blacklight/templates/catalog_controller.rb +4 -1
  100. data/lib/railties/blacklight.rake +3 -1
  101. data/solr/sample_solr_documents.yml +641 -0
  102. data/spec/controllers/application_controller_spec.rb +5 -21
  103. data/spec/controllers/bookmarks_controller_spec.rb +11 -11
  104. data/spec/controllers/catalog_controller_spec.rb +122 -119
  105. data/spec/controllers/search_history_controller_spec.rb +8 -8
  106. data/spec/features/alternate_controller_spec.rb +5 -5
  107. data/spec/features/facets_spec.rb +9 -0
  108. data/spec/features/record_view_spec.rb +1 -1
  109. data/spec/features/search_filters_spec.rb +97 -41
  110. data/spec/features/search_results_spec.rb +14 -17
  111. data/spec/features/search_sort_spec.rb +1 -1
  112. data/spec/helpers/blacklight_helper_spec.rb +170 -285
  113. data/spec/helpers/catalog_helper_spec.rb +57 -96
  114. data/spec/helpers/facets_helper_spec.rb +130 -152
  115. data/spec/helpers/hash_as_hidden_fields_spec.rb +9 -15
  116. data/spec/helpers/render_constraints_helper_spec.rb +5 -5
  117. data/spec/helpers/search_history_constraints_helper_spec.rb +21 -21
  118. data/spec/lib/blacklight/routes_spec.rb +25 -0
  119. data/spec/lib/blacklight/solr/request_spec.rb +37 -0
  120. data/spec/lib/blacklight/solr_response/group_response_spec.rb +2 -2
  121. data/spec/lib/blacklight_configurable_spec.rb +16 -16
  122. data/spec/lib/blacklight_configuration_spec.rb +132 -132
  123. data/spec/lib/blacklight_email_spec.rb +4 -4
  124. data/spec/lib/blacklight_sms_spec.rb +4 -4
  125. data/spec/lib/blacklight_solr_document_dublin_core_spec.rb +6 -6
  126. data/spec/lib/blacklight_solr_document_more_like_this_spec.rb +4 -4
  127. data/spec/lib/blacklight_solr_document_spec.rb +36 -36
  128. data/spec/lib/blacklight_solr_response_spec.rb +43 -48
  129. data/spec/lib/blacklight_spec.rb +6 -14
  130. data/spec/lib/blacklight_user_spec.rb +5 -9
  131. data/spec/lib/facet_paginator_spec.rb +59 -51
  132. data/spec/lib/search_fields_spec.rb +13 -13
  133. data/spec/lib/solr_helper_spec.rb +258 -304
  134. data/spec/lib/tasks/blacklight_task_spec.rb +1 -1
  135. data/spec/lib/utils_spec.rb +16 -46
  136. data/spec/models/bookmark_spec.rb +6 -7
  137. data/spec/models/record_mailer_spec.rb +16 -16
  138. data/spec/models/search_spec.rb +8 -8
  139. data/spec/models/solr_document_spec.rb +6 -77
  140. data/spec/routing/catalog_routing_spec.rb +16 -10
  141. data/spec/spec_helper.rb +7 -7
  142. data/spec/support/assert_difference.rb +2 -2
  143. data/spec/support/features.rb +0 -11
  144. data/spec/support/features/session_helpers.rb +3 -3
  145. data/spec/support/include_text.rb +2 -2
  146. data/spec/test_app_templates/Gemfile.extra +10 -2
  147. data/spec/test_app_templates/lib/generators/test_app_generator.rb +12 -18
  148. data/spec/views/catalog/_constraints_element.html.erb_spec.rb +13 -13
  149. data/spec/views/catalog/_document.html.erb_spec.rb +1 -1
  150. data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -1
  151. data/spec/views/catalog/_facets.html.erb_spec.rb +13 -14
  152. data/spec/views/catalog/_index_default.erb_spec.rb +21 -21
  153. data/spec/views/catalog/_search_header.erb_spec.rb +1 -1
  154. data/spec/views/catalog/_show_default.erb_spec.rb +21 -21
  155. data/spec/views/catalog/_show_sidebar.erb_spec.rb +7 -7
  156. data/spec/views/catalog/_thumbnail_default.erb_spec.rb +3 -3
  157. data/spec/views/catalog/index.atom.builder_spec.rb +29 -29
  158. data/spec/views/catalog/index.html.erb_spec.rb +6 -7
  159. data/tasks/blacklight.rake +8 -2
  160. metadata +84 -180
  161. data/app/assets/javascripts/blacklight/css_dropdowns.js +0 -10
  162. data/app/assets/javascripts/blacklight/facet_expand_contract.js +0 -41
  163. data/app/assets/javascripts/blacklight/lightbox_dialog.js +0 -70
  164. data/app/assets/javascripts/blacklight/select_submit.js +0 -27
  165. data/app/assets/javascripts/blacklight/zebra_stripe.js +0 -13
  166. data/app/assets/javascripts/improved-modal/bootstrap-modal.js +0 -355
  167. data/app/assets/javascripts/improved-modal/bootstrap-modalmanager.js +0 -370
  168. data/app/assets/stylesheets/blacklight/_bookmark.scss +0 -33
  169. data/app/assets/stylesheets/blacklight/_catalog.scss +0 -255
  170. data/app/assets/stylesheets/blacklight/_dropdown.scss +0 -57
  171. data/app/assets/stylesheets/blacklight/_facets.scss +0 -197
  172. data/app/assets/stylesheets/blacklight/_footer.scss +0 -0
  173. data/app/assets/stylesheets/blacklight/_header.scss +0 -53
  174. data/app/assets/stylesheets/blacklight/_layout.scss +0 -10
  175. data/app/assets/stylesheets/blacklight/_mixins.scss +0 -0
  176. data/app/assets/stylesheets/blacklight/_print.scss +0 -0
  177. data/app/assets/stylesheets/blacklight/_responsive.scss +0 -3
  178. data/app/assets/stylesheets/blacklight/_search_history.scss +0 -42
  179. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +0 -49
  180. data/app/assets/stylesheets/blacklight/responsive_partials/_catalog.scss +0 -5
  181. data/app/assets/stylesheets/blacklight/responsive_partials/_facets.scss +0 -37
  182. data/app/assets/stylesheets/blacklight/responsive_partials/_header.scss +0 -30
  183. data/app/assets/stylesheets/improved-modal/bootstrap-modal.css +0 -217
  184. data/app/helpers/blacklight/html_head_helper_behavior.rb +0 -118
  185. data/app/helpers/html_head_helper.rb +0 -3
  186. data/app/views/catalog/_bookmark_form.html.erb +0 -7
  187. data/app/views/catalog/_marc_view.html.erb +0 -32
  188. data/app/views/catalog/librarian_view.html.erb +0 -10
  189. data/config/routes.rb +0 -17
  190. data/doc/Atom-Responses.md +0 -90
  191. data/doc/Blacklight-3.0-Release-Notes-And-Upgrade-Guide.md +0 -107
  192. data/doc/Blacklight-3.2-Release-Notes-and-Upgrade-Guide.md +0 -191
  193. data/doc/Blacklight-3.3-release-notes-and-upgrade-guide.md +0 -37
  194. data/doc/Blacklight-3.4-release-notes-and-upgrade-guide.md +0 -27
  195. data/doc/Blacklight-3.5-release-notes-and-upgrade-guide.md +0 -44
  196. data/doc/Blacklight-3.6-release-notes-and-upgrade-guide.md +0 -25
  197. data/doc/Blacklight-3.7-release-notes-and-upgrade-guide.md +0 -80
  198. data/doc/Blacklight-3.8-release-notes-and-upgrade-guide.md +0 -11
  199. data/doc/Blacklight-4.0-release-notes-and-upgrade-guide.md +0 -135
  200. data/doc/Blacklight-4.1-release-notes-and-upgrade-guide.md +0 -17
  201. data/doc/Blacklight-4.2-release-notes-and-upgrade-guide.md +0 -25
  202. data/doc/Blacklight-4.3-release-notes-and-upgrade-guide.md +0 -21
  203. data/doc/Blacklight-4.4-release-notes-and-upgrade-guide.md +0 -41
  204. data/doc/Blacklight-Add-ons.md +0 -28
  205. data/doc/Blacklight-configuration.md +0 -411
  206. data/doc/Blacklight-on-Heroku.md +0 -135
  207. data/doc/Code4Lib-2014.md +0 -48
  208. data/doc/Community-principles.md +0 -44
  209. data/doc/Configuring-and-Customizing-Blacklight.md +0 -271
  210. data/doc/Configuring-rails-routes.md +0 -13
  211. data/doc/Contributing-to-Blacklight.md +0 -25
  212. data/doc/Examples.md +0 -94
  213. data/doc/Extending-or-Modifying-Blacklight-Search-Behavior.md +0 -141
  214. data/doc/FAQs.md +0 -1
  215. data/doc/Home.md +0 -80
  216. data/doc/How-to-release-a-version.md +0 -29
  217. data/doc/Indexing-your-data-into-solr.md +0 -32
  218. data/doc/Integration-with-Rails-Footnotes.md +0 -20
  219. data/doc/Internationalization.md +0 -32
  220. data/doc/JSON-API.md +0 -17
  221. data/doc/Pagination.md +0 -51
  222. data/doc/Providing-your-own-view-templates.md +0 -109
  223. data/doc/Quickstart.md +0 -115
  224. data/doc/README_SOLR.md +0 -245
  225. data/doc/Release-Notes-And-Upgrade-Guides.md +0 -20
  226. data/doc/Roadmap.md +0 -43
  227. data/doc/Sunspot-for-indexing.md +0 -46
  228. data/doc/Theming.md +0 -64
  229. data/doc/User-Authentication.md +0 -60
  230. data/doc/testing.md +0 -57
  231. data/lib/SolrMarc.jar +0 -0
  232. data/lib/blacklight/mash.rb +0 -19
  233. data/lib/blacklight/solr/document/marc.rb +0 -71
  234. data/lib/blacklight/solr/document/marc_export.rb +0 -590
  235. data/lib/generators/blacklight/marc_generator.rb +0 -66
  236. data/lib/generators/blacklight/templates/blacklight.scss +0 -4
  237. data/lib/generators/blacklight/templates/config/SolrMarc/config-test.properties +0 -37
  238. data/lib/generators/blacklight/templates/config/SolrMarc/config.properties +0 -37
  239. data/lib/generators/blacklight/templates/config/SolrMarc/index.properties +0 -97
  240. data/lib/generators/blacklight/templates/config/SolrMarc/index_scripts/dewey.bsh +0 -47
  241. data/lib/generators/blacklight/templates/config/SolrMarc/index_scripts/format.bsh +0 -126
  242. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/README_MAPS +0 -1
  243. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/callnumber_map.properties +0 -407
  244. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/composition_era_map.properties +0 -56
  245. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/country_map.properties +0 -379
  246. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/format_map.properties +0 -50
  247. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/instrument_map.properties +0 -101
  248. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/language_map.properties +0 -490
  249. data/lib/railties/solr_marc.rake +0 -162
  250. data/spec/data/test_data.utf8.mrc +0 -1
  251. data/spec/features/librarian_view_spec.rb +0 -13
  252. data/spec/helpers/html_head_helper_spec.rb +0 -164
  253. data/spec/lib/blacklight_solr_document_marc_spec.rb +0 -89
  254. data/spec/lib/marc_export_spec.rb +0 -746
  255. data/spec/lib/tasks/solr_marc_task_spec.rb +0 -60
  256. data/spec/requests/alternate_controller_spec.rb +0 -16
  257. data/spec/routing/routes_spec.rb +0 -20
  258. data/spec/views/catalog/_constraints.html.erb_spec.rb +0 -33
  259. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +0 -49
  260. data/test_support/data/test_data.utf8.mrc +0 -1
@@ -11,44 +11,18 @@ describe CatalogHelper do
11
11
  start = (current_page - 1) * per_page
12
12
 
13
13
  mock_docs = (1..total).to_a.map { {}.with_indifferent_access }
14
-
14
+
15
15
  mock_response = Kaminari.paginate_array(mock_docs).page(current_page).per(per_page)
16
16
 
17
- allow(mock_response).to receive(:docs).and_return(mock_docs.slice(start, per_page))
17
+ mock_response.stub(:docs).and_return(mock_docs.slice(start, per_page))
18
18
  mock_response
19
19
  end
20
20
 
21
21
  def render_grouped_response?
22
22
  false
23
23
  end
24
-
25
- describe "deprecated methods" do
26
- describe "response_has_no_search_results?" do
27
- it "should be deprecated" do
28
- expect(Blacklight::CatalogHelperBehavior.deprecation_behavior.first).to receive(:call)
29
- assign(:response, double(:empty? => false))
30
- expect(helper.response_has_no_search_results?).to eq false
31
- end
32
- end
33
-
34
- describe "paginate_params" do
35
- let(:response) { double }
36
- it "should be deprecated" do
37
- expect(Blacklight::CatalogHelperBehavior.deprecation_behavior.first).to receive(:call)
38
- assign(:response, response)
39
- expect(helper.paginate_params(response)).to eq response
40
- end
41
- end
42
-
43
- describe "format_num" do
44
- it "should be deprecated" do
45
- expect(Blacklight::CatalogHelperBehavior.deprecation_behavior.first).to receive(:call)
46
- expect(format_num(10000)).to eq '10,000'
47
- end
48
- end
49
-
50
- end
51
-
24
+
25
+
52
26
  describe "page_entries_info" do
53
27
  before(:all) do
54
28
  end
@@ -57,16 +31,16 @@ describe CatalogHelper do
57
31
  @response = mock_response :total => 0
58
32
 
59
33
  html = page_entries_info(@response, { :entry_name => 'entry_name' })
60
- expect(html).to eq("No entry_names found")
61
- expect(html.html_safe?).to eq(true)
34
+ html.should == "No entry_names found"
35
+ html.html_safe?.should == true
62
36
  end
63
37
 
64
38
  it "with no results (and no entry_name provided)" do
65
39
  @response = mock_response :total => 0
66
40
 
67
41
  html = page_entries_info(@response)
68
- expect(html).to eq("No entries found")
69
- expect(html.html_safe?).to eq(true)
42
+ html.should == "No entries found"
43
+ html.html_safe?.should == true
70
44
  end
71
45
 
72
46
  describe "with a single result" do
@@ -74,21 +48,21 @@ describe CatalogHelper do
74
48
  response = mock_response :total => 1
75
49
 
76
50
  html = page_entries_info(response, { :entry_name => 'entry_name' })
77
- expect(html).to eq("<strong>1</strong> entry_name found")
78
- expect(html.html_safe?).to eq(true)
51
+ html.should == "<strong>1</strong> entry_name found"
52
+ html.html_safe?.should == true
79
53
  end
80
54
 
81
55
  it "should infer a name" do
82
56
  response = mock_response :total => 1
83
57
 
84
58
  html = page_entries_info(response)
85
- expect(html).to eq("<strong>1</strong> entry found")
86
- expect(html.html_safe?).to eq(true)
59
+ html.should == "<strong>1</strong> entry found"
60
+ html.html_safe?.should == true
87
61
  end
88
62
 
89
63
  it "should use the model_name from the response" do
90
64
  response = mock_response :total => 1
91
- allow(response).to receive(:model_name).and_return(double(:human => 'thingy'))
65
+ response.stub(:model_name).and_return('thingy')
92
66
 
93
67
  html = page_entries_info(response)
94
68
  expect(html).to eq "<strong>1</strong> thingy found"
@@ -100,139 +74,126 @@ describe CatalogHelper do
100
74
  response = mock_response :total => 7
101
75
 
102
76
  html = page_entries_info(response, { :entry_name => 'entry_name' })
103
- expect(html).to eq("<strong>1</strong> - <strong>7</strong> of <strong>7</strong>")
104
- expect(html.html_safe?).to eq(true)
77
+ html.should == "<strong>1</strong> - <strong>7</strong> of <strong>7</strong>"
78
+ html.html_safe?.should == true
105
79
  end
106
80
 
107
81
  it "on the first page of multiple pages of results" do
108
82
  @response = mock_response :total => 15, :per_page => 10
109
83
 
110
84
  html = page_entries_info(@response, { :entry_name => 'entry_name' })
111
- expect(html).to eq("<strong>1</strong> - <strong>10</strong> of <strong>15</strong>")
112
- expect(html.html_safe?).to eq(true)
85
+ html.should == "<strong>1</strong> - <strong>10</strong> of <strong>15</strong>"
86
+ html.html_safe?.should == true
113
87
  end
114
88
 
115
89
  it "on the second page of multiple pages of results" do
116
90
  @response = mock_response :total => 47, :per_page => 10, :current_page => 2
117
91
 
118
92
  html = page_entries_info(@response, { :entry_name => 'entry_name' })
119
- expect(html).to eq("<strong>11</strong> - <strong>20</strong> of <strong>47</strong>")
120
- expect(html.html_safe?).to eq(true)
93
+ html.should == "<strong>11</strong> - <strong>20</strong> of <strong>47</strong>"
94
+ html.html_safe?.should == true
121
95
  end
122
96
 
123
97
  it "on the last page of results" do
124
98
  @response = mock_response :total => 47, :per_page => 10, :current_page => 5
125
99
 
126
100
  html = page_entries_info(@response, { :entry_name => 'entry_name' })
127
- expect(html).to eq("<strong>41</strong> - <strong>47</strong> of <strong>47</strong>")
128
- expect(html.html_safe?).to eq(true)
101
+ html.should == "<strong>41</strong> - <strong>47</strong> of <strong>47</strong>"
102
+ html.html_safe?.should == true
129
103
  end
130
104
  it "should work with rows the same as per_page" do
131
105
  @response = mock_response :total => 47, :rows => 20, :current_page => 2
132
106
 
133
107
  html = page_entries_info(@response, { :entry_name => 'entry_name' })
134
- expect(html).to eq("<strong>21</strong> - <strong>40</strong> of <strong>47</strong>")
135
- expect(html.html_safe?).to eq(true)
136
- end
137
-
138
- it "uses delimiters with large numbers" do
139
- @response = mock_response :total => 5000, :rows => 10, :current_page => 101
140
- html = page_entries_info(@response, { :entry_name => 'entry_name' })
141
-
142
- expect(html).to eq("<strong>1,001</strong> - <strong>1,010</strong> of <strong>5,000</strong>")
143
- end
144
-
145
- it "should work with an activerecord collection" do
146
- 50.times { b = Bookmark.new; b.user_id = 1; b.save! }
147
- html = helper.page_entries_info(Bookmark.page(1).per(25))
148
- expect(html).to eq "<strong>1</strong> - <strong>25</strong> of <strong>50</strong>"
108
+ html.should == "<strong>21</strong> - <strong>40</strong> of <strong>47</strong>"
109
+ html.html_safe?.should == true
149
110
  end
150
111
 
151
112
  end
152
113
 
153
114
  describe "should_autofocus_on_search_box?" do
154
115
  it "should be focused if we're on a catalog-like index page without query or facet parameters" do
155
- allow(helper).to receive_messages(:controller => CatalogController.new, :action_name => "index", :params => { })
156
- expect(helper.should_autofocus_on_search_box?).to eq true
116
+ helper.stub(:controller => CatalogController.new, :action_name => "index", :params => { })
117
+ expect(helper.should_autofocus_on_search_box?).to be_true
157
118
  end
158
119
 
159
120
  it "should not be focused if we're not on a catalog controller" do
160
- allow(helper).to receive_messages(:controller => ApplicationController.new)
161
- expect(helper.should_autofocus_on_search_box?).to eq false
121
+ helper.stub(:controller => ApplicationController.new)
122
+ expect(helper.should_autofocus_on_search_box?).to be_false
162
123
  end
163
124
 
164
125
  it "should not be focused if we're not on a catalog controller index" do
165
- allow(helper).to receive_messages(:controller => CatalogController.new, :action_name => "show")
166
- expect(helper.should_autofocus_on_search_box?).to eq false
126
+ helper.stub(:controller => CatalogController.new, :action_name => "show")
127
+ expect(helper.should_autofocus_on_search_box?).to be_false
167
128
  end
168
129
 
169
130
  it "should not be focused if a search string is provided" do
170
- allow(helper).to receive_messages(:controller => CatalogController.new, :action_name => "index", :params => { :q => "hello"})
171
- expect(helper.should_autofocus_on_search_box?).to eq false
131
+ helper.stub(:controller => CatalogController.new, :action_name => "index", :params => { :q => "hello"})
132
+ expect(helper.should_autofocus_on_search_box?).to be_false
172
133
  end
173
134
 
174
135
  it "should not be focused if a facet is selected" do
175
- allow(helper).to receive_messages(:controller => CatalogController.new, :action_name => "index", :params => { :f => { "field" => ["value"]}})
176
- expect(helper.should_autofocus_on_search_box?).to eq false
136
+ helper.stub(:controller => CatalogController.new, :action_name => "index", :params => { :f => { "field" => ["value"]}})
137
+ expect(helper.should_autofocus_on_search_box?).to be_false
177
138
  end
178
139
  end
179
140
 
180
141
  describe "has_thumbnail?" do
181
142
  it "should have a thumbnail if a thumbnail_method is configured" do
182
- allow(helper).to receive_messages(:blacklight_config => OpenStruct.new(:index => OpenStruct.new(:thumbnail_method => :xyz) ))
143
+ helper.stub(:blacklight_config => OpenStruct.new(:index => OpenStruct.new(:thumbnail_method => :xyz) ))
183
144
  document = double()
184
- expect(helper.has_thumbnail? document).to be_truthy
145
+ expect(helper.has_thumbnail? document).to be_true
185
146
  end
186
147
 
187
148
  it "should have a thumbnail if a thumbnail_field is configured and it exists in the document" do
188
- allow(helper).to receive_messages(:blacklight_config => OpenStruct.new(:index => OpenStruct.new(:thumbnail_field => :xyz) ))
149
+ helper.stub(:blacklight_config => OpenStruct.new(:index => OpenStruct.new(:thumbnail_field => :xyz) ))
189
150
  document = double(:has? => true)
190
- expect(helper.has_thumbnail? document).to be_truthy
151
+ expect(helper.has_thumbnail? document).to be_true
191
152
  end
192
-
153
+
193
154
  it "should not have a thumbnail if the thumbnail_field is missing from the document" do
194
- allow(helper).to receive_messages(:blacklight_config => OpenStruct.new(:index => OpenStruct.new(:thumbnail_field => :xyz) ))
155
+ helper.stub(:blacklight_config => OpenStruct.new(:index => OpenStruct.new(:thumbnail_field => :xyz) ))
195
156
  document = double(:has? => false)
196
- expect(helper.has_thumbnail? document).to eq false
157
+ expect(helper.has_thumbnail? document).to be_false
197
158
  end
198
159
 
199
160
  it "should not have a thumbnail if none of the fields are configured" do
200
- allow(helper).to receive_messages(:blacklight_config => OpenStruct.new(:index => OpenStruct.new()))
201
- expect(helper.has_thumbnail? double()).to be_falsey
161
+ helper.stub(:blacklight_config => OpenStruct.new(:index => OpenStruct.new()))
162
+ expect(helper.has_thumbnail? double()).to be_false
202
163
  end
203
164
  end
204
165
 
205
166
  describe "render_thumbnail_tag" do
206
167
  it "should call the provided thumbnail method" do
207
- allow(helper).to receive_messages(:blacklight_config => double(:index => double(:thumbnail_method => :xyz)))
168
+ helper.stub(:blacklight_config => double(:index => double(:thumbnail_method => :xyz)))
208
169
  document = double()
209
- allow(helper).to receive_messages(:xyz => "some-thumbnail")
170
+ helper.stub(:xyz => "some-thumbnail")
210
171
 
211
- expect(helper).to receive(:link_to_document).with(document, :label => "some-thumbnail")
172
+ helper.should_receive(:link_to_document).with(document, :label => "some-thumbnail")
212
173
  helper.render_thumbnail_tag document
213
174
  end
214
175
 
215
176
  it "should create an image tag from the given field" do
216
- allow(helper).to receive_messages(:blacklight_config => double(:index => OpenStruct.new(:thumbnail_field => :xyz)))
177
+ helper.stub(:blacklight_config => double(:index => OpenStruct.new(:thumbnail_field => :xyz)))
217
178
  document = double()
218
179
 
219
- allow(document).to receive(:has?).with(:xyz).and_return(true)
220
- allow(document).to receive(:first).with(:xyz).and_return("http://example.com/some.jpg")
180
+ document.stub(:has?).with(:xyz).and_return(true)
181
+ document.stub(:first).with(:xyz).and_return("http://example.com/some.jpg")
221
182
 
222
- expect(helper).to receive(:link_to_document).with(document, :label => image_tag("http://example.com/some.jpg"))
183
+ helper.should_receive(:link_to_document).with(document, :label => image_tag("http://example.com/some.jpg"))
223
184
  helper.render_thumbnail_tag document
224
185
  end
225
186
 
226
187
  it "should return nil if no thumbnail is available" do
227
- allow(helper).to receive_messages(:blacklight_config => double(:index => OpenStruct.new()))
188
+ helper.stub(:blacklight_config => double(:index => OpenStruct.new()))
228
189
 
229
190
  document = double()
230
191
  expect(helper.render_thumbnail_tag document).to be_nil
231
192
  end
232
193
 
233
194
  it "should return nil if no thumbnail is returned from the thumbnail method" do
234
- allow(helper).to receive_messages(:blacklight_config => double(:index => OpenStruct.new(:thumbnail_method => :xyz)))
235
- allow(helper).to receive_messages(:xyz => nil)
195
+ helper.stub(:blacklight_config => double(:index => OpenStruct.new(:thumbnail_method => :xyz)))
196
+ helper.stub(:xyz => nil)
236
197
  document = double()
237
198
 
238
199
  expect(helper.render_thumbnail_tag document).to be_nil
@@ -241,17 +202,17 @@ describe CatalogHelper do
241
202
 
242
203
  describe "thumbnail_url" do
243
204
  it "should pull the configured thumbnail field out of the document" do
244
- allow(helper).to receive_messages(:blacklight_config => double(:index => double(:thumbnail_field => "xyz")))
205
+ helper.stub(:blacklight_config => double(:index => double(:thumbnail_field => "xyz")))
245
206
  document = double()
246
- allow(document).to receive(:has?).with("xyz").and_return(true)
247
- allow(document).to receive(:first).with("xyz").and_return("asdf")
207
+ document.stub(:has?).with("xyz").and_return(true)
208
+ document.stub(:first).with("xyz").and_return("asdf")
248
209
  expect(helper.thumbnail_url document).to eq("asdf")
249
210
  end
250
211
 
251
212
  it "should return nil if the thumbnail field doesn't exist" do
252
- allow(helper).to receive_messages(:blacklight_config => double(:index => double(:thumbnail_field => "xyz")))
213
+ helper.stub(:blacklight_config => double(:index => double(:thumbnail_field => "xyz")))
253
214
  document = double()
254
- allow(document).to receive(:has?).with("xyz").and_return(false)
215
+ document.stub(:has?).with("xyz").and_return(false)
255
216
  expect(helper.thumbnail_url document).to be_nil
256
217
  end
257
218
  end
@@ -1,15 +1,14 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
- require 'nokogiri'
4
3
  require 'equivalent-xml'
5
4
 
6
5
  describe FacetsHelper do
7
6
  let(:blacklight_config) { Blacklight::Configuration.new }
8
7
 
9
8
  before(:each) do
10
- allow(helper).to receive(:blacklight_config).and_return blacklight_config
9
+ helper.stub(:blacklight_config).and_return blacklight_config
11
10
  end
12
-
11
+
13
12
  describe "has_facet_values?" do
14
13
  it "should be true if there are any facets to display" do
15
14
 
@@ -18,7 +17,7 @@ describe FacetsHelper do
18
17
  empty = double(:items => [])
19
18
 
20
19
  fields = [a,b,empty]
21
- expect(helper.has_facet_values?(fields)).to be_truthy
20
+ helper.has_facet_values?(fields).should be_true
22
21
  end
23
22
 
24
23
  it "should be false if all facets are empty" do
@@ -26,7 +25,7 @@ describe FacetsHelper do
26
25
  empty = double(:items => [])
27
26
 
28
27
  fields = [empty]
29
- expect(helper.has_facet_values?(fields)).not_to be_truthy
28
+ helper.has_facet_values?(fields).should_not be_true
30
29
  end
31
30
  end
32
31
 
@@ -34,49 +33,23 @@ describe FacetsHelper do
34
33
  before do
35
34
  @config = Blacklight::Configuration.new do |config|
36
35
  config.add_facet_field 'basic_field'
37
- config.add_facet_field 'no_show', :show => false
38
- config.add_facet_field 'helper_show', :show => :my_helper
39
- config.add_facet_field 'helper_with_an_arg_show', :show => :my_helper_with_an_arg
40
- config.add_facet_field 'lambda_show', :show => lambda { |context, config, field| true }
41
- config.add_facet_field 'lambda_no_show', :show => lambda { |context, config, field| false }
36
+ config.add_facet_field 'no_show', :show=>false
42
37
  end
43
38
 
44
- allow(helper).to receive_messages(:blacklight_config => @config)
39
+ helper.stub(:blacklight_config => @config)
45
40
  end
46
-
47
41
  it "should render facets with items" do
48
42
  a = double(:items => [1,2], :name=>'basic_field')
49
- expect(helper.should_render_facet?(a)).to eq(true)
43
+ helper.should_render_facet?(a).should == true
50
44
  end
51
45
  it "should not render facets without items" do
52
46
  empty = double(:items => [], :name=>'basic_field')
53
- expect(helper.should_render_facet?(empty)).to eq(false)
47
+ helper.should_render_facet?(empty).should == false
54
48
  end
55
49
 
56
50
  it "should not render facets where show is set to false" do
57
51
  a = double(:items => [1,2], :name=>'no_show')
58
- expect(helper.should_render_facet?(a)).to eq(false)
59
- end
60
-
61
- it "should call a helper to determine if it should render a field" do
62
- allow(helper).to receive_messages(:my_helper => true)
63
- a = double(:items => [1,2], :name=>'helper_show')
64
- expect(helper.should_render_facet?(a)).to eq true
65
- end
66
-
67
- it "should call a helper to determine if it should render a field" do
68
- a = double(:items => [1,2], :name=>'helper_with_an_arg_show')
69
- expect(helper).to receive(:my_helper_with_an_arg).with(a).and_return(true)
70
- expect(helper.should_render_facet?(a)).to eq true
71
- end
72
-
73
-
74
- it "should evaluate a Proc to determine if it should render a field" do
75
- a = double(:items => [1,2], :name=>'lambda_show')
76
- expect(helper.should_render_facet?(a)).to eq true
77
-
78
- a = double(:items => [1,2], :name=>'lambda_no_show')
79
- expect(helper.should_render_facet?(a)).to eq false
52
+ helper.should_render_facet?(a).should == false
80
53
  end
81
54
  end
82
55
 
@@ -84,24 +57,24 @@ describe FacetsHelper do
84
57
  it "should retrieve the facet from the response given a string" do
85
58
  facet_config = double(:query => nil)
86
59
  facet_field = double()
87
- expect(helper).to receive(:facet_configuration_for_field).with(anything()).and_return(facet_config)
60
+ helper.should_receive(:facet_configuration_for_field).with(anything()).and_return(facet_config)
88
61
 
89
62
  @response = double()
90
- expect(@response).to receive(:facet_by_field_name).with('a').and_return(facet_field)
63
+ @response.should_receive(:facet_by_field_name).with('a').and_return(facet_field)
91
64
 
92
- expect(helper.facet_by_field_name('a')).to eq(facet_field)
65
+ helper.facet_by_field_name('a').should == facet_field
93
66
  end
94
67
 
95
68
  it "should also work for facet query fields" do
96
69
  facet_config = double(:query => {})
97
- expect(helper).to receive(:facet_configuration_for_field).with('a_query_facet_field').and_return(facet_config)
98
- expect(helper).to receive(:create_rsolr_facet_field_response_for_query_facet_field).with('a_query_facet_field', facet_config)
70
+ helper.should_receive(:facet_configuration_for_field).with('a_query_facet_field').and_return(facet_config)
71
+ helper.should_receive(:create_rsolr_facet_field_response_for_query_facet_field).with('a_query_facet_field', facet_config)
99
72
 
100
73
  helper.facet_by_field_name 'a_query_facet_field'
101
74
  end
102
75
 
103
76
  describe "query facets" do
104
- let(:facet_config) {
77
+ let(:facet_config) {
105
78
  double(
106
79
  :query => {
107
80
  'a_simple_query' => { :fq => 'field:search', :label => 'A Human Readable label'},
@@ -112,7 +85,7 @@ describe FacetsHelper do
112
85
  }
113
86
 
114
87
  before(:each) do
115
- expect(helper).to receive(:facet_configuration_for_field).with(anything()).and_return(facet_config)
88
+ helper.should_receive(:facet_configuration_for_field).with(anything()).and_return(facet_config)
116
89
 
117
90
  @response = double(:facet_queries => {
118
91
  'field:search' => 10,
@@ -124,17 +97,17 @@ describe FacetsHelper do
124
97
 
125
98
  it"should convert the query facets into a double RSolr FacetField" do
126
99
  field = helper.facet_by_field_name('my_query_facet_field')
127
- expect(field).to be_a_kind_of Blacklight::SolrResponse::Facets::FacetField
100
+ field.should be_a_kind_of Blacklight::SolrResponse::Facets::FacetField
128
101
 
129
- expect(field.name).to eq('my_query_facet_field')
130
- expect(field.items.length).to eq(2)
131
- expect(field.items.map { |x| x.value }).not_to include 'field:not_appearing_in_the_config'
102
+ field.name.should == 'my_query_facet_field'
103
+ field.items.length.should == 2
104
+ field.items.map { |x| x.value }.should_not include 'field:not_appearing_in_the_config'
132
105
 
133
106
  facet_item = field.items.select { |x| x.value == 'a_simple_query' }.first
134
107
 
135
- expect(facet_item.value).to eq('a_simple_query')
136
- expect(facet_item.hits).to eq(10)
137
- expect(facet_item.label).to eq('A Human Readable label')
108
+ facet_item.value.should == 'a_simple_query'
109
+ facet_item.hits.should == 10
110
+ facet_item.label.should == 'A Human Readable label'
138
111
  end
139
112
  end
140
113
 
@@ -143,24 +116,24 @@ describe FacetsHelper do
143
116
  double(:pivot => ['field_a', 'field_b'])
144
117
  }
145
118
 
146
- before(:each) do
147
- expect(helper).to receive(:facet_configuration_for_field).with(anything()).and_return(facet_config)
148
-
119
+ before(:each) do
120
+ helper.should_receive(:facet_configuration_for_field).with(anything()).and_return(facet_config)
121
+
149
122
  @response = double(:facet_pivot => { 'field_a,field_b' => [{:field => 'field_a', :value => 'a', :count => 10, :pivot => [{:field => 'field_b', :value => 'b', :count => 2}]}]})
150
123
  end
151
124
 
152
125
  it "should convert the pivot facet into a double RSolr FacetField" do
153
126
  field = helper.facet_by_field_name('my_pivot_facet_field')
154
- expect(field).to be_a_kind_of Blacklight::SolrResponse::Facets::FacetField
127
+ field.should be_a_kind_of Blacklight::SolrResponse::Facets::FacetField
155
128
 
156
- expect(field.name).to eq('my_pivot_facet_field')
129
+ field.name.should == 'my_pivot_facet_field'
157
130
 
158
- expect(field.items.length).to eq(1)
131
+ field.items.length.should == 1
159
132
 
160
- expect(field.items.first).to respond_to(:items)
133
+ field.items.first.should respond_to(:items)
161
134
 
162
- expect(field.items.first.items.length).to eq(1)
163
- expect(field.items.first.items.first.fq).to eq({ 'field_a' => 'a' })
135
+ field.items.first.items.length.should == 1
136
+ field.items.first.items.first.fq.should == { 'field_a' => 'a' }
164
137
  end
165
138
  end
166
139
  end
@@ -174,9 +147,9 @@ describe FacetsHelper do
174
147
 
175
148
  fields = [a,b,empty]
176
149
 
177
- expect(helper).to receive(:render_facet_limit).with(a, {})
178
- expect(helper).to receive(:render_facet_limit).with(b, {})
179
- expect(helper).to receive(:render_facet_limit).with(empty, {})
150
+ helper.should_receive(:render_facet_limit).with(a, {})
151
+ helper.should_receive(:render_facet_limit).with(b, {})
152
+ helper.should_receive(:render_facet_limit).with(empty, {})
180
153
 
181
154
  helper.render_facet_partials fields
182
155
  end
@@ -184,10 +157,10 @@ describe FacetsHelper do
184
157
  it "should default to the configured facets" do
185
158
  a = double(:items => [1,2])
186
159
  b = double(:items => ['b','c'])
187
- expect(helper).to receive(:facet_field_names) { [a,b] }
160
+ helper.should_receive(:facet_field_names) { [a,b] }
188
161
 
189
- expect(helper).to receive(:render_facet_limit).with(a, {})
190
- expect(helper).to receive(:render_facet_limit).with(b, {})
162
+ helper.should_receive(:render_facet_limit).with(a, {})
163
+ helper.should_receive(:render_facet_limit).with(b, {})
191
164
 
192
165
  helper.render_facet_partials
193
166
  end
@@ -204,16 +177,15 @@ describe FacetsHelper do
204
177
  config.add_facet_field 'my_facet_field_with_custom_partial', :partial => 'custom_facet_partial'
205
178
  end
206
179
 
207
- allow(helper).to receive_messages(:blacklight_config => @config)
180
+ helper.stub(:blacklight_config => @config)
208
181
  @response = double()
209
182
  end
210
183
 
211
184
  it "should set basic local variables" do
212
185
  @mock_facet = double(:name => 'basic_field', :items => [1,2,3])
213
- expect(helper).to receive(:render).with(hash_including(:partial => 'facet_limit',
214
- :locals => {
186
+ helper.should_receive(:render).with(hash_including(:partial => 'facet_limit',
187
+ :locals => {
215
188
  :solr_field => 'basic_field',
216
- :solr_fname => 'basic_field',
217
189
  :facet_field => helper.blacklight_config.facet_fields['basic_field'],
218
190
  :display_facet => @mock_facet }
219
191
  ))
@@ -222,46 +194,39 @@ describe FacetsHelper do
222
194
 
223
195
  it "should render a facet _not_ declared in the configuration" do
224
196
  @mock_facet = double(:name => 'asdf', :items => [1,2,3])
225
- expect(helper).to receive(:render).with(hash_including(:partial => 'facet_limit'))
197
+ helper.should_receive(:render).with(hash_including(:partial => 'facet_limit'))
226
198
  helper.render_facet_limit(@mock_facet)
227
199
  end
228
200
 
229
201
  it "should get the partial name from the configuration" do
230
202
  @mock_facet = double(:name => 'my_facet_field_with_custom_partial', :items => [1,2,3])
231
- expect(helper).to receive(:render).with(hash_including(:partial => 'custom_facet_partial'))
203
+ helper.should_receive(:render).with(hash_including(:partial => 'custom_facet_partial'))
232
204
  helper.render_facet_limit(@mock_facet)
233
- end
205
+ end
234
206
 
235
207
  it "should use a partial layout for rendering the facet frame" do
236
208
  @mock_facet = double(:name => 'my_facet_field_with_custom_partial', :items => [1,2,3])
237
- expect(helper).to receive(:render).with(hash_including(:layout => 'facet_layout'))
209
+ helper.should_receive(:render).with(hash_including(:layout => 'facet_layout'))
238
210
  helper.render_facet_limit(@mock_facet)
239
211
  end
240
212
 
241
213
  it "should allow the caller to opt-out of facet layouts" do
242
214
  @mock_facet = double(:name => 'my_facet_field_with_custom_partial', :items => [1,2,3])
243
- expect(helper).to receive(:render).with(hash_including(:layout => nil))
215
+ helper.should_receive(:render).with(hash_including(:layout => nil))
244
216
  helper.render_facet_limit(@mock_facet, :layout => nil)
245
217
  end
246
218
 
247
219
  it "should render the facet_pivot partial for pivot facets" do
248
220
  @mock_facet = double(:name => 'pivot_facet_field', :items => [1,2,3])
249
- expect(helper).to receive(:render).with(hash_including(:partial => 'facet_pivot'))
221
+ helper.should_receive(:render).with(hash_including(:partial => 'facet_pivot'))
250
222
  helper.render_facet_limit(@mock_facet)
251
- end
223
+ end
252
224
 
253
225
  it "should let you override the rendered partial for pivot facets" do
254
226
  @mock_facet = double(:name => 'my_pivot_facet_field_with_custom_partial', :items => [1,2,3])
255
- expect(helper).to receive(:render).with(hash_including(:partial => 'custom_facet_partial'))
227
+ helper.should_receive(:render).with(hash_including(:partial => 'custom_facet_partial'))
256
228
  helper.render_facet_limit(@mock_facet)
257
- end
258
-
259
- it "should be deprecated when a string is passed" do
260
- expect(@response).to receive(:facet_by_field_name)
261
- expect(Blacklight::FacetsHelperBehavior.deprecation_behavior.first).to receive(:call)
262
- helper.render_facet_limit('basic_field')
263
- end
264
-
229
+ end
265
230
  end
266
231
 
267
232
  describe "add_facet_params" do
@@ -271,84 +236,84 @@ describe FacetsHelper do
271
236
  end
272
237
 
273
238
  it "should add facet value for no pre-existing facets" do
274
- allow(helper).to receive(:params).and_return(@params_no_existing_facet)
239
+ helper.stub(:params).and_return(@params_no_existing_facet)
275
240
 
276
241
  result_params = helper.add_facet_params("facet_field", "facet_value")
277
- expect(result_params[:f]).to be_a_kind_of(Hash)
278
- expect(result_params[:f]["facet_field"]).to be_a_kind_of(Array)
279
- expect(result_params[:f]["facet_field"]).to eq(["facet_value"])
242
+ result_params[:f].should be_a_kind_of(Hash)
243
+ result_params[:f]["facet_field"].should be_a_kind_of(Array)
244
+ result_params[:f]["facet_field"].should == ["facet_value"]
280
245
  end
281
246
 
282
247
  it "should add a facet param to existing facet constraints" do
283
- allow(helper).to receive(:params).and_return(@params_existing_facets)
284
-
248
+ helper.stub(:params).and_return(@params_existing_facets)
249
+
285
250
  result_params = helper.add_facet_params("facet_field_2", "new_facet_value")
286
251
 
287
- expect(result_params[:f]).to be_a_kind_of(Hash)
252
+ result_params[:f].should be_a_kind_of(Hash)
288
253
 
289
254
  @params_existing_facets[:f].each_pair do |facet_field, value_list|
290
- expect(result_params[:f][facet_field]).to be_a_kind_of(Array)
291
-
255
+ result_params[:f][facet_field].should be_a_kind_of(Array)
256
+
292
257
  if facet_field == 'facet_field_2'
293
- expect(result_params[:f][facet_field]).to eq(@params_existing_facets[:f][facet_field] | ["new_facet_value"])
258
+ result_params[:f][facet_field].should == (@params_existing_facets[:f][facet_field] | ["new_facet_value"])
294
259
  else
295
- expect(result_params[:f][facet_field]).to eq(@params_existing_facets[:f][facet_field])
296
- end
260
+ result_params[:f][facet_field].should == @params_existing_facets[:f][facet_field]
261
+ end
297
262
  end
298
263
  end
299
264
  it "should leave non-facet params alone" do
300
265
  [@params_existing_facets, @params_no_existing_facet].each do |params|
301
- allow(helper).to receive(:params).and_return(params)
266
+ helper.stub(:params).and_return(params)
302
267
 
303
268
  result_params = helper.add_facet_params("facet_field_2", "new_facet_value")
304
269
 
305
270
  params.each_pair do |key, value|
306
271
  next if key == :f
307
- expect(result_params[key]).to eq(params[key])
308
- end
272
+ result_params[key].should == params[key]
273
+ end
309
274
  end
310
- end
275
+ end
311
276
 
312
277
  it "should replace facets for facets configured as single" do
313
- expect(helper).to receive(:facet_configuration_for_field).with('single_value_facet_field').and_return(double(:single => true))
278
+ helper.should_receive(:facet_configuration_for_field).with('single_value_facet_field').and_return(double(:single => true))
314
279
  params = { :f => { 'single_value_facet_field' => 'other_value'}}
315
- allow(helper).to receive(:params).and_return params
280
+ helper.stub(:params).and_return params
316
281
 
317
282
  result_params = helper.add_facet_params('single_value_facet_field', 'my_value')
318
283
 
319
284
 
320
- expect(result_params[:f]['single_value_facet_field'].length).to eq(1)
321
- expect(result_params[:f]['single_value_facet_field'].first).to eq('my_value')
285
+ result_params[:f]['single_value_facet_field'].length.should == 1
286
+ result_params[:f]['single_value_facet_field'].first.should == 'my_value'
322
287
  end
323
288
 
324
289
  it "should accept a FacetItem instead of a plain facet value" do
325
-
290
+
326
291
  result_params = helper.add_facet_params('facet_field_1', double(:value => 123))
327
292
 
328
- expect(result_params[:f]['facet_field_1']).to include(123)
293
+ result_params[:f]['facet_field_1'].should include(123)
329
294
  end
330
295
 
331
296
  it "should defer to the field set on a FacetItem" do
332
-
297
+
333
298
  result_params = helper.add_facet_params('facet_field_1', double(:field => 'facet_field_2', :value => 123))
334
299
 
335
- expect(result_params[:f]['facet_field_1']).to be_blank
336
- expect(result_params[:f]['facet_field_2']).to include(123)
300
+ result_params[:f]['facet_field_1'].should be_blank
301
+ result_params[:f]['facet_field_2'].should include(123)
337
302
  end
338
303
 
339
304
  it "should add any extra fq parameters from the FacetItem" do
340
-
305
+
341
306
  result_params = helper.add_facet_params('facet_field_1', double(:value => 123, :fq => {'facet_field_2' => 'abc'}))
342
307
 
343
- expect(result_params[:f]['facet_field_1']).to include(123)
344
- expect(result_params[:f]['facet_field_2']).to include('abc')
308
+ result_params[:f]['facet_field_1'].should include(123)
309
+ result_params[:f]['facet_field_2'].should include('abc')
345
310
  end
346
311
  end
347
312
 
348
313
  describe "add_facet_params_and_redirect" do
349
314
  before do
350
- catalog_facet_params = {:q => "query",
351
- :search_field => "search_field",
315
+ catalog_facet_params = {:q => "query",
316
+ :search_field => "search_field",
352
317
  :per_page => "50",
353
318
  :page => "5",
354
319
  :f => {"facet_field_1" => ["value1"], "facet_field_2" => ["value2", "value2a"]},
@@ -356,25 +321,25 @@ describe FacetsHelper do
356
321
  Blacklight::Solr::FacetPaginator.request_keys[:sort] => "index",
357
322
  :id => 'facet_field_name'
358
323
  }
359
- allow(helper).to receive(:params).and_return(catalog_facet_params)
324
+ helper.stub(:params).and_return(catalog_facet_params)
360
325
  end
361
326
  it "should redirect to 'index' action" do
362
327
  params = helper.add_facet_params_and_redirect("facet_field_2", "facet_value")
363
328
 
364
- expect(params[:action]).to eq("index")
329
+ params[:action].should == "index"
365
330
  end
366
331
  it "should not include request parameters used by the facet paginator" do
367
332
  params = helper.add_facet_params_and_redirect("facet_field_2", "facet_value")
368
333
 
369
334
  bad_keys = Blacklight::Solr::FacetPaginator.request_keys.values + [:id]
370
335
  bad_keys.each do |paginator_key|
371
- expect(params.keys).not_to include(paginator_key)
336
+ params.keys.should_not include(paginator_key)
372
337
  end
373
338
  end
374
339
  it 'should remove :page request key' do
375
340
  params = helper.add_facet_params_and_redirect("facet_field_2", "facet_value")
376
341
 
377
- expect(params.keys).not_to include(:page)
342
+ params.keys.should_not include(:page)
378
343
  end
379
344
  it "should otherwise do the same thing as add_facet_params" do
380
345
  added_facet_params = helper.add_facet_params("facet_field_2", "facet_value")
@@ -382,8 +347,8 @@ describe FacetsHelper do
382
347
 
383
348
  added_facet_params_from_facet_action.each_pair do |key, value|
384
349
  next if key == :action
385
- expect(value).to eq(added_facet_params[key])
386
- end
350
+ value.should == added_facet_params[key]
351
+ end
387
352
  end
388
353
  end
389
354
 
@@ -393,9 +358,9 @@ describe FacetsHelper do
393
358
 
394
359
  describe "facet_field_in_params?" do
395
360
  it "should check if the facet field is selected in the user params" do
396
- allow(helper).to receive_messages(:params => { :f => { "some-field" => ["x"]}})
397
- expect(helper.facet_field_in_params?("some-field")).to be_truthy
398
- expect(helper.facet_field_in_params?("other-field")).to_not be_truthy
361
+ helper.stub(:params => { :f => { "some-field" => ["x"]}})
362
+ expect(helper.facet_field_in_params?("some-field")).to be_true
363
+ expect(helper.facet_field_in_params?("other-field")).to_not be_true
399
364
  end
400
365
  end
401
366
 
@@ -404,54 +369,67 @@ describe FacetsHelper do
404
369
  end
405
370
 
406
371
  describe "render_facet_value" do
407
- it "should use facet_display_value" do
408
- allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(double(:query => nil, :date => nil, :helper_method => nil, :single => false))
409
-
410
- expect(helper).to receive(:facet_display_value).and_return('Z')
411
- expect(helper).to receive(:add_facet_params_and_redirect).and_return('link')
412
- expected = Nokogiri::HTML "<a class=\"facet_select\" href=\"link\">Z</a> <span class=\"count\">10</span>"
413
- rendered = Nokogiri::HTML helper.render_facet_value('simple_field', double(:value => 'A', :hits => 10))
414
-
415
- expect(rendered).to be_equivalent_to(expected).respecting_element_order
372
+ let (:item) { double(:value => 'A', :hits => 10) }
373
+ before do
374
+ helper.stub(:facet_configuration_for_field).with('simple_field').and_return(double(:query => nil, :date => nil, :helper_method => nil, :single => false))
375
+ helper.should_receive(:facet_display_value).and_return('Z')
376
+ helper.should_receive(:add_facet_params_and_redirect).and_return({controller:'catalog'})
377
+ end
378
+ describe "simple case" do
379
+ let(:expected_html) { "<span class=\"facet-label\"><a class=\"facet_select\" href=\"/\">Z</a></span><span class=\"facet-count\">10</span>" }
380
+ it "should use facet_display_value" do
381
+ result = helper.render_facet_value('simple_field', item)
382
+ expect(result).to be_equivalent_to(expected_html).respecting_element_order
383
+ end
416
384
  end
417
385
 
386
+ describe "when :suppress_link is set" do
387
+ let(:expected_html) { "<span class=\"facet-label\">Z</span><span class=\"facet-count\">10</span>" }
388
+ it "should suppress the link" do
389
+ result = helper.render_facet_value('simple_field', item, :suppress_link => true)
390
+ expect(result).to be_equivalent_to(expected_html).respecting_element_order
391
+ end
392
+ end
418
393
 
419
- it "should suppress the link" do
420
- allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(double(:query => nil, :date => nil, :helper_method => nil, :single => false))
394
+ describe "when a route_set is passed" do
395
+ let(:my_engine) { double("Engine") }
396
+ let(:expected_html) { "<span class=\"facet-label\"><a class=\"facet_select\" href=\"/\">Z</a></span><span class=\"facet-count\">10</span>" }
421
397
 
422
- expect(helper).to receive(:facet_display_value).and_return('Z')
423
- expect(helper).to receive(:add_facet_params_and_redirect).and_return('link')
424
- expect(helper.render_facet_value('simple_field', double(:value => 'A', :hits => 10), :suppress_link => true)).to eq("Z <span class=\"count\">10</span>")
398
+ it "should use the engine scope" do
399
+ expect(my_engine).to receive(:url_for).and_return({controller: 'catalog'})
400
+ result = helper.render_facet_value('simple_field', item, route_set: my_engine)
401
+ expect(result).to be_equivalent_to(expected_html).respecting_element_order
402
+ end
425
403
  end
426
404
  end
427
-
405
+
428
406
  describe "#facet_display_value" do
429
407
  it "should just be the facet value for an ordinary facet" do
430
- allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(double(:query => nil, :date => nil, :helper_method => nil))
431
- expect(helper.facet_display_value('simple_field', 'asdf')).to eq('asdf')
408
+ helper.stub(:facet_configuration_for_field).with('simple_field').and_return(double(:query => nil, :date => nil, :helper_method => nil))
409
+ helper.facet_display_value('simple_field', 'asdf').should == 'asdf'
432
410
  end
433
411
 
434
412
  it "should allow you to pass in a :helper_method argument to the configuration" do
435
- allow(helper).to receive(:facet_configuration_for_field).with('helper_field').and_return(double(:query => nil, :date => nil, :helper_method => :my_facet_value_renderer))
436
-
437
- expect(helper).to receive(:my_facet_value_renderer).with('qwerty').and_return('abc')
413
+ helper.stub(:facet_configuration_for_field).with('helper_field').and_return(double(:query => nil, :date => nil, :helper_method => :my_facet_value_renderer))
414
+
415
+ helper.should_receive(:my_facet_value_renderer).with('qwerty').and_return('abc')
438
416
 
439
- expect(helper.facet_display_value('helper_field', 'qwerty')).to eq('abc')
417
+ helper.facet_display_value('helper_field', 'qwerty').should == 'abc'
440
418
  end
441
419
 
442
420
  it "should extract the configuration label for a query facet" do
443
- allow(helper).to receive(:facet_configuration_for_field).with('query_facet').and_return(double(:query => { 'query_key' => { :label => 'XYZ'}}, :date => nil, :helper_method => nil))
444
- expect(helper.facet_display_value('query_facet', 'query_key')).to eq('XYZ')
421
+ helper.stub(:facet_configuration_for_field).with('query_facet').and_return(double(:query => { 'query_key' => { :label => 'XYZ'}}, :date => nil, :helper_method => nil))
422
+ helper.facet_display_value('query_facet', 'query_key').should == 'XYZ'
445
423
  end
446
424
 
447
425
  it "should localize the label for date-type facets" do
448
- allow(helper).to receive(:facet_configuration_for_field).with('date_facet').and_return(double('date' => true, :query => nil, :helper_method => nil))
449
- expect(helper.facet_display_value('date_facet', '2012-01-01')).to eq('Sun, 01 Jan 2012 00:00:00 +0000')
426
+ helper.stub(:facet_configuration_for_field).with('date_facet').and_return(double('date' => true, :query => nil, :helper_method => nil))
427
+ helper.facet_display_value('date_facet', '2012-01-01').should == 'Sun, 01 Jan 2012 00:00:00 +0000'
450
428
  end
451
429
 
452
430
  it "should localize the label for date-type facets with the supplied localization options" do
453
- allow(helper).to receive(:facet_configuration_for_field).with('date_facet').and_return(double('date' => { :format => :short }, :query => nil, :helper_method => nil))
454
- expect(helper.facet_display_value('date_facet', '2012-01-01')).to eq('01 Jan 00:00')
431
+ helper.stub(:facet_configuration_for_field).with('date_facet').and_return(double('date' => { :format => :short }, :query => nil, :helper_method => nil))
432
+ helper.facet_display_value('date_facet', '2012-01-01').should == '01 Jan 00:00'
455
433
  end
456
434
  end
457
435
  end