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::Parameters do
|
@@ -5,7 +6,7 @@ describe Blacklight::Parameters do
|
|
5
6
|
subject { described_class.sanitize(params) }
|
6
7
|
|
7
8
|
context "with nil values" do
|
8
|
-
let(:params) {
|
9
|
+
let(:params) { ActionController::Parameters.new a: nil, b: 1 }
|
9
10
|
it "removes them" do
|
10
11
|
expect(subject).to_not have_key(:a)
|
11
12
|
expect(subject[:b]).to eq 1
|
@@ -13,7 +14,7 @@ describe Blacklight::Parameters do
|
|
13
14
|
end
|
14
15
|
|
15
16
|
context "with blacklisted keys" do
|
16
|
-
let(:params) {
|
17
|
+
let(:params) { ActionController::Parameters.new action: true, controller: true, id: true, commit: true, utf8: true }
|
17
18
|
it "removes them" do
|
18
19
|
expect(subject).to be_empty
|
19
20
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe Blacklight::SearchState do
|
@@ -8,11 +9,12 @@ describe Blacklight::SearchState do
|
|
8
9
|
end
|
9
10
|
end
|
10
11
|
|
12
|
+
let(:parameter_class) { ActionController::Parameters }
|
11
13
|
let(:helper) { described_class.new(params, blacklight_config) }
|
12
|
-
let(:params) {
|
14
|
+
let(:params) { parameter_class.new }
|
13
15
|
|
14
16
|
describe "params_for_search" do
|
15
|
-
let(:params) {
|
17
|
+
let(:params) { parameter_class.new 'default' => 'params' }
|
16
18
|
|
17
19
|
it "takes original params" do
|
18
20
|
result = helper.params_for_search
|
@@ -22,11 +24,11 @@ describe Blacklight::SearchState do
|
|
22
24
|
|
23
25
|
it "accepts params to merge into the controller's params" do
|
24
26
|
result = helper.params_for_search(q: 'query')
|
25
|
-
expect(result).to
|
27
|
+
expect(result).to eq('q' => 'query', 'default' => 'params')
|
26
28
|
end
|
27
29
|
|
28
30
|
context "when params have blacklisted keys" do
|
29
|
-
let(:params) {
|
31
|
+
let(:params) { parameter_class.new action: 'action', controller: 'controller', id: "id", commit: 'commit' }
|
30
32
|
it "removes them" do
|
31
33
|
result = helper.params_for_search
|
32
34
|
expect(result.keys).to_not include(:action, :controller, :commit, :id)
|
@@ -35,7 +37,7 @@ describe Blacklight::SearchState do
|
|
35
37
|
|
36
38
|
context "when params has page" do
|
37
39
|
context "and per_page changed" do
|
38
|
-
let(:params) {
|
40
|
+
let(:params) { parameter_class.new per_page: 20, page: 5 }
|
39
41
|
it "adjusts the current page" do
|
40
42
|
result = helper.params_for_search(per_page: 100)
|
41
43
|
expect(result[:page]).to eq 1
|
@@ -43,7 +45,7 @@ describe Blacklight::SearchState do
|
|
43
45
|
end
|
44
46
|
|
45
47
|
context "and per_page didn't change" do
|
46
|
-
let(:params) {
|
48
|
+
let(:params) { parameter_class.new per_page: 20, page: 5 }
|
47
49
|
it "doesn't change the current page" do
|
48
50
|
result = helper.params_for_search(per_page: 20)
|
49
51
|
expect(result[:page]).to eq 5
|
@@ -51,7 +53,7 @@ describe Blacklight::SearchState do
|
|
51
53
|
end
|
52
54
|
|
53
55
|
context "and the sort changes" do
|
54
|
-
let(:params) {
|
56
|
+
let(:params) { parameter_class.new sort: 'field_a', page: 5 }
|
55
57
|
it "adjusts the current page" do
|
56
58
|
result = helper.params_for_search(sort: 'field_b')
|
57
59
|
expect(result[:page]).to eq 1
|
@@ -59,7 +61,7 @@ describe Blacklight::SearchState do
|
|
59
61
|
end
|
60
62
|
|
61
63
|
context "and the sort didn't change" do
|
62
|
-
let(:params) {
|
64
|
+
let(:params) { parameter_class.new sort: 'field_a', page: 5 }
|
63
65
|
it "doesn't change the current page" do
|
64
66
|
result = helper.params_for_search(sort: 'field_a')
|
65
67
|
expect(result[:page]).to eq 5
|
@@ -68,10 +70,10 @@ describe Blacklight::SearchState do
|
|
68
70
|
end
|
69
71
|
|
70
72
|
context "with a block" do
|
71
|
-
let(:params) {
|
73
|
+
let(:params) { parameter_class.new a: 1, b: 2 }
|
72
74
|
it "should evalute the block and allow it to add or remove keys" do
|
73
75
|
result = helper.params_for_search(c: 3) do |params|
|
74
|
-
params.
|
76
|
+
params.extract! :a, :b
|
75
77
|
params[:d] = 'd'
|
76
78
|
end
|
77
79
|
|
@@ -83,14 +85,24 @@ describe Blacklight::SearchState do
|
|
83
85
|
end
|
84
86
|
|
85
87
|
describe "add_facet_params" do
|
86
|
-
let(:params_no_existing_facet)
|
87
|
-
|
88
|
+
let(:params_no_existing_facet) do
|
89
|
+
parameter_class.new q: "query",
|
90
|
+
search_field: "search_field",
|
91
|
+
per_page: "50"
|
92
|
+
end
|
93
|
+
let(:params_existing_facets) do
|
94
|
+
parameter_class.new q: "query",
|
95
|
+
search_field: "search_field",
|
96
|
+
per_page: "50",
|
97
|
+
f: { "facet_field_1" => ["value1"],
|
98
|
+
"facet_field_2" => ["value2", "value2a"] }
|
99
|
+
end
|
88
100
|
|
89
101
|
context "when there are no pre-existing facets" do
|
90
102
|
let(:params) { params_no_existing_facet }
|
91
103
|
it "adds facet value" do
|
92
104
|
result_params = helper.add_facet_params("facet_field", "facet_value")
|
93
|
-
expect(result_params[:f]).to
|
105
|
+
expect(result_params[:f]).to be_a Hash
|
94
106
|
expect(result_params[:f]["facet_field"]).to be_a_kind_of(Array)
|
95
107
|
expect(result_params[:f]["facet_field"]).to eq ["facet_value"]
|
96
108
|
end
|
@@ -119,7 +131,7 @@ describe Blacklight::SearchState do
|
|
119
131
|
it "adds a facet param to existing facet constraints" do
|
120
132
|
result_params = helper.add_facet_params("facet_field_2", "new_facet_value")
|
121
133
|
|
122
|
-
expect(result_params[:f]).to
|
134
|
+
expect(result_params[:f]).to be_a Hash
|
123
135
|
|
124
136
|
params_existing_facets[:f].each_pair do |facet_field, value_list|
|
125
137
|
expect(result_params[:f][facet_field]).to be_a_kind_of(Array)
|
@@ -135,14 +147,14 @@ describe Blacklight::SearchState do
|
|
135
147
|
result_params = helper.add_facet_params("facet_field_2", "new_facet_value")
|
136
148
|
|
137
149
|
params.each_pair do |key, value|
|
138
|
-
next if key ==
|
150
|
+
next if key == 'f'
|
139
151
|
expect(result_params[key]).to eq params[key]
|
140
152
|
end
|
141
153
|
end
|
142
154
|
end
|
143
155
|
|
144
156
|
context "with a facet selected in the params" do
|
145
|
-
let(:params) {
|
157
|
+
let(:params) { parameter_class.new f: { 'single_value_facet_field' => 'other_value' } }
|
146
158
|
it "replaces facets configured as single" do
|
147
159
|
allow(helper).to receive(:facet_configuration_for_field).with('single_value_facet_field').and_return(double(single: true, key: "single_value_facet_field"))
|
148
160
|
result_params = helper.add_facet_params('single_value_facet_field', 'my_value')
|
@@ -174,15 +186,15 @@ describe Blacklight::SearchState do
|
|
174
186
|
end
|
175
187
|
|
176
188
|
describe "add_facet_params_and_redirect" do
|
177
|
-
let(:params) {
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
189
|
+
let(:params) { parameter_class.new(
|
190
|
+
q: "query",
|
191
|
+
search_field: "search_field",
|
192
|
+
per_page: "50",
|
193
|
+
page: "5",
|
194
|
+
f: { "facet_field_1" => ["value1"], "facet_field_2" => ["value2", "value2a"] },
|
195
|
+
Blacklight::Solr::FacetPaginator.request_keys[:page] => "100",
|
196
|
+
Blacklight::Solr::FacetPaginator.request_keys[:sort] => "index",
|
197
|
+
id: 'facet_field_name')
|
186
198
|
}
|
187
199
|
|
188
200
|
it "does not include request parameters used by the facet paginator" do
|
@@ -196,10 +208,10 @@ describe Blacklight::SearchState do
|
|
196
208
|
|
197
209
|
it 'removes :page request key' do
|
198
210
|
params = helper.add_facet_params_and_redirect("facet_field_2", "facet_value")
|
199
|
-
expect(params
|
211
|
+
expect(params).to_not have_key(:page)
|
200
212
|
end
|
201
213
|
|
202
|
-
it "
|
214
|
+
it "otherwise does the same thing as add_facet_params" do
|
203
215
|
added_facet_params = helper.add_facet_params("facet_field_2", "facet_value")
|
204
216
|
added_facet_params_from_facet_action = helper.add_facet_params_and_redirect("facet_field_2", "facet_value")
|
205
217
|
|
@@ -208,7 +220,7 @@ describe Blacklight::SearchState do
|
|
208
220
|
end
|
209
221
|
|
210
222
|
describe "#remove_facet_params" do
|
211
|
-
let(:params) {
|
223
|
+
let(:params) { parameter_class.new 'f' => facet_params }
|
212
224
|
let(:facet_params) { { } }
|
213
225
|
context "when the facet has multiple values" do
|
214
226
|
let(:facet_params) { { 'some_field' => ['some_value', 'another_value'] } }
|
@@ -234,21 +246,21 @@ describe Blacklight::SearchState do
|
|
234
246
|
end
|
235
247
|
end
|
236
248
|
|
237
|
-
it "
|
249
|
+
it "removes the facet entirely when the last facet value is removed" do
|
238
250
|
facet_params['another_field'] = ['some_value']
|
239
251
|
facet_params['some_field'] = ['some_value']
|
240
252
|
|
241
253
|
params = helper.remove_facet_params('some_field', 'some_value')
|
242
254
|
|
243
|
-
expect(params[:f]).not_to
|
255
|
+
expect(params[:f]).not_to have_key 'some_field'
|
244
256
|
end
|
245
257
|
|
246
|
-
it "
|
258
|
+
it "removes the 'f' parameter entirely when no facets remain" do
|
247
259
|
facet_params['some_field'] = ['some_value']
|
248
260
|
|
249
261
|
params = helper.remove_facet_params('some_field', 'some_value')
|
250
262
|
|
251
|
-
expect(params).not_to
|
263
|
+
expect(params).not_to have_key :f
|
252
264
|
end
|
253
265
|
end
|
254
266
|
end
|
data/spec/lib/blacklight_spec.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe Blacklight do
|
4
|
-
|
5
5
|
context 'root' do
|
6
|
-
|
7
6
|
let(:blroot) { File.expand_path(File.join(__FILE__, '..', '..', '..' )) }
|
8
7
|
|
9
8
|
it 'should return the full path to the BL plugin' do
|
10
9
|
expect(Blacklight.root).to eq blroot
|
11
10
|
end
|
12
|
-
|
13
11
|
end
|
14
12
|
|
15
13
|
describe '.default_index' do
|
@@ -25,6 +23,16 @@ describe Blacklight do
|
|
25
23
|
end
|
26
24
|
|
27
25
|
describe '.repository_class' do
|
26
|
+
context 'when the adapter key is missing' do
|
27
|
+
before do
|
28
|
+
allow(Blacklight).to receive(:connection_config).and_return({})
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'raises an error' do
|
32
|
+
expect { Blacklight.repository_class }.to raise_error RuntimeError, 'The value for :adapter was not found in the blacklight.yml config'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
28
36
|
context 'for a solr index' do
|
29
37
|
before do
|
30
38
|
allow(Blacklight).to receive(:connection_config).and_return(adapter: 'solr')
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe Blacklight::FacetPaginator do
|
@@ -62,8 +63,8 @@ describe Blacklight::FacetPaginator do
|
|
62
63
|
|
63
64
|
it 'should know a manually set sort, and produce proper sort url' do
|
64
65
|
expect(subject.sort).to eq 'index'
|
65
|
-
|
66
|
-
click_params = subject.params_for_resort_url('count', {})
|
66
|
+
|
67
|
+
click_params = subject.params_for_resort_url('count', {}.with_indifferent_access)
|
67
68
|
|
68
69
|
expect(click_params[ sort_key ]).to eq 'count'
|
69
70
|
expect(click_params[ page_key ]).to be_nil
|
@@ -71,23 +72,35 @@ describe Blacklight::FacetPaginator do
|
|
71
72
|
|
72
73
|
context 'when sorting by "count"' do
|
73
74
|
subject { described_class.new([]) }
|
75
|
+
let(:params) { HashWithIndifferentAccess.new :'facet.prefix' => 'A' }
|
74
76
|
|
75
77
|
it 'includes the prefix filter for "index" sorting' do
|
76
|
-
expect(subject.params_for_resort_url('index',
|
78
|
+
expect(subject.params_for_resort_url('index', params)).to include :'facet.prefix' => 'A'
|
77
79
|
end
|
78
80
|
|
79
81
|
it 'removes the prefix filter' do
|
80
|
-
expect(subject.params_for_resort_url('count',
|
82
|
+
expect(subject.params_for_resort_url('count', params)).not_to include :'facet.prefix' => 'A'
|
81
83
|
end
|
82
84
|
end
|
83
85
|
end
|
84
86
|
|
85
87
|
context "for a nil :limit" do
|
86
|
-
|
87
|
-
|
88
|
-
|
88
|
+
let(:paginator) { described_class.new(seven_facet_values, offset: 0, limit: nil) }
|
89
|
+
|
90
|
+
describe "#items" do
|
91
|
+
subject { paginator.items }
|
92
|
+
it { is_expected.to eq seven_facet_values }
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "#last_page?" do
|
96
|
+
subject { paginator.last_page? }
|
97
|
+
it { is_expected.to be true }
|
98
|
+
end
|
99
|
+
|
100
|
+
describe "#current_page" do
|
101
|
+
subject { paginator.current_page }
|
102
|
+
it { is_expected.to eq 1 }
|
89
103
|
end
|
90
|
-
it { should be_last_page }
|
91
104
|
end
|
92
105
|
|
93
106
|
describe "#as_json" do
|