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
@@ -8,17 +8,17 @@ describe "Blacklight::Solr::Document::Email" do
8
8
  it "should only return values that are available in the field semantics" do
9
9
  doc = SolrDocument.new({:id=>"1234", :title_display=>"My Title"})
10
10
  email_body = doc.to_email_text
11
- expect(email_body).to match(/Title: My Title/)
12
- expect(email_body).not_to match(/Author/)
11
+ email_body.should match(/Title: My Title/)
12
+ email_body.should_not match(/Author/)
13
13
  end
14
14
  it "should handle multi-values fields correctly" do
15
15
  doc = SolrDocument.new({:id=>"1234", :title_display=>["My Title", "My Alt. Title"]})
16
16
  email_body = doc.to_email_text
17
- expect(email_body).to match(/Title: My Title My Alt. Title/)
17
+ email_body.should match(/Title: My Title My Alt. Title/)
18
18
  end
19
19
  it "should return nil if there are no valid field semantics to build the email body from" do
20
20
  doc = SolrDocument.new({:id=>"1234"})
21
- expect(doc.to_email_text).to be_nil
21
+ doc.to_email_text.should be_nil
22
22
  end
23
23
  end
24
24
 
@@ -8,17 +8,17 @@ describe "Blacklight::Solr::Document::Email" do
8
8
  it "should only return values that are available in the field semantics" do
9
9
  doc = SolrDocument.new({:id=>"1234", :title_display=>"My Title", :author_display=>"Joe Schmoe"})
10
10
  sms_text = doc.to_sms_text
11
- expect(sms_text).to match(/My Title by Joe Schmoe/)
11
+ sms_text.should match(/My Title by Joe Schmoe/)
12
12
  end
13
13
  it "should handle multi-values fields correctly and only take the first" do
14
14
  doc = SolrDocument.new({:id=>"1234", :title_display=>["My Title", "My Alt. Title"]})
15
15
  sms_text = doc.to_sms_text
16
- expect(sms_text).to match(/My Title/)
17
- expect(sms_text).not_to match(/My Alt\. Title/)
16
+ sms_text.should match(/My Title/)
17
+ sms_text.should_not match(/My Alt\. Title/)
18
18
  end
19
19
  it "should return nil if there are no valid field semantics to build the email body from" do
20
20
  doc = SolrDocument.new({:id=>"1234"})
21
- expect(doc.to_sms_text).to be_nil
21
+ doc.to_sms_text.should be_nil
22
22
  end
23
23
  end
24
24
 
@@ -16,27 +16,27 @@ describe "Blacklight::Solr::Document::DublinCore" do
16
16
 
17
17
  it "should register all its export formats" do
18
18
  document = @mock_class.new
19
- expect(Set.new(document.export_formats.keys)).to be_superset(Set.new([:oai_dc_xml,:dc_xml, :xml]))
19
+ Set.new(document.export_formats.keys).should be_superset(Set.new([:oai_dc_xml,:dc_xml, :xml]))
20
20
  end
21
21
 
22
22
  it "should export oai_dc with the proper namespaces" do
23
23
  document = @mock_class.new
24
- expect(document.export_as_oai_dc_xml).to match 'xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"'
24
+ document.export_as_oai_dc_xml.should match 'xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"'
25
25
 
26
26
  end
27
27
 
28
28
  it "should include 'dc:'-prefixed semantic fields" do
29
29
  data = {'id'=>'123456','title_display'=>['654321'] }
30
30
  document = @mock_class.new(data)
31
- expect(document.export_as_oai_dc_xml).to match 'xmlns:dc="http://purl.org/dc/elements/1.1/"'
32
- expect(document.export_as_oai_dc_xml).to match '<dc:title>654321</dc:title>'
31
+ document.export_as_oai_dc_xml.should match 'xmlns:dc="http://purl.org/dc/elements/1.1/"'
32
+ document.export_as_oai_dc_xml.should match '<dc:title>654321</dc:title>'
33
33
  end
34
34
 
35
35
  it "should work with multi-value fields" do
36
36
  data = {'id'=>'123456','title_display'=>['654321', '987'] }
37
37
  document = @mock_class.new(data)
38
- expect(document.export_as_oai_dc_xml).to match '<dc:title>654321</dc:title>'
39
- expect(document.export_as_oai_dc_xml).to match '<dc:title>987</dc:title></oai_dc:dc>'
38
+ document.export_as_oai_dc_xml.should match '<dc:title>654321</dc:title>'
39
+ document.export_as_oai_dc_xml.should match '<dc:title>987</dc:title></oai_dc:dc>'
40
40
  end
41
41
  end
42
42
 
@@ -10,9 +10,9 @@ describe Blacklight::Solr::Document::MoreLikeThis do
10
10
  it "should pluck the MoreLikeThis results from the Solr Response" do
11
11
  mock_solr_response = double(:more_like => [{'id' => 'abc'}])
12
12
  result = @mock_class.new({:id => '123'}, mock_solr_response).more_like_this
13
- expect(result.size).to eq(1)
14
- expect(result.first).to be_a_kind_of(SolrDocument)
15
- expect(result.first.id).to eq('abc')
16
- expect(result.first.solr_response).to eq(mock_solr_response)
13
+ result.should have(1).item
14
+ result.first.should be_a_kind_of(SolrDocument)
15
+ result.first.id.should == 'abc'
16
+ result.first.solr_response.should == mock_solr_response
17
17
  end
18
18
  end
@@ -23,13 +23,13 @@ describe "Blacklight::Solr::Document" do
23
23
  it 'should create a doc with hashy methods' do
24
24
  doc = SolrDocument.new({'id'=>'SP2514N','inStock'=>true,'manu'=>'Samsung Electronics Co. Ltd.','name'=>'Samsung SpinPoint P120 SP2514N - hard drive - 250 GB - ATA-133','popularity'=>6,'price'=>92.0,'sku'=>'SP2514N','timestamp'=>'2009-03-20T14:42:49.795Z','cat'=>['electronics','hard drive'],'spell'=>['Samsung SpinPoint P120 SP2514N - hard drive - 250 GB - ATA-133'],'features'=>['7200RPM, 8MB cache, IDE Ultra ATA-133','NoiseGuard, SilentSeek technology, Fluid Dynamic Bearing (FDB) motor']})
25
25
 
26
- expect(doc.has?(:cat, /^elec/)).to eq(true)
27
- expect(doc.has?(:cat, 'elec')).not_to eq(true)
28
- expect(doc.has?(:cat, 'electronics')).to eq(true)
26
+ doc.has?(:cat, /^elec/).should == true
27
+ doc.has?(:cat, 'elec').should_not == true
28
+ doc.has?(:cat, 'electronics').should == true
29
29
 
30
- expect(doc.get(:cat)).to eq('electronics, hard drive')
31
- expect(doc.get(:xyz)).to eq(nil)
32
- expect(doc.get(:xyz, :default=>'def')).to eq('def')
30
+ doc.get(:cat).should == 'electronics, hard drive'
31
+ doc.get(:xyz).should == nil
32
+ doc.get(:xyz, :default=>'def').should == 'def'
33
33
  end
34
34
  end
35
35
 
@@ -44,7 +44,7 @@ describe "Blacklight::Solr::Document" do
44
44
  end
45
45
  it "should use a configuration-defined document unique key" do
46
46
  @document = MockDocument.new :id => 'asdf', :my_unique_key => '1234'
47
- expect(@document.id).to eq('1234')
47
+ @document.id.should == '1234'
48
48
  end
49
49
  end
50
50
 
@@ -57,54 +57,54 @@ describe "Blacklight::Solr::Document" do
57
57
  it "should let you register an extension" do
58
58
  MockDocument.use_extension(MockExtension) { |doc| true }
59
59
 
60
- expect(MockDocument.registered_extensions.find {|a| a[:module_obj] == MockExtension}).not_to be_nil
60
+ MockDocument.registered_extensions.find {|a| a[:module_obj] == MockExtension}.should_not be_nil
61
61
  end
62
62
  it "should let you register an extension with a nil condition proc" do
63
63
  MockDocument.use_extension(MockExtension) { |doc| true }
64
- expect(MockDocument.registered_extensions.find {|a| a[:module_obj] == MockExtension}).not_to be_nil
64
+ MockDocument.registered_extensions.find {|a| a[:module_obj] == MockExtension}.should_not be_nil
65
65
  end
66
66
  it "should apply an extension whose condition is met" do
67
67
  MockDocument.use_extension(MockExtension) {|doc| true}
68
68
  doc = MockDocument.new()
69
69
 
70
- expect(doc.methods.find {|name| name.to_s == "my_extension_method"}).not_to be_nil
71
- expect(doc.my_extension_method.to_s).to eq("my_extension_results")
70
+ doc.methods.find {|name| name.to_s == "my_extension_method"}.should_not be_nil
71
+ doc.my_extension_method.to_s.should == "my_extension_results"
72
72
  end
73
73
  it "should apply an extension based on a Solr field" do
74
74
  MockDocument.use_extension(MockExtension) {|doc| doc.key?(:required_key)}
75
75
 
76
76
  with_extension = MockDocument.new(:required_key => "value")
77
- expect(with_extension.my_extension_method.to_s).to eq("my_extension_results")
77
+ with_extension.my_extension_method.to_s.should == "my_extension_results"
78
78
 
79
79
  without_extension = MockDocument.new(:other_key => "value")
80
- expect(without_extension.methods.find {|name| name.to_s == "my_extension_method"}).to be_nil
80
+ without_extension.methods.find {|name| name.to_s == "my_extension_method"}.should be_nil
81
81
 
82
82
  end
83
83
  it "should not apply an extension whose condition is not met" do
84
84
  MockDocument.use_extension(MockExtension) {|doc| false}
85
85
  doc = MockDocument.new()
86
86
 
87
- expect(doc.methods.find {|name| name.to_s == "my_extension_method"}).to be_nil
87
+ doc.methods.find {|name| name.to_s == "my_extension_method"}.should be_nil
88
88
  end
89
89
  it "should treat a nil condition as always applyable" do
90
90
  MockDocument.use_extension(MockExtension)
91
91
 
92
92
  doc = MockDocument.new()
93
93
 
94
- expect(doc.methods.find {|name | name.to_s =="my_extension_method"}).not_to be_nil
95
- expect(doc.my_extension_method).to eq("my_extension_results")
94
+ doc.methods.find {|name | name.to_s =="my_extension_method"}.should_not be_nil
95
+ doc.my_extension_method.should == "my_extension_results"
96
96
  end
97
97
  it "should let last extension applied override earlier extensions" do
98
98
  MockDocument.use_extension(MockExtension)
99
99
  MockDocument.use_extension(MockSecondExtension)
100
100
 
101
- expect(MockDocument.new().my_extension_method.to_s).to eq("override")
101
+ MockDocument.new().my_extension_method.to_s.should == "override"
102
102
  end
103
103
 
104
104
  describe "extension_parameters class-level hash" do
105
105
  it "should provide an extension_parameters hash at the class level" do
106
106
  MockDocument.extension_parameters[:key] = "value"
107
- expect(MockDocument.extension_parameters[:key]).to eq("value")
107
+ MockDocument.extension_parameters[:key].should == "value"
108
108
  end
109
109
 
110
110
  it "extension_parameters should not be shared between classes" do
@@ -118,7 +118,7 @@ describe "Blacklight::Solr::Document" do
118
118
  class_one.extension_parameters[:key] = "class_one_value"
119
119
  class_two.extension_parameters[:key] = "class_two_value"
120
120
 
121
- expect(class_one.extension_parameters[:key]).to eq("class_one_value")
121
+ class_one.extension_parameters[:key].should == "class_one_value"
122
122
  end
123
123
  end
124
124
 
@@ -136,14 +136,14 @@ describe "Blacklight::Solr::Document" do
136
136
  it "reports it's exportable formats properly" do
137
137
  doc = MockDocument.new
138
138
  doc.will_export_as(:marc, "application/marc" )
139
- expect(doc.export_formats).to have_key(:marc)
140
- expect(doc.export_formats[:marc][:content_type]).to eq("application/marc")
139
+ doc.export_formats.should have_key(:marc)
140
+ doc.export_formats[:marc][:content_type].should == "application/marc"
141
141
  end
142
142
 
143
143
  it "looks up content-type from Mime::Type if not given in arg" do
144
144
  doc = MockDocument.new
145
145
  doc.will_export_as(:html)
146
- expect(doc.export_formats).to have_key(:html)
146
+ doc.export_formats.should have_key(:html)
147
147
  end
148
148
 
149
149
  context "format not registered with Mime::Type" do
@@ -154,17 +154,17 @@ describe "Blacklight::Solr::Document" do
154
154
  # registration in an after, sorry.
155
155
  end
156
156
  it "registers format" do
157
- expect(defined?("Mime::MOCK2")).to be_truthy
157
+ defined?("Mime::MOCK2").should be_true
158
158
  end
159
159
  it "registers as alias only" do
160
- expect(Mime::Type.lookup("application/mock2")).not_to equal(Mime::Type.lookup_by_extension("mock2"))
160
+ Mime::Type.lookup("application/mock2").should_not equal(Mime::Type.lookup_by_extension("mock2"))
161
161
  end
162
162
  end
163
163
 
164
164
  it "export_as(:format) by calling export_as_format" do
165
165
  doc = MockDocument.new
166
166
  doc.will_export_as(:marc, "application/marc")
167
- expect(doc.export_as(:marc)).to eq("fake_marc")
167
+ doc.export_as(:marc).should == "fake_marc"
168
168
  end
169
169
  end
170
170
 
@@ -183,17 +183,17 @@ describe "Blacklight::Solr::Document" do
183
183
  end
184
184
 
185
185
  it "should return complete dictionary based on config'd fields" do
186
- expect(@doc1.to_semantic_values).to eq({:title => ["doc1 title"], :something => ["val1", "val2"]})
186
+ @doc1.to_semantic_values.should == {:title => ["doc1 title"], :something => ["val1", "val2"]}
187
187
  end
188
188
  it "should return empty array for a key without a value" do
189
- expect(@doc1.to_semantic_values[:author]).to eq([])
190
- expect(@doc1.to_semantic_values[:nonexistent_token]).to eq([])
189
+ @doc1.to_semantic_values[:author].should == []
190
+ @doc1.to_semantic_values[:nonexistent_token].should == []
191
191
  end
192
192
  it "should return an array even for a single-value field" do
193
- expect(@doc1.to_semantic_values[:title]).to be_kind_of(Array)
193
+ @doc1.to_semantic_values[:title].should be_kind_of(Array)
194
194
  end
195
195
  it "should return complete array for a multi-value field" do
196
- expect(@doc1.to_semantic_values[:something]).to eq(["val1", "val2"])
196
+ @doc1.to_semantic_values[:something].should == ["val1", "val2"]
197
197
  end
198
198
 
199
199
  end
@@ -207,27 +207,27 @@ describe "Blacklight::Solr::Document" do
207
207
 
208
208
  describe "#has_highlight_field?" do
209
209
  it "should be true if the highlight field is in the solr response" do
210
- expect(@document).to have_highlight_field 'title_text'
211
- expect(@document).to have_highlight_field :title_text
210
+ @document.should have_highlight_field 'title_text'
211
+ @document.should have_highlight_field :title_text
212
212
  end
213
213
 
214
214
  it "should be false if the highlight field isn't in the solr response" do
215
- expect(@document).not_to have_highlight_field 'nonexisting_field'
215
+ @document.should_not have_highlight_field 'nonexisting_field'
216
216
  end
217
217
  end
218
218
 
219
219
  describe "#highlight_field" do
220
220
  it "should return a value" do
221
- expect(@document.highlight_field('title_text')).to include('doc <em>1</em>')
221
+ @document.highlight_field('title_text').should include('doc <em>1</em>')
222
222
  end
223
223
 
224
224
 
225
225
  it "should return a value that is html safe" do
226
- expect(@document.highlight_field('title_text').first).to be_html_safe
226
+ @document.highlight_field('title_text').first.should be_html_safe
227
227
  end
228
228
 
229
229
  it "should return nil when the field doesn't exist" do
230
- expect(@document.highlight_field('nonexisting_field')).to be_nil
230
+ @document.highlight_field('nonexisting_field').should be_nil
231
231
  end
232
232
  end
233
233
  end
@@ -11,47 +11,47 @@ describe Blacklight::SolrResponse do
11
11
  let(:r) { create_response }
12
12
 
13
13
  it 'should create a valid response' do
14
- expect(r).to respond_to(:header)
14
+ r.should respond_to(:header)
15
15
  end
16
16
 
17
17
  it 'should have accurate pagination numbers' do
18
- expect(r.rows).to eq(11)
19
- expect(r.total).to eq(26)
20
- expect(r.start).to eq(0)
18
+ r.rows.should == 11
19
+ r.total.should == 26
20
+ r.start.should == 0
21
21
  end
22
22
 
23
23
  it 'should create a valid response class' do
24
- expect(r).to respond_to(:response)
25
- expect(r.docs.size).to eq(11)
26
- expect(r.params[:echoParams]).to eq('EXPLICIT')
24
+ r.should respond_to(:response)
25
+ r.docs.size.should == 11
26
+ r.params[:echoParams].should == 'EXPLICIT'
27
27
 
28
- expect(r).to be_a(Blacklight::SolrResponse::Facets)
28
+ r.should be_a(Blacklight::SolrResponse::Facets)
29
29
  end
30
30
 
31
31
  it 'should provide facet helpers' do
32
- expect(r.facets.size).to eq(2)
32
+ r.facets.size.should == 2
33
33
 
34
34
  field_names = r.facets.collect{|facet|facet.name}
35
- expect(field_names.include?('cat')).to eq(true)
36
- expect(field_names.include?('manu')).to eq(true)
35
+ field_names.include?('cat').should == true
36
+ field_names.include?('manu').should == true
37
37
 
38
38
  first_facet = r.facets.select { |x| x.name == 'cat'}.first
39
- expect(first_facet.name).to eq('cat')
39
+ first_facet.name.should == 'cat'
40
40
 
41
- expect(first_facet.items.size).to eq(10)
41
+ first_facet.items.size.should == 10
42
42
 
43
43
  expected = "electronics - 14, memory - 3, card - 2, connector - 2, drive - 2, graphics - 2, hard - 2, monitor - 2, search - 2, software - 2"
44
44
  received = first_facet.items.collect do |item|
45
45
  item.value + ' - ' + item.hits.to_s
46
46
  end.join(', ')
47
47
 
48
- expect(received).to eq(expected)
48
+ received.should == expected
49
49
 
50
50
  r.facets.each do |facet|
51
- expect(facet.respond_to?(:name)).to eq(true)
51
+ facet.respond_to?(:name).should == true
52
52
  facet.items.each do |item|
53
- expect(item.respond_to?(:value)).to eq(true)
54
- expect(item.respond_to?(:hits)).to eq(true)
53
+ item.respond_to?(:value).should == true
54
+ item.respond_to?(:hits).should == true
55
55
  end
56
56
  end
57
57
 
@@ -70,43 +70,44 @@ describe Blacklight::SolrResponse do
70
70
  end
71
71
 
72
72
  it "should provide a model name helper" do
73
- first_doc_model_name = double(:human => 'xyz')
73
+ first_doc_model_name = 'xyz'
74
74
 
75
- allow(r.docs.first).to receive(:model_name).and_return first_doc_model_name
75
+ r.docs.first.stub(:model_name).and_return first_doc_model_name
76
76
 
77
77
  expect(r.model_name).to eq first_doc_model_name
78
+
78
79
  end
79
80
 
80
81
  describe "FacetItem" do
81
82
  it "should work with a field,value tuple" do
82
83
  item = Blacklight::SolrResponse::Facets::FacetItem.new('value', 15)
83
- expect(item.value).to eq('value')
84
- expect(item.hits).to eq(15)
84
+ item.value.should == 'value'
85
+ item.hits.should == 15
85
86
  end
86
87
 
87
88
  it "should work with a field,value + hash triple" do
88
89
  item = Blacklight::SolrResponse::Facets::FacetItem.new('value', 15, :a => 1, :value => 'ignored')
89
- expect(item.value).to eq('value')
90
- expect(item.hits).to eq(15)
91
- expect(item.a).to eq(1)
90
+ item.value.should == 'value'
91
+ item.hits.should == 15
92
+ item.a.should == 1
92
93
  end
93
94
 
94
95
  it "should work like an openstruct" do
95
96
  item = Blacklight::SolrResponse::Facets::FacetItem.new(:value => 'value', :hits => 15)
96
97
 
97
- expect(item.hits).to eq(15)
98
- expect(item.value).to eq('value')
99
- expect(item).to be_a_kind_of(OpenStruct)
98
+ item.hits.should == 15
99
+ item.value.should == 'value'
100
+ item.should be_a_kind_of(OpenStruct)
100
101
  end
101
102
 
102
103
  it "should provide a label accessor" do
103
104
  item = Blacklight::SolrResponse::Facets::FacetItem.new('value', :hits => 15)
104
- expect(item.label).to eq('value')
105
+ item.label.should == 'value'
105
106
  end
106
107
 
107
108
  it "should use a provided label" do
108
109
  item = Blacklight::SolrResponse::Facets::FacetItem.new('value', 15, :label => 'custom label')
109
- expect(item.label).to eq('custom label')
110
+ item.label.should == 'custom label'
110
111
 
111
112
  end
112
113
 
@@ -115,72 +116,66 @@ describe Blacklight::SolrResponse do
115
116
  it 'should return the correct value when calling facet_by_field_name' do
116
117
  r = create_response
117
118
  facet = r.facet_by_field_name('cat')
118
- expect(facet.name).to eq('cat')
119
+ facet.name.should == 'cat'
119
120
  end
120
121
 
121
122
  it 'should provide the responseHeader params' do
122
123
  raw_response = eval(mock_query_response)
123
124
  raw_response['responseHeader']['params']['test'] = :test
124
125
  r = Blacklight::SolrResponse.new(raw_response, raw_response['params'])
125
- expect(r.params['test']).to eq(:test)
126
+ r.params['test'].should == :test
126
127
  end
127
128
 
128
129
  it 'should provide the solr-returned params and "rows" should be 11' do
129
130
  raw_response = eval(mock_query_response)
130
131
  r = Blacklight::SolrResponse.new(raw_response, {})
131
- expect(r.params[:rows].to_s).to eq('11')
132
+ r.params[:rows].to_s.should == '11'
132
133
  end
133
134
 
134
135
  it 'should provide the ruby request params if responseHeader["params"] does not exist' do
135
136
  raw_response = eval(mock_query_response)
136
137
  raw_response.delete 'responseHeader'
137
138
  r = Blacklight::SolrResponse.new(raw_response, :rows => 999)
138
- expect(r.params[:rows].to_s).to eq('999')
139
+ r.params[:rows].to_s.should == '999'
139
140
  end
140
141
 
141
142
  it 'should provide spelling suggestions for regular spellcheck results' do
142
143
  raw_response = eval(mock_response_with_spellcheck)
143
144
  r = Blacklight::SolrResponse.new(raw_response, {})
144
- expect(r.spelling.words).to include("dell")
145
- expect(r.spelling.words).to include("ultrasharp")
145
+ r.spelling.words.should include("dell")
146
+ r.spelling.words.should include("ultrasharp")
146
147
  end
147
148
 
148
149
  it 'should provide spelling suggestions for extended spellcheck results' do
149
150
  raw_response = eval(mock_response_with_spellcheck_extended)
150
151
  r = Blacklight::SolrResponse.new(raw_response, {})
151
- expect(r.spelling.words).to include("dell")
152
- expect(r.spelling.words).to include("ultrasharp")
152
+ r.spelling.words.should include("dell")
153
+ r.spelling.words.should include("ultrasharp")
153
154
  end
154
155
 
155
156
  it 'should provide no spelling suggestions when extended results and suggestion frequency is the same as original query frequency' do
156
157
  raw_response = eval(mock_response_with_spellcheck_same_frequency)
157
158
  r = Blacklight::SolrResponse.new(raw_response, {})
158
- expect(r.spelling.words).to eq([])
159
+ r.spelling.words.should == []
159
160
  end
160
161
 
161
162
  it 'should provide spelling suggestions for a regular spellcheck results with a collation' do
162
163
  raw_response = eval(mock_response_with_spellcheck_collation)
163
164
  r = Blacklight::SolrResponse.new(raw_response, {})
164
- expect(r.spelling.words).to include("dell")
165
- expect(r.spelling.words).to include("ultrasharp")
165
+ r.spelling.words.should include("dell")
166
+ r.spelling.words.should include("ultrasharp")
166
167
  end
167
168
 
168
169
  it 'should provide spelling suggestion collation' do
169
170
  raw_response = eval(mock_response_with_spellcheck_collation)
170
171
  r = Blacklight::SolrResponse.new(raw_response, {})
171
- expect(r.spelling.collation).to eq('dell ultrasharp')
172
+ r.spelling.collation.should == 'dell ultrasharp'
172
173
  end
173
174
 
174
175
  it "should provide MoreLikeThis suggestions" do
175
176
  raw_response = eval(mock_response_with_more_like_this)
176
177
  r = Blacklight::SolrResponse.new(raw_response, {})
177
- expect(r.more_like(double(:id => '79930185')).size).to eq(2)
178
- end
179
-
180
- it "should be empty when the response has no results" do
181
- r = Blacklight::SolrResponse.new({}, {})
182
- allow(r).to receive_messages(:total => 0)
183
- expect(r).to be_empty
178
+ r.more_like(double(:id => '79930185')).should have(2).items
184
179
  end
185
180
 
186
181
  def mock_query_response