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
@@ -1,30 +1,14 @@
1
1
  # -*- encoding : utf-8 -*-
2
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+ require 'spec_helper'
3
+
3
4
  describe ApplicationController do
4
5
  include Devise::TestHelpers
5
6
 
6
- # HEAD CONTENT
7
- describe "head content from variables" do
8
-
9
- describe "#default_html_head" do
10
- it "should setup js and css defaults" do
11
- Deprecation.silence(Blacklight::LegacyControllerMethods) do
12
- controller.send(:default_html_head)
13
-
14
- # by default, these should be empty, but left in for backwards compatibility
15
- expect(controller.javascript_includes).to be_empty
16
- expect(controller.stylesheet_links).to be_empty
17
- end
18
- end
19
- end
20
-
21
- describe "#blacklight_config" do
7
+ describe "#blacklight_config" do
22
8
 
23
- it "should provide a default blacklight_config everywhere" do
24
- expect(controller.blacklight_config).to eq(CatalogController.blacklight_config)
25
- end
9
+ it "should provide a default blacklight_config everywhere" do
10
+ controller.blacklight_config.should == CatalogController.blacklight_config
26
11
  end
27
-
28
12
  end
29
13
 
30
14
  end
@@ -8,34 +8,34 @@ describe BookmarksController do
8
8
  describe "update" do
9
9
  it "has a 204 status code when creating a new one" do
10
10
  xhr :put, :update, :id => '2007020969', :format => :js
11
- expect(response).to be_success
12
- expect(response.code).to eq("204")
11
+ response.should be_success
12
+ response.code.should == "204"
13
13
  end
14
14
 
15
15
  it "has a 500 status code when fails is success" do
16
- allow(@controller).to receive_message_chain(:current_or_guest_user, :existing_bookmark_for).and_return(false)
17
- allow(@controller).to receive_message_chain(:current_or_guest_user, :persisted?).and_return(true)
18
- allow(@controller).to receive_message_chain(:current_or_guest_user, :bookmarks, :create).and_return(false)
16
+ @controller.stub_chain(:current_or_guest_user, :existing_bookmark_for).and_return(false)
17
+ @controller.stub_chain(:current_or_guest_user, :persisted?).and_return(true)
18
+ @controller.stub_chain(:current_or_guest_user, :bookmarks, :create).and_return(false)
19
19
  xhr :put, :update, :id => 'iamabooboo', :format => :js
20
- expect(response.code).to eq("500")
20
+ response.code.should == "500"
21
21
  end
22
22
  end
23
23
 
24
24
  describe "delete" do
25
25
  it "has a 204 status code when delete is success" do
26
26
  xhr :delete, :destroy, :id => '2007020969', :format => :js
27
- expect(response).to be_success
28
- expect(response.code).to eq("204")
27
+ response.should be_success
28
+ response.code.should == "204"
29
29
  end
30
30
 
31
31
  it "has a 500 status code when delete is not success" do
32
32
  bm = double(Bookmark)
33
- allow(@controller).to receive_message_chain(:current_or_guest_user, :existing_bookmark_for).and_return(bm)
34
- allow(@controller).to receive_message_chain(:current_or_guest_user, :bookmarks, :delete).and_return(false)
33
+ @controller.stub_chain(:current_or_guest_user, :existing_bookmark_for).and_return(bm)
34
+ @controller.stub_chain(:current_or_guest_user, :bookmarks, :delete).and_return(false)
35
35
 
36
36
  xhr :delete, :destroy, :id => 'pleasekillme', :format => :js
37
37
  #
38
- expect(response.code).to eq("500")
38
+ response.code.should == "500"
39
39
  end
40
40
  end
41
41
 
@@ -1,7 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
3
- require 'rubygems'
4
- require 'marc'
5
3
 
6
4
  describe CatalogController do
7
5
  include Devise::TestHelpers
@@ -23,68 +21,68 @@ describe CatalogController do
23
21
 
24
22
  describe "with format :html" do
25
23
  it "should have no search history if no search criteria" do
26
- expect(controller).to receive(:get_search_results)
24
+ controller.should_receive(:get_search_results)
27
25
  session[:history] = []
28
26
  get :index
29
- expect(session[:history].length).to eq(0)
27
+ session[:history].length.should == 0
30
28
  end
31
29
 
32
30
  # check each user manipulated parameter
33
31
  it "should have docs and facets for query with results", :integration => true do
34
32
  get :index, :q => @user_query
35
- expect(assigns_response.docs.size).to be > 1
33
+ assigns_response.docs.size.should > 1
36
34
  assert_facets_have_values(assigns_response.facets)
37
35
  end
38
36
  it "should have docs and facets for existing facet value", :integration => true do
39
37
  get :index, :f => @facet_query
40
- expect(assigns_response.docs.size).to be > 1
38
+ assigns_response.docs.size.should > 1
41
39
  assert_facets_have_values(assigns_response.facets)
42
40
  end
43
41
  it "should have docs and facets for non-default results per page", :integration => true do
44
42
  num_per_page = 7
45
43
  get :index, :per_page => num_per_page
46
- expect(assigns_response.docs.size).to eq(num_per_page)
44
+ assigns_response.docs.size.should == num_per_page
47
45
  assert_facets_have_values(assigns_response.facets)
48
46
  end
49
47
 
50
48
  it "should have docs and facets for second page", :integration => true do
51
49
  page = 2
52
50
  get :index, :page => page
53
- expect(assigns_response.docs.size).to be > 1
54
- expect(assigns_response.params[:start].to_i).to eq((page-1) * @controller.blacklight_config[:default_solr_params][:rows])
51
+ assigns_response.docs.size.should > 1
52
+ assigns_response.params[:start].to_i.should == (page-1) * @controller.blacklight_config[:default_solr_params][:rows]
55
53
  assert_facets_have_values(assigns_response.facets)
56
54
  end
57
55
 
58
56
  it "should have no docs or facet values for query without results", :integration => true do
59
57
  get :index, :q => @no_docs_query
60
58
 
61
- expect(assigns_response.docs.size).to eq(0)
59
+ assigns_response.docs.size.should == 0
62
60
  assigns_response.facets.each do |facet|
63
- expect(facet.items.size).to eq(0)
61
+ facet.items.size.should == 0
64
62
  end
65
63
  end
66
64
 
67
65
  it "should have a spelling suggestion for an appropriately poor query", :integration => true do
68
66
  get :index, :q => 'boo'
69
- expect(assigns_response.spelling.words).not_to be_nil
67
+ assigns_response.spelling.words.should_not be_nil
70
68
  end
71
69
 
72
70
  describe "session" do
73
71
  before do
74
- allow(controller).to receive(:get_search_results)
72
+ controller.stub(:get_search_results)
75
73
  end
76
74
  it "should include :search key with hash" do
77
75
  get :index
78
- expect(session[:search]).not_to be_nil
79
- expect(session[:search]).to be_kind_of(Hash)
76
+ session[:search].should_not be_nil
77
+ session[:search].should be_kind_of(Hash)
80
78
  end
81
79
  it "should include search hash with key :q" do
82
80
  get :index, :q => @user_query
83
- expect(session[:search]).not_to be_nil
84
- expect(session[:search].keys).to include('id')
81
+ session[:search].should_not be_nil
82
+ session[:search].keys.should include(:id)
85
83
 
86
- search = Search.find(session[:search]['id'])
87
- expect(search.query_params['q']).to eq @user_query
84
+ search = Search.find(session[:search][:id])
85
+ expect(search.query_params[:q]).to eq @user_query
88
86
  end
89
87
  end
90
88
 
@@ -92,7 +90,7 @@ describe CatalogController do
92
90
  describe "for default query" do
93
91
  it "should get documents when no query", :integration => true do
94
92
  get :index
95
- expect(assigns_response.docs.size).to be > 1
93
+ assigns_response.docs.size.should > 1
96
94
  end
97
95
  it "should get facets when no query", :integration => true do
98
96
  get :index
@@ -101,29 +99,29 @@ describe CatalogController do
101
99
  end
102
100
 
103
101
  it "should render index.html.erb" do
104
- allow(controller).to receive(:get_search_results)
102
+ controller.stub(:get_search_results)
105
103
  get :index
106
- expect(response).to render_template(:index)
104
+ response.should render_template(:index)
107
105
  end
108
106
 
109
107
  # NOTE: status code is always 200 in isolation mode ...
110
108
  it "HTTP status code for GET should be 200", :integration => true do
111
109
  get :index
112
- expect(response).to be_success
110
+ response.should be_success
113
111
  end
114
112
  end
115
113
 
116
114
  describe "with format :rss" do
117
115
  it "should get the feed", :integration => true do
118
116
  get :index, :format => 'rss'
119
- expect(response).to be_success
117
+ response.should be_success
120
118
  end
121
119
  end
122
120
 
123
121
  describe "with format :json" do
124
122
  before do
125
123
  get :index, :format => 'json'
126
- expect(response).to be_success
124
+ response.should be_success
127
125
  end
128
126
  let(:json) { JSON.parse(response.body)['response'] }
129
127
  let(:pages) { json["pages"] }
@@ -131,29 +129,29 @@ describe CatalogController do
131
129
  let(:facets) { json["facets"] }
132
130
 
133
131
  it "should get the pages" do
134
- expect(pages["total_count"]).to eq(30)
135
- expect(pages["current_page"]).to eq(1)
136
- expect(pages["total_pages"]).to eq(3)
132
+ pages["total_count"].should == 30
133
+ pages["current_page"].should == 1
134
+ pages["total_pages"].should == 3
137
135
  end
138
136
 
139
137
  it "should get the documents" do
140
- expect(docs.size).to eq(10)
138
+ docs.size.should == 10
141
139
  expect(docs.first.keys).to match_array(["published_display", "author_display", "lc_callnum_display", "pub_date", "subtitle_display", "format", "material_type_display", "title_display", "id", "subject_topic_facet", "language_facet", "score"])
142
140
  end
143
141
 
144
142
  it "should get the facets" do
145
- expect(facets.length).to eq(9)
146
- expect(facets.first).to eq({"name"=>"format", "label" => "Format", "items"=>[{"value"=>"Book", "hits"=>30, "label"=>"Book"}]})
143
+ facets.length.should == 9
144
+ facets.first.should == {"name"=>"format", "label" => "Format", "items"=>[{"value"=>"Book", "hits"=>30, "label"=>"Book"}]}
147
145
  end
148
146
 
149
147
  describe "facets" do
150
148
  let(:query_facet_items) { facets.last['items'] }
151
149
  let(:regular_facet_items) { facets.first['items'] }
152
150
  it "should have items with labels and values" do
153
- expect(query_facet_items.first['label']).to eq('within 10 Years')
154
- expect(query_facet_items.first['value']).to eq('years_10')
155
- expect(regular_facet_items.first['label']).to eq("Book")
156
- expect(regular_facet_items.first['value']).to eq("Book")
151
+ query_facet_items.first['label'].should == 'within 10 Years'
152
+ query_facet_items.first['value'].should == 'years_10'
153
+ regular_facet_items.first['label'].should == "Book"
154
+ regular_facet_items.first['value'].should == "Book"
157
155
  end
158
156
  end
159
157
  end
@@ -165,13 +163,18 @@ describe CatalogController do
165
163
 
166
164
  it "should set counter value into session[:search]" do
167
165
  put :update, :id => doc_id, :counter => 3
168
- expect(session[:search]['counter']).to eq("3")
166
+ session[:search][:counter].should == "3"
169
167
  end
170
168
 
171
169
  it "should redirect to show action for doc id" do
172
170
  put :update, :id => doc_id, :counter => 3
173
171
  assert_redirected_to(catalog_path(doc_id))
174
172
  end
173
+
174
+ it "HTTP status code for redirect should be 303" do
175
+ put :update, :id => doc_id, :counter => 3
176
+ response.status.should == 303
177
+ end
175
178
  end
176
179
 
177
180
  # SHOW ACTION
@@ -182,14 +185,14 @@ describe CatalogController do
182
185
  describe "with format :html" do
183
186
  it "should get document", :integration => true do
184
187
  get :show, :id => doc_id
185
- expect(assigns[:document]).not_to be_nil
188
+ assigns[:document].should_not be_nil
186
189
  end
187
190
  end
188
191
 
189
192
  describe "with format :json" do
190
193
  it "should get the feed" do
191
194
  get :show, id: doc_id, format: 'json'
192
- expect(response).to be_success
195
+ response.should be_success
193
196
  json = JSON.parse response.body
194
197
  expect(json["response"]["document"].keys).to match_array(["author_t", "opensearch_display", "marc_display", "published_display", "author_display", "lc_callnum_display", "title_t", "pub_date", "pub_date_sort", "subtitle_display", "format", "url_suppl_display", "material_type_display", "title_display", "subject_addl_t", "subject_t", "isbn_t", "id", "title_addl_t", "subject_geo_facet", "subject_topic_facet", "author_addl_t", "language_facet", "subtitle_t", "timestamp"])
195
198
  end
@@ -199,59 +202,59 @@ describe CatalogController do
199
202
  before do
200
203
  @mock_response = double()
201
204
  @mock_document = double()
202
- allow(@mock_document).to receive_messages(:export_formats => {})
203
- allow(controller).to receive_messages(:get_solr_response_for_doc_id => [@mock_response, @mock_document],
205
+ @mock_document.stub(:export_formats => {})
206
+ controller.stub(:get_solr_response_for_doc_id => [@mock_response, @mock_document],
204
207
  :get_previous_and_next_documents_for_search => [double(:total => 5), [double("a"), @mock_document, double("b")]])
205
208
 
206
209
  current_search = Search.create(:query_params => { :q => ""})
207
- allow(controller).to receive_messages(:current_search_session => current_search)
210
+ controller.stub(:current_search_session => current_search)
208
211
 
209
212
  @search_session = { :id => current_search.id }
210
213
  end
211
214
  it "should set previous document if counter present in session" do
212
- session[:search] = @search_session.merge('counter' => 2)
215
+ session[:search] = @search_session.merge(:counter => 2)
213
216
  get :show, :id => doc_id
214
- expect(assigns[:previous_document]).not_to be_nil
217
+ assigns[:previous_document].should_not be_nil
215
218
  end
216
219
  it "should not set previous or next document if session is blank" do
217
220
  get :show, :id => doc_id
218
- expect(assigns[:previous_document]).to be_nil
219
- expect(assigns[:next_document]).to be_nil
221
+ assigns[:previous_document].should be_nil
222
+ assigns[:next_document].should be_nil
220
223
  end
221
- it "should not set previous or next document if session[:search]['counter'] is nil" do
224
+ it "should not set previous or next document if session[:search][:counter] is nil" do
222
225
  session[:search] = {}
223
226
  get :show, :id => doc_id
224
- expect(assigns[:previous_document]).to be_nil
225
- expect(assigns[:next_document]).to be_nil
227
+ assigns[:previous_document].should be_nil
228
+ assigns[:next_document].should be_nil
226
229
  end
227
230
  it "should set next document if counter present in session" do
228
- session[:search] = @search_session.merge('counter' => 2)
231
+ session[:search] = @search_session.merge(:counter => 2)
229
232
  get :show, :id => doc_id
230
- expect(assigns[:next_document]).not_to be_nil
233
+ assigns[:next_document].should_not be_nil
231
234
  end
232
235
  end
233
236
 
234
237
  # NOTE: status code is always 200 in isolation mode ...
235
238
  it "HTTP status code for GET should be 200", :integration => true do
236
239
  get :show, :id => doc_id
237
- expect(response).to be_success
240
+ response.should be_success
238
241
  end
239
242
  it "should render show.html.erb" do
240
243
  @mock_response = double()
241
244
  @mock_document = double()
242
- allow(@mock_document).to receive_messages(:export_formats => {})
243
- allow(controller).to receive_messages(:get_solr_response_for_doc_id => [@mock_response, @mock_document],
245
+ @mock_document.stub(:export_formats => {})
246
+ controller.stub(:get_solr_response_for_doc_id => [@mock_response, @mock_document],
244
247
  :get_single_doc_via_search => @mock_document)
245
248
  get :show, :id => doc_id
246
- expect(response).to render_template(:show)
249
+ response.should render_template(:show)
247
250
  end
248
251
 
249
252
  describe "@document" do
250
253
  before do
251
254
  @mock_response = double()
252
- allow(@mock_response).to receive_messages(:docs => [{ :id => 'my_fake_doc' }])
255
+ @mock_response.stub(:docs => [{ :id => 'my_fake_doc' }])
253
256
  @mock_document = double()
254
- allow(controller).to receive_messages(:find => @mock_response,
257
+ controller.stub(:find => @mock_response,
255
258
  :get_single_doc_via_search => @mock_document)
256
259
  end
257
260
  before(:each) do
@@ -259,7 +262,7 @@ describe CatalogController do
259
262
  @document = assigns[:document]
260
263
  end
261
264
  it "should be a SolrDocument" do
262
- expect(@document).to be_instance_of(SolrDocument)
265
+ @document.should be_instance_of(SolrDocument)
263
266
  end
264
267
  end
265
268
 
@@ -276,12 +279,12 @@ describe CatalogController do
276
279
  end
277
280
  before do
278
281
  @mock_response = double()
279
- allow(@mock_response).to receive_messages(:docs => [{ :id => 'my_fake_doc' }])
282
+ @mock_response.stub(:docs => [{ :id => 'my_fake_doc' }])
280
283
  @mock_document = double()
281
- allow(controller).to receive_messages(:find => @mock_response,
284
+ controller.stub(:find => @mock_response,
282
285
  :get_single_doc_via_search => @mock_document)
283
286
 
284
- allow(controller).to receive_messages(:find => @mock_response,
287
+ controller.stub(:find => @mock_response,
285
288
  :get_single_doc_via_search => @mock_document)
286
289
  end
287
290
 
@@ -299,8 +302,8 @@ describe CatalogController do
299
302
 
300
303
  it "should respond to an extension-registered format properly" do
301
304
  get :show, :id => doc_id, :format => "mock" # This no longer works: :format => "mock"
302
- expect(response).to be_success
303
- expect(response.body).to match(/mock_export/)
305
+ response.should be_success
306
+ response.body.should =~ /mock_export/
304
307
  end
305
308
 
306
309
 
@@ -316,18 +319,18 @@ describe CatalogController do
316
319
  before do
317
320
  @mock_response = double()
318
321
  @mock_document = double()
319
- allow(@mock_response).to receive_messages(:docs => [{ :id => 'my_fake_doc' }, { :id => 'my_other_doc'}])
322
+ @mock_response.stub(:docs => [{ :id => 'my_fake_doc' }, { :id => 'my_other_doc'}])
320
323
  @mock_document = double()
321
- allow(controller).to receive_messages(:find => @mock_response,
324
+ controller.stub(:find => @mock_response,
322
325
  :get_single_doc_via_search => @mock_document)
323
326
  end
324
327
  it "should return an opensearch description" do
325
328
  get :opensearch, :format => 'xml'
326
- expect(response).to be_success
329
+ response.should be_success
327
330
  end
328
331
  it "should return valid JSON" do
329
332
  get :opensearch,:format => 'json', :q => "a"
330
- expect(response).to be_success
333
+ response.should be_success
331
334
  end
332
335
  end
333
336
  #=end
@@ -336,9 +339,9 @@ describe CatalogController do
336
339
  before do
337
340
  @mock_response = double()
338
341
  @mock_document = double()
339
- allow(@mock_response).to receive_messages(:docs => [{ :id => 'my_fake_doc' }, { :id => 'my_other_doc'}])
342
+ @mock_response.stub(:docs => [{ :id => 'my_fake_doc' }, { :id => 'my_other_doc'}])
340
343
  @mock_document = double()
341
- allow(controller).to receive_messages(:find => @mock_response,
344
+ controller.stub(:find => @mock_response,
342
345
  :get_single_doc_via_search => @mock_document)
343
346
  end
344
347
  before(:each) do
@@ -349,24 +352,24 @@ describe CatalogController do
349
352
  describe "email" do
350
353
  it "should give error if no TO paramater" do
351
354
  post :email, :id => doc_id
352
- expect(request.flash[:error]).to eq("You must enter a recipient in order to send this message")
355
+ request.flash[:error].should == "You must enter a recipient in order to send this message"
353
356
  end
354
357
  it "should give an error if the email address is not valid" do
355
358
  post :email, :id => doc_id, :to => 'test_bad_email'
356
- expect(request.flash[:error]).to eq("You must enter a valid email address")
359
+ request.flash[:error].should == "You must enter a valid email address"
357
360
  end
358
361
  it "should not give error if no Message paramater is set" do
359
362
  post :email, :id => doc_id, :to => 'test_email@projectblacklight.org'
360
- expect(request.flash[:error]).to be_nil
363
+ request.flash[:error].should be_nil
361
364
  end
362
365
  it "should redirect back to the record upon success" do
363
366
  mock_mailer = double
364
- expect(mock_mailer).to receive(:deliver)
365
- expect(RecordMailer).to receive(:email_record).with(anything, { :to => 'test_email@projectblacklight.org', :message => 'xyz' }, hash_including(:host => 'test.host')).and_return mock_mailer
367
+ mock_mailer.should_receive(:deliver)
368
+ RecordMailer.should_receive(:email_record).with(anything, { :to => 'test_email@projectblacklight.org', :message => 'xyz' }, hash_including(:host => 'test.host')).and_return mock_mailer
366
369
 
367
370
  post :email, :id => doc_id, :to => 'test_email@projectblacklight.org', :message => 'xyz'
368
- expect(request.flash[:error]).to be_nil
369
- expect(request).to redirect_to(catalog_path(doc_id))
371
+ request.flash[:error].should be_nil
372
+ request.should redirect_to(catalog_path(doc_id))
370
373
  end
371
374
 
372
375
  it "should render email_sent for XHR requests" do
@@ -378,29 +381,29 @@ describe CatalogController do
378
381
  describe "sms" do
379
382
  it "should give error if no phone number is given" do
380
383
  post :sms, :id => doc_id, :carrier => 'att'
381
- expect(request.flash[:error]).to eq("You must enter a recipient's phone number in order to send this message")
384
+ request.flash[:error].should == "You must enter a recipient's phone number in order to send this message"
382
385
  end
383
386
  it "should give an error when a carrier is not provided" do
384
387
  post :sms, :id => doc_id, :to => '5555555555', :carrier => ''
385
- expect(request.flash[:error]).to eq("You must select a carrier")
388
+ request.flash[:error].should == "You must select a carrier"
386
389
  end
387
390
  it "should give an error when the phone number is not 10 digits" do
388
391
  post :sms, :id => doc_id, :to => '555555555', :carrier => 'txt.att.net'
389
- expect(request.flash[:error]).to eq("You must enter a valid 10 digit phone number")
392
+ request.flash[:error].should == "You must enter a valid 10 digit phone number"
390
393
  end
391
394
  it "should give an error when the carrier is not in our list of carriers" do
392
395
  post :sms, :id => doc_id, :to => '5555555555', :carrier => 'no-such-carrier'
393
- expect(request.flash[:error]).to eq("You must enter a valid carrier")
396
+ request.flash[:error].should == "You must enter a valid carrier"
394
397
  end
395
398
  it "should allow punctuation in phone number" do
396
399
  post :sms, :id => doc_id, :to => '(555) 555-5555', :carrier => 'txt.att.net'
397
- expect(request.flash[:error]).to be_nil
398
- expect(request).to redirect_to(catalog_path(doc_id))
400
+ request.flash[:error].should be_nil
401
+ request.should redirect_to(catalog_path(doc_id))
399
402
  end
400
403
  it "should redirect back to the record upon success" do
401
404
  post :sms, :id => doc_id, :to => '5555555555', :carrier => 'txt.att.net'
402
- expect(request.flash[:error]).to be_nil
403
- expect(request).to redirect_to(catalog_path(doc_id))
405
+ request.flash[:error].should be_nil
406
+ request.should redirect_to(catalog_path(doc_id))
404
407
  end
405
408
 
406
409
  it "should render sms_sent template for XHR requests" do
@@ -414,36 +417,36 @@ describe CatalogController do
414
417
  describe "errors" do
415
418
  it "should return status 404 for a record that doesn't exist" do
416
419
  @mock_response = double()
417
- allow(@mock_response).to receive_messages(:docs => [])
420
+ @mock_response.stub(:docs => [])
418
421
  @mock_document = double()
419
- allow(controller).to receive_messages(:find => @mock_response,
422
+ controller.stub(:find => @mock_response,
420
423
  :get_single_doc_via_search => @mock_document)
421
424
  get :show, :id=>"987654321"
422
- expect(request.flash[:notice]).to eq("Sorry, you have requested a record that doesn't exist.")
423
- expect(response).to render_template('index')
424
- expect(response.status).to eq(404)
425
+ request.flash[:notice].should == "Sorry, you have requested a record that doesn't exist."
426
+ response.should render_template('index')
427
+ response.status.should == 404
425
428
  end
426
429
  it "should redirect the user to the root url for a bad search" do
427
430
  req = {}
428
431
  res = {}
429
432
  fake_error = RSolr::Error::Http.new(req, res)
430
- allow(controller).to receive(:get_search_results) { |*args| raise fake_error }
431
- expect(controller.logger).to receive(:error).with(fake_error)
433
+ controller.stub(:get_search_results) { |*args| raise fake_error }
434
+ controller.logger.should_receive(:error).with(fake_error)
432
435
  get :index, :q=>"+"
433
436
 
434
- expect(response.redirect_url).to eq(root_url)
435
- expect(request.flash[:notice]).to eq("Sorry, I don't understand your search.")
436
- expect(response).not_to be_success
437
- expect(response.status).to eq(302)
437
+ response.redirect_url.should == root_url
438
+ request.flash[:notice].should == "Sorry, I don't understand your search."
439
+ response.should_not be_success
440
+ response.status.should == 302
438
441
  end
439
442
  it "should return status 500 if the catalog path is raising an exception" do
440
443
 
441
444
  req = {}
442
445
  res = {}
443
446
  fake_error = RSolr::Error::Http.new(req, res)
444
- allow(controller).to receive(:get_search_results) { |*args| raise fake_error }
445
- allow(controller.flash).to receive(:sweep)
446
- allow(controller).to receive(:flash).and_return(:notice => I18n.t('blacklight.search.errors.request_error'))
447
+ controller.stub(:get_search_results) { |*args| raise fake_error }
448
+ controller.flash.stub(:sweep)
449
+ controller.stub(:flash).and_return(:notice => I18n.t('blacklight.search.errors.request_error'))
447
450
  expect {
448
451
  get :index, :q=>"+"
449
452
  }.to raise_error
@@ -455,18 +458,18 @@ describe CatalogController do
455
458
  render_views
456
459
 
457
460
  before do
458
- allow(controller).to receive(:has_user_authentication_provider?) { false }
461
+ controller.stub(:has_user_authentication_provider?) { false }
459
462
  @mock_response = double()
460
463
  @mock_document = double()
461
- allow(@mock_response).to receive_messages(:docs => [], :total => 1, :facets => [], :facet_queries => {}, :facet_by_field_name => nil)
464
+ @mock_response.stub(:docs => [], :total => 1, :facets => [], :facet_queries => {}, :facet_by_field_name => nil)
462
465
  @mock_document = double()
463
- allow(controller).to receive_messages(:find => @mock_response,
466
+ controller.stub(:find => @mock_response,
464
467
  :get_single_doc_via_search => @mock_document)
465
468
  end
466
469
 
467
470
  it "should not show user util links" do
468
471
  get :index
469
- expect(response.body).not_to match(/Login/)
472
+ response.body.should_not =~ /Login/
470
473
  end
471
474
  end
472
475
 
@@ -474,22 +477,22 @@ describe CatalogController do
474
477
  describe "requesting js" do
475
478
  it "should be successful" do
476
479
  xhr :get, :facet, id: 'format'
477
- expect(response).to be_successful
480
+ response.should be_successful
478
481
  end
479
482
  end
480
483
  describe "requesting html" do
481
484
  it "should be successful" do
482
485
  get :facet, id: 'format'
483
- expect(response).to be_successful
484
- expect(assigns[:pagination]).to be_kind_of Blacklight::Solr::FacetPaginator
486
+ response.should be_successful
487
+ assigns[:pagination].should be_kind_of Blacklight::Solr::FacetPaginator
485
488
  end
486
489
  end
487
490
  describe "requesting json" do
488
491
  it "should be successful" do
489
492
  get :facet, id: 'format', format: 'json'
490
- expect(response).to be_successful
493
+ response.should be_successful
491
494
  json = JSON.parse(response.body)
492
- expect(json["response"]["facets"]["items"].first["value"]).to eq('Book')
495
+ json["response"]["facets"]["items"].first["value"].should == 'Book'
493
496
  end
494
497
  end
495
498
  end
@@ -497,8 +500,8 @@ describe CatalogController do
497
500
  describe 'render_search_results_as_json' do
498
501
  before do
499
502
  controller.instance_variable_set :@document_list, [{id: '123', title_t: 'Book1'}, {id: '456', title_t: 'Book2'}]
500
- allow(controller).to receive(:pagination_info).and_return({current_page: 1, next_page: 2, prev_page: nil})
501
- allow(controller).to receive(:search_facets_as_json).and_return(
503
+ controller.stub(:pagination_info).and_return({current_page: 1, next_page: 2, prev_page: nil})
504
+ controller.stub(:search_facets_as_json).and_return(
502
505
  [{name: "format", label: "Format", items: [{value: 'Book', hits: 30, label: 'Book'}]}])
503
506
  end
504
507
 
@@ -527,18 +530,18 @@ describe CatalogController do
527
530
  it "should prepend the current search to the list" do
528
531
  session[:history] = []
529
532
  controller.send(:add_to_search_history, double(:id => 1))
530
- expect(session[:history].size).to eq(1)
533
+ expect(session[:history]).to have(1).item
531
534
 
532
535
  controller.send(:add_to_search_history, double(:id => 2))
533
- expect(session[:history].size).to eq(2)
536
+ expect(session[:history]).to have(2).items
534
537
  expect(session[:history].first).to eq 2
535
538
  end
536
539
 
537
540
  it "should remove searches from the list when the list gets too big" do
538
- allow(controller).to receive(:blacklight_config).and_return(double(:search_history_window => 5))
541
+ controller.stub(:blacklight_config).and_return(double(:search_history_window => 5))
539
542
  session[:history] = (0..4).to_a.reverse
540
543
 
541
- expect(session[:history].size).to eq(5)
544
+ expect(session[:history]).to have(5).items
542
545
  controller.send(:add_to_search_history, double(:id => 5))
543
546
  controller.send(:add_to_search_history, double(:id => 6))
544
547
  controller.send(:add_to_search_history, double(:id => 7))
@@ -549,15 +552,15 @@ describe CatalogController do
549
552
 
550
553
  describe "current_search_session" do
551
554
  it "should create a session if we're on an search action" do
552
- allow(controller).to receive_messages(:action_name => "index")
553
- allow(controller).to receive_messages(:params => { :q => "x", :page => 5})
555
+ controller.stub(:action_name => "index")
556
+ controller.stub(:params => { :q => "x", :page => 5})
554
557
  session = controller.send(:current_search_session)
555
558
  expect(session.query_params).to include(:q => "x")
556
559
  expect(session.query_params).to_not include(:page => 5)
557
560
  end
558
561
 
559
562
  it "should create a session if a search context was provided" do
560
- allow(controller).to receive_messages(:params => { :search_context => JSON.dump(:q => "x")})
563
+ controller.stub(:params => { :search_context => JSON.dump(:q => "x")})
561
564
  session = controller.send(:current_search_session)
562
565
  expect(session.query_params).to include("q" => "x")
563
566
  end
@@ -566,7 +569,7 @@ describe CatalogController do
566
569
  s = Search.create(:query_params => { :q => "x" })
567
570
  session[:history] ||= []
568
571
  session[:history] << s.id
569
- allow(controller).to receive_messages(:params => { :search_id => s.id})
572
+ controller.stub(:params => { :search_id => s.id})
570
573
  session = controller.send(:current_search_session)
571
574
  expect(session.query_params).to include(:q => "x")
572
575
  expect(session).to eq(s)
@@ -575,7 +578,7 @@ describe CatalogController do
575
578
  it "should use an existing search session if the search is in the uri" do
576
579
  s = Search.create(:query_params => { :q => "x" })
577
580
  session[:search] ||= {}
578
- session[:search]['id'] = s.id
581
+ session[:search][:id] = s.id
579
582
  session[:history] ||= []
580
583
  session[:history] << s.id
581
584
  session = controller.send(:current_search_session)
@@ -588,10 +591,10 @@ end
588
591
 
589
592
  # there must be at least one facet, and each facet must have at least one value
590
593
  def assert_facets_have_values(facets)
591
- expect(facets.size).to be > 1
594
+ facets.size.should > 1
592
595
  # should have at least one value for each facet
593
596
  facets.each do |facet|
594
- expect(facet.items.size).to be >= 1
597
+ facet.items.size.should >= 1
595
598
  end
596
599
  end
597
600