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.
- checksums.yaml +4 -4
- data/.travis.yml +8 -8
- data/Gemfile +11 -2
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/_facets.scss +1 -10
- data/app/controllers/bookmarks_controller.rb +1 -0
- data/app/controllers/catalog_controller.rb +1 -0
- data/app/controllers/concerns/blacklight/base.rb +1 -0
- data/app/controllers/concerns/blacklight/bookmarks.rb +13 -1
- data/app/controllers/concerns/blacklight/catalog.rb +7 -1
- data/app/controllers/concerns/blacklight/controller.rb +7 -6
- data/app/controllers/concerns/blacklight/default_component_configuration.rb +1 -0
- data/app/controllers/concerns/blacklight/facet.rb +1 -0
- data/app/controllers/concerns/blacklight/request_builders.rb +1 -0
- data/app/controllers/concerns/blacklight/search_context.rb +8 -12
- data/app/controllers/concerns/blacklight/search_fields.rb +1 -0
- data/app/controllers/concerns/blacklight/search_helper.rb +2 -1
- data/app/controllers/concerns/blacklight/search_history.rb +32 -0
- data/app/controllers/concerns/blacklight/suggest.rb +1 -0
- data/app/controllers/concerns/blacklight/suggest_search.rb +1 -0
- data/app/controllers/concerns/blacklight/token_based_user.rb +1 -0
- data/app/controllers/saved_searches_controller.rb +20 -9
- data/app/controllers/search_history_controller.rb +2 -18
- data/app/controllers/suggest_controller.rb +1 -0
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/catalog_helper_behavior.rb +15 -1
- data/app/helpers/blacklight/component_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/configuration_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/deprecated_url_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/facets_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/layout_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +9 -6
- data/app/helpers/blacklight/render_partials_helper.rb +15 -4
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/suggest_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/url_helper_behavior.rb +6 -6
- data/app/helpers/blacklight_configuration_helper.rb +1 -0
- data/app/helpers/blacklight_helper.rb +1 -0
- data/app/helpers/blacklight_url_helper.rb +1 -0
- data/app/helpers/catalog_helper.rb +1 -0
- data/app/helpers/component_helper.rb +1 -0
- data/app/helpers/facets_helper.rb +1 -0
- data/app/helpers/hash_as_hidden_fields_helper.rb +1 -0
- data/app/helpers/layout_helper.rb +1 -0
- data/app/helpers/render_constraints_helper.rb +1 -0
- data/app/helpers/search_history_constraints_helper.rb +1 -0
- data/app/helpers/suggest_helper.rb +1 -0
- data/app/models/blacklight/facet_paginator.rb +6 -2
- data/app/models/blacklight/solr/facet_paginator.rb +1 -0
- data/app/models/bookmark.rb +1 -0
- data/app/models/concerns/blacklight/configurable.rb +1 -0
- data/app/models/concerns/blacklight/document.rb +1 -0
- data/app/models/concerns/blacklight/document/active_model_shim.rb +1 -0
- data/app/models/concerns/blacklight/document/cache_key.rb +1 -0
- data/app/models/concerns/blacklight/document/dublin_core.rb +1 -0
- data/app/models/concerns/blacklight/document/email.rb +1 -0
- data/app/models/concerns/blacklight/document/export.rb +1 -0
- data/app/models/concerns/blacklight/document/extensions.rb +1 -0
- data/app/models/concerns/blacklight/document/schema_org.rb +1 -0
- data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -0
- data/app/models/concerns/blacklight/document/sms.rb +1 -0
- data/app/models/concerns/blacklight/solr/document.rb +1 -0
- data/app/models/concerns/blacklight/solr/document/more_like_this.rb +1 -0
- data/app/models/concerns/blacklight/suggest/response.rb +1 -0
- data/app/models/concerns/blacklight/user.rb +1 -0
- data/app/models/record_mailer.rb +1 -0
- data/app/models/search.rb +4 -1
- data/app/models/solr_document.rb +1 -0
- data/app/presenters/blacklight/document_presenter.rb +17 -1
- data/app/presenters/blacklight/json_presenter.rb +1 -0
- data/app/views/bookmarks/_tools.html.erb +1 -1
- data/app/views/catalog/_facet_index_navigation.html.erb +2 -2
- data/app/views/catalog/_facet_pagination.html.erb +4 -4
- data/app/views/catalog/_search_results.html.erb +3 -5
- data/app/views/catalog/_view_type_group.html.erb +1 -1
- data/app/views/catalog/index.atom.builder +7 -7
- data/app/views/catalog/index.json.jbuilder +0 -1
- data/app/views/catalog/index.rss.builder +1 -4
- data/config/locales/blacklight.de.yml +0 -2
- data/config/locales/blacklight.es.yml +0 -2
- data/config/locales/blacklight.it.yml +0 -2
- data/config/locales/blacklight.pt-BR.yml +0 -6
- data/config/routes.rb +1 -0
- data/db/migrate/20140202020201_create_searches.rb +1 -0
- data/db/migrate/20140202020202_create_bookmarks.rb +1 -0
- data/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +1 -0
- data/lib/blacklight.rb +3 -1
- data/lib/blacklight/abstract_repository.rb +1 -0
- data/lib/blacklight/configuration.rb +1 -0
- data/lib/blacklight/configuration/context.rb +1 -0
- data/lib/blacklight/configuration/facet_field.rb +1 -0
- data/lib/blacklight/configuration/field.rb +1 -0
- data/lib/blacklight/configuration/fields.rb +1 -0
- data/lib/blacklight/configuration/search_field.rb +1 -0
- data/lib/blacklight/configuration/sort_field.rb +1 -0
- data/lib/blacklight/configuration/tool_config.rb +1 -0
- data/lib/blacklight/configuration/view_config.rb +1 -0
- data/lib/blacklight/engine.rb +1 -0
- data/lib/blacklight/exceptions.rb +1 -0
- data/lib/blacklight/parameters.rb +4 -4
- data/lib/blacklight/routes.rb +1 -0
- data/lib/blacklight/routes/exportable.rb +1 -0
- data/lib/blacklight/routes/searchable.rb +1 -0
- data/lib/blacklight/search_builder.rb +1 -0
- data/lib/blacklight/search_state.rb +22 -5
- data/lib/blacklight/solr.rb +1 -0
- data/lib/blacklight/solr/repository.rb +1 -0
- data/lib/blacklight/solr/request.rb +1 -0
- data/lib/blacklight/solr/response.rb +7 -1
- data/lib/blacklight/solr/response/facets.rb +1 -0
- data/lib/blacklight/solr/response/group.rb +1 -0
- data/lib/blacklight/solr/response/group_response.rb +1 -0
- data/lib/blacklight/solr/response/more_like_this.rb +1 -0
- data/lib/blacklight/solr/response/pagination_methods.rb +1 -0
- data/lib/blacklight/solr/response/response.rb +1 -0
- data/lib/blacklight/solr/response/spelling.rb +1 -0
- data/lib/blacklight/solr/search_builder_behavior.rb +19 -14
- data/lib/blacklight/utils.rb +1 -0
- data/lib/blacklight/version.rb +1 -0
- data/lib/generators/blacklight/assets_generator.rb +1 -0
- data/lib/generators/blacklight/controller_generator.rb +1 -0
- data/lib/generators/blacklight/document_generator.rb +1 -0
- data/lib/generators/blacklight/install_generator.rb +1 -0
- data/lib/generators/blacklight/models_generator.rb +1 -0
- data/lib/generators/blacklight/search_builder_generator.rb +1 -0
- data/lib/generators/blacklight/solr4_generator.rb +1 -0
- data/lib/generators/blacklight/solr5_generator.rb +2 -2
- data/lib/generators/blacklight/templates/alternate_controller.rb +1 -0
- data/lib/generators/blacklight/templates/catalog_controller.rb +1 -0
- data/lib/generators/blacklight/templates/search_builder.rb +1 -0
- data/lib/generators/blacklight/templates/solr_document.rb +1 -0
- data/lib/generators/blacklight/test_support_generator.rb +1 -0
- data/lib/generators/blacklight/user_generator.rb +10 -6
- data/lib/railties/blacklight.rake +3 -3
- data/spec/controllers/alternate_controller_spec.rb +1 -0
- data/spec/controllers/application_controller_spec.rb +1 -0
- data/spec/controllers/blacklight/base_spec.rb +5 -3
- data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +1 -0
- data/spec/controllers/blacklight/facet_spec.rb +1 -0
- data/spec/controllers/blacklight/search_fields_spec.rb +1 -0
- data/spec/controllers/blacklight/search_helper_spec.rb +1 -0
- data/spec/controllers/blacklight/suggest_search_spec.rb +1 -0
- data/spec/controllers/bookmarks_controller_spec.rb +1 -0
- data/spec/controllers/catalog_controller_spec.rb +17 -14
- data/spec/controllers/saved_searches_controller_spec.rb +1 -0
- data/spec/controllers/search_history_controller_spec.rb +1 -0
- data/spec/controllers/suggest_controller_spec.rb +1 -0
- data/spec/features/alternate_controller_spec.rb +1 -0
- data/spec/features/bookmarks_spec.rb +1 -0
- data/spec/features/did_you_mean_spec.rb +1 -0
- data/spec/features/facets_spec.rb +1 -0
- data/spec/features/record_view_spec.rb +1 -0
- data/spec/features/saved_searches_spec.rb +1 -0
- data/spec/features/search_context_spec.rb +1 -0
- data/spec/features/search_filters_spec.rb +2 -1
- data/spec/features/search_formats_spec.rb +1 -0
- data/spec/features/search_history_spec.rb +1 -0
- data/spec/features/search_pagination_spec.rb +1 -0
- data/spec/features/search_results_spec.rb +1 -0
- data/spec/features/search_sort_spec.rb +1 -0
- data/spec/features/search_spec.rb +1 -0
- data/spec/features/sitelinks_search_box.rb +1 -0
- data/spec/helpers/blacklight_helper_spec.rb +3 -2
- data/spec/helpers/catalog_helper_spec.rb +11 -16
- data/spec/helpers/configuration_helper_spec.rb +1 -0
- data/spec/helpers/deprecated_url_helper_behavior_spec.rb +18 -9
- data/spec/helpers/facets_helper_spec.rb +1 -0
- data/spec/helpers/hash_as_hidden_fields_spec.rb +1 -0
- data/spec/helpers/layout_helper_spec.rb +1 -0
- data/spec/helpers/render_constraints_helper_spec.rb +18 -8
- data/spec/helpers/search_history_constraints_helper_spec.rb +1 -0
- data/spec/helpers/suggest_helper_spec.rb +1 -0
- data/spec/helpers/url_helper_spec.rb +72 -68
- data/spec/lib/blacklight/parameters_spec.rb +3 -2
- data/spec/lib/blacklight/search_state_spec.rb +44 -32
- data/spec/lib/blacklight/utils_spec.rb +1 -0
- data/spec/lib/blacklight_spec.rb +11 -3
- data/spec/lib/tasks/blacklight_task_spec.rb +1 -0
- data/spec/models/blacklight/configurable_spec.rb +1 -0
- data/spec/models/blacklight/configuration/context_spec.rb +1 -0
- data/spec/models/blacklight/configuration_spec.rb +1 -0
- data/spec/models/blacklight/document/active_model_shim_spec.rb +1 -0
- data/spec/models/blacklight/document/cache_key_spec.rb +1 -0
- data/spec/models/blacklight/document/dublin_core_spec.rb +1 -0
- data/spec/models/blacklight/document/email_spec.rb +1 -0
- data/spec/models/blacklight/document/sms_spec.rb +1 -0
- data/spec/models/blacklight/document_spec.rb +1 -0
- data/spec/models/blacklight/facet_paginator_spec.rb +21 -8
- data/spec/models/blacklight/search_builder_spec.rb +1 -0
- data/spec/models/blacklight/solr/document/more_like_this_spec.rb +1 -0
- data/spec/models/blacklight/solr/document_spec.rb +1 -0
- data/spec/models/blacklight/solr/facet_paginator_spec.rb +1 -0
- data/spec/models/blacklight/solr/repository_spec.rb +1 -0
- data/spec/models/blacklight/solr/request_spec.rb +1 -0
- data/spec/models/blacklight/solr/response/facets_spec.rb +1 -0
- data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -0
- data/spec/models/blacklight/solr/response/group_spec.rb +1 -0
- data/spec/models/blacklight/solr/response_spec.rb +1 -0
- data/spec/models/blacklight/solr/search_builder_spec.rb +21 -30
- data/spec/models/blacklight/suggest/response_spec.rb +1 -0
- data/spec/models/blacklight/user_spec.rb +1 -0
- data/spec/models/bookmark_spec.rb +4 -3
- data/spec/models/record_mailer_spec.rb +1 -0
- data/spec/models/search_spec.rb +22 -38
- data/spec/models/solr_document_spec.rb +1 -0
- data/spec/presenters/document_presenter_spec.rb +7 -3
- data/spec/routing/catalog_routing_spec.rb +1 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/controller_level_helpers.rb +2 -1
- data/spec/support/features.rb +1 -0
- data/spec/support/features/session_helpers.rb +1 -0
- data/spec/test_app_templates/Gemfile.extra +14 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -0
- data/spec/views/_user_util_links.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_constraints.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_constraints_element.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_document.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +4 -1
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_facets.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_index_default.erb_spec.rb +1 -0
- data/spec/views/catalog/_index_header_default.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_search_header.erb_spec.rb +1 -0
- data/spec/views/catalog/_show_default.erb_spec.rb +1 -0
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -0
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_thumbnail_default.erb_spec.rb +1 -0
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +1 -0
- data/spec/views/catalog/facet.html.erb_spec.rb +1 -0
- data/spec/views/catalog/facet.json.jbuilder_spec.rb +1 -0
- data/spec/views/catalog/index.atom.builder_spec.rb +19 -27
- data/spec/views/catalog/index.html.erb_spec.rb +1 -0
- data/spec/views/catalog/index.json.jbuilder_spec.rb +1 -0
- data/spec/views/catalog/opensearch.xml.builder_spec.rb +1 -0
- data/spec/views/catalog/show.html.erb_spec.rb +1 -0
- data/template.demo.rb +1 -0
- metadata +7 -5
- 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,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
|
data/spec/models/search_spec.rb
CHANGED
@@ -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
|
-
|
10
|
-
|
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
|
-
|
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 "
|
22
|
-
@search = Search.new
|
23
|
-
@search.
|
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 "
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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 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(
|
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(
|
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(
|
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'
|
data/spec/spec_helper.rb
CHANGED
@@ -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
|
data/spec/support/features.rb
CHANGED
@@ -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,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
|