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,7 +15,7 @@ describe "blacklight:delete_old_searches" do
15
15
 
16
16
  it "should call Search.delete_old_searches" do
17
17
  days_old = 7
18
- expect(Search).to receive(:delete_old_searches).with(days_old)
18
+ Search.should_receive(:delete_old_searches).with(days_old)
19
19
  @rake[@task_name].invoke(days_old)
20
20
  end
21
21
 
@@ -6,16 +6,16 @@ describe 'Blacklight::Utils' do
6
6
  it "should provide hash-like accessors for OpenStruct data" do
7
7
  a = Blacklight::OpenStructWithHashAccess.new :foo => :bar, :baz => 1
8
8
 
9
- expect(a[:foo]).to eq(:bar)
10
- expect(a[:baz]).to eq(1)
11
- expect(a[:asdf]).to be_nil
9
+ a[:foo].should == :bar
10
+ a[:baz].should == 1
11
+ a[:asdf].should be_nil
12
12
  end
13
13
 
14
14
  it "should provide hash-like writers for OpenStruct data" do
15
15
  a = Blacklight::OpenStructWithHashAccess.new :foo => :bar, :baz => 1
16
16
 
17
17
  a[:asdf] = 'qwerty'
18
- expect(a.asdf).to eq('qwerty')
18
+ a.asdf.should == 'qwerty'
19
19
 
20
20
  end
21
21
 
@@ -23,66 +23,36 @@ describe 'Blacklight::Utils' do
23
23
  h = Blacklight::OpenStructWithHashAccess.new
24
24
 
25
25
  h["string"] = "value"
26
- expect(h[:string]).to eq("value")
27
- expect(h.string).to eq("value")
26
+ h[:string].should == "value"
27
+ h.string.should == "value"
28
28
 
29
29
  h[:symbol] = "value"
30
- expect(h["symbol"]).to eq("value")
31
- expect(h.symbol).to eq("value")
30
+ h["symbol"].should == "value"
31
+ h.symbol.should == "value"
32
32
  end
33
33
 
34
34
  describe "internal hash table" do
35
35
  before do
36
36
  @h = Blacklight::OpenStructWithHashAccess.new
37
+
37
38
  @h[:a] = 1
38
39
  @h[:b] = 2
39
- end
40
40
 
41
- it "should expose the internal hash table" do
42
- expect(@h.to_h).to be_a_kind_of(Hash)
43
- expect(@h.to_h[:a]).to eq(1)
44
- end
45
41
 
46
- it "should expose keys" do
47
- expect(@h.keys).to include(:a, :b)
48
- end
49
- end
50
-
51
- describe "#merge" do
52
-
53
- before do
54
- @h = Blacklight::OpenStructWithHashAccess.new
55
- @h[:a] = 1
56
- @h[:b] = 2
57
42
  end
58
-
59
- it "should merge the object with a hash" do
60
- expect(@h.merge(:a => 'a')[:a]).to eq 'a'
43
+ it "should expose the internal hash table" do
44
+ @h.to_h.should be_a_kind_of(Hash)
45
+ @h.to_h[:a].should == 1
61
46
  end
62
47
 
63
- it "should merge the object with another struct" do
64
- expect(@h.merge(Blacklight::OpenStructWithHashAccess.new(:a => 'a'))[:a]).to eq 'a'
48
+ it "should expose keys" do
49
+ @h.keys.should include(:a, :b)
65
50
  end
66
- end
67
51
 
68
-
69
- describe "#merge!" do
70
-
71
- before do
72
- @h = Blacklight::OpenStructWithHashAccess.new
73
- @h[:a] = 1
74
- @h[:b] = 2
75
- end
76
-
77
- it "should merge the object with a hash" do
78
- @h.merge!(:a => 'a')
79
- expect(@h[:a]).to eq 'a'
52
+ it "should expose merge" do
53
+ @h.merge(:a => 'a')[:a].should == 'a'
80
54
  end
81
55
 
82
- it "should merge the object with another struct" do
83
- @h.merge!(Blacklight::OpenStructWithHashAccess.new(:a => 'a'))
84
- expect(@h[:a]).to eq 'a'
85
- end
86
56
  end
87
57
  end
88
58
  end
@@ -5,21 +5,20 @@ describe Bookmark do
5
5
  before(:each) do
6
6
  @bookmark = Bookmark.new
7
7
  end
8
-
8
+
9
9
  it "should be valid" do
10
10
  @bookmark.id = 1
11
11
  @bookmark.user_id = 1
12
12
  @bookmark.document_id = 'u001'
13
- expect(@bookmark).to be_valid
13
+ @bookmark.should be_valid
14
14
  end
15
-
15
+
16
16
  it "should require user_id" do
17
- expect(@bookmark).not_to be_valid
18
- expect(@bookmark.errors[:user_id].length).to eq 1
17
+ @bookmark.should have(1).error_on(:user_id)
19
18
  end
20
19
 
21
20
  it "should belong to user" do
22
- expect(Bookmark.reflect_on_association(:user)).not_to be_nil
21
+ Bookmark.reflect_on_association(:user).should_not be_nil
23
22
  end
24
23
 
25
24
  it "should be valid after saving" do
@@ -27,6 +26,6 @@ describe Bookmark do
27
26
  @bookmark.user_id = 1
28
27
  @bookmark.document_id = 'u001'
29
28
  @bookmark.save
30
- expect(@bookmark).to be_valid
29
+ @bookmark.should be_valid
31
30
  end
32
31
  end
@@ -4,7 +4,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
4
 
5
5
  describe RecordMailer do
6
6
  before(:each) do
7
- allow(RecordMailer).to receive(:default) { { :from => 'no-reply@projectblacklight.org' } }
7
+ RecordMailer.stub(:default) { { :from => 'no-reply@projectblacklight.org' } }
8
8
  SolrDocument.use_extension( Blacklight::Solr::Document::Email )
9
9
  SolrDocument.use_extension( Blacklight::Solr::Document::Sms )
10
10
  document = SolrDocument.new({:id=>"123456", :format=>["book"], :title_display => "The horn", :language_facet => "English", :author_display => "Janetzky, Kurt"})
@@ -16,26 +16,26 @@ describe RecordMailer do
16
16
  @email = RecordMailer.email_record(@documents,details,{:host =>'projectblacklight.org', :protocol => 'https'})
17
17
  end
18
18
  it "should receive the TO paramater and send the email to that address" do
19
- expect(@email.to).to eq(['test@test.com'])
19
+ @email.to.should == ['test@test.com']
20
20
  end
21
21
  it "should start the subject w/ Item Record:" do
22
- expect(@email.subject).to match(/^Item Record:/)
22
+ @email.subject.should =~ /^Item Record:/
23
23
  end
24
24
  it "should put the title of the item in the subject" do
25
- expect(@email.subject).to match(/The horn/)
25
+ @email.subject.should =~ /The horn/
26
26
  end
27
27
  it "should have the correct from address (w/o the port number)" do
28
- expect(@email.from).to eq(["no-reply@projectblacklight.org"])
28
+ @email.from.should == ["no-reply@projectblacklight.org"]
29
29
  end
30
30
  it "should print out the correct body" do
31
- expect(@email.body).to match(/Title: The horn/)
32
- expect(@email.body).to match(/Author: Janetzky, Kurt/)
33
- expect(@email.body).to match(/projectblacklight.org/)
31
+ @email.body.should =~ /Title: The horn/
32
+ @email.body.should =~ /Author: Janetzky, Kurt/
33
+ @email.body.should =~ /projectblacklight.org/
34
34
  end
35
35
  it "should use https URLs when protocol is set" do
36
36
  details = {:to => 'test@test.com', :message => "This is my message"}
37
37
  @https_email = RecordMailer.email_record(@documents,details,{:host =>'projectblacklight.org', :protocol => 'https'})
38
- expect(@https_email.body).to match(%r|https://projectblacklight.org/|)
38
+ @https_email.body.should =~ %r|https://projectblacklight.org/|
39
39
  end
40
40
  end
41
41
 
@@ -45,23 +45,23 @@ describe RecordMailer do
45
45
  @sms = RecordMailer.sms_record(@documents,details,{:host =>'projectblacklight.org:3000'})
46
46
  end
47
47
  it "should create the correct TO address for the SMS email" do
48
- expect(@sms.to).to eq(['5555555555@txt.att.net'])
48
+ @sms.to.should == ['5555555555@txt.att.net']
49
49
  end
50
50
  it "should not have a subject" do
51
- expect(@sms.subject).to eq("") unless @sms.subject.nil?
51
+ @sms.subject.should == "" unless @sms.subject.nil?
52
52
  end
53
53
  it "should have the correct from address (w/o the port number)" do
54
- expect(@sms.from).to eq(["no-reply@projectblacklight.org"])
54
+ @sms.from.should == ["no-reply@projectblacklight.org"]
55
55
  end
56
56
  it "should print out the correct body" do
57
- expect(@sms.body).to match(/The horn/)
58
- expect(@sms.body).to match(/by Janetzky, Kurt/)
59
- expect(@sms.body).to match(/projectblacklight.org:3000/)
57
+ @sms.body.should =~ /The horn/
58
+ @sms.body.should =~ /by Janetzky, Kurt/
59
+ @sms.body.should =~ /projectblacklight.org:3000/
60
60
  end
61
61
  it "should use https URL when protocol is set" do
62
62
  details = {:to => '5555555555@txt.att.net'}
63
63
  @https_sms = RecordMailer.sms_record(@documents,details,{:host =>'projectblacklight.org', :protocol => 'https'})
64
- expect(@https_sms.body).to match(%r|https://projectblacklight.org/|)
64
+ @https_sms.body.should =~ %r|https://projectblacklight.org/|
65
65
  end
66
66
  end
67
67
 
@@ -14,7 +14,7 @@ describe Search do
14
14
  it "should return a Hash as the value" do
15
15
  @search.query_params = @query_params
16
16
  assert @search.save
17
- expect(Search.find(@search.id).query_params).to eq(@query_params)
17
+ Search.find(@search.id).query_params.should == @query_params
18
18
  end
19
19
  end
20
20
 
@@ -24,23 +24,23 @@ describe Search do
24
24
  @search.user_id = 1
25
25
  @search.save
26
26
 
27
- expect(@search.saved?).to be_truthy
27
+ @search.saved?.should be_true
28
28
  end
29
29
  it "should be false when user_id is NULL or less than 1" do
30
30
  @search = Search.create
31
- expect(@search.saved?).not_to be_truthy
31
+ @search.saved?.should_not be_true
32
32
  end
33
33
  end
34
34
 
35
35
  describe "delete_old_searches" do
36
36
  it "should throw an ArgumentError if days_old is not a number" do
37
- expect { Search.delete_old_searches("blah") }.to raise_error(ArgumentError)
37
+ lambda { Search.delete_old_searches("blah") }.should raise_error(ArgumentError)
38
38
  end
39
39
  it "should throw an ArgumentError if days_old is equal to 0" do
40
- expect { Search.delete_old_searches(0) }.to raise_error(ArgumentError)
40
+ lambda { Search.delete_old_searches(0) }.should raise_error(ArgumentError)
41
41
  end
42
42
  it "should throw an ArgumentError if days_old is less than 0" do
43
- expect { Search.delete_old_searches(-1) }.to raise_error(ArgumentError)
43
+ lambda { Search.delete_old_searches(-1) }.should raise_error(ArgumentError)
44
44
  end
45
45
  it "should destroy searches with no user_id that are older than X days" do
46
46
  Search.destroy_all
@@ -65,9 +65,9 @@ describe Search do
65
65
  saved_search_past.created_at = Date.today - (days_old + 1).days
66
66
  saved_search_past.save
67
67
 
68
- expect do
68
+ lambda do
69
69
  Search.delete_old_searches(days_old)
70
- end.to change(Search, :count).by(-1)
70
+ end.should change(Search, :count).by(-1)
71
71
  end
72
72
 
73
73
  end
@@ -1,104 +1,33 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
- require 'rubygems'
5
- require 'marc'
6
4
 
7
- # WARNING!!!
8
- # If you set any values in Blacklight here, you must reset them to the original
9
- # values in an after() block so other tests get expected results.
10
- # Blacklight is a Singleton for application configuration.
11
-
12
- ## TODO: ALL these specs probably really ought to be on the modules
13
- # being tested, not on the bare SolrDocument class that has no logic
14
- # of it's own, it just includes modules. No? jrochkind 29 Mar 2010
15
-
16
- def get_hash_with_marcxml
17
- {'responseHeader'=>{'status'=>0,'QTime'=>0,'params'=>{'q'=>'id:00282214','wt'=>'ruby'}},'response'=>{'numFound'=>1,'start'=>0,'docs'=>[{'id'=>'00282214', "marc_display" =>'<record xmlns=\'http://www.loc.gov/MARC21/slim\'><leader>00799cam a2200241 a 4500</leader><controlfield tag=\'001\'> 00282214 </controlfield><controlfield tag=\'003\'>DLC</controlfield><controlfield tag=\'005\'>20090120022042.0</controlfield><controlfield tag=\'008\'>000417s1998 pk 000 0 urdo </controlfield><datafield tag=\'010\' ind1=\' \' ind2=\' \'><subfield code=\'a\'> 00282214 </subfield></datafield><datafield tag=\'025\' ind1=\' \' ind2=\' \'><subfield code=\'a\'>P-U-00282214; 05; 06</subfield></datafield><datafield tag=\'040\' ind1=\' \' ind2=\' \'><subfield code=\'a\'>DLC</subfield><subfield code=\'c\'>DLC</subfield><subfield code=\'d\'>DLC</subfield></datafield><datafield tag=\'041\' ind1=\'1\' ind2=\' \'><subfield code=\'a\'>urd</subfield><subfield code=\'h\'>snd</subfield></datafield><datafield tag=\'042\' ind1=\' \' ind2=\' \'><subfield code=\'a\'>lcode</subfield></datafield><datafield tag=\'050\' ind1=\'0\' ind2=\'0\'><subfield code=\'a\'>PK2788.9.A9</subfield><subfield code=\'b\'>F55 1998</subfield></datafield><datafield tag=\'100\' ind1=\'1\' ind2=\' \'><subfield code=\'a\'>Ayaz, Shaikh,</subfield><subfield code=\'d\'>1923-1997.</subfield></datafield><datafield tag=\'245\' ind1=\'1\' ind2=\'0\'><subfield code=\'a\'>Fikr-i Ayāz /</subfield><subfield code=\'c\'>murattibīn, Āṣif Farruk̲h̲ī, Shāh Muḥammad Pīrzādah.</subfield></datafield><datafield tag=\'260\' ind1=\' \' ind2=\' \'><subfield code=\'a\'>Karācī :</subfield><subfield code=\'b\'>Dāniyāl,</subfield><subfield code=\'c\'>[1998]</subfield></datafield><datafield tag=\'300\' ind1=\' \' ind2=\' \'><subfield code=\'a\'>375 p. ;</subfield><subfield code=\'c\'>23 cm.</subfield></datafield><datafield tag=\'546\' ind1=\' \' ind2=\' \'><subfield code=\'a\'>In Urdu.</subfield></datafield><datafield tag=\'520\' ind1=\' \' ind2=\' \'><subfield code=\'a\'>Selected poems and articles from the works of renowned Sindhi poet; chiefly translated from Sindhi.</subfield></datafield><datafield tag=\'700\' ind1=\'1\' ind2=\' \'><subfield code=\'a\'>Farruk̲h̲ī, Āṣif,</subfield><subfield code=\'d\'>1959-</subfield></datafield><datafield tag=\'700\' ind1=\'1\' ind2=\' \'><subfield code=\'a\'>Pīrzādah, Shāh Muḥammad.</subfield></datafield></record>','timestamp'=>'2009-03-26T18:15:31.074Z','material_type_display'=>['375 p'],'title_display'=>['Fikr-i Ayāz'],'author_display'=>['Farruk̲h̲ī, Āṣif','Pīrzādah, Shāh Muḥammad'],'language_facet'=>['Urdu'],'format'=>['Book'],'published_display'=>['Karācī']}]}}
18
- end
19
- def get_hash_without_marcxml
20
- {'responseHeader'=>{'status'=>0,'QTime'=>0,'params'=>{'q'=>'id:00282214','wt'=>'ruby'}},'response'=>{'numFound'=>1,'start'=>0,'docs'=>[{'id'=>'00282214','timestamp'=>'2009-03-26T18:15:31.074Z','material_type_display'=>['375 p'],'title_display'=>['Fikr-i Ayāz'],'author_display'=>['Farruk̲h̲ī, Āṣif','Pīrzādah, Shāh Muḥammad'],'language_facet'=>['Urdu'],'format'=>['Book'],'published_display'=>['Karācī']}]}}
21
- end
22
-
23
- def get_hash_with_marc21
24
- reader = MARC::Reader.new(File.dirname(__FILE__) + '/../data/test_data.utf8.mrc')
25
- # doing weird i= stuff to get only first record. reader.first, or i = 0, i+1 didn't work and this was the only way I could get it working. Needs refactoring.
26
- i = "1st"
27
- for record in reader
28
- if i == "1st"
29
- first_rec = record.to_marc
30
- end
31
- i = "not1st"
32
- end
33
- return {'responseHeader'=>{'status'=>0,'QTime'=>0,'params'=>{'q'=>'id:00282214','wt'=>'ruby'}},'response'=>{'numFound'=>1,'start'=>0,'docs'=>[{'id'=>'00282214', "marc_display" => first_rec, 'timestamp'=>'2009-03-26T18:15:31.074Z','material_type_display'=>['375 p'],'title_display'=>['Fikr-i Ayāz'],'author_display'=>['Farruk̲h̲ī, Āṣif','Pīrzādah, Shāh Muḥammad'],'language_facet'=>['Urdu'],'format'=>['Book'],'published_display'=>['Karācī']}]}}
34
- end
35
-
36
5
  describe SolrDocument do
37
6
 
38
7
  before(:each) do
39
- @hash_with_marcxml = get_hash_with_marcxml['response']['docs'][0]
40
- SolrDocument.extension_parameters[:marc_source_field] = :marc_display
41
- SolrDocument.extension_parameters[:marc_format_type] = :marcxml
42
-
43
- # rsolr seems to reload SolrDocument from time to time, so we can't
44
- # count on the initializer to register the extension, need to re-register
45
- # it.
46
- SolrDocument.registered_extensions = nil
47
- SolrDocument.use_extension( Blacklight::Solr::Document::Marc ) { |document| document.has_key?(:marc_display)}
48
8
 
49
- @solrdoc = SolrDocument.new(@hash_with_marcxml)
9
+ @solrdoc = SolrDocument.new :id => '00282214', :format => ['Book'], :title_display => 'some-title'
50
10
 
51
11
  end
52
12
 
53
13
  describe "new" do
54
14
  it "should take a Hash as the argument" do
55
- expect { SolrDocument.new(@hash_with_marcxml) }.not_to raise_error
15
+ lambda { SolrDocument.new(:id => 1) }.should_not raise_error
56
16
  end
57
17
  end
58
18
 
59
19
  describe "access methods" do
60
20
 
61
21
  it "should have the right value for title_display" do
62
- expect(@solrdoc[:title_display]).not_to be_nil
22
+ @solrdoc[:title_display].should_not be_nil
63
23
  end
64
24
 
65
25
  it "should have the right value for format" do
66
- expect(@solrdoc[:format][0]).to eq('Book')
26
+ @solrdoc[:format][0].should == 'Book'
67
27
  end
68
28
 
69
29
  it "should provide the item's solr id" do
70
- expect(@solrdoc.id).to eq('00282214')
71
- end
72
- end
73
-
74
- describe "ruby marc creation" do
75
-
76
- it "should have a valid to_marc" do
77
- @solrdoc = SolrDocument.new(@hash_with_marcxml)
78
-
79
- expect(@solrdoc).to respond_to(:to_marc)
80
- expect(@solrdoc.to_marc).to be_kind_of(MARC::Record)
81
- end
82
-
83
- it "should not try to create marc for objects w/out stored marc (marcxml test only at this time)" do
84
- # TODO: Create another double object that does not have marc-xml in it and make
85
- # sure everything fails gracefully
86
- @hash_without_marcxml = get_hash_without_marcxml['response']['docs'][0]
87
- @solrdoc_without_marc = SolrDocument.new(@hash_without_marcxml)
88
- expect(@solrdoc_without_marc).not_to respond_to(:to_marc)
89
- # legacy check
90
- # @solrdoc_without_marc.should respond_to(:marc)
91
- # @solrdoc_without_marc.marc.should == nil
30
+ @solrdoc.id.should == '00282214'
92
31
  end
93
32
  end
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
- end
33
+ end
@@ -4,45 +4,51 @@ describe "Routing" do
4
4
  describe "Paths Generated by Custom Routes:" do
5
5
  # paths generated by custom routes
6
6
  it "should have a path for showing the email form" do
7
- expect({ :get => "/catalog/email" }).to route_to(:controller => 'catalog', :action => 'email')
7
+ { :get => "/catalog/email" }.should route_to(:controller => 'catalog', :action => 'email')
8
8
  end
9
9
  it "should have a path for sending the email" do
10
- expect({ :post => "/catalog/email" }).to route_to(:controller => 'catalog', :action => 'email')
10
+ { :post => "/catalog/email" }.should route_to(:controller => 'catalog', :action => 'email')
11
11
  end
12
12
  it "should map {:controller => 'catalog', :action => 'sms'} to /catalog/sms" do
13
- expect({ :get => "/catalog/sms" }).to route_to(:controller => 'catalog', :action => 'sms')
13
+ { :get => "/catalog/sms" }.should route_to(:controller => 'catalog', :action => 'sms')
14
14
  end
15
15
  it "should map { :controller => 'catalog', :action => 'show', :id => 666 } to /catalog/666" do
16
- expect({ :get => "/catalog/666" }).to route_to(:controller => 'catalog', :action => 'show', :id => "666")
16
+ { :get => "/catalog/666" }.should route_to(:controller => 'catalog', :action => 'show', :id => "666")
17
17
  end
18
18
  it "should map {:controller => 'catalog', :id => '111', :action => 'librarian_view'} to /catalog/111/librarian_view" do
19
- expect({ :get => "/catalog/111/librarian_view" }).to route_to(:controller => 'catalog', :action => 'librarian_view', :id => "111")
19
+ { :get => "/catalog/111/librarian_view" }.should route_to(:controller => 'catalog', :action => 'librarian_view', :id => "111")
20
+ { :get => librarian_view_catalog_path('111') }.should route_to(:controller => 'catalog', :action => 'librarian_view', :id => "111")
20
21
  end
21
22
  end
22
23
 
23
24
 
24
25
  describe "catalog_path for SolrDocument", :test => true do
25
26
  it "should route correctly" do
26
- expect({ :get => catalog_path(SolrDocument.new(:id => 'asdf')) }).to route_to(:controller => 'catalog', :action => 'show', :id => 'asdf')
27
+ { :get => catalog_path(SolrDocument.new(:id => 'asdf')) }.should route_to(:controller => 'catalog', :action => 'show', :id => 'asdf')
27
28
  end
28
29
 
29
30
  context "should escape solr document ids" do
30
31
 
31
32
  it "should pass-through url-valid ids" do
32
- expect({ :get => catalog_path(SolrDocument.new(:id => 'qwerty'))}).to route_to(:controller => 'catalog', :action => 'show', :id => 'qwerty')
33
+ { :get => catalog_path(SolrDocument.new(:id => 'qwerty'))}.should route_to(:controller => 'catalog', :action => 'show', :id => 'qwerty')
33
34
  end
34
35
 
35
36
  it "should route url-like ids" do
36
37
  pending "This works if you configure your routing to have very liberal constraints on :id.. not sure how to go about testing it though"
37
- expect({ :get => catalog_path(SolrDocument.new(:id => 'http://example.com'))}).to route_to(:controller => 'catalog', :action => 'show', :id => 'http://example.com')
38
+ { :get => catalog_path(SolrDocument.new(:id => 'http://example.com'))}.should route_to(:controller => 'catalog', :action => 'show', :id => 'http://example.com')
38
39
  end
39
40
 
40
41
  it "should route ids with whitespace" do
41
- expect({ :get => catalog_path(SolrDocument.new(:id => 'mm 123')) }).to route_to(:controller => 'catalog', :action => 'show', :id => 'mm 123')
42
+ { :get => catalog_path(SolrDocument.new(:id => 'mm 123')) }.should route_to(:controller => 'catalog', :action => 'show', :id => 'mm 123')
42
43
  end
43
44
 
44
45
  it "should route ids with a literal '+'" do
45
- expect({ :get => catalog_path(SolrDocument.new(:id => 'this+that')) }).to route_to(:controller => 'catalog', :action => 'show', :id => 'this+that')
46
+ { :get => catalog_path(SolrDocument.new(:id => 'this+that')) }.should route_to(:controller => 'catalog', :action => 'show', :id => 'this+that')
47
+ end
48
+
49
+ it "should route ids with a literal '/" do
50
+ pending "This works if you configure your routing to have very liberal constraints on :id.. not sure how to go about testing it though"
51
+ { :get => catalog_path(SolrDocument.new(:id => 'and/or')) }.should route_to(:controller => 'catalog', :action => 'show', :id => 'and/or')
46
52
  end
47
53
  end
48
54
  end
@@ -1,7 +1,7 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  # This file is copied to spec/ when you run 'rails generate rspec:install'
3
3
  # Has been customized by Blacklight to work when application is in one place,
4
- # and actual spec/ stuff is in another (the blacklight gem checkout).
4
+ # and actual spec/ stuff is in another (the blacklight gem checkout).
5
5
 
6
6
  ENV["RAILS_ENV"] ||= 'test'
7
7
 
@@ -16,15 +16,17 @@ if ENV['COVERAGE'] and RUBY_VERSION =~ /^1.9/ and ruby_engine != "jruby"
16
16
  end
17
17
  end
18
18
 
19
+ require 'blacklight'
20
+ require 'blacklight_marc'
21
+
19
22
  require 'engine_cart'
20
23
  EngineCart.load_application!
21
24
 
22
25
  require 'rspec/rails'
23
- require 'rspec/its'
24
26
  require 'capybara/rspec'
25
27
  require 'capybara/poltergeist'
26
28
 
27
- Capybara.server = :webrick
29
+
28
30
  Capybara.javascript_driver = :poltergeist
29
31
 
30
32
  Capybara.register_driver :poltergeist do |app|
@@ -37,8 +39,8 @@ end
37
39
 
38
40
  # Requires supporting ruby files with custom matchers and macros, etc,
39
41
  # in spec/support/ and its subdirectories.
40
- # Blacklight, again, make sure we're looking in the right place for em.
41
- # Relative to HERE, NOT to Rails.root, which is off somewhere else.
42
+ # Blacklight, again, make sure we're looking in the right place for em.
43
+ # Relative to HERE, NOT to Rails.root, which is off somewhere else.
42
44
  Dir[Pathname.new(File.expand_path("../support/**/*.rb", __FILE__))].each {|f| require f}
43
45
 
44
46
  RSpec.configure do |config|
@@ -58,6 +60,4 @@ RSpec.configure do |config|
58
60
  # examples within a transaction, remove the following line or assign false
59
61
  # instead of true.
60
62
  config.use_transactional_fixtures = true
61
-
62
- config.infer_spec_type_from_file_location!
63
63
  end