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
@@ -15,26 +15,26 @@ describe SearchHistoryController do
15
15
  session[:history] = [@one.id, @three.id]
16
16
  get :index
17
17
  @searches = assigns(:searches)
18
- expect(@searches.length).to eq(2)
19
- expect(@searches).to include(@one)
20
- expect(@searches).to include(@three)
21
- expect(@searches).not_to include(@two)
18
+ @searches.length.should == 2
19
+ @searches.should include(@one)
20
+ @searches.should include(@three)
21
+ @searches.should_not include(@two)
22
22
  end
23
23
 
24
24
  it "should tolerate bad ids in session" do
25
25
  session[:history] = [@one.id, @three.id, "NOT_IN_DB"]
26
26
  get :index
27
27
  @searches = assigns(:searches)
28
- expect(@searches.length).to eq(2)
29
- expect(@searches).to include(@one)
30
- expect(@searches).to include(@three)
28
+ @searches.length.should == 2
29
+ @searches.should include(@one)
30
+ @searches.should include(@three)
31
31
  end
32
32
 
33
33
  it "should not fetch any searches if there is no history" do
34
34
  session[:history] = []
35
35
  get :index
36
36
  @searches = assigns(:searches)
37
- expect(@searches.length).to eq(0)
37
+ @searches.length.should == 0
38
38
  end
39
39
  end
40
40
 
@@ -3,19 +3,19 @@ require 'spec_helper'
3
3
  describe "Alternate Controller Behaviors" do
4
4
  it "should have the correct per-page form" do
5
5
  visit alternate_index_path
6
- expect(page).to have_selector("form[action='#{alternate_index_path}']")
6
+ page.should have_selector("form[action='#{alternate_index_path}']")
7
7
  fill_in "q", :with=>"history"
8
8
  click_button 'search'
9
9
  expect(current_path).to match /#{alternate_index_path}/
10
- within ("#per_page-dropdown") do
11
- click_link '20 per page'
10
+ within "#per_page-dropdown .dropdown-menu" do
11
+ click_on '10 per page'
12
12
  end
13
13
  expect(current_path).to match /#{alternate_index_path}/
14
14
  end
15
15
 
16
16
  it "should have the correct search field form" do
17
17
  visit alternate_index_path
18
- expect(page).to have_selector("form[action='#{alternate_index_path}']")
18
+ page.should have_selector("form[action='#{alternate_index_path}']")
19
19
  fill_in "q", :with=>"history"
20
20
  click_button 'search'
21
21
  expect(current_path).to match /#{alternate_index_path}/
@@ -25,7 +25,7 @@ describe "Alternate Controller Behaviors" do
25
25
 
26
26
  it "should display document thumbnails" do
27
27
  visit alternate_index_path
28
- expect(page).to have_selector("form[action='#{alternate_index_path}']")
28
+ page.should have_selector("form[action='#{alternate_index_path}']")
29
29
  fill_in "q", :with=>"history"
30
30
  click_button 'search'
31
31
  expect(page).to have_selector ".document-thumbnail"
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Facets" do
4
+ it "should show a single facet's values" do
5
+ visit catalog_facet_path("language_facet")
6
+ expect(page).to have_selector(".modal-title", :text => "Language")
7
+ expect(page).to have_selector(".facet_select", :text => "Tibetan")
8
+ end
9
+ end
@@ -34,7 +34,7 @@ describe "Record View" do
34
34
  end
35
35
  it "should not display 404" do
36
36
  visit catalog_path('this_id_does_not_exist')
37
- expect(page.driver.status_code).to eq(404)
37
+ page.driver.status_code.should == 404
38
38
  expect(page).to have_content "Sorry, you have requested a record that doesn't exist."
39
39
  end
40
40
  end
@@ -3,25 +3,32 @@ require 'spec_helper'
3
3
  describe "Facets" do
4
4
  it "should work without a search term" do
5
5
  visit root_path
6
- within 'div.blacklight-language_facet' do
6
+ within '#facet-language' do
7
7
  click_link "Tibetan"
8
8
  end
9
9
  within "#sortAndPerPage" do
10
10
  expect(page).to have_content "1 - 6 of 6"
11
11
  end
12
- within("div.blacklight-language_facet") do
13
- expect(page).to have_selector("span.selected", :text => "Tibetan 6")
12
+
13
+ expect(page).to have_selector(".blacklight-language_facet")
14
+ expect(page).to have_selector(".blacklight-language_facet.facet_limit-active")
15
+
16
+ within "#facet-language" do
17
+ expect(page).to have_selector("span.selected", :text => "Tibetan")
18
+ expect(page).to have_selector("span.facet-count.selected", :text => "6")
14
19
  end
15
20
 
16
21
  click_link "India"
17
22
  within ("#sortAndPerPage") do
18
23
  expect(page).to have_content "1 - 2 of 2"
19
24
  end
20
- within("div.blacklight-language_facet") do
21
- expect(page).to have_selector("span.selected", :text => "Tibetan 2")
25
+ within "#facet-language" do
26
+ expect(page).to have_selector("span.selected", :text => "Tibetan")
27
+ expect(page).to have_selector("span.facet-count.selected", :text => "2")
22
28
  end
23
- within(".blacklight-subject_geo_facet") do
24
- expect(page).to have_selector("span.selected", :text => "India 2")
29
+ within "#facet-region" do
30
+ expect(page).to have_selector("span.selected", :text => "India")
31
+ expect(page).to have_selector("span.facet-count.selected", :text => "2")
25
32
  end
26
33
  end
27
34
 
@@ -33,14 +40,15 @@ describe "Facets" do
33
40
  expect(page).to have_content "1 - 9 of 9"
34
41
  end
35
42
 
36
- within "div.blacklight-language_facet" do
43
+ within "#facet-language" do
37
44
  click_link "Tibetan"
38
45
  end
39
46
  within ("#sortAndPerPage") do
40
47
  expect(page).to have_content "1 - 2 of 2"
41
48
  end
42
- within("div.blacklight-language_facet") do
43
- expect(page).to have_selector("span.selected", :text => "Tibetan 2")
49
+ within "#facet-language" do
50
+ expect(page).to have_selector("span.selected", :text => "Tibetan")
51
+ expect(page).to have_selector("span.facet-count.selected", :text => "2")
44
52
  end
45
53
  within "#appliedParams" do
46
54
  expect(page).to have_content "You searched for:"
@@ -52,23 +60,26 @@ describe "Facets" do
52
60
  within ("#sortAndPerPage") do
53
61
  expect(page).to have_content "1 entry found"
54
62
  end
55
- within("div.blacklight-language_facet") do
56
- expect(page).to have_selector("span.selected", :text => "Tibetan 1")
63
+ within "#facet-language" do
64
+ expect(page).to have_selector("span.selected", :text => "Tibetan")
65
+ expect(page).to have_selector("span.facet-count.selected", :text => "1")
57
66
  end
58
- within(".blacklight-pub_date") do
59
- expect(page).to have_selector("span.selected", :text => "2004 1")
67
+ within(".blacklight-pub_date") do
68
+ expect(page).to have_selector("span.selected", :text => "2004")
69
+ expect(page).to have_selector("span.facet-count.selected", :text => "1")
60
70
  end
61
71
  end
62
72
 
63
73
  it "should allow removing filters" do
64
74
  visit root_path
65
- within "div.blacklight-language_facet" do
75
+ within "#facet-language" do
66
76
  click_link "Tibetan"
67
77
  end
68
- within("div.blacklight-language_facet") do
69
- expect(page).to have_selector("span.selected", :text => "Tibetan 6")
78
+ within "#facet-language" do
79
+ expect(page).to have_selector("span.selected", :text => "Tibetan")
80
+ expect(page).to have_selector("span.facet-count.selected", :text => "6")
70
81
  end
71
- within("div.blacklight-language_facet") do
82
+ within "#facet-language" do
72
83
  click_link 'remove'
73
84
  end
74
85
  expect(page).to_not have_link 'remove'
@@ -79,29 +90,34 @@ describe "Facets" do
79
90
  visit root_path
80
91
  fill_in "q", with: 'history'
81
92
  click_button 'search'
82
- within "div.blacklight-language_facet" do
83
- click_link "Tibetan"
93
+ within "#facet-language" do
94
+ click_link 'Tibetan'
84
95
  end
85
- within("div.blacklight-language_facet") do
86
- expect(page).to have_selector("span.selected", :text => "Tibetan 2")
96
+ within "#facet-language" do
97
+ expect(page).to have_selector("span.selected", :text => "Tibetan")
98
+ expect(page).to have_selector("span.facet-count.selected", :text => "2")
87
99
  end
88
100
 
89
101
  click_link '2004'
90
102
 
91
- within("div.blacklight-language_facet") do
92
- expect(page).to have_selector("span.selected", :text => "Tibetan 1")
103
+ within "#facet-language" do
104
+ expect(page).to have_selector("span.selected", :text => "Tibetan")
105
+ expect(page).to have_selector("span.facet-count.selected", :text => "1")
93
106
  end
94
- within(".blacklight-pub_date") do
95
- expect(page).to have_selector("span.selected", :text => "2004 1")
107
+ within(".blacklight-pub_date") do
108
+ expect(page).to have_selector("span.selected", :text => "2004")
109
+ expect(page).to have_selector("span.facet-count.selected", :text => "1")
96
110
  end
97
111
  fill_in "q", with: 'china'
98
112
  click_button 'search'
99
113
 
100
- within("div.blacklight-language_facet") do
101
- expect(page).to have_selector("span.selected", :text => "Tibetan 1")
114
+ within "#facet-language" do
115
+ expect(page).to have_selector("span.selected", :text => "Tibetan")
116
+ expect(page).to have_selector("span.facet-count.selected", :text => "1")
102
117
  end
103
- within(".blacklight-pub_date") do
104
- expect(page).to have_selector("span.selected", :text => "2004 1")
118
+ within(".blacklight-pub_date") do
119
+ expect(page).to have_selector("span.selected", :text => "2004")
120
+ expect(page).to have_selector("span.facet-count.selected", :text => "1")
105
121
  end
106
122
  end
107
123
 
@@ -109,15 +125,17 @@ describe "Facets" do
109
125
  visit root_path
110
126
  fill_in "q", with: 'history'
111
127
  click_button 'search'
112
- within("div.blacklight-language_facet") do
128
+ within "#facet-language" do
113
129
  click_link 'Tibetan'
114
130
  end
115
- within("div.blacklight-language_facet") do
116
- expect(page).to have_selector("span.selected", :text => "Tibetan 2")
131
+ within "#facet-language" do
132
+ expect(page).to have_selector("span.selected", :text => "Tibetan")
133
+ expect(page).to have_selector("span.facet-count.selected", :text => "2")
117
134
  end
118
135
  click_link 'title'
119
- within("div.blacklight-language_facet") do
120
- expect(page).to have_selector("span.selected", :text => "Tibetan 2")
136
+ within "#facet-language" do
137
+ expect(page).to have_selector("span.selected", :text => "Tibetan")
138
+ expect(page).to have_selector("span.facet-count.selected", :text => "2")
121
139
  end
122
140
  within "#appliedParams" do
123
141
  expect(page).to have_content "You searched for:"
@@ -129,22 +147,60 @@ describe "Facets" do
129
147
  visit root_path
130
148
  fill_in "q", with: 'history'
131
149
  click_button 'search'
132
-
133
- within("div.blacklight-language_facet") do
150
+ within "#facet-language" do
134
151
  click_link 'Tibetan'
135
152
  end
136
- within("div.blacklight-language_facet") do
137
- expect(page).to have_selector("span.selected", :text => "Tibetan 2")
153
+ within "#facet-language" do
154
+ expect(page).to have_selector("span.selected", :text => "Tibetan")
155
+ expect(page).to have_selector("span.facet-count.selected", :text => "2")
138
156
  end
139
157
  within '#per_page-dropdown' do
140
158
  click_link '20'
141
159
  end
142
- within("div.blacklight-language_facet") do
143
- expect(page).to have_selector("span.selected", :text => "Tibetan 2")
160
+ within "#facet-language" do
161
+ expect(page).to have_selector("span.selected", :text => "Tibetan")
162
+ expect(page).to have_selector("span.facet-count.selected", :text => "2")
144
163
  end
145
164
  within "#appliedParams" do
146
165
  expect(page).to have_content "You searched for:"
147
166
  expect(page).to have_content "history"
148
167
  end
149
168
  end
169
+ it "should be collapsed when not selected", :js => true do
170
+ pending("Test passes locally but not on Travis.")
171
+ visit root_path
172
+ within(".blacklight-subject_topic_facet") do
173
+ expect(page).not_to have_selector(".panel-collapse", :visible => true)
174
+ end
175
+ end
176
+ it "should expand when the heading is clicked", :js => true do
177
+ pending("Test passes locally but not on Travis.")
178
+ visit root_path
179
+ within(".blacklight-subject_topic_facet") do
180
+ expect(page).not_to have_selector(".panel-collapse", :visible => true)
181
+ find(".panel-heading").click
182
+ expect(page).to have_selector(".panel-collapse", :visible => true)
183
+ end
184
+ end
185
+ it "should expand when the anchor is clicked", :js => true do
186
+ pending("Test passes locally but not on Travis.")
187
+ visit root_path
188
+ within(".blacklight-subject_topic_facet") do
189
+ expect(page).not_to have_selector(".panel-collapse", :visible => true)
190
+ click_link "Topic"
191
+ expect(page).to have_selector(".panel-collapse", :visible => true)
192
+ end
193
+ end
194
+ it "should keep selected facets expanded on page load", :js => true do
195
+ pending("Test passes locally but not on Travis.")
196
+ visit root_path
197
+ within(".blacklight-subject_topic_facet") do
198
+ click_link "Topic"
199
+ expect(page).to have_selector(".panel-collapse", :visible => true)
200
+ click_link "Japanese drama"
201
+ end
202
+ within(".blacklight-subject_topic_facet") do
203
+ expect(page).to have_selector(".panel-collapse", :visible => true)
204
+ end
205
+ end
150
206
  end
@@ -4,34 +4,34 @@ require 'spec_helper'
4
4
  describe "Search Results" do
5
5
  it "should have for an empty query" do
6
6
  search_for ''
7
- expect(number_of_results_from_page(page)).to eq(30)
8
- expect(page).to have_xpath("//a[contains(@href, #{2007020969})]")
7
+ number_of_results_from_page(page).should == 30
8
+ page.should have_xpath("//a[contains(@href, #{2007020969})]")
9
9
  search_for 'korea'
10
- expect(number_of_results_from_page(page)).to eq(4)
10
+ number_of_results_from_page(page).should == 4
11
11
  end
12
12
 
13
13
  it "should find same result set with or without diacritcs" do
14
14
  search_for 'inmul'
15
- expect(number_of_results_from_page(page)).to eq(1)
16
- expect(page).to have_xpath("//a[contains(@href, #{77826928})]")
15
+ number_of_results_from_page(page).should == 1
16
+ page.should have_xpath("//a[contains(@href, #{77826928})]")
17
17
 
18
18
  search_for 'inmül'
19
- expect(number_of_results_from_page(page)).to eq(1)
19
+ number_of_results_from_page(page).should == 1
20
20
  end
21
21
  it "should find same result set for a case-insensitive query " do
22
22
  search_for 'inmul'
23
- expect(number_of_results_from_page(page)).to eq(1)
24
- expect(page).to have_xpath("//a[contains(@href, #{77826928})]")
23
+ number_of_results_from_page(page).should == 1
24
+ page.should have_xpath("//a[contains(@href, #{77826928})]")
25
25
 
26
26
  search_for 'INMUL'
27
- expect(number_of_results_from_page(page)).to eq(1)
27
+ number_of_results_from_page(page).should == 1
28
28
  end
29
29
 
30
30
  it "should order by relevancy" do
31
31
  search_for "Korea"
32
- expect(position_in_result_page(page, '77826928')).to eq(1)
33
- expect(position_in_result_page(page, '94120425')).to eq(2)
34
-
32
+ position_in_result_page(page, '77826928').should == 1
33
+ position_in_result_page(page, '94120425').should == 2
34
+
35
35
  end
36
36
 
37
37
  it "should have an opensearch description document" do
@@ -49,10 +49,7 @@ describe "Search Results" do
49
49
  end
50
50
 
51
51
  it "should pass the current search id through", :js => true do
52
- pending
53
- visit root_path
54
- fill_in "q", with: ''
55
- click_button 'search'
52
+ search_for ''
56
53
  search_id = Search.last.id.to_s
57
54
  click_on 'Pluvial nectar of blessings'
58
55
  expect(page).to have_content "« Previous | 10 of 30 | Next »"
@@ -83,7 +80,7 @@ def position_in_result_page(page, id)
83
80
  end
84
81
  i.to_i
85
82
  end
86
-
83
+
87
84
  def number_of_results_for_query(query)
88
85
  visit root_path
89
86
  fill_in "q", :with => query
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe "Search Sort" do
4
4
  it "should sort on facet results with no search terms" do
5
5
  visit root_path
6
- within("div.blacklight-language_facet") do
6
+ within "#facet-language" do
7
7
  click_link 'English'
8
8
  end
9
9
  expect(page).to have_content 'Sort by relevance'
@@ -1,4 +1,3 @@
1
- #ste -*- encoding : utf-8 -*-
2
1
  # -*- coding: UTF-8 -*-
3
2
  require 'spec_helper'
4
3
 
@@ -82,7 +81,7 @@ describe BlacklightHelper do
82
81
  end
83
82
 
84
83
  before(:each) do
85
- allow(helper).to receive(:search_action_url) do |*args|
84
+ helper.stub(:search_action_url) do |*args|
86
85
  catalog_index_url *args
87
86
  end
88
87
  end
@@ -91,221 +90,157 @@ describe BlacklightHelper do
91
90
 
92
91
  end
93
92
 
94
- describe "deprecated methods" do
95
- describe "#index_field_names" do
96
- it "should warn" do
97
- expect(Blacklight::BlacklightHelperBehavior.deprecation_behavior.first).to receive(:call)
98
- allow(helper).to receive_messages(:index_fields => {})
99
- helper.index_field_names
100
- end
101
- end
102
- describe "#index_field_labels" do
103
- it "should warn" do
104
- expect(Blacklight::BlacklightHelperBehavior.deprecation_behavior.first).to receive(:call)
105
- allow(helper).to receive_messages(:index_fields => {})
106
- helper.index_field_labels
107
- end
108
- end
109
- describe "#document_show_field_labels" do
110
- it "should warn" do
111
- expect(Blacklight::BlacklightHelperBehavior.deprecation_behavior.first).to receive(:call)
112
- allow(helper).to receive_messages(:document_show_fields => {})
113
- helper.document_show_field_labels
114
- end
115
- end
116
-
117
- describe "#render_document_list_partial" do
118
- it "should warn" do
119
- expect(Blacklight::BlacklightHelperBehavior.deprecation_behavior.first).to receive(:call)
120
- allow(helper).to receive(:render)
121
- helper.render_document_list_partial
122
- end
123
- end
124
- end
125
-
126
93
  describe "#application_name", :test => true do
127
94
  it "should use the Rails application config application_name if available" do
128
- allow(Rails.application.config).to receive_messages(:application_name => 'asdf')
129
- expect(Rails.application.config).to receive(:respond_to?).with(:application_name).and_return(true)
130
- expect(application_name).to eq('asdf')
95
+ Rails.application.config.stub(:application_name => 'asdf')
96
+ Rails.application.config.should_receive(:respond_to?).with(:application_name).and_return(true)
97
+ application_name.should == 'asdf'
131
98
  end
132
99
  it "should default to 'Blacklight'" do
133
- expect(application_name).to eq("Blacklight")
100
+ application_name.should == "Blacklight"
134
101
  end
135
102
  end
136
103
 
137
104
  describe "link_back_to_catalog" do
138
- before(:all) do
139
- @query_params = {:q => "query", :f => "facets", :per_page => "10", :page => "2", :controller=>'catalog'}
140
- @bookmarks_query_params = { :page => "2", :controller=>'bookmarks'}
141
- end
105
+ let(:query_params) {{:q => "query", :f => "facets", :per_page => "10", :page => "2", :controller=>'catalog'}}
106
+ let(:bookmarks_query_params) {{ :page => "2", :controller=>'bookmarks'}}
142
107
 
143
108
  it "should build a link tag to catalog using session[:search] for query params" do
144
- allow(helper).to receive(:current_search_session).and_return double(:query_params => @query_params)
109
+ helper.stub(:current_search_session).and_return double(:query_params => query_params)
145
110
  tag = helper.link_back_to_catalog
146
- expect(tag).to match(/q=query/)
147
- expect(tag).to match(/f=facets/)
148
- expect(tag).to match(/per_page=10/)
149
- expect(tag).to match(/page=2/)
111
+ tag.should =~ /q=query/
112
+ tag.should =~ /f=facets/
113
+ tag.should =~ /per_page=10/
114
+ tag.should =~ /page=2/
150
115
  end
151
116
 
152
117
  it "should build a link tag to bookmarks using session[:search] for query params" do
153
- allow(helper).to receive(:current_search_session).and_return double(:query_params => @bookmarks_query_params)
118
+ helper.stub(:current_search_session).and_return double(:query_params => bookmarks_query_params)
154
119
  tag = helper.link_back_to_catalog
155
- expect(tag).to match(/Back to Bookmarks/)
156
- expect(tag).to match(/\/bookmarks/)
157
- expect(tag).to match(/page=2/)
120
+ tag.should =~ /Back to Bookmarks/
121
+ tag.should =~ /\/bookmarks/
122
+ tag.should =~ /page=2/
123
+ end
124
+
125
+ describe "when an alternate scope is passed in" do
126
+ let(:my_engine) { double("Engine") }
127
+
128
+ it "should call url_for on the engine scope" do
129
+ helper.stub(:current_search_session).and_return double(:query_params => query_params)
130
+ expect(my_engine).to receive(:url_for).and_return(url_for(query_params))
131
+ tag = helper.link_back_to_catalog(route_set: my_engine)
132
+ tag.should =~ /Back to Search/
133
+ tag.should =~ /q=query/
134
+ tag.should =~ /f=facets/
135
+ tag.should =~ /per_page=10/
136
+ tag.should =~ /page=2/
137
+ end
158
138
  end
159
139
  end
160
140
 
161
141
  describe "link_to_query" do
162
142
  it "should build a link tag to catalog using query string (no other params)" do
163
143
  query = "brilliant"
164
- expect(self).to receive(:params).and_return({})
144
+ self.should_receive(:params).and_return({})
165
145
  tag = link_to_query(query)
166
- expect(tag).to match(/q=#{query}/)
167
- expect(tag).to match(/>#{query}<\/a>/)
146
+ tag.should =~ /q=#{query}/
147
+ tag.should =~ />#{query}<\/a>/
168
148
  end
169
149
  it "should build a link tag to catalog using query string and other existing params" do
170
150
  query = "wonderful"
171
- expect(self).to receive(:params).and_return({:qt => "title_search", :per_page => "50"})
151
+ self.should_receive(:params).and_return({:qt => "title_search", :per_page => "50"})
172
152
  tag = link_to_query(query)
173
- expect(tag).to match(/qt=title_search/)
174
- expect(tag).to match(/per_page=50/)
153
+ tag.should =~ /qt=title_search/
154
+ tag.should =~ /per_page=50/
175
155
  end
176
156
  it "should ignore existing :page param" do
177
157
  query = "yes"
178
- expect(self).to receive(:params).and_return({:page => "2", :qt => "author_search"})
158
+ self.should_receive(:params).and_return({:page => "2", :qt => "author_search"})
179
159
  tag = link_to_query(query)
180
- expect(tag).to match(/qt=author_search/)
181
- expect(tag).not_to match(/page/)
160
+ tag.should =~ /qt=author_search/
161
+ tag.should_not =~ /page/
182
162
  end
183
163
  it "should be html_safe" do
184
164
  query = "brilliant"
185
- expect(self).to receive(:params).and_return({:page => "2", :qt => "author_search"})
165
+ self.should_receive(:params).and_return({:page => "2", :qt => "author_search"})
186
166
  tag = link_to_query(query)
187
- expect(tag.html_safe?).to eq(true)
188
- end
189
- end
190
-
191
- describe "sanitize_search_params" do
192
- it "should strip nil values" do
193
- result = sanitize_search_params(:a => nil, :b => 1)
194
- expect(result).to_not have_key(:a)
195
- expect(result[:b]).to eq 1
196
- end
197
-
198
- it "should remove blacklisted keys" do
199
- result = sanitize_search_params(:action => true, :controller => true, :id => true, :commit => true, :utf8 => true)
200
- expect(result).to be_empty
167
+ tag.html_safe?.should == true
201
168
  end
202
169
  end
203
170
 
204
171
  describe "params_for_search" do
205
- around(:each) do |example|
206
- Deprecation.silence(Blacklight::BlacklightHelperBehavior) { example.run }
207
- end
208
-
209
172
  def params
210
173
  { 'default' => 'params'}
211
174
  end
212
175
 
213
176
  it "should default to using the controller's params" do
214
177
  result = params_for_search
215
- expect(result).to eq(params)
216
- expect(params.object_id).not_to eq(result.object_id)
178
+ result.should == params
179
+ params.object_id.should_not == result.object_id
217
180
  end
218
181
 
219
182
  it "should let you pass in params to use" do
220
- source_params = { :q => 'query'}
221
- result = params_for_search(source_params, {})
222
- expect(source_params).to eq(result)
223
- expect(source_params.object_id).not_to eq(result.object_id)
224
- end
225
-
226
- it "should let you pass in params to use (the deprecated way)" do
227
183
  source_params = { :q => 'query'}
228
184
  result = params_for_search(:params => source_params )
229
- expect(source_params).to eq(result)
230
- expect(source_params.object_id).not_to eq(result.object_id)
231
- end
232
-
233
-
234
- it "should let you pass in params to merge into the controller's params" do
235
- source_params = { :q => 'query'}
236
- result = params_for_search( source_params )
237
- expect(result).to include(:q => 'query', 'default' => 'params')
185
+ source_params.should == result
186
+ source_params.object_id.should_not == result.object_id
238
187
  end
239
188
 
240
189
  it "should not return blacklisted elements" do
241
190
  source_params = { :action => 'action', :controller => 'controller', :id => "id", :commit => 'commit'}
242
- result = params_for_search(source_params, {} )
243
- expect(result.keys).not_to include(:action, :controller, :commit, :id)
191
+ result = params_for_search(:params => source_params )
192
+ result.keys.should_not include(:action, :controller, :commit, :id)
244
193
 
245
194
  end
246
195
 
247
196
  it "should adjust the current page if the per_page changes" do
248
197
  source_params = { :per_page => 20, :page => 5}
249
- result = params_for_search(source_params, :per_page => 100)
250
- expect(result[:page]).to eq(1)
198
+ result = params_for_search(:params => source_params, :per_page => 100)
199
+ result[:page].should == 1
251
200
  end
252
201
 
253
202
  it "should not adjust the current page if the per_page is the same as it always was" do
254
203
  source_params = { :per_page => 20, :page => 5}
255
- result = params_for_search(source_params, :per_page => 20)
256
- expect(result[:page]).to eq(5)
204
+ result = params_for_search(:params => source_params, :per_page => 20)
205
+ result[:page].should == 5
257
206
  end
258
207
 
259
208
  it "should adjust the current page if the sort changes" do
260
209
  source_params = { :sort => 'field_a', :page => 5}
261
- result = params_for_search(source_params, :sort => 'field_b')
262
- expect(result[:page]).to eq(1)
210
+ result = params_for_search(:params => source_params, :sort => 'field_b')
211
+ result[:page].should == 1
263
212
  end
264
213
 
265
214
  it "should not adjust the current page if the sort is the same as it always was" do
266
215
  source_params = { :sort => 'field_a', :page => 5}
267
- result = params_for_search(source_params, :sort => 'field_a')
268
- expect(result[:page]).to eq(5)
216
+ result = params_for_search(:params => source_params, :sort => 'field_a')
217
+ result[:page].should == 5
269
218
  end
270
219
 
271
220
  describe "omit keys parameter" do
272
221
  it "should omit keys by key name" do
273
222
  source_params = { :a => 1, :b => 2, :c => 3}
274
- result = params_for_search(source_params, :omit_keys => [:a, :b] )
223
+ result = params_for_search(:params => source_params, :omit_keys => [:a, :b] )
275
224
 
276
- expect(result.keys).not_to include(:a, :b)
277
- expect(result[:c]).to eq(3)
225
+ result.keys.should_not include(:a, :b)
226
+ result[:c].should == 3
278
227
  end
279
228
 
280
229
  it "should remove keys if a key/value pair was passed and no values are left for that key" do
281
230
  source_params = { :f => ['a']}
282
- result = params_for_search(source_params, :omit_keys => [{:f => 'a' }])
283
- expect(result.keys).not_to include(:f)
231
+ result = params_for_search(:params => source_params, :omit_keys => [{:f => 'a' }])
232
+ result.keys.should_not include(:f)
284
233
  end
285
234
 
286
235
  it "should only remove keys when a key/value pair is based that are in that pair" do
287
236
 
288
237
  source_params = { :f => ['a', 'b']}
289
- result = params_for_search(source_params, :omit_keys => [{:f => 'a' }])
290
- expect(result[:f]).not_to include('a')
291
- expect(result[:f]).to include('b')
238
+ result = params_for_search(:params => source_params, :omit_keys => [{:f => 'a' }])
239
+ result[:f].should_not include('a')
240
+ result[:f].should include('b')
292
241
  end
293
242
  end
294
243
 
295
- describe "params_for_search with a block" do
296
- it "should evalute the block and allow it to add or remove keys" do
297
- result = params_for_search({:a => 1, :b => 2}, :c => 3) do |params|
298
- params.except! :a, :b
299
- params[:d] = 'd'
300
- end
301
-
302
- expect(result.keys).not_to include(:a, :b)
303
- expect(result[:c]).to eq 3
304
- expect(result[:d]).to eq 'd'
305
- end
306
-
307
- end
308
-
309
244
  end
310
245
 
311
246
  describe "search_as_hidden_fields" do
@@ -314,9 +249,7 @@ describe BlacklightHelper do
314
249
  end
315
250
  describe "for default arguments" do
316
251
  it "should default to omitting :page" do
317
- Deprecation.silence(Blacklight::BlacklightHelperBehavior) do
318
- expect(search_as_hidden_fields).not_to have_selector("input[name='page']")
319
- end
252
+ search_as_hidden_fields.should_not have_selector("input[name='page']")
320
253
  end
321
254
  end
322
255
  end
@@ -325,18 +258,18 @@ describe BlacklightHelper do
325
258
  describe "render body class" do
326
259
  it "should include a serialization of the current controller name" do
327
260
  @controller = double("controller")
328
- allow(@controller).to receive(:controller_name).and_return("123456")
329
- allow(@controller).to receive(:action_name).and_return("abcdef")
261
+ @controller.stub(:controller_name).and_return("123456")
262
+ @controller.stub(:action_name).and_return("abcdef")
330
263
 
331
- expect(render_body_class.split(' ')).to include('blacklight-123456')
264
+ render_body_class.split(' ').should include('blacklight-123456')
332
265
  end
333
266
 
334
267
  it "should include a serialization of the current action name" do
335
268
  @controller = double("controller")
336
- allow(@controller).to receive(:controller_name).and_return("123456")
337
- allow(@controller).to receive(:action_name).and_return("abcdef")
269
+ @controller.stub(:controller_name).and_return("123456")
270
+ @controller.stub(:action_name).and_return("abcdef")
338
271
 
339
- expect(render_body_class.split(' ')).to include('blacklight-123456-abcdef')
272
+ render_body_class.split(' ').should include('blacklight-123456-abcdef')
340
273
  end
341
274
  end
342
275
 
@@ -345,12 +278,12 @@ describe BlacklightHelper do
345
278
  it "should consist of the show heading field when available" do
346
279
  @document = SolrDocument.new('title_display' => "A Fake Document")
347
280
 
348
- expect(document_heading).to eq("A Fake Document")
281
+ document_heading.should == "A Fake Document"
349
282
  end
350
283
 
351
284
  it "should fallback on the document id if no title is available" do
352
285
  @document = SolrDocument.new(:id => '123456')
353
- expect(document_heading).to eq('123456')
286
+ document_heading.should == '123456'
354
287
  end
355
288
  end
356
289
 
@@ -358,97 +291,77 @@ describe BlacklightHelper do
358
291
  it "should consist of #document_heading wrapped in a <h1>" do
359
292
  @document = SolrDocument.new('title_display' => "A Fake Document")
360
293
 
361
- expect(render_document_heading).to have_selector("h4", :text => "A Fake Document", :count => 1)
362
- expect(render_document_heading.html_safe?).to eq(true)
294
+ render_document_heading.should have_selector("h4", :text => "A Fake Document", :count => 1)
295
+ render_document_heading.html_safe?.should == true
363
296
  end
364
297
  it "should join the values if it is an array" do
365
298
  @document = SolrDocument.new('title_display' => ["A Fake Document", 'Something Else'])
366
299
 
367
- expect(render_document_heading).to have_selector("h4", :text => "A Fake Document, Something Else", :count => 1)
368
- expect(render_document_heading.html_safe?).to eq(true)
300
+ render_document_heading.should have_selector("h4", :text => "A Fake Document, Something Else", :count => 1)
301
+ render_document_heading.html_safe?.should == true
369
302
  end
370
303
  end
371
304
 
372
305
  describe "document_show_html_title" do
373
306
  it "should join the values if it is an array" do
374
307
  @document = SolrDocument.new('title_display' => ["A Fake Document", 'Something Else'])
375
- expect(document_show_html_title).to eq("A Fake Document, Something Else")
308
+ document_show_html_title.should == "A Fake Document, Something Else"
376
309
  end
377
310
  end
378
311
 
379
312
  describe "document_index_view_type" do
380
313
  it "should default to 'list'" do
381
- expect(document_index_view_type).to eq('list')
314
+ document_index_view_type.should == 'list'
382
315
  end
383
316
 
384
317
  it "should pluck values out of params" do
385
- allow(blacklight_config).to receive(:document_index_view_types) { ['list', 'asdf'] }
318
+ blacklight_config.stub(:document_index_view_types) { ['list', 'asdf'] }
386
319
  params[:view] = 'asdf'
387
- expect(document_index_view_type).to eq('asdf')
320
+ document_index_view_type.should == 'asdf'
388
321
 
389
322
  params[:view] = 'not_in_list'
390
- expect(document_index_view_type).to eq('list')
391
- end
392
-
393
- it "should pluck values from supplied params" do
394
- allow(blacklight_config).to receive(:document_index_view_types) { ['list', 'asdf'] }
395
- params[:view] = 'asdf'
396
- expect(document_index_view_type(:view => 'list')).to eq 'list'
323
+ document_index_view_type.should == 'list'
397
324
  end
398
325
  end
399
326
 
400
- describe "start_over_path" do
401
- it 'should be the catalog path with the current view type' do
402
- allow(blacklight_config).to receive(:document_index_view_types) { ['list', 'abc'] }
403
- allow(helper).to receive_messages(:blacklight_config => blacklight_config)
404
- expect(helper.start_over_path(:view => 'abc')).to eq catalog_index_url(:view => 'abc')
405
- end
406
-
407
- it 'should not include the current view type if it is the default' do
408
- allow(blacklight_config).to receive(:document_index_view_types) { ['list', 'abc'] }
409
- allow(helper).to receive_messages(:blacklight_config => blacklight_config)
410
- expect(helper.start_over_path(:view => 'list')).to eq catalog_index_url
411
- end
412
- end
413
-
414
327
  describe "render_document_index" do
415
328
  it "should render the document_list" do
416
329
  @document_list = ['a', 'b']
417
- expect(self).to receive(:render).with(hash_including(:partial => 'document_gallery'))
330
+ self.should_receive(:render).with(hash_including(:partial => 'document_gallery'))
418
331
  render_document_index_with_view 'gallery', @document_list
419
332
  end
420
333
 
421
334
  it "should fall back on more specific templates" do
422
335
  ex = ActionView::MissingTemplate.new [], '', '', '',''
423
- expect(self).to receive(:render).with(hash_including(:partial => 'document_gallery')).and_raise(ex)
424
- expect(self).to receive(:render).with(hash_including(:partial => 'catalog/document_gallery')).and_raise(ex)
425
- expect(self).to receive(:render).with(hash_including(:partial => 'catalog/document_list'))
336
+ self.should_receive(:render).with(hash_including(:partial => 'document_gallery')).and_raise(ex)
337
+ self.should_receive(:render).with(hash_including(:partial => 'catalog/document_gallery')).and_raise(ex)
338
+ self.should_receive(:render).with(hash_including(:partial => 'catalog/document_list'))
426
339
  render_document_index_with_view 'gallery', @document_list
427
340
  end
428
341
  end
429
342
 
430
343
  describe "document_partial_name" do
431
344
  it "should default to 'default' when a format blank" do
432
- expect(document_partial_name({})).to eq("default")
345
+ document_partial_name({}).should == "default"
433
346
  end
434
347
  it "should handle normal formats correctly" do
435
- expect(document_partial_name({"format" => "myformat"})).to eq("myformat")
348
+ document_partial_name({"format" => "myformat"}).should == "myformat"
436
349
  end
437
350
  it "should handle spaces correctly" do
438
- expect(document_partial_name({"format" => "my format"})).to eq("my_format")
351
+ document_partial_name({"format" => "my format"}).should == "my_format"
439
352
  end
440
353
  it "should handle capitalization correctly" do
441
- expect(document_partial_name({"format" => "MyFormat"})).to eq("myformat")
354
+ document_partial_name({"format" => "MyFormat"}).should == "myformat"
442
355
  end
443
356
  it "should handle puncuation correctly" do
444
- expect(document_partial_name({"format" => "My.Format"})).to eq("my_format")
357
+ document_partial_name({"format" => "My.Format"}).should == "my_format"
445
358
  end
446
359
  it "should handle multi-valued fields correctly" do
447
- expect(document_partial_name({"format" => ["My Format", "My OtherFormat"]})).to eq("my_format_my_otherformat")
360
+ document_partial_name({"format" => ["My Format", "My OtherFormat"]}).should == "my_format_my_otherformat"
448
361
  end
449
362
  it "should remove - characters because they will throw errors" do
450
- expect(document_partial_name({"format" => "My-Format"})).to eq("my_format")
451
- expect(document_partial_name({"format" => ["My-Format",["My Other-Format"]]})).to eq("my_format_my_other_format")
363
+ document_partial_name({"format" => "My-Format"}).should == "my_format"
364
+ document_partial_name({"format" => ["My-Format",["My Other-Format"]]}).should == "my_format_my_other_format"
452
365
  end
453
366
  end
454
367
 
@@ -456,45 +369,45 @@ describe BlacklightHelper do
456
369
  it "should consist of the document title wrapped in a <a>" do
457
370
  data = {'id'=>'123456','title_display'=>['654321'] }
458
371
  @document = SolrDocument.new(data)
459
- expect(link_to_document(@document, { :label => :title_display })).to have_selector("a", :text => '654321', :count => 1)
372
+ link_to_document(@document, { :label => :title_display }).should have_selector("a", :text => '654321', :count => 1)
460
373
  end
461
374
  it "should accept and return a string label" do
462
375
  data = {'id'=>'123456','title_display'=>['654321'] }
463
376
  @document = SolrDocument.new(data)
464
- expect(link_to_document(@document, { :label => "title_display" })).to have_selector("a", :text => 'title_display', :count => 1)
377
+ link_to_document(@document, { :label => "title_display" }).should have_selector("a", :text => 'title_display', :count => 1)
465
378
  end
466
379
 
467
380
  it "should accept and return a Proc" do
468
381
  data = {'id'=>'123456','title_display'=>['654321'] }
469
382
  @document = SolrDocument.new(data)
470
- expect(link_to_document(@document, { :label => Proc.new { |doc, opts| doc.get(:id) + ": " + doc.get(:title_display) } })).to have_selector("a", :text => '123456: 654321', :count => 1)
383
+ link_to_document(@document, { :label => Proc.new { |doc, opts| doc.get(:id) + ": " + doc.get(:title_display) } }).should have_selector("a", :text => '123456: 654321', :count => 1)
471
384
  end
472
385
  it "should return id when label is missing" do
473
386
  data = {'id'=>'123456'}
474
387
  @document = SolrDocument.new(data)
475
- expect(link_to_document(@document, { :label => :title_display })).to have_selector("a", :text => '123456', :count => 1)
388
+ link_to_document(@document, { :label => :title_display }).should have_selector("a", :text => '123456', :count => 1)
476
389
  end
477
390
 
478
391
  it "should be html safe" do
479
392
  data = {'id'=>'123456'}
480
393
  @document = SolrDocument.new(data)
481
- expect(link_to_document(@document, { :label => :title_display }).html_safe?).to eq(true)
394
+ link_to_document(@document, { :label => :title_display }).html_safe?.should == true
482
395
  end
483
396
 
484
397
  it "should convert the counter parameter into a data- attribute" do
485
398
  data = {'id'=>'123456','title_display'=>['654321']}
486
399
  @document = SolrDocument.new(data)
487
- expect(link_to_document(@document, { :label => :title_display, :counter => 5 })).to match(/data-counter="5"/)
400
+ link_to_document(@document, { :label => :title_display, :counter => 5 }).should =~ /data-counter="5"/
488
401
  end
489
402
 
490
403
  it "passes on the title attribute to the link_to_with_data method" do
491
404
  @document = SolrDocument.new('id'=>'123456')
492
- expect(link_to_document(@document,:label=>"Some crazy long label...",:title=>"Some crazy longer label")).to match(/title=\"Some crazy longer label\"/)
405
+ link_to_document(@document,:label=>"Some crazy long label...",:title=>"Some crazy longer label").should match(/title=\"Some crazy longer label\"/)
493
406
  end
494
407
 
495
408
  it "doesn't add an erroneous title attribute if one isn't provided" do
496
409
  @document = SolrDocument.new('id'=>'123456')
497
- expect(link_to_document(@document,:label=>"Some crazy long label...")).not_to match(/title=/)
410
+ link_to_document(@document,:label=>"Some crazy long label...").should_not match(/title=/)
498
411
  end
499
412
  end
500
413
 
@@ -521,7 +434,7 @@ describe BlacklightHelper do
521
434
  @doc_id = "MOCK_ID1"
522
435
  @document = MockDocumentAppHelper.new(:id => @doc_id)
523
436
  render_params = {:controller => "controller", :action => "action"}
524
- allow(helper).to receive(:params).and_return(render_params)
437
+ helper.stub(:params).and_return(render_params)
525
438
  end
526
439
  it "generates <link rel=alternate> tags" do
527
440
 
@@ -530,12 +443,12 @@ describe BlacklightHelper do
530
443
  tmp_value = Capybara.ignore_hidden_elements
531
444
  Capybara.ignore_hidden_elements = false
532
445
  @document.export_formats.each_pair do |format, spec|
533
- expect(response).to have_selector("link[href$='.#{ format }']") do |matches|
534
- expect(matches.length).to eq(1)
446
+ response.should have_selector("link[href$='.#{ format }']") do |matches|
447
+ matches.length.should == 1
535
448
  tag = matches[0]
536
- expect(tag.attributes["rel"].value).to eq("alternate")
537
- expect(tag.attributes["title"].value).to eq(format.to_s)
538
- expect(tag.attributes["href"].value).to be === mock_document_app_helper_url(@document, :format =>format)
449
+ tag.attributes["rel"].value.should == "alternate"
450
+ tag.attributes["title"].value.should == format.to_s
451
+ tag.attributes["href"].value.should === mock_document_app_helper_url(@document, :format =>format)
539
452
  end
540
453
  end
541
454
  Capybara.ignore_hidden_elements = tmp_value
@@ -558,7 +471,7 @@ describe BlacklightHelper do
558
471
 
559
472
  it "should be html safe" do
560
473
  response = render_link_rel_alternates(@document)
561
- expect(response.html_safe?).to eq(true)
474
+ response.html_safe?.should == true
562
475
  end
563
476
  end
564
477
 
@@ -574,20 +487,20 @@ describe BlacklightHelper do
574
487
  end
575
488
 
576
489
  @document = SolrDocument.new('title_display' => "A Fake Document", 'id'=>'8')
577
- allow(helper).to receive(:blacklight_config).and_return(@config)
578
- allow(helper).to receive(:has_user_authentication_provider?).and_return(true)
579
- allow(helper).to receive(:current_or_guest_user).and_return(User.new)
490
+ helper.stub(:blacklight_config).and_return(@config)
491
+ helper.stub(:has_user_authentication_provider?).and_return(true)
492
+ helper.stub(:current_or_guest_user).and_return(User.new)
580
493
  end
581
494
  describe "render_index_doc_actions" do
582
495
  it "should render partials" do
583
496
  response = helper.render_index_doc_actions(@document)
584
- expect(response).to have_selector(".bookmark_toggle")
497
+ response.should have_selector(".bookmark_toggle")
585
498
  end
586
499
  end
587
500
  describe "render_show_doc_actions" do
588
501
  it "should render partials" do
589
502
  response = helper.render_show_doc_actions(@document)
590
- expect(response).to have_selector(".bookmark_toggle")
503
+ response.should have_selector(".bookmark_toggle")
591
504
  end
592
505
  end
593
506
  end
@@ -601,67 +514,67 @@ describe BlacklightHelper do
601
514
  config.add_index_field 'link_to_search_named', :link_to_search => :some_field
602
515
  config.add_index_field 'highlight', :highlight => true
603
516
  end
604
- allow(helper).to receive(:blacklight_config).and_return(@config)
517
+ helper.stub(:blacklight_config).and_return(@config)
605
518
  end
606
519
 
607
520
  it "should check for an explicit value" do
608
521
  doc = double()
609
- expect(doc).not_to receive(:get).with('asdf', :sep => nil)
522
+ doc.should_not_receive(:get).with('asdf', :sep => nil)
610
523
  value = helper.render_index_field_value :value => 'asdf', :document => doc, :field => 'asdf'
611
- expect(value).to eq('asdf')
524
+ value.should == 'asdf'
612
525
  end
613
526
 
614
527
  it "should check for a helper method to call" do
615
528
  doc = double()
616
- expect(doc).not_to receive(:get).with('asdf', :sep => nil)
617
- allow(helper).to receive(:render_asdf_index_field).and_return('custom asdf value')
529
+ doc.should_not_receive(:get).with('asdf', :sep => nil)
530
+ helper.stub(:render_asdf_index_field).and_return('custom asdf value')
618
531
  value = helper.render_index_field_value :document => doc, :field => 'asdf'
619
- expect(value).to eq('custom asdf value')
532
+ value.should == 'custom asdf value'
620
533
  end
621
534
 
622
535
  it "should check for a link_to_search" do
623
536
  doc = double()
624
- expect(doc).to receive(:get).with('link_to_search_true', :sep => nil).and_return('x')
537
+ doc.should_receive(:get).with('link_to_search_true', :sep => nil).and_return('x')
625
538
  value = helper.render_index_field_value :document => doc, :field => 'link_to_search_true'
626
- expect(value).to eq(helper.link_to("x", helper.search_action_url(:f => { :link_to_search_true => ['x'] })))
539
+ value.should == helper.link_to("x", helper.search_action_url(:f => { :link_to_search_true => ['x'] }))
627
540
  end
628
541
 
629
542
  it "should check for a link_to_search with a field name" do
630
543
  doc = double()
631
- expect(doc).to receive(:get).with('link_to_search_named', :sep => nil).and_return('x')
544
+ doc.should_receive(:get).with('link_to_search_named', :sep => nil).and_return('x')
632
545
  value = helper.render_index_field_value :document => doc, :field => 'link_to_search_named'
633
- expect(value).to eq(helper.link_to("x", helper.search_action_url(:f => { :some_field => ['x'] })))
546
+ value.should == helper.link_to("x", helper.search_action_url(:f => { :some_field => ['x'] }))
634
547
  end
635
548
 
636
549
  it "should gracefully handle when no highlight field is available" do
637
550
  doc = double()
638
- expect(doc).not_to receive(:get)
639
- expect(doc).to receive(:has_highlight_field?).and_return(false)
551
+ doc.should_not_receive(:get)
552
+ doc.should_receive(:has_highlight_field?).and_return(false)
640
553
  value = helper.render_index_field_value :document => doc, :field => 'highlight'
641
- expect(value).to be_blank
554
+ value.should be_blank
642
555
  end
643
556
 
644
557
  it "should check for a highlighted field" do
645
558
  doc = double()
646
- expect(doc).not_to receive(:get)
647
- expect(doc).to receive(:has_highlight_field?).and_return(true)
648
- expect(doc).to receive(:highlight_field).with('highlight').and_return(['<em>highlight</em>'.html_safe])
559
+ doc.should_not_receive(:get)
560
+ doc.should_receive(:has_highlight_field?).and_return(true)
561
+ doc.should_receive(:highlight_field).with('highlight').and_return(['<em>highlight</em>'.html_safe])
649
562
  value = helper.render_index_field_value :document => doc, :field => 'highlight'
650
- expect(value).to eq('<em>highlight</em>')
563
+ value.should == '<em>highlight</em>'
651
564
  end
652
565
 
653
566
  it "should check the document field value" do
654
567
  doc = double()
655
- expect(doc).to receive(:get).with('qwer', :sep => nil).and_return('document qwer value')
568
+ doc.should_receive(:get).with('qwer', :sep => nil).and_return('document qwer value')
656
569
  value = helper.render_index_field_value :document => doc, :field => 'qwer'
657
- expect(value).to eq('document qwer value')
570
+ value.should == 'document qwer value'
658
571
  end
659
572
 
660
573
  it "should work with index fields that aren't explicitly defined" do
661
574
  doc = double()
662
- expect(doc).to receive(:get).with('mnbv', :sep => nil).and_return('document mnbv value')
575
+ doc.should_receive(:get).with('mnbv', :sep => nil).and_return('document mnbv value')
663
576
  value = helper.render_index_field_value :document => doc, :field => 'mnbv'
664
- expect(value).to eq('document mnbv value')
577
+ value.should == 'document mnbv value'
665
578
  end
666
579
  end
667
580
 
@@ -675,86 +588,86 @@ describe BlacklightHelper do
675
588
  config.add_show_field 'link_to_search_named', :link_to_search => :some_field
676
589
  config.add_show_field 'highlight', :highlight => true
677
590
  end
678
- allow(helper).to receive(:blacklight_config).and_return(@config)
591
+ helper.stub(:blacklight_config).and_return(@config)
679
592
  end
680
593
 
681
594
  it "should check for an explicit value" do
682
595
  doc = double()
683
- expect(doc).not_to receive(:get).with('asdf', :sep => nil)
684
- expect(helper).not_to receive(:render_asdf_document_show_field)
596
+ doc.should_not_receive(:get).with('asdf', :sep => nil)
597
+ helper.should_not_receive(:render_asdf_document_show_field)
685
598
  value = helper.render_document_show_field_value :value => 'asdf', :document => doc, :field => 'asdf'
686
- expect(value).to eq('asdf')
599
+ value.should == 'asdf'
687
600
  end
688
601
 
689
602
  it "should check for a helper method to call" do
690
603
  doc = double()
691
- expect(doc).not_to receive(:get).with('asdf', :sep => nil)
692
- allow(helper).to receive(:render_asdf_document_show_field).and_return('custom asdf value')
604
+ doc.should_not_receive(:get).with('asdf', :sep => nil)
605
+ helper.stub(:render_asdf_document_show_field).and_return('custom asdf value')
693
606
  value = helper.render_document_show_field_value :document => doc, :field => 'asdf'
694
- expect(value).to eq('custom asdf value')
607
+ value.should == 'custom asdf value'
695
608
  end
696
609
 
697
610
  it "should check for a link_to_search" do
698
611
  doc = double()
699
- expect(doc).to receive(:get).with('link_to_search_true', :sep => nil).and_return('x')
612
+ doc.should_receive(:get).with('link_to_search_true', :sep => nil).and_return('x')
700
613
  value = helper.render_document_show_field_value :document => doc, :field => 'link_to_search_true'
701
- expect(value).to eq(helper.link_to("x", helper.search_action_url(:f => { :link_to_search_true => ['x'] })))
614
+ value.should == helper.link_to("x", helper.search_action_url(:f => { :link_to_search_true => ['x'] }))
702
615
  end
703
616
 
704
617
  it "should check for a link_to_search with a field name" do
705
618
  doc = double()
706
- expect(doc).to receive(:get).with('link_to_search_named', :sep => nil).and_return('x')
619
+ doc.should_receive(:get).with('link_to_search_named', :sep => nil).and_return('x')
707
620
  value = helper.render_document_show_field_value :document => doc, :field => 'link_to_search_named'
708
- expect(value).to eq(helper.link_to("x", helper.search_action_url(:f => { :some_field => ['x'] })))
621
+ value.should == helper.link_to("x", helper.search_action_url(:f => { :some_field => ['x'] }))
709
622
  end
710
623
 
711
624
  it "should gracefully handle when no highlight field is available" do
712
625
  doc = double()
713
- expect(doc).not_to receive(:get)
714
- expect(doc).to receive(:has_highlight_field?).and_return(false)
626
+ doc.should_not_receive(:get)
627
+ doc.should_receive(:has_highlight_field?).and_return(false)
715
628
  value = helper.render_document_show_field_value :document => doc, :field => 'highlight'
716
- expect(value).to be_blank
629
+ value.should be_blank
717
630
  end
718
631
 
719
632
  it "should check for a highlighted field" do
720
633
  doc = double()
721
- expect(doc).not_to receive(:get)
722
- expect(doc).to receive(:has_highlight_field?).and_return(true)
723
- expect(doc).to receive(:highlight_field).with('highlight').and_return(['<em>highlight</em>'.html_safe])
634
+ doc.should_not_receive(:get)
635
+ doc.should_receive(:has_highlight_field?).and_return(true)
636
+ doc.should_receive(:highlight_field).with('highlight').and_return(['<em>highlight</em>'.html_safe])
724
637
  value = helper.render_document_show_field_value :document => doc, :field => 'highlight'
725
- expect(value).to eq('<em>highlight</em>')
638
+ value.should == '<em>highlight</em>'
726
639
  end
727
640
 
728
641
 
729
642
  it "should check the document field value" do
730
643
  doc = double()
731
- expect(doc).to receive(:get).with('qwer', :sep => nil).and_return('document qwer value')
644
+ doc.should_receive(:get).with('qwer', :sep => nil).and_return('document qwer value')
732
645
  value = helper.render_document_show_field_value :document => doc, :field => 'qwer'
733
- expect(value).to eq('document qwer value')
646
+ value.should == 'document qwer value'
734
647
  end
735
648
 
736
649
  it "should work with show fields that aren't explicitly defined" do
737
650
  doc = double()
738
- expect(doc).to receive(:get).with('mnbv', :sep => nil).and_return('document mnbv value')
651
+ doc.should_receive(:get).with('mnbv', :sep => nil).and_return('document mnbv value')
739
652
  value = helper.render_document_show_field_value :document => doc, :field => 'mnbv'
740
- expect(value).to eq('document mnbv value')
653
+ value.should == 'document mnbv value'
741
654
  end
742
655
  end
743
656
 
744
657
  describe "#should_render_index_field?" do
745
658
  it "should if the document has the field value" do
746
659
  doc = double()
747
- allow(doc).to receive(:has?).with('asdf').and_return(true)
660
+ doc.stub(:has?).with('asdf').and_return(true)
748
661
  field_config = double(:field => 'asdf')
749
- expect(helper.should_render_index_field?(doc, field_config)).to eq(true)
662
+ helper.should_render_index_field?(doc, field_config).should == true
750
663
  end
751
664
 
752
665
  it "should if the document has a highlight field value" do
753
666
  doc = double()
754
- allow(doc).to receive(:has?).with('asdf').and_return(false)
755
- allow(doc).to receive(:has_highlight_field?).with('asdf').and_return(true)
667
+ doc.stub(:has?).with('asdf').and_return(false)
668
+ doc.stub(:has_highlight_field?).with('asdf').and_return(true)
756
669
  field_config = double(:field => 'asdf', :highlight => true)
757
- expect(helper.should_render_index_field?(doc, field_config)).to eq(true)
670
+ helper.should_render_index_field?(doc, field_config).should == true
758
671
  end
759
672
  end
760
673
 
@@ -762,17 +675,17 @@ describe BlacklightHelper do
762
675
  describe "#should_render_show_field?" do
763
676
  it "should if the document has the field value" do
764
677
  doc = double()
765
- allow(doc).to receive(:has?).with('asdf').and_return(true)
678
+ doc.stub(:has?).with('asdf').and_return(true)
766
679
  field_config = double(:field => 'asdf')
767
- expect(helper.should_render_show_field?(doc, field_config)).to eq(true)
680
+ helper.should_render_show_field?(doc, field_config).should == true
768
681
  end
769
682
 
770
683
  it "should if the document has a highlight field value" do
771
684
  doc = double()
772
- allow(doc).to receive(:has?).with('asdf').and_return(false)
773
- allow(doc).to receive(:has_highlight_field?).with('asdf').and_return(true)
685
+ doc.stub(:has?).with('asdf').and_return(false)
686
+ doc.stub(:has_highlight_field?).with('asdf').and_return(true)
774
687
  field_config = double(:field => 'asdf', :highlight => true)
775
- expect(helper.should_render_show_field?(doc, field_config)).to eq(true)
688
+ helper.should_render_show_field?(doc, field_config).should == true
776
689
  end
777
690
  end
778
691
 
@@ -780,13 +693,13 @@ describe BlacklightHelper do
780
693
  describe "render_grouped_response?" do
781
694
  it "should check if the response ivar contains grouped data" do
782
695
  assign(:response, double("SolrResponse", :grouped? => true))
783
- expect(helper.render_grouped_response?).to eq true
696
+ expect(helper.render_grouped_response?).to be_true
784
697
  end
785
698
 
786
699
 
787
700
  it "should check if the response param contains grouped data" do
788
701
  response = double("SolrResponse", :grouped? => true)
789
- expect(helper.render_grouped_response?(response)).to eq true
702
+ expect(helper.render_grouped_response?(response)).to be_true
790
703
  end
791
704
  end
792
705
 
@@ -800,7 +713,7 @@ describe BlacklightHelper do
800
713
  end
801
714
 
802
715
  it "should join values using the field_value_separator" do
803
- allow(helper).to receive(:field_value_separator).and_return(" -- ")
716
+ helper.stub(:field_value_separator).and_return(" -- ")
804
717
  expect(helper.render_field_value(['a', 'b'])).to eq "a -- b"
805
718
  end
806
719
 
@@ -808,32 +721,4 @@ describe BlacklightHelper do
808
721
  expect(helper.render_field_value(['c', 'd'], double(:separator => '; '))).to eq "c; d"
809
722
  end
810
723
  end
811
-
812
- describe "link_to_previous_search" do
813
- it "should link to the given search parameters" do
814
- params = {}
815
- expect(helper).to receive(:render_search_to_s).with(params).and_return "link text"
816
- expect(helper.link_to_previous_search({})).to eq helper.link_to("link text", catalog_index_path)
817
- end
818
- end
819
-
820
- describe "should_show_spellcheck_suggestions?" do
821
- before :each do
822
- allow(helper).to receive_messages spell_check_max: 5
823
- end
824
- it "should not show suggestions if there are enough results" do
825
- response = double(total: 10)
826
- expect(helper.should_show_spellcheck_suggestions? response).to eq false
827
- end
828
-
829
- it "should only show suggestions if there are very few results" do
830
- response = double(total: 4, spelling: double(words: [1]))
831
- expect(helper.should_show_spellcheck_suggestions? response).to eq true
832
- end
833
-
834
- it "should show suggestions only if there are spelling suggestions available" do
835
- response = double(total: 4, spelling: double(words: []))
836
- expect(helper.should_show_spellcheck_suggestions? response).to eq false
837
- end
838
- end
839
724
  end