blacklight 6.0.0.pre5 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (242) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +8 -8
  3. data/Gemfile +11 -2
  4. data/VERSION +1 -1
  5. data/app/assets/stylesheets/blacklight/_facets.scss +1 -10
  6. data/app/controllers/bookmarks_controller.rb +1 -0
  7. data/app/controllers/catalog_controller.rb +1 -0
  8. data/app/controllers/concerns/blacklight/base.rb +1 -0
  9. data/app/controllers/concerns/blacklight/bookmarks.rb +13 -1
  10. data/app/controllers/concerns/blacklight/catalog.rb +7 -1
  11. data/app/controllers/concerns/blacklight/controller.rb +7 -6
  12. data/app/controllers/concerns/blacklight/default_component_configuration.rb +1 -0
  13. data/app/controllers/concerns/blacklight/facet.rb +1 -0
  14. data/app/controllers/concerns/blacklight/request_builders.rb +1 -0
  15. data/app/controllers/concerns/blacklight/search_context.rb +8 -12
  16. data/app/controllers/concerns/blacklight/search_fields.rb +1 -0
  17. data/app/controllers/concerns/blacklight/search_helper.rb +2 -1
  18. data/app/controllers/concerns/blacklight/search_history.rb +32 -0
  19. data/app/controllers/concerns/blacklight/suggest.rb +1 -0
  20. data/app/controllers/concerns/blacklight/suggest_search.rb +1 -0
  21. data/app/controllers/concerns/blacklight/token_based_user.rb +1 -0
  22. data/app/controllers/saved_searches_controller.rb +20 -9
  23. data/app/controllers/search_history_controller.rb +2 -18
  24. data/app/controllers/suggest_controller.rb +1 -0
  25. data/app/helpers/blacklight/blacklight_helper_behavior.rb +1 -0
  26. data/app/helpers/blacklight/catalog_helper_behavior.rb +15 -1
  27. data/app/helpers/blacklight/component_helper_behavior.rb +1 -0
  28. data/app/helpers/blacklight/configuration_helper_behavior.rb +1 -0
  29. data/app/helpers/blacklight/deprecated_url_helper_behavior.rb +1 -0
  30. data/app/helpers/blacklight/facets_helper_behavior.rb +1 -0
  31. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +1 -0
  32. data/app/helpers/blacklight/layout_helper_behavior.rb +1 -0
  33. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +9 -6
  34. data/app/helpers/blacklight/render_partials_helper.rb +15 -4
  35. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -0
  36. data/app/helpers/blacklight/suggest_helper_behavior.rb +1 -0
  37. data/app/helpers/blacklight/url_helper_behavior.rb +6 -6
  38. data/app/helpers/blacklight_configuration_helper.rb +1 -0
  39. data/app/helpers/blacklight_helper.rb +1 -0
  40. data/app/helpers/blacklight_url_helper.rb +1 -0
  41. data/app/helpers/catalog_helper.rb +1 -0
  42. data/app/helpers/component_helper.rb +1 -0
  43. data/app/helpers/facets_helper.rb +1 -0
  44. data/app/helpers/hash_as_hidden_fields_helper.rb +1 -0
  45. data/app/helpers/layout_helper.rb +1 -0
  46. data/app/helpers/render_constraints_helper.rb +1 -0
  47. data/app/helpers/search_history_constraints_helper.rb +1 -0
  48. data/app/helpers/suggest_helper.rb +1 -0
  49. data/app/models/blacklight/facet_paginator.rb +6 -2
  50. data/app/models/blacklight/solr/facet_paginator.rb +1 -0
  51. data/app/models/bookmark.rb +1 -0
  52. data/app/models/concerns/blacklight/configurable.rb +1 -0
  53. data/app/models/concerns/blacklight/document.rb +1 -0
  54. data/app/models/concerns/blacklight/document/active_model_shim.rb +1 -0
  55. data/app/models/concerns/blacklight/document/cache_key.rb +1 -0
  56. data/app/models/concerns/blacklight/document/dublin_core.rb +1 -0
  57. data/app/models/concerns/blacklight/document/email.rb +1 -0
  58. data/app/models/concerns/blacklight/document/export.rb +1 -0
  59. data/app/models/concerns/blacklight/document/extensions.rb +1 -0
  60. data/app/models/concerns/blacklight/document/schema_org.rb +1 -0
  61. data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -0
  62. data/app/models/concerns/blacklight/document/sms.rb +1 -0
  63. data/app/models/concerns/blacklight/solr/document.rb +1 -0
  64. data/app/models/concerns/blacklight/solr/document/more_like_this.rb +1 -0
  65. data/app/models/concerns/blacklight/suggest/response.rb +1 -0
  66. data/app/models/concerns/blacklight/user.rb +1 -0
  67. data/app/models/record_mailer.rb +1 -0
  68. data/app/models/search.rb +4 -1
  69. data/app/models/solr_document.rb +1 -0
  70. data/app/presenters/blacklight/document_presenter.rb +17 -1
  71. data/app/presenters/blacklight/json_presenter.rb +1 -0
  72. data/app/views/bookmarks/_tools.html.erb +1 -1
  73. data/app/views/catalog/_facet_index_navigation.html.erb +2 -2
  74. data/app/views/catalog/_facet_pagination.html.erb +4 -4
  75. data/app/views/catalog/_search_results.html.erb +3 -5
  76. data/app/views/catalog/_view_type_group.html.erb +1 -1
  77. data/app/views/catalog/index.atom.builder +7 -7
  78. data/app/views/catalog/index.json.jbuilder +0 -1
  79. data/app/views/catalog/index.rss.builder +1 -4
  80. data/config/locales/blacklight.de.yml +0 -2
  81. data/config/locales/blacklight.es.yml +0 -2
  82. data/config/locales/blacklight.it.yml +0 -2
  83. data/config/locales/blacklight.pt-BR.yml +0 -6
  84. data/config/routes.rb +1 -0
  85. data/db/migrate/20140202020201_create_searches.rb +1 -0
  86. data/db/migrate/20140202020202_create_bookmarks.rb +1 -0
  87. data/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +1 -0
  88. data/lib/blacklight.rb +3 -1
  89. data/lib/blacklight/abstract_repository.rb +1 -0
  90. data/lib/blacklight/configuration.rb +1 -0
  91. data/lib/blacklight/configuration/context.rb +1 -0
  92. data/lib/blacklight/configuration/facet_field.rb +1 -0
  93. data/lib/blacklight/configuration/field.rb +1 -0
  94. data/lib/blacklight/configuration/fields.rb +1 -0
  95. data/lib/blacklight/configuration/search_field.rb +1 -0
  96. data/lib/blacklight/configuration/sort_field.rb +1 -0
  97. data/lib/blacklight/configuration/tool_config.rb +1 -0
  98. data/lib/blacklight/configuration/view_config.rb +1 -0
  99. data/lib/blacklight/engine.rb +1 -0
  100. data/lib/blacklight/exceptions.rb +1 -0
  101. data/lib/blacklight/parameters.rb +4 -4
  102. data/lib/blacklight/routes.rb +1 -0
  103. data/lib/blacklight/routes/exportable.rb +1 -0
  104. data/lib/blacklight/routes/searchable.rb +1 -0
  105. data/lib/blacklight/search_builder.rb +1 -0
  106. data/lib/blacklight/search_state.rb +22 -5
  107. data/lib/blacklight/solr.rb +1 -0
  108. data/lib/blacklight/solr/repository.rb +1 -0
  109. data/lib/blacklight/solr/request.rb +1 -0
  110. data/lib/blacklight/solr/response.rb +7 -1
  111. data/lib/blacklight/solr/response/facets.rb +1 -0
  112. data/lib/blacklight/solr/response/group.rb +1 -0
  113. data/lib/blacklight/solr/response/group_response.rb +1 -0
  114. data/lib/blacklight/solr/response/more_like_this.rb +1 -0
  115. data/lib/blacklight/solr/response/pagination_methods.rb +1 -0
  116. data/lib/blacklight/solr/response/response.rb +1 -0
  117. data/lib/blacklight/solr/response/spelling.rb +1 -0
  118. data/lib/blacklight/solr/search_builder_behavior.rb +19 -14
  119. data/lib/blacklight/utils.rb +1 -0
  120. data/lib/blacklight/version.rb +1 -0
  121. data/lib/generators/blacklight/assets_generator.rb +1 -0
  122. data/lib/generators/blacklight/controller_generator.rb +1 -0
  123. data/lib/generators/blacklight/document_generator.rb +1 -0
  124. data/lib/generators/blacklight/install_generator.rb +1 -0
  125. data/lib/generators/blacklight/models_generator.rb +1 -0
  126. data/lib/generators/blacklight/search_builder_generator.rb +1 -0
  127. data/lib/generators/blacklight/solr4_generator.rb +1 -0
  128. data/lib/generators/blacklight/solr5_generator.rb +2 -2
  129. data/lib/generators/blacklight/templates/alternate_controller.rb +1 -0
  130. data/lib/generators/blacklight/templates/catalog_controller.rb +1 -0
  131. data/lib/generators/blacklight/templates/search_builder.rb +1 -0
  132. data/lib/generators/blacklight/templates/solr_document.rb +1 -0
  133. data/lib/generators/blacklight/test_support_generator.rb +1 -0
  134. data/lib/generators/blacklight/user_generator.rb +10 -6
  135. data/lib/railties/blacklight.rake +3 -3
  136. data/spec/controllers/alternate_controller_spec.rb +1 -0
  137. data/spec/controllers/application_controller_spec.rb +1 -0
  138. data/spec/controllers/blacklight/base_spec.rb +5 -3
  139. data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +1 -0
  140. data/spec/controllers/blacklight/facet_spec.rb +1 -0
  141. data/spec/controllers/blacklight/search_fields_spec.rb +1 -0
  142. data/spec/controllers/blacklight/search_helper_spec.rb +1 -0
  143. data/spec/controllers/blacklight/suggest_search_spec.rb +1 -0
  144. data/spec/controllers/bookmarks_controller_spec.rb +1 -0
  145. data/spec/controllers/catalog_controller_spec.rb +17 -14
  146. data/spec/controllers/saved_searches_controller_spec.rb +1 -0
  147. data/spec/controllers/search_history_controller_spec.rb +1 -0
  148. data/spec/controllers/suggest_controller_spec.rb +1 -0
  149. data/spec/features/alternate_controller_spec.rb +1 -0
  150. data/spec/features/bookmarks_spec.rb +1 -0
  151. data/spec/features/did_you_mean_spec.rb +1 -0
  152. data/spec/features/facets_spec.rb +1 -0
  153. data/spec/features/record_view_spec.rb +1 -0
  154. data/spec/features/saved_searches_spec.rb +1 -0
  155. data/spec/features/search_context_spec.rb +1 -0
  156. data/spec/features/search_filters_spec.rb +2 -1
  157. data/spec/features/search_formats_spec.rb +1 -0
  158. data/spec/features/search_history_spec.rb +1 -0
  159. data/spec/features/search_pagination_spec.rb +1 -0
  160. data/spec/features/search_results_spec.rb +1 -0
  161. data/spec/features/search_sort_spec.rb +1 -0
  162. data/spec/features/search_spec.rb +1 -0
  163. data/spec/features/sitelinks_search_box.rb +1 -0
  164. data/spec/helpers/blacklight_helper_spec.rb +3 -2
  165. data/spec/helpers/catalog_helper_spec.rb +11 -16
  166. data/spec/helpers/configuration_helper_spec.rb +1 -0
  167. data/spec/helpers/deprecated_url_helper_behavior_spec.rb +18 -9
  168. data/spec/helpers/facets_helper_spec.rb +1 -0
  169. data/spec/helpers/hash_as_hidden_fields_spec.rb +1 -0
  170. data/spec/helpers/layout_helper_spec.rb +1 -0
  171. data/spec/helpers/render_constraints_helper_spec.rb +18 -8
  172. data/spec/helpers/search_history_constraints_helper_spec.rb +1 -0
  173. data/spec/helpers/suggest_helper_spec.rb +1 -0
  174. data/spec/helpers/url_helper_spec.rb +72 -68
  175. data/spec/lib/blacklight/parameters_spec.rb +3 -2
  176. data/spec/lib/blacklight/search_state_spec.rb +44 -32
  177. data/spec/lib/blacklight/utils_spec.rb +1 -0
  178. data/spec/lib/blacklight_spec.rb +11 -3
  179. data/spec/lib/tasks/blacklight_task_spec.rb +1 -0
  180. data/spec/models/blacklight/configurable_spec.rb +1 -0
  181. data/spec/models/blacklight/configuration/context_spec.rb +1 -0
  182. data/spec/models/blacklight/configuration_spec.rb +1 -0
  183. data/spec/models/blacklight/document/active_model_shim_spec.rb +1 -0
  184. data/spec/models/blacklight/document/cache_key_spec.rb +1 -0
  185. data/spec/models/blacklight/document/dublin_core_spec.rb +1 -0
  186. data/spec/models/blacklight/document/email_spec.rb +1 -0
  187. data/spec/models/blacklight/document/sms_spec.rb +1 -0
  188. data/spec/models/blacklight/document_spec.rb +1 -0
  189. data/spec/models/blacklight/facet_paginator_spec.rb +21 -8
  190. data/spec/models/blacklight/search_builder_spec.rb +1 -0
  191. data/spec/models/blacklight/solr/document/more_like_this_spec.rb +1 -0
  192. data/spec/models/blacklight/solr/document_spec.rb +1 -0
  193. data/spec/models/blacklight/solr/facet_paginator_spec.rb +1 -0
  194. data/spec/models/blacklight/solr/repository_spec.rb +1 -0
  195. data/spec/models/blacklight/solr/request_spec.rb +1 -0
  196. data/spec/models/blacklight/solr/response/facets_spec.rb +1 -0
  197. data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -0
  198. data/spec/models/blacklight/solr/response/group_spec.rb +1 -0
  199. data/spec/models/blacklight/solr/response_spec.rb +1 -0
  200. data/spec/models/blacklight/solr/search_builder_spec.rb +21 -30
  201. data/spec/models/blacklight/suggest/response_spec.rb +1 -0
  202. data/spec/models/blacklight/user_spec.rb +1 -0
  203. data/spec/models/bookmark_spec.rb +4 -3
  204. data/spec/models/record_mailer_spec.rb +1 -0
  205. data/spec/models/search_spec.rb +22 -38
  206. data/spec/models/solr_document_spec.rb +1 -0
  207. data/spec/presenters/document_presenter_spec.rb +7 -3
  208. data/spec/routing/catalog_routing_spec.rb +1 -0
  209. data/spec/spec_helper.rb +1 -0
  210. data/spec/support/controller_level_helpers.rb +2 -1
  211. data/spec/support/features.rb +1 -0
  212. data/spec/support/features/session_helpers.rb +1 -0
  213. data/spec/test_app_templates/Gemfile.extra +14 -0
  214. data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -0
  215. data/spec/views/_user_util_links.html.erb_spec.rb +1 -0
  216. data/spec/views/catalog/_constraints.html.erb_spec.rb +1 -0
  217. data/spec/views/catalog/_constraints_element.html.erb_spec.rb +1 -0
  218. data/spec/views/catalog/_document.html.erb_spec.rb +1 -0
  219. data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -0
  220. data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +4 -1
  221. data/spec/views/catalog/_facet_layout.html.erb_spec.rb +1 -0
  222. data/spec/views/catalog/_facets.html.erb_spec.rb +1 -0
  223. data/spec/views/catalog/_index_default.erb_spec.rb +1 -0
  224. data/spec/views/catalog/_index_header_default.html.erb_spec.rb +1 -0
  225. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +1 -0
  226. data/spec/views/catalog/_search_header.erb_spec.rb +1 -0
  227. data/spec/views/catalog/_show_default.erb_spec.rb +1 -0
  228. data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -0
  229. data/spec/views/catalog/_show_tools.html.erb_spec.rb +1 -0
  230. data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +1 -0
  231. data/spec/views/catalog/_thumbnail_default.erb_spec.rb +1 -0
  232. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +1 -0
  233. data/spec/views/catalog/facet.html.erb_spec.rb +1 -0
  234. data/spec/views/catalog/facet.json.jbuilder_spec.rb +1 -0
  235. data/spec/views/catalog/index.atom.builder_spec.rb +19 -27
  236. data/spec/views/catalog/index.html.erb_spec.rb +1 -0
  237. data/spec/views/catalog/index.json.jbuilder_spec.rb +1 -0
  238. data/spec/views/catalog/opensearch.xml.builder_spec.rb +1 -0
  239. data/spec/views/catalog/show.html.erb_spec.rb +1 -0
  240. data/template.demo.rb +1 -0
  241. metadata +7 -5
  242. data/app/views/catalog/show.refworks.erb +0 -1
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::Solr::SearchBuilderBehavior do
@@ -81,10 +82,6 @@ describe Blacklight::Solr::SearchBuilderBehavior do
81
82
  it "should take q from request params" do
82
83
  expect(subject[:q]).to eq "test query"
83
84
  end
84
-
85
- it "should add in extra facet.field from params" do
86
- expect(subject[:"facet.field"]).to include("extra_facet")
87
- end
88
85
  end
89
86
  end
90
87
 
@@ -111,6 +108,26 @@ describe Blacklight::Solr::SearchBuilderBehavior do
111
108
  expect(subject[:"f.subject_topic_facet.facet.limit"]).to eq 21
112
109
  end
113
110
 
111
+ context 'with a negative facet limit' do
112
+ before do
113
+ blacklight_config.facet_fields['subject_topic_facet'].limit = -1
114
+ end
115
+
116
+ it 'is negative' do
117
+ expect(subject[:"f.subject_topic_facet.facet.limit"]).to eq -1
118
+ end
119
+ end
120
+
121
+ context 'with a facet limit set to 0' do
122
+ before do
123
+ blacklight_config.facet_fields['subject_topic_facet'].limit = 0
124
+ end
125
+
126
+ it 'is negative' do
127
+ expect(subject[:"f.subject_topic_facet.facet.limit"]).to eq 0
128
+ end
129
+ end
130
+
114
131
  it "should handle no facet_limits in config" do
115
132
  blacklight_config.facet_fields = {}
116
133
  expect(subject).not_to have_key(:"f.subject_topic_facet.facet.limit")
@@ -333,32 +350,6 @@ describe Blacklight::Solr::SearchBuilderBehavior do
333
350
  config.add_facet_fields_to_solr_request!
334
351
  end
335
352
  end
336
-
337
- context "user provides a single facet.field" do
338
- let(:user_params) { { "facet.field" => "additional_facet" } }
339
- it "adds the field" do
340
- expect(subject[:"facet.field"]).to include("additional_facet")
341
- expect(subject[:"facet.field"]).to have(2).fields
342
- end
343
- end
344
-
345
- context "user provides a multiple facet.field" do
346
- let(:user_params) { { "facet.field" => ["add_facet1", "add_facet2"] } }
347
- it "adds the fields" do
348
- expect(subject[:"facet.field"]).to include("add_facet1")
349
- expect(subject[:"facet.field"]).to include("add_facet2")
350
- expect(subject[:"facet.field"]).to have(3).fields
351
- end
352
- end
353
-
354
- context "user provides a multiple facets" do
355
- let(:user_params) { { "facets" => ["add_facet1", "add_facet2"] } }
356
- it "adds the fields" do
357
- expect(subject[:"facet.field"]).to include("add_facet1")
358
- expect(subject[:"facet.field"]).to include("add_facet2")
359
- expect(subject[:"facet.field"]).to have(3).fields
360
- end
361
- end
362
353
  end
363
354
  end
364
355
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::Suggest::Response do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Blacklight::User" do
@@ -1,13 +1,14 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Bookmark do
5
+ let(:user) { User.create! email: 'xyz@example.com', password: 'xyz12345'}
4
6
  subject do
5
- b = Bookmark.new
6
- b.user_id = 1
7
+ b = Bookmark.new(user: user)
7
8
  b.document = SolrDocument.new(id: 'u001')
8
9
  b
9
10
  end
10
-
11
+
11
12
  it "should be valid" do
12
13
  expect(subject).to be_valid
13
14
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe RecordMailer do
@@ -1,27 +1,25 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Search do
5
+ let(:user) { User.create! email: 'xyz@example.com', password: 'xyz12345'}
4
6
  describe "query_params" do
5
7
  before(:each) do
6
- @search = Search.new
8
+ @search = Search.new(user: user)
7
9
  @query_params = { :q => "query", :f => "facet" }
8
10
  end
9
- it "should accept a Hash as the value and save without error" do
10
- @search.query_params = @query_params
11
- assert @search.save
12
- end
13
- it "should return a Hash as the value" do
11
+
12
+ it "can save and retrieve the hash" do
14
13
  @search.query_params = @query_params
15
- assert @search.save
14
+ @search.save!
16
15
  expect(Search.find(@search.id).query_params).to eq @query_params
17
16
  end
18
17
  end
19
-
18
+
20
19
  describe "saved?" do
21
- it "should be true when user_id is not NULL and greater than 0" do
22
- @search = Search.new
23
- @search.user_id = 1
24
- @search.save
20
+ it "is true when user_id is not NULL and greater than 0" do
21
+ @search = Search.new(user: user)
22
+ @search.save!
25
23
 
26
24
  expect(@search).to be_saved
27
25
  end
@@ -30,45 +28,31 @@ describe Search do
30
28
  expect(@search).not_to be_saved
31
29
  end
32
30
  end
33
-
31
+
34
32
  describe "delete_old_searches" do
35
- it "should throw an ArgumentError if days_old is not a number" do
33
+ it "throws an ArgumentError if days_old is not a number" do
36
34
  expect { Search.delete_old_searches("blah") }.to raise_error(ArgumentError)
37
35
  end
38
- it "should throw an ArgumentError if days_old is equal to 0" do
36
+
37
+ it "throws an ArgumentError if days_old is equal to 0" do
39
38
  expect { Search.delete_old_searches(0) }.to raise_error(ArgumentError)
40
39
  end
41
- it "should throw an ArgumentError if days_old is less than 0" do
40
+
41
+ it "throws an ArgumentError if days_old is less than 0" do
42
42
  expect { Search.delete_old_searches(-1) }.to raise_error(ArgumentError)
43
43
  end
44
- it "should destroy searches with no user_id that are older than X days" do
44
+
45
+ it "destroy searches with no user_id that are older than X days" do
45
46
  Search.destroy_all
46
47
  days_old = 7
47
- unsaved_search_today = Search.new
48
- unsaved_search_today.user_id = nil
49
- unsaved_search_today.created_at = Date.today
50
- unsaved_search_today.save
51
-
52
- unsaved_search_past = Search.new
53
- unsaved_search_past.user_id = nil
54
- unsaved_search_past.created_at = Date.today - (days_old + 1).days
55
- unsaved_search_past.save
56
-
57
- saved_search_today = Search.new
58
- saved_search_today.user_id = 1
59
- saved_search_today.created_at = Date.today
60
- saved_search_today.save
61
-
62
- saved_search_past = Search.new
63
- saved_search_past.user_id = 1
64
- saved_search_past.created_at = Date.today - (days_old + 1).days
65
- saved_search_past.save
48
+ Search.create!(created_at: Date.today)
49
+ Search.create!(created_at: Date.today - (days_old + 1).days)
50
+ Search.create!(user: user, created_at: Date.today)
51
+ Search.create!(user: user, created_at: Date.today - (days_old + 1).days)
66
52
 
67
53
  expect do
68
54
  Search.delete_old_searches(days_old)
69
55
  end.to change(Search, :count).by(-1)
70
56
  end
71
-
72
57
  end
73
-
74
58
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe SolrDocument do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::DocumentPresenter do
@@ -7,6 +8,9 @@ describe Blacklight::DocumentPresenter do
7
8
 
8
9
  subject { presenter }
9
10
  let(:presenter) { Blacklight::DocumentPresenter.new(document, request_context, config) }
11
+ let(:parameter_class) { ActionController::Parameters }
12
+ let(:params) { parameter_class.new }
13
+ let(:search_state) { Blacklight::SearchState.new(params, config) }
10
14
 
11
15
  let(:document) do
12
16
  SolrDocument.new(id: 1,
@@ -17,7 +21,7 @@ describe Blacklight::DocumentPresenter do
17
21
  end
18
22
 
19
23
  before do
20
- allow(request_context).to receive(:search_state).and_return(Blacklight::SearchState.new({}, config))
24
+ allow(request_context).to receive(:search_state).and_return(search_state)
21
25
  end
22
26
 
23
27
  describe "link_rel_alternates" do
@@ -120,14 +124,14 @@ describe Blacklight::DocumentPresenter do
120
124
  end
121
125
 
122
126
  it "should check for a link_to_search" do
123
- allow(request_context).to receive(:search_action_path).with(:f => { :link_to_search_true => ['x'] }).and_return('/foo')
127
+ allow(request_context).to receive(:search_action_path).with('f' => { 'link_to_search_true' => ['x'] }).and_return('/foo')
124
128
  allow(request_context).to receive(:link_to).with("x", '/foo').and_return('bar')
125
129
  value = subject.render_index_field_value 'link_to_search_true'
126
130
  expect(value).to eq 'bar'
127
131
  end
128
132
 
129
133
  it "should check for a link_to_search with a field name" do
130
- allow(request_context).to receive(:search_action_path).with(:f => { :some_field => ['x'] }).and_return('/foo')
134
+ allow(request_context).to receive(:search_action_path).with('f' => { 'some_field' => ['x'] }).and_return('/foo')
131
135
  allow(request_context).to receive(:link_to).with("x", '/foo').and_return('bar')
132
136
  value = subject.render_index_field_value 'link_to_search_named'
133
137
  expect(value).to eq 'bar'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
3
 
3
4
  describe "Routing" do
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # This file is copied to spec/ when you run 'rails generate rspec:install'
2
3
  # Has been customized by Blacklight to work when application is in one place,
3
4
  # and actual spec/ stuff is in another (the blacklight gem checkout).
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ControllerLevelHelpers
2
3
  module ControllerViewHelpers
3
4
  include Blacklight::Facet
@@ -14,4 +15,4 @@ module ControllerLevelHelpers
14
15
  def initialize_controller_helpers(helper)
15
16
  helper.extend ControllerViewHelpers
16
17
  end
17
- end
18
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # spec/support/features.rb
2
3
 
3
4
  require File.expand_path("../features/session_helpers.rb", __FILE__)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # spec/support/features/session_helpers.rb
2
3
  module Features
3
4
  module SessionHelpers
@@ -0,0 +1,14 @@
1
+
2
+ if ENV['RAILS_VERSION'] =~ /^5\.0/ || ENV['RAILS_VERSION'] == 'edge'
3
+ gem 'rails-controller-testing', github: 'rails/rails-controller-testing'
4
+ gem 'capybara', github: 'jnicklas/capybara' # we need 2.6.0 to be released
5
+ gem 'rspec-mocks', github: 'rspec/rspec-mocks' # we need 3.5.0 to be released
6
+ gem 'rspec-expectations', github: 'rspec/rspec-expectations' # we need 3.5.0 to be released
7
+ gem 'rspec-support', github: 'rspec/rspec-support' # we need 3.5.0 to be released
8
+ gem 'rspec', github: 'rspec/rspec' # we need 3.5.0 to be released
9
+ gem 'rspec-core', github: 'rspec/rspec-core' # we need 3.5.0 to be released
10
+ gem 'rspec-rails', github: 'rspec/rspec-rails' # we need 3.5.0 to be released
11
+ gem 'kaminari', github: 'amatsuda/kaminari' # need > 0.16.3
12
+ gem 'deprecation', github: 'jcoyne/deprecation', branch: 'no_alias_method_chain'
13
+ gem 'turbolinks', github: 'basecamp/turbolinks', branch: 'v5' # need >= 5.0.0
14
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rails/generators'
2
3
 
3
4
  class TestAppGenerator < Rails::Generators::Base
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "_user_util_links" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "catalog/constraints" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "catalog/_constraints_element.html.erb" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "catalog/_document" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "catalog/_document_list", type: :view do
@@ -1,12 +1,15 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe 'catalog/_facet_index_navigation.html.erb', type: :view do
4
5
  let(:pagination) { Blacklight::Solr::FacetPaginator.new([]) }
5
6
  let(:facet) { Blacklight::Configuration::FacetField.new({ index_range: '0'..'9' })}
7
+ let(:blacklight_config) { Blacklight::Configuration.new }
6
8
 
7
9
  before do
8
10
  assign(:pagination, pagination)
9
11
  assign(:facet, facet)
12
+ allow(view).to receive(:blacklight_config).and_return(blacklight_config)
10
13
  end
11
14
 
12
15
  it 'renders the facet index navigation range' do
@@ -37,4 +40,4 @@ describe 'catalog/_facet_index_navigation.html.erb', type: :view do
37
40
  expect(rendered).to have_link 'Clear Filter'
38
41
  end
39
42
  end
40
- end
43
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "catalog/facet_layout" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "catalog/_facets" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  # spec for default partial to display solr document fields
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "catalog/_index_header_default" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "catalog/_paginate_compact.html.erb" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  # spec for sidebar partial in catalog show view
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  # spec for default partial to display solr document fields
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  # spec for sidebar partial in catalog show view
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "catalog/_show_tools.html.erb" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "catalog/_sort_and_per_page" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "catalog/_thumbnail_default" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "catalog/_view_type_group" do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe 'catalog/facet.html.erb' do