blacklight 7.0.0.rc1 → 7.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +30 -18
- data/.rubocop_todo.yml +308 -67
- data/.solr_wrapper.yml +8 -1
- data/.travis.yml +15 -13
- data/Gemfile +2 -0
- data/README.md +2 -2
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/Vagrantfile +2 -0
- data/app/assets/javascripts/blacklight/blacklight.js +17 -17
- data/app/assets/stylesheets/blacklight/_blacklight_base.scss +17 -16
- data/app/assets/stylesheets/blacklight/_facets.scss +2 -13
- data/app/assets/stylesheets/blacklight/_icons.scss +8 -2
- data/app/assets/stylesheets/blacklight/_search_form.scss +7 -0
- data/app/assets/stylesheets/blacklight/blacklight.scss +1 -1
- data/app/builders/blacklight/action_builder.rb +1 -0
- data/app/controllers/concerns/blacklight/bookmarks.rb +19 -13
- data/app/controllers/concerns/blacklight/catalog.rb +19 -7
- data/app/controllers/concerns/blacklight/controller.rb +12 -18
- data/app/controllers/concerns/blacklight/facet.rb +3 -0
- data/app/controllers/concerns/blacklight/search_context.rb +7 -3
- data/app/controllers/concerns/blacklight/search_history.rb +1 -6
- data/app/controllers/concerns/blacklight/token_based_user.rb +3 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +5 -1
- data/app/helpers/blacklight/configuration_helper_behavior.rb +5 -3
- data/app/helpers/blacklight/facets_helper_behavior.rb +15 -12
- data/app/helpers/blacklight/icon_helper_behavior.rb +2 -0
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +2 -0
- data/app/helpers/blacklight/render_partials_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/url_helper_behavior.rb +29 -14
- data/app/javascript/blacklight/checkbox_submit.js +9 -8
- data/app/javascript/blacklight/core.js +8 -6
- data/app/javascript/blacklight/modal.js +1 -3
- data/app/javascript/blacklight/search_context.js +0 -1
- data/app/models/blacklight/icon.rb +3 -0
- data/app/models/blacklight/suggest_search.rb +3 -14
- data/app/models/bookmark.rb +1 -1
- data/app/models/concerns/blacklight/document.rb +3 -1
- data/app/models/concerns/blacklight/solr/document.rb +1 -0
- data/app/models/concerns/blacklight/suggest/response.rb +5 -3
- data/app/models/concerns/blacklight/user.rb +1 -0
- data/app/models/search.rb +1 -0
- data/app/presenters/blacklight/document_presenter.rb +38 -0
- data/app/presenters/blacklight/field_presenter.rb +2 -0
- data/app/presenters/blacklight/index_presenter.rb +13 -5
- data/app/presenters/blacklight/json_presenter.rb +5 -12
- data/app/presenters/blacklight/link_alternate_presenter.rb +2 -0
- data/app/presenters/blacklight/rendering/abstract_step.rb +2 -0
- data/app/presenters/blacklight/rendering/helper_method.rb +2 -0
- data/app/presenters/blacklight/rendering/join.rb +2 -0
- data/app/presenters/blacklight/rendering/link_to_facet.rb +4 -0
- data/app/presenters/blacklight/rendering/microdata.rb +3 -0
- data/app/presenters/blacklight/rendering/pipeline.rb +2 -0
- data/app/presenters/blacklight/rendering/terminator.rb +2 -0
- data/app/presenters/blacklight/search_bar_presenter.rb +2 -0
- data/app/presenters/blacklight/show_presenter.rb +8 -5
- data/app/presenters/blacklight/thumbnail_presenter.rb +2 -0
- data/app/services/blacklight/document_factory.rb +2 -0
- data/app/services/blacklight/field_retriever.rb +2 -0
- data/app/services/blacklight/search_service.rb +7 -9
- data/app/values/blacklight/types.rb +3 -0
- data/app/views/bookmarks/index.html.erb +12 -13
- data/app/views/catalog/_citation.html.erb +4 -4
- data/app/views/catalog/_constraints.html.erb +2 -0
- data/app/views/catalog/_did_you_mean.html.erb +1 -1
- data/app/views/catalog/_document.atom.builder +17 -16
- data/app/views/catalog/_document.rss.builder +2 -0
- data/app/views/catalog/_facet_index_navigation.html.erb +5 -4
- data/app/views/catalog/_facet_layout.html.erb +3 -5
- data/app/views/catalog/_facets.html.erb +5 -4
- data/app/views/catalog/_field.json.jbuilder +10 -0
- data/app/views/catalog/_group.html.erb +1 -1
- data/app/views/catalog/_home_text.html.erb +5 -5
- data/app/views/catalog/_index.html.erb +5 -7
- data/app/views/catalog/_index_header.html.erb +1 -1
- data/app/views/catalog/_per_page_widget.html.erb +1 -1
- data/app/views/catalog/_results_pagination.html.erb +2 -2
- data/app/views/catalog/_search_form.html.erb +1 -1
- data/app/views/catalog/_search_results.html.erb +2 -2
- data/app/views/catalog/_show.html.erb +3 -5
- data/app/views/catalog/_show_more_like_this.html.erb +1 -1
- data/app/views/catalog/_show_sidebar.html.erb +1 -1
- data/app/views/catalog/_show_tools.html.erb +1 -1
- data/app/views/catalog/_sort_widget.html.erb +1 -1
- data/app/views/catalog/_zero_results.html.erb +1 -1
- data/app/views/catalog/citation.js.erb +1 -1
- data/app/views/catalog/facet.html.erb +5 -4
- data/app/views/catalog/facet.json.jbuilder +2 -0
- data/app/views/catalog/index.atom.builder +4 -2
- data/app/views/catalog/index.json.jbuilder +29 -10
- data/app/views/catalog/index.rss.builder +2 -0
- data/app/views/catalog/opensearch.xml.builder +3 -1
- data/app/views/catalog/show.json.jbuilder +21 -0
- data/app/views/kaminari/blacklight/_first_page.html.erb +1 -1
- data/app/views/kaminari/blacklight/_last_page.html.erb +1 -1
- data/app/views/kaminari/blacklight/_next_page.html.erb +3 -3
- data/app/views/kaminari/blacklight/_page.html.erb +4 -2
- data/app/views/kaminari/blacklight/_prev_page.html.erb +2 -2
- data/app/views/layouts/blacklight.html.erb +4 -4
- data/app/views/layouts/blacklight/base.html.erb +1 -9
- data/app/views/search_history/index.html.erb +3 -3
- data/app/views/shared/_header_navbar.html.erb +1 -1
- data/app/views/shared/_modal.html.erb +2 -2
- data/blacklight.gemspec +7 -6
- data/config/i18n-tasks.yml +17 -0
- data/config/locales/blacklight.de.yml +72 -57
- data/config/locales/blacklight.en.yml +11 -1
- data/config/locales/blacklight.es.yml +15 -1
- data/config/locales/blacklight.fr.yml +17 -8
- data/config/locales/blacklight.hu.yml +3 -1
- data/config/locales/blacklight.it.yml +16 -1
- data/config/locales/blacklight.nl.yml +3 -1
- data/config/locales/blacklight.pt-BR.yml +19 -2
- data/config/locales/blacklight.sq.yml +3 -1
- data/config/locales/blacklight.zh.yml +3 -1
- data/config/routes.rb +0 -1
- data/lib/blacklight.rb +3 -0
- data/lib/blacklight/abstract_repository.rb +12 -0
- data/lib/blacklight/configuration.rb +21 -3
- data/lib/blacklight/configuration/context.rb +11 -0
- data/lib/blacklight/configuration/fields.rb +31 -26
- data/lib/blacklight/configuration/null_field.rb +2 -0
- data/lib/blacklight/engine.rb +4 -1
- data/lib/blacklight/routes/exportable.rb +1 -3
- data/lib/blacklight/routes/searchable.rb +2 -3
- data/lib/blacklight/runtime_registry.rb +2 -0
- data/lib/blacklight/search_builder.rb +2 -0
- data/lib/blacklight/search_state.rb +2 -0
- data/lib/blacklight/solr/repository.rb +34 -0
- data/lib/blacklight/solr/response/spelling.rb +1 -0
- data/lib/generators/blacklight/assets_generator.rb +10 -9
- data/lib/generators/blacklight/controller_generator.rb +1 -1
- data/lib/generators/blacklight/install_generator.rb +7 -14
- data/lib/generators/blacklight/solr_generator.rb +8 -0
- data/lib/generators/blacklight/templates/alternate_controller.rb +4 -4
- data/lib/generators/blacklight/templates/catalog_controller.rb +7 -1
- data/lib/generators/blacklight/templates/solr/conf/schema.xml +20 -22
- data/lib/generators/blacklight/user_generator.rb +2 -0
- data/lib/railties/blacklight.rake +9 -13
- data/package-lock.json +544 -406
- data/package.json +3 -2
- data/spec/controllers/alternate_controller_spec.rb +4 -3
- data/spec/controllers/application_controller_spec.rb +0 -4
- data/spec/controllers/blacklight/base_spec.rb +5 -2
- data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +4 -4
- data/spec/controllers/blacklight/facet_spec.rb +0 -1
- data/spec/controllers/blacklight/search_fields_spec.rb +25 -22
- data/spec/controllers/bookmarks_controller_spec.rb +45 -10
- data/spec/controllers/catalog_controller_spec.rb +206 -138
- data/spec/controllers/search_history_controller_spec.rb +4 -4
- data/spec/features/alternate_controller_spec.rb +3 -3
- data/spec/features/autocomplete_spec.rb +2 -0
- data/spec/features/did_you_mean_spec.rb +4 -3
- data/spec/features/facets_spec.rb +7 -7
- data/spec/features/record_view_spec.rb +11 -12
- data/spec/features/search_context_spec.rb +4 -5
- data/spec/features/search_crawler_spec.rb +3 -5
- data/spec/features/search_filters_spec.rb +44 -44
- data/spec/features/search_history_spec.rb +5 -3
- data/spec/features/search_pagination_spec.rb +3 -1
- data/spec/features/search_results_spec.rb +11 -8
- data/spec/features/search_spec.rb +3 -3
- data/spec/features/sitelinks_search_box.rb +4 -4
- data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +30 -30
- data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +65 -59
- data/spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb +1 -1
- data/spec/helpers/blacklight/icon_helper_behavior_spec.rb +2 -0
- data/spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb +8 -3
- data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +16 -4
- data/spec/helpers/blacklight/search_history_constraints_helper_behavior_spec.rb +21 -22
- data/spec/helpers/blacklight/suggest_helper_behavior_spec.rb +6 -1
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +49 -43
- data/spec/helpers/blacklight_helper_spec.rb +28 -12
- data/spec/helpers/catalog_helper_spec.rb +50 -47
- data/spec/i18n_spec.rb +18 -0
- data/spec/integration/generators/blacklight/solr_generator_spec.rb +18 -10
- data/spec/lib/blacklight/configuration/facet_field_spec.rb +2 -0
- data/spec/lib/blacklight/configuration/field_spec.rb +3 -0
- data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +15 -20
- data/spec/lib/blacklight/parameters_spec.rb +3 -1
- data/spec/lib/blacklight/search_state_spec.rb +51 -34
- data/spec/lib/blacklight_spec.rb +13 -14
- data/spec/lib/tasks/blacklight_task_spec.rb +3 -5
- data/spec/models/blacklight/configurable_spec.rb +11 -13
- data/spec/models/blacklight/configuration/context_spec.rb +9 -10
- data/spec/models/blacklight/configuration_spec.rb +103 -91
- data/spec/models/blacklight/document/active_model_shim_spec.rb +5 -6
- data/spec/models/blacklight/document/cache_key_spec.rb +9 -2
- data/spec/models/blacklight/document/dublin_core_spec.rb +16 -19
- data/spec/models/blacklight/document/email_spec.rb +9 -9
- data/spec/models/blacklight/document/sms_spec.rb +9 -9
- data/spec/models/blacklight/document_spec.rb +9 -8
- data/spec/models/blacklight/facet_paginator_spec.rb +40 -30
- data/spec/models/blacklight/icon_spec.rb +12 -2
- data/spec/models/blacklight/search_builder_spec.rb +12 -3
- data/spec/models/blacklight/solr/document_spec.rb +216 -219
- data/spec/models/blacklight/solr/facet_paginator_spec.rb +6 -4
- data/spec/models/blacklight/solr/repository_spec.rb +37 -34
- data/spec/models/blacklight/solr/request_spec.rb +17 -18
- data/spec/models/blacklight/solr/response/facets_spec.rb +58 -58
- data/spec/models/blacklight/solr/response/group_response_spec.rb +16 -22
- data/spec/models/blacklight/solr/response/group_spec.rb +18 -25
- data/spec/models/blacklight/solr/response_spec.rb +48 -50
- data/spec/models/blacklight/solr/search_builder_spec.rb +120 -121
- data/spec/models/blacklight/suggest/response_spec.rb +6 -4
- data/spec/models/blacklight/suggest_search_spec.rb +9 -16
- data/spec/models/blacklight/user_spec.rb +9 -11
- data/spec/models/bookmark_spec.rb +6 -5
- data/spec/models/record_mailer_spec.rb +22 -20
- data/spec/models/search_spec.rb +18 -17
- data/spec/models/solr_document_spec.rb +6 -2
- data/spec/presenters/blacklight/document_presenter_spec.rb +86 -0
- data/spec/presenters/blacklight/index_presenter_spec.rb +186 -0
- data/spec/presenters/blacklight/json_presenter_spec.rb +59 -0
- data/spec/presenters/blacklight/link_alternate_presenter_spec.rb +3 -0
- data/spec/presenters/blacklight/search_bar_presenter_spec.rb +7 -0
- data/spec/presenters/{show_presenter_spec.rb → blacklight/show_presenter_spec.rb} +138 -91
- data/spec/presenters/pipeline_spec.rb +15 -8
- data/spec/presenters/thumbnail_presenter_spec.rb +5 -2
- data/spec/routing/catalog_routing_spec.rb +12 -14
- data/spec/services/blacklight/search_service_spec.rb +112 -70
- data/spec/spec_helper.rb +6 -2
- data/spec/support/features.rb +1 -1
- data/spec/support/features/session_helpers.rb +4 -4
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +12 -13
- data/spec/views/catalog/_constraints.html.erb_spec.rb +2 -3
- data/spec/views/catalog/_constraints_element.html.erb_spec.rb +9 -5
- data/spec/views/catalog/_document.html.erb_spec.rb +4 -4
- data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +4 -4
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +3 -3
- data/spec/views/catalog/_facets.html.erb_spec.rb +8 -10
- data/spec/views/catalog/_index.html.erb_spec.rb +13 -14
- data/spec/views/catalog/_index_header.html.erb_spec.rb +5 -8
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +3 -3
- data/spec/views/catalog/_show.html.erb_spec.rb +12 -13
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +4 -7
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +2 -2
- data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +0 -1
- data/spec/views/catalog/_sort_widget.html.erb_spec.rb +3 -1
- data/spec/views/catalog/_thumbnail.html.erb_spec.rb +6 -8
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +7 -9
- data/spec/views/catalog/email_success.html.erb_spec.rb +0 -1
- data/spec/views/catalog/facet.html.erb_spec.rb +3 -2
- data/spec/views/catalog/facet.json.jbuilder_spec.rb +3 -2
- data/spec/views/catalog/index.atom.builder_spec.rb +9 -4
- data/spec/views/catalog/index.html.erb_spec.rb +2 -1
- data/spec/views/catalog/index.json.jbuilder_spec.rb +84 -36
- data/spec/views/catalog/show.html.erb_spec.rb +6 -6
- data/spec/views/catalog/show.json.jbuilder_spec.rb +40 -0
- data/spec/views/catalog/sms_success.html.erb_spec.rb +0 -1
- data/spec/views/shared/_user_util_links.html.erb_spec.rb +1 -4
- data/tasks/blacklight.rake +6 -4
- data/template.demo.rb +2 -0
- metadata +50 -24
- data/app/javascript/blacklight/autofocus.js +0 -20
- data/spec/presenters/index_presenter_spec.rb +0 -150
data/spec/lib/blacklight_spec.rb
CHANGED
@@ -2,21 +2,21 @@
|
|
2
2
|
|
3
3
|
RSpec.describe Blacklight do
|
4
4
|
context 'root' do
|
5
|
-
let(:blroot) { File.expand_path(File.join(__FILE__, '..', '..', '..'
|
5
|
+
let(:blroot) { File.expand_path(File.join(__FILE__, '..', '..', '..')) }
|
6
6
|
|
7
7
|
it 'returns the full path to the BL plugin' do
|
8
|
-
expect(
|
8
|
+
expect(described_class.root).to eq blroot
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
describe '.default_index' do
|
13
13
|
context 'for a solr index' do
|
14
14
|
before do
|
15
|
-
allow(
|
15
|
+
allow(described_class).to receive(:connection_config).and_return(adapter: 'solr')
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'is an instance of Blacklight::Solr::Repository' do
|
19
|
-
expect(
|
19
|
+
expect(described_class.default_index).to be_a Blacklight::Solr::Repository
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -24,51 +24,50 @@ RSpec.describe Blacklight do
|
|
24
24
|
describe '.repository_class' do
|
25
25
|
context 'when the adapter key is missing' do
|
26
26
|
before do
|
27
|
-
allow(
|
27
|
+
allow(described_class).to receive(:connection_config).and_return({})
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'raises an error' do
|
31
|
-
expect {
|
31
|
+
expect { described_class.repository_class }.to raise_error RuntimeError, 'The value for :adapter was not found in the blacklight.yml config'
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
context 'for a solr index' do
|
36
36
|
before do
|
37
|
-
allow(
|
37
|
+
allow(described_class).to receive(:connection_config).and_return(adapter: 'solr')
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'resolves to the SolrRepository implementation' do
|
41
|
-
expect(
|
41
|
+
expect(described_class.repository_class).to eq Blacklight::Solr::Repository
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
context 'for an elastic_search index' do
|
46
46
|
before do
|
47
47
|
stub_const("Blacklight::ElasticSearch::Repository", double)
|
48
|
-
allow(
|
48
|
+
allow(described_class).to receive(:connection_config).and_return(adapter: 'elastic_search')
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'resolves to the SolrRepository implementation' do
|
52
|
-
expect(
|
52
|
+
expect(described_class.repository_class).to eq Blacklight::ElasticSearch::Repository
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
context 'for an explicitly provided class' do
|
57
57
|
before do
|
58
58
|
stub_const("CustomSearch::Repository", double)
|
59
|
-
allow(
|
59
|
+
allow(described_class).to receive(:connection_config).and_return(adapter: 'CustomSearch::Repository')
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'resolves to the custom implementation' do
|
63
|
-
expect(
|
63
|
+
expect(described_class.repository_class).to eq CustomSearch::Repository
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
68
|
describe '.default_configuration' do
|
69
69
|
it 'is a Blacklight configuration' do
|
70
|
-
expect(
|
70
|
+
expect(described_class.default_configuration).to be_a Blacklight::Configuration
|
71
71
|
end
|
72
72
|
end
|
73
|
-
|
74
73
|
end
|
@@ -2,19 +2,17 @@
|
|
2
2
|
require 'rake'
|
3
3
|
|
4
4
|
RSpec.describe "blacklight:delete_old_searches" do
|
5
|
-
|
6
5
|
before do
|
7
|
-
@rake = Rake::Application.new
|
6
|
+
@rake = Rake::Application.new
|
8
7
|
Rake.application = @rake
|
9
8
|
Rake.application.rake_require "../lib/railties/blacklight"
|
10
9
|
Rake::Task.define_task(:environment)
|
11
10
|
@task_name = "blacklight:delete_old_searches"
|
12
11
|
end
|
13
|
-
|
12
|
+
|
14
13
|
it "calls Search.delete_old_searches" do
|
15
14
|
days_old = 7
|
16
|
-
allow(Search).to receive(:delete_old_searches).with(days_old)
|
15
|
+
allow(Search).to receive(:delete_old_searches).with(days_old)
|
17
16
|
@rake[@task_name].invoke(days_old)
|
18
17
|
end
|
19
|
-
|
20
18
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
RSpec.describe "Blacklight::Configurable" do
|
4
|
-
|
3
|
+
RSpec.describe "Blacklight::Configurable", api: true do
|
5
4
|
describe "inheritence" do
|
6
5
|
before(:all) do
|
7
6
|
module TestCaseInheritence
|
@@ -9,7 +8,7 @@ RSpec.describe "Blacklight::Configurable" do
|
|
9
8
|
include Blacklight::Configurable
|
10
9
|
|
11
10
|
blacklight_config.configure do |config|
|
12
|
-
config.list = [1,2,3]
|
11
|
+
config.list = [1, 2, 3]
|
13
12
|
end
|
14
13
|
end
|
15
14
|
|
@@ -17,23 +16,23 @@ RSpec.describe "Blacklight::Configurable" do
|
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
19
|
+
|
20
20
|
it "inherits the configuration when subclassed" do
|
21
|
-
expect(TestCaseInheritence::Child.blacklight_config.list).to include(1,2,3)
|
21
|
+
expect(TestCaseInheritence::Child.blacklight_config.list).to include(1, 2, 3)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "inherited version should be a deep copy, not original" do
|
25
|
-
expect(TestCaseInheritence::Child.blacklight_config).
|
25
|
+
expect(TestCaseInheritence::Child.blacklight_config).not_to be(TestCaseInheritence::Parent.blacklight_config)
|
26
26
|
|
27
27
|
TestCaseInheritence::Child.blacklight_config.list << "child_only"
|
28
28
|
|
29
|
-
|
30
29
|
expect(TestCaseInheritence::Child.blacklight_config.list).to include("child_only")
|
31
|
-
expect(TestCaseInheritence::Parent.blacklight_config.list).
|
30
|
+
expect(TestCaseInheritence::Parent.blacklight_config.list).not_to include("child_only")
|
32
31
|
end
|
33
32
|
end
|
34
33
|
|
35
34
|
describe "default configuration" do
|
36
|
-
before
|
35
|
+
before do
|
37
36
|
Blacklight::Configurable.default_configuration = nil
|
38
37
|
end
|
39
38
|
|
@@ -51,7 +50,7 @@ RSpec.describe "Blacklight::Configurable" do
|
|
51
50
|
it "allows the user to provide a default configuration" do
|
52
51
|
a = Class.new
|
53
52
|
|
54
|
-
Blacklight::Configurable.default_configuration = Blacklight::Configuration.new :
|
53
|
+
Blacklight::Configurable.default_configuration = Blacklight::Configuration.new a: 1
|
55
54
|
|
56
55
|
a.send(:include, Blacklight::Configurable)
|
57
56
|
expect(a.blacklight_config.a).to eq 1
|
@@ -76,7 +75,7 @@ RSpec.describe "Blacklight::Configurable" do
|
|
76
75
|
instance = klass.new
|
77
76
|
instance.blacklight_config = Blacklight::Configuration.new
|
78
77
|
|
79
|
-
expect(instance.blacklight_config).
|
78
|
+
expect(instance.blacklight_config).not_to eq klass.blacklight_config
|
80
79
|
expect(instance.blacklight_config.foo).to be_nil
|
81
80
|
end
|
82
81
|
|
@@ -92,10 +91,10 @@ RSpec.describe "Blacklight::Configurable" do
|
|
92
91
|
|
93
92
|
instance = klass.new
|
94
93
|
instance.blacklight_config.bar << "123"
|
95
|
-
expect(instance.blacklight_config).
|
94
|
+
expect(instance.blacklight_config).not_to eq klass.blacklight_config
|
96
95
|
expect(klass.blacklight_config.foo).to eq "bar"
|
97
96
|
expect(instance.blacklight_config.foo).to eq "bar"
|
98
|
-
expect(klass.blacklight_config.bar).
|
97
|
+
expect(klass.blacklight_config.bar).not_to include("123")
|
99
98
|
expect(instance.blacklight_config.bar).to include("asd", "123")
|
100
99
|
end
|
101
100
|
|
@@ -111,6 +110,5 @@ RSpec.describe "Blacklight::Configurable" do
|
|
111
110
|
expect(klass.blacklight_config.foo).to eq "bar"
|
112
111
|
expect(klass2.blacklight_config.foo).to eq "asdf"
|
113
112
|
end
|
114
|
-
|
115
113
|
end
|
116
114
|
end
|
@@ -1,33 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
RSpec.describe Blacklight::Configuration::Context do
|
4
|
-
|
3
|
+
RSpec.describe Blacklight::Configuration::Context, api: true do
|
5
4
|
subject { described_class.new(context) }
|
5
|
+
|
6
6
|
let(:context) { double }
|
7
7
|
|
8
8
|
describe "#evaluate_configuration_conditional" do
|
9
|
-
it "
|
9
|
+
it "passes through regular values" do
|
10
10
|
val = double
|
11
11
|
expect(subject.evaluate_configuration_conditional(val)).to eq val
|
12
12
|
end
|
13
13
|
|
14
|
-
it "
|
15
|
-
allow(context).to receive_messages(:
|
14
|
+
it "executes a helper method" do
|
15
|
+
allow(context).to receive_messages(my_check: true)
|
16
16
|
expect(subject.evaluate_configuration_conditional(:my_check)).to be true
|
17
17
|
end
|
18
18
|
|
19
|
-
it "
|
19
|
+
it "calls a helper to determine if it should render a field" do
|
20
20
|
a = double
|
21
21
|
allow(context).to receive(:my_check_with_an_arg).with(a).and_return(true)
|
22
22
|
expect(subject.evaluate_configuration_conditional(:my_check_with_an_arg, a)).to be true
|
23
23
|
end
|
24
24
|
|
25
|
-
it "
|
26
|
-
one_arg_lambda =
|
27
|
-
two_arg_lambda =
|
25
|
+
it "evaluates a Proc to determine if it should render a field" do
|
26
|
+
one_arg_lambda = ->(_context, _a) { true }
|
27
|
+
two_arg_lambda = ->(_context, _a, _b) { true }
|
28
28
|
expect(subject.evaluate_configuration_conditional(one_arg_lambda, 1)).to be true
|
29
29
|
expect(subject.evaluate_configuration_conditional(two_arg_lambda, 1, 2)).to be true
|
30
30
|
end
|
31
31
|
end
|
32
|
-
|
33
32
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
RSpec.describe "Blacklight::Configuration" do
|
4
|
-
|
3
|
+
RSpec.describe "Blacklight::Configuration", api: true do
|
5
4
|
let(:config) do
|
6
5
|
Blacklight::Configuration.new
|
7
6
|
end
|
@@ -19,7 +18,7 @@ RSpec.describe "Blacklight::Configuration" do
|
|
19
18
|
end
|
20
19
|
|
21
20
|
it "accepts a block for configuration" do
|
22
|
-
config = Blacklight::Configuration.new(:
|
21
|
+
config = Blacklight::Configuration.new(a: 1) { |c| c.a = 2 }
|
23
22
|
|
24
23
|
expect(config.a).to eq 2
|
25
24
|
|
@@ -52,6 +51,7 @@ RSpec.describe "Blacklight::Configuration" do
|
|
52
51
|
|
53
52
|
describe "#connection_config" do
|
54
53
|
let(:custom_config) { double }
|
54
|
+
|
55
55
|
it "has the global blacklight configuration" do
|
56
56
|
expect(config.connection_config).to eq Blacklight.connection_config
|
57
57
|
end
|
@@ -65,9 +65,9 @@ RSpec.describe "Blacklight::Configuration" do
|
|
65
65
|
it "has a list of additional formats for index requests to respond to" do
|
66
66
|
config.index.respond_to.xml = true
|
67
67
|
|
68
|
-
config.index.respond_to.csv = { :
|
68
|
+
config.index.respond_to.csv = { layout: false }
|
69
69
|
|
70
|
-
config.index.respond_to.yaml =
|
70
|
+
config.index.respond_to.yaml = -> { render plain: "" }
|
71
71
|
|
72
72
|
expect(config.index.respond_to.keys).to eq [:xml, :csv, :yaml]
|
73
73
|
end
|
@@ -79,15 +79,15 @@ RSpec.describe "Blacklight::Configuration" do
|
|
79
79
|
end
|
80
80
|
|
81
81
|
it "accepts config'd value" do
|
82
|
-
expect(Blacklight::Configuration.new(:
|
82
|
+
expect(Blacklight::Configuration.new(spell_max: 10).spell_max).to eq 10
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
86
|
describe "for_display_type" do
|
87
|
-
let(:mock_field) { Blacklight::Configuration::IndexField.new }
|
88
87
|
let(:image) { SolrDocument.new(format: 'Image') }
|
89
88
|
let(:sound) { SolrDocument.new(format: 'Sound') }
|
90
|
-
|
89
|
+
|
90
|
+
it "adds index fields just for a certain type" do
|
91
91
|
config.for_display_type "Image" do |c|
|
92
92
|
c.add_index_field :dimensions
|
93
93
|
end
|
@@ -99,13 +99,37 @@ RSpec.describe "Blacklight::Configuration" do
|
|
99
99
|
expect(config.index_fields_for(image)).to have_key 'title'
|
100
100
|
expect(config.index_fields).not_to have_key 'dimensions'
|
101
101
|
end
|
102
|
+
|
103
|
+
it "adds show fields just for a certain type" do
|
104
|
+
config.for_display_type "Image" do |c|
|
105
|
+
c.add_show_field :dimensions
|
106
|
+
end
|
107
|
+
config.add_show_field :title
|
108
|
+
|
109
|
+
expect(config.show_fields_for(image)).to have_key 'dimensions'
|
110
|
+
expect(config.show_fields_for(image)).to have_key 'title'
|
111
|
+
expect(config.show_fields_for(sound)).not_to have_key 'dimensions'
|
112
|
+
expect(config.show_fields_for(image)).to have_key 'title'
|
113
|
+
expect(config.show_fields).not_to have_key 'dimensions'
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'calls the block on subsequent invocations' do
|
117
|
+
config.for_display_type "Image" do |c|
|
118
|
+
c.add_show_field :dimensions
|
119
|
+
end
|
120
|
+
config.for_display_type "Image" do |c|
|
121
|
+
c.add_show_field :photographer
|
122
|
+
end
|
123
|
+
|
124
|
+
expect(config.show_fields_for(image)).to have_key 'dimensions'
|
125
|
+
expect(config.show_fields_for(image)).to have_key 'photographer'
|
126
|
+
end
|
102
127
|
end
|
103
128
|
|
104
129
|
describe "inheritable_copy" do
|
105
130
|
let(:klass) { Class.new }
|
106
131
|
let(:config_copy) { config.inheritable_copy(klass) }
|
107
132
|
|
108
|
-
|
109
133
|
it "provides a deep copy of the configuration" do
|
110
134
|
config_copy.a = 1
|
111
135
|
|
@@ -113,7 +137,7 @@ RSpec.describe "Blacklight::Configuration" do
|
|
113
137
|
config_copy.add_facet_field "dummy_field", @mock_facet
|
114
138
|
|
115
139
|
expect(config.a).to be_nil
|
116
|
-
expect(config.facet_fields).
|
140
|
+
expect(config.facet_fields).not_to include(@mock_facet)
|
117
141
|
end
|
118
142
|
|
119
143
|
context "when model classes are customised" do
|
@@ -142,15 +166,15 @@ RSpec.describe "Blacklight::Configuration" do
|
|
142
166
|
|
143
167
|
it "provides cloned copies of mutable data structures" do
|
144
168
|
config.a = { value: 1 }
|
145
|
-
config.b = [1,2,3]
|
169
|
+
config.b = [1, 2, 3]
|
146
170
|
|
147
171
|
config_copy.a[:value] = 2
|
148
172
|
config_copy.b << 5
|
149
173
|
|
150
174
|
expect(config.a[:value]).to eq 1
|
151
175
|
expect(config_copy.a[:value]).to eq 2
|
152
|
-
expect(config.b).to match_array [1,2,3]
|
153
|
-
expect(config_copy.b).to match_array [1,2,3,5]
|
176
|
+
expect(config.b).to match_array [1, 2, 3]
|
177
|
+
expect(config_copy.b).to match_array [1, 2, 3, 5]
|
154
178
|
end
|
155
179
|
end
|
156
180
|
|
@@ -159,42 +183,36 @@ RSpec.describe "Blacklight::Configuration" do
|
|
159
183
|
Blacklight::Configuration.define_field_access :my_custom_field
|
160
184
|
|
161
185
|
config = Blacklight::Configuration.new do |config|
|
162
|
-
config.add_my_custom_field 'qwerty', :
|
186
|
+
config.add_my_custom_field 'qwerty', label: "asdf"
|
163
187
|
end
|
164
188
|
|
165
|
-
|
166
|
-
|
167
189
|
expect(config.my_custom_fields.keys).to include('qwerty')
|
168
190
|
end
|
169
191
|
|
170
192
|
it "lets you define a field accessor that uses an existing field-type" do
|
171
|
-
|
172
|
-
Blacklight::Configuration.define_field_access :my_custom_facet_field, :class => Blacklight::Configuration::FacetField
|
193
|
+
Blacklight::Configuration.define_field_access :my_custom_facet_field, class: Blacklight::Configuration::FacetField
|
173
194
|
|
174
195
|
config = Blacklight::Configuration.new do |config|
|
175
|
-
config.add_my_custom_facet_field 'qwerty', :
|
196
|
+
config.add_my_custom_facet_field 'qwerty', label: "asdf"
|
176
197
|
end
|
177
198
|
|
178
|
-
|
179
|
-
|
180
199
|
expect(config.my_custom_facet_fields['qwerty']).to be_a_kind_of(Blacklight::Configuration::FacetField)
|
181
200
|
end
|
182
|
-
|
183
201
|
end
|
184
202
|
|
185
203
|
describe "add_facet_field" do
|
186
204
|
it "accepts field name and hash form arg" do
|
187
|
-
config.add_facet_field('format',
|
205
|
+
config.add_facet_field('format', label: "Format", limit: true)
|
188
206
|
|
189
|
-
expect(config.facet_fields["format"]).
|
207
|
+
expect(config.facet_fields["format"]).not_to be_nil
|
190
208
|
expect(config.facet_fields["format"]["label"]).to eq "Format"
|
191
209
|
expect(config.facet_fields["format"]["limit"]).to be true
|
192
210
|
end
|
193
211
|
|
194
212
|
it "accepts FacetField obj arg" do
|
195
|
-
config.add_facet_field("format", Blacklight::Configuration::FacetField.new(
|
213
|
+
config.add_facet_field("format", Blacklight::Configuration::FacetField.new(label: "Format"))
|
196
214
|
|
197
|
-
expect(config.facet_fields["format"]).
|
215
|
+
expect(config.facet_fields["format"]).not_to be_nil
|
198
216
|
expect(config.facet_fields["format"]["label"]).to eq "Format"
|
199
217
|
end
|
200
218
|
|
@@ -204,7 +222,7 @@ RSpec.describe "Blacklight::Configuration" do
|
|
204
222
|
facet.limit = true
|
205
223
|
end
|
206
224
|
|
207
|
-
expect(config.facet_fields["format"]).
|
225
|
+
expect(config.facet_fields["format"]).not_to be_nil
|
208
226
|
expect(config.facet_fields["format"].limit).to be true
|
209
227
|
end
|
210
228
|
|
@@ -214,23 +232,23 @@ RSpec.describe "Blacklight::Configuration" do
|
|
214
232
|
facet.label = "Format"
|
215
233
|
end
|
216
234
|
|
217
|
-
expect(config.facet_fields['format']).
|
235
|
+
expect(config.facet_fields['format']).not_to be_nil
|
218
236
|
end
|
219
237
|
|
220
238
|
it "accepts a configuration hash" do
|
221
|
-
config.add_facet_field :
|
222
|
-
expect(config.facet_fields['format']).
|
239
|
+
config.add_facet_field field: 'format', label: 'Format'
|
240
|
+
expect(config.facet_fields['format']).not_to be_nil
|
223
241
|
end
|
224
242
|
|
225
243
|
it "accepts array form" do
|
226
|
-
config.add_facet_field([{ :
|
244
|
+
config.add_facet_field([{ field: 'format', label: 'Format' }, { field: 'publication_date', label: 'Publication Date' }])
|
227
245
|
|
228
246
|
expect(config.facet_fields).to have(2).fields
|
229
247
|
end
|
230
248
|
|
231
249
|
it "accepts array form with a block" do
|
232
250
|
expect do |b|
|
233
|
-
config.add_facet_field([{ :
|
251
|
+
config.add_facet_field([{ field: 'format', label: 'Format' }, { field: 'publication_date', label: 'Publication Date' }], &b)
|
234
252
|
end.to yield_control.twice
|
235
253
|
end
|
236
254
|
|
@@ -241,7 +259,7 @@ RSpec.describe "Blacklight::Configuration" do
|
|
241
259
|
end
|
242
260
|
|
243
261
|
it "allows you to not show the facet in the facet bar" do
|
244
|
-
config.add_facet_field("publication_date", :
|
262
|
+
config.add_facet_field("publication_date", show: false)
|
245
263
|
|
246
264
|
expect(config.facet_fields["publication_date"]['show']).to be false
|
247
265
|
end
|
@@ -251,25 +269,25 @@ RSpec.describe "Blacklight::Configuration" do
|
|
251
269
|
end
|
252
270
|
|
253
271
|
it "looks up and match field names" do
|
254
|
-
allow(config).to
|
272
|
+
allow(config).to receive(:reflected_fields).and_return(
|
255
273
|
"some_field_facet" => {},
|
256
274
|
"another_field_facet" => {},
|
257
|
-
"a_facet_field" => {}
|
258
|
-
|
275
|
+
"a_facet_field" => {}
|
276
|
+
)
|
259
277
|
expect { |b| config.add_facet_field match: /_facet$/, &b }.to yield_control.twice
|
260
278
|
|
261
|
-
expect(config.facet_fields.keys).to eq [
|
279
|
+
expect(config.facet_fields.keys).to eq %w[some_field_facet another_field_facet]
|
262
280
|
end
|
263
281
|
|
264
282
|
it "takes wild-carded field names and dereference them to solr fields" do
|
265
|
-
allow(config).to
|
283
|
+
allow(config).to receive(:reflected_fields).and_return(
|
266
284
|
"some_field_facet" => {},
|
267
285
|
"another_field_facet" => {},
|
268
|
-
"a_facet_field" => {}
|
269
|
-
|
286
|
+
"a_facet_field" => {}
|
287
|
+
)
|
270
288
|
expect { |b| config.add_facet_field "*_facet", &b }.to yield_control.twice
|
271
289
|
|
272
|
-
expect(config.facet_fields.keys).to eq [
|
290
|
+
expect(config.facet_fields.keys).to eq %w[some_field_facet another_field_facet]
|
273
291
|
end
|
274
292
|
|
275
293
|
describe "if/unless conditions with legacy show parameter" do
|
@@ -291,22 +309,22 @@ RSpec.describe "Blacklight::Configuration" do
|
|
291
309
|
|
292
310
|
describe "add_index_field" do
|
293
311
|
it "takes hash form" do
|
294
|
-
config.add_index_field("title_tsim", :
|
312
|
+
config.add_index_field("title_tsim", label: "Title")
|
295
313
|
|
296
|
-
expect(config.index_fields["title_tsim"]).
|
314
|
+
expect(config.index_fields["title_tsim"]).not_to be_nil
|
297
315
|
expect(config.index_fields["title_tsim"].label).to eq "Title"
|
298
316
|
end
|
299
317
|
it "takes IndexField param" do
|
300
|
-
config.add_index_field("title_tsim", Blacklight::Configuration::IndexField.new(:
|
318
|
+
config.add_index_field("title_tsim", Blacklight::Configuration::IndexField.new(field: "title_display", label: "Title"))
|
301
319
|
|
302
|
-
expect(config.index_fields["title_tsim"]).
|
320
|
+
expect(config.index_fields["title_tsim"]).not_to be_nil
|
303
321
|
expect(config.index_fields["title_tsim"].label).to eq "Title"
|
304
322
|
end
|
305
323
|
it "takes block form" do
|
306
324
|
config.add_index_field("title_tsim") do |field|
|
307
325
|
field.label = "Title"
|
308
326
|
end
|
309
|
-
expect(config.index_fields["title_tsim"]).
|
327
|
+
expect(config.index_fields["title_tsim"]).not_to be_nil
|
310
328
|
expect(config.index_fields["title_tsim"].label).to eq "Title"
|
311
329
|
end
|
312
330
|
|
@@ -321,14 +339,14 @@ RSpec.describe "Blacklight::Configuration" do
|
|
321
339
|
end
|
322
340
|
|
323
341
|
it "takes wild-carded field names and dereference them to solr fields" do
|
324
|
-
allow(config).to
|
342
|
+
allow(config).to receive(:reflected_fields).and_return(
|
325
343
|
"some_field_display" => {},
|
326
344
|
"another_field_display" => {},
|
327
|
-
"a_facet_field" => {}
|
328
|
-
|
345
|
+
"a_facet_field" => {}
|
346
|
+
)
|
329
347
|
config.add_index_field "*_display"
|
330
348
|
|
331
|
-
expect(config.index_fields.keys).to eq [
|
349
|
+
expect(config.index_fields.keys).to eq %w[some_field_display another_field_display]
|
332
350
|
end
|
333
351
|
|
334
352
|
it "queries solr and get live values for match fields", integration: true do
|
@@ -339,30 +357,30 @@ RSpec.describe "Blacklight::Configuration" do
|
|
339
357
|
|
340
358
|
describe "add_show_field" do
|
341
359
|
it "takes hash form" do
|
342
|
-
config.add_show_field("title_tsim", :
|
360
|
+
config.add_show_field("title_tsim", label: "Title")
|
343
361
|
|
344
|
-
expect(config.show_fields["title_tsim"]).
|
362
|
+
expect(config.show_fields["title_tsim"]).not_to be_nil
|
345
363
|
expect(config.show_fields["title_tsim"].label).to eq "Title"
|
346
364
|
end
|
347
365
|
it "takes ShowField argument" do
|
348
|
-
config.add_show_field("title_tsim", Blacklight::Configuration::ShowField.new(:
|
366
|
+
config.add_show_field("title_tsim", Blacklight::Configuration::ShowField.new(field: "title_display", label: "Title"))
|
349
367
|
|
350
|
-
expect(config.show_fields["title_tsim"]).
|
351
|
-
expect(config.show_fields["title_tsim"].label).to eq
|
368
|
+
expect(config.show_fields["title_tsim"]).not_to be_nil
|
369
|
+
expect(config.show_fields["title_tsim"].label).to eq "Title"
|
352
370
|
end
|
353
371
|
it "takes block form" do
|
354
372
|
config.add_show_field("title_tsim") do |f|
|
355
373
|
f.label = "Title"
|
356
374
|
end
|
357
375
|
|
358
|
-
expect(config.show_fields["title_tsim"]).
|
359
|
-
expect(config.show_fields["title_tsim"].label).to eq
|
376
|
+
expect(config.show_fields["title_tsim"]).not_to be_nil
|
377
|
+
expect(config.show_fields["title_tsim"].label).to eq "Title"
|
360
378
|
end
|
361
379
|
|
362
380
|
it "creates default label humanized from field" do
|
363
381
|
config.add_show_field("my_custom_field")
|
364
382
|
|
365
|
-
expect(config.show_fields["my_custom_field"].label).to eq
|
383
|
+
expect(config.show_fields["my_custom_field"].label).to eq "My Custom Field"
|
366
384
|
end
|
367
385
|
|
368
386
|
it "raises on nil solr field name" do
|
@@ -370,72 +388,67 @@ RSpec.describe "Blacklight::Configuration" do
|
|
370
388
|
end
|
371
389
|
|
372
390
|
it "takes wild-carded field names and dereference them to solr fields" do
|
373
|
-
allow(config).to
|
391
|
+
allow(config).to receive(:reflected_fields).and_return(
|
374
392
|
"some_field_display" => {},
|
375
393
|
"another_field_display" => {},
|
376
|
-
"a_facet_field" => {}
|
377
|
-
|
394
|
+
"a_facet_field" => {}
|
395
|
+
)
|
378
396
|
config.add_show_field "*_display"
|
379
397
|
|
380
|
-
expect(config.show_fields.keys).to eq [
|
398
|
+
expect(config.show_fields.keys).to eq %w[some_field_display another_field_display]
|
381
399
|
end
|
382
|
-
|
383
400
|
end
|
384
401
|
|
385
|
-
|
386
402
|
describe "add_search_field" do
|
387
403
|
it "accepts hash form" do
|
388
404
|
c = Blacklight::Configuration.new
|
389
|
-
c.add_search_field(:
|
390
|
-
expect(c.search_fields["my_search_key"]).
|
405
|
+
c.add_search_field(key: "my_search_key")
|
406
|
+
expect(c.search_fields["my_search_key"]).not_to be_nil
|
391
407
|
end
|
392
408
|
|
393
409
|
it "accepts two-arg hash form" do
|
394
410
|
c = Blacklight::Configuration.new
|
395
411
|
|
396
412
|
c.add_search_field("my_search_type",
|
397
|
-
|
398
|
-
|
399
|
-
|
413
|
+
key: "my_search_type",
|
414
|
+
solr_parameters: { qf: "my_field_qf^10" },
|
415
|
+
solr_local_parameters: { pf: "$my_field_pf" })
|
400
416
|
|
401
417
|
field = c.search_fields["my_search_type"]
|
402
418
|
|
403
|
-
expect(field).
|
404
|
-
|
405
|
-
|
406
|
-
expect(field.solr_parameters).to_not be_nil
|
407
|
-
expect(field.solr_local_parameters).to_not be_nil
|
408
|
-
|
419
|
+
expect(field).not_to be_nil
|
409
420
|
|
421
|
+
expect(field.solr_parameters).not_to be_nil
|
422
|
+
expect(field.solr_local_parameters).not_to be_nil
|
410
423
|
end
|
411
424
|
|
412
425
|
it "accepts block form" do
|
413
426
|
c = Blacklight::Configuration.new
|
414
427
|
|
415
428
|
c.add_search_field("some_field") do |field|
|
416
|
-
field.solr_parameters = {:
|
417
|
-
field.solr_local_parameters = {:
|
429
|
+
field.solr_parameters = { qf: "solr_field^10" }
|
430
|
+
field.solr_local_parameters = { pf: "$some_field_pf" }
|
418
431
|
end
|
419
432
|
|
420
433
|
f = c.search_fields["some_field"]
|
421
434
|
|
422
|
-
expect(f).
|
423
|
-
expect(f.solr_parameters).
|
424
|
-
expect(f.solr_local_parameters).
|
435
|
+
expect(f).not_to be_nil
|
436
|
+
expect(f.solr_parameters).not_to be_nil
|
437
|
+
expect(f.solr_local_parameters).not_to be_nil
|
425
438
|
end
|
426
439
|
|
427
440
|
it "accepts SearchField object" do
|
428
441
|
c = Blacklight::Configuration.new
|
429
442
|
|
430
|
-
f = Blacklight::Configuration::SearchField.new(
|
443
|
+
f = Blacklight::Configuration::SearchField.new(foo: "bar")
|
431
444
|
|
432
445
|
c.add_search_field("foo", f)
|
433
446
|
|
434
|
-
expect(c.search_fields["foo"]).
|
447
|
+
expect(c.search_fields["foo"]).not_to be_nil
|
435
448
|
end
|
436
449
|
|
437
450
|
it "raises on nil key" do
|
438
|
-
expect {config.add_search_field(nil, :
|
451
|
+
expect { config.add_search_field(nil, foo: "bar") }.to raise_error ArgumentError
|
439
452
|
end
|
440
453
|
|
441
454
|
it "creates default label from titleized field key" do
|
@@ -464,13 +477,13 @@ RSpec.describe "Blacklight::Configuration" do
|
|
464
477
|
describe "add_sort_field" do
|
465
478
|
it "takes a hash" do
|
466
479
|
c = Blacklight::Configuration.new
|
467
|
-
c.add_sort_field(:
|
468
|
-
expect(c.sort_fields["my_sort_key"]).
|
480
|
+
c.add_sort_field(key: "my_sort_key", sort: "score desc")
|
481
|
+
expect(c.sort_fields["my_sort_key"]).not_to be_nil
|
469
482
|
end
|
470
483
|
|
471
484
|
it "takes a two-arg form with a hash" do
|
472
|
-
config.add_sort_field("score desc, pub_date_si desc, title_si asc", :
|
473
|
-
expect(config.sort_fields.values.find{|f| f.label == "relevance"}).
|
485
|
+
config.add_sort_field("score desc, pub_date_si desc, title_si asc", label: "relevance")
|
486
|
+
expect(config.sort_fields.values.find { |f| f.label == "relevance" }).not_to be_nil
|
474
487
|
end
|
475
488
|
|
476
489
|
it "takes a SortField object" do
|
@@ -478,7 +491,7 @@ RSpec.describe "Blacklight::Configuration" do
|
|
478
491
|
Blacklight::Configuration::SortField.new(label: "relevance",
|
479
492
|
sort: "score desc, pub_date_sort desc, title_sort asc")
|
480
493
|
)
|
481
|
-
expect(config.sort_fields.values.find{|f| f.label == "relevance"}).
|
494
|
+
expect(config.sort_fields.values.find { |f| f.label == "relevance" }).not_to be_nil
|
482
495
|
end
|
483
496
|
|
484
497
|
it "takes block form" do
|
@@ -487,15 +500,14 @@ RSpec.describe "Blacklight::Configuration" do
|
|
487
500
|
field.sort = "score desc, pub_date_si desc, title_si asc"
|
488
501
|
end
|
489
502
|
|
490
|
-
expect(config.sort_fields.values.find{|f| f.label == "relevance"}).
|
491
|
-
|
503
|
+
expect(config.sort_fields.values.find { |f| f.label == "relevance" }).not_to be_nil
|
492
504
|
end
|
493
505
|
end
|
494
506
|
|
495
507
|
describe "#default_search_field" do
|
496
508
|
it "uses the field with a :default key" do
|
497
509
|
config.add_search_field('search_field_1')
|
498
|
-
config.add_search_field('search_field_2', :
|
510
|
+
config.add_search_field('search_field_2', default: true)
|
499
511
|
|
500
512
|
expect(config.default_search_field.key).to eq 'search_field_2'
|
501
513
|
end
|