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 "Facets" do
|
@@ -12,7 +13,7 @@ describe "Facets" do
|
|
12
13
|
|
13
14
|
expect(page).to have_selector(".blacklight-language_facet")
|
14
15
|
expect(page).to have_selector(".blacklight-language_facet.facet_limit-active")
|
15
|
-
|
16
|
+
|
16
17
|
within "#facet-language_facet" do
|
17
18
|
expect(page).to have_selector("span.selected", :text => "Tibetan")
|
18
19
|
expect(page).to have_selector("span.facet-count.selected", :text => "6")
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe BlacklightHelper do
|
@@ -84,8 +85,8 @@ describe BlacklightHelper do
|
|
84
85
|
end
|
85
86
|
|
86
87
|
describe "render_nav_actions" do
|
87
|
-
it "
|
88
|
-
buff =
|
88
|
+
it "renders partials" do
|
89
|
+
buff = String.new
|
89
90
|
helper.render_nav_actions { |config, item| buff << "<foo>#{item}</foo>" }
|
90
91
|
expect(buff).to have_selector "foo a#bookmarks_nav[href=\"/bookmarks\"]"
|
91
92
|
expect(buff).to have_selector "foo a span[data-role='bookmark-counter']", text: '0'
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe CatalogHelper do
|
@@ -24,9 +25,6 @@ describe CatalogHelper do
|
|
24
25
|
|
25
26
|
|
26
27
|
describe "page_entries_info" do
|
27
|
-
before(:all) do
|
28
|
-
end
|
29
|
-
|
30
28
|
it "with no results" do
|
31
29
|
@response = mock_response :total => 0
|
32
30
|
|
@@ -123,12 +121,13 @@ describe CatalogHelper do
|
|
123
121
|
expect(html).to eq "<strong>1,001</strong> - <strong>1,010</strong> of <strong>5,000</strong>"
|
124
122
|
end
|
125
123
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
end
|
124
|
+
context "with an ActiveRecord collection" do
|
125
|
+
let(:user) { User.create! email: 'xyz@example.com', password: 'xyz12345' }
|
126
|
+
before { 50.times { Bookmark.create!(user: user) } }
|
127
|
+
subject { helper.page_entries_info(Bookmark.page(1).per(25)) }
|
131
128
|
|
129
|
+
it { is_expected.to eq "<strong>1</strong> - <strong>25</strong> of <strong>50</strong>" }
|
130
|
+
end
|
132
131
|
end
|
133
132
|
|
134
133
|
describe "should_autofocus_on_search_box?" do
|
@@ -360,14 +359,10 @@ describe CatalogHelper do
|
|
360
359
|
allow(helper).to receive(:label_for_search_field).with(nil).and_return('')
|
361
360
|
end
|
362
361
|
|
363
|
-
let
|
364
|
-
|
365
|
-
|
362
|
+
let(:blacklight_config) { Blacklight::Configuration.new }
|
363
|
+
let(:params) { ActionController::Parameters.new(q: 'foobar', f: { format: ["Book"] }) }
|
364
|
+
subject { helper.render_search_to_page_title(params) }
|
366
365
|
|
367
|
-
|
368
|
-
|
369
|
-
it "should render a page title" do
|
370
|
-
expect(helper.render_search_to_page_title(params)).to eq "foobar / Format: Book"
|
371
|
-
end
|
366
|
+
it { is_expected.to eq "foobar / Format: Book" }
|
372
367
|
end
|
373
368
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe Blacklight::DeprecatedUrlHelperBehavior do
|
@@ -6,9 +7,10 @@ describe Blacklight::DeprecatedUrlHelperBehavior do
|
|
6
7
|
test.call
|
7
8
|
end
|
8
9
|
end
|
9
|
-
|
10
|
+
|
11
|
+
let(:parameter_class) { ActionController::Parameters }
|
10
12
|
let(:search_state) { Blacklight::SearchState.new(params, blacklight_config) }
|
11
|
-
let(:params) {
|
13
|
+
let(:params) { parameter_class.new }
|
12
14
|
let(:blacklight_config) { Blacklight::Configuration.new }
|
13
15
|
|
14
16
|
before do
|
@@ -27,7 +29,7 @@ describe Blacklight::DeprecatedUrlHelperBehavior do
|
|
27
29
|
end
|
28
30
|
|
29
31
|
it 'generates a search state for the source parameters' do
|
30
|
-
expect(helper.params_for_search(
|
32
|
+
expect(helper.params_for_search(parameter_class.new(source: 1), { merge: 1 })).to include merge: 1, source: 1
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
@@ -38,8 +40,9 @@ describe Blacklight::DeprecatedUrlHelperBehavior do
|
|
38
40
|
end
|
39
41
|
|
40
42
|
describe '#reset_search_params' do
|
43
|
+
let(:source_parameters) { parameter_class.new page: 1, counter: 10 }
|
41
44
|
it 'resets the current page and counter' do
|
42
|
-
expect(helper.reset_search_params(
|
45
|
+
expect(helper.reset_search_params(source_parameters)).to be_blank
|
43
46
|
end
|
44
47
|
end
|
45
48
|
|
@@ -55,8 +58,11 @@ describe Blacklight::DeprecatedUrlHelperBehavior do
|
|
55
58
|
expect(helper.add_facet_params(field, item)).to eq search_state.add_facet_params(field, item)
|
56
59
|
end
|
57
60
|
|
58
|
-
|
59
|
-
|
61
|
+
context "with source_parameters" do
|
62
|
+
let(:source_parameters) { parameter_class.new source: 1 }
|
63
|
+
it 'generates a search state for the source parameters' do
|
64
|
+
expect(helper.add_facet_params(field, item, source_parameters)).to include source: 1
|
65
|
+
end
|
60
66
|
end
|
61
67
|
end
|
62
68
|
|
@@ -85,8 +91,11 @@ describe Blacklight::DeprecatedUrlHelperBehavior do
|
|
85
91
|
expect(helper.remove_facet_params(field, item)).to eq search_state.remove_facet_params(field, item)
|
86
92
|
end
|
87
93
|
|
88
|
-
|
89
|
-
|
94
|
+
context "with source_parameters" do
|
95
|
+
let(:source_parameters) { parameter_class.new source: 1 }
|
96
|
+
it 'generates a search state for the source parameters' do
|
97
|
+
expect(helper.remove_facet_params(field, item, source_parameters)).to include source: 1
|
98
|
+
end
|
90
99
|
end
|
91
100
|
end
|
92
|
-
end
|
101
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe RenderConstraintsHelper do
|
@@ -18,12 +19,19 @@ describe RenderConstraintsHelper do
|
|
18
19
|
|
19
20
|
describe '#render_constraints_query' do
|
20
21
|
let(:my_engine) { double("Engine") }
|
21
|
-
|
22
|
-
|
22
|
+
let(:params) { ActionController::Parameters.new(q: 'foobar', f: { type: 'journal' }) }
|
23
|
+
subject { helper.render_constraints_query(params) }
|
24
|
+
|
25
|
+
it "has a link relative to the current url" do
|
26
|
+
expect(subject).to have_selector "a[href='/?f%5Btype%5D=journal']"
|
23
27
|
end
|
24
|
-
|
25
|
-
|
26
|
-
|
28
|
+
|
29
|
+
context "with a route_set" do
|
30
|
+
let(:params) { ActionController::Parameters.new(q: 'foobar', f: { type: 'journal' }, route_set: my_engine) }
|
31
|
+
it "accepts an optional route set" do
|
32
|
+
expect(my_engine).to receive(:url_for).and_return('/?f%5Btype%5D=journal')
|
33
|
+
expect(subject).to have_selector "a[href='/?f%5Btype%5D=journal']"
|
34
|
+
end
|
27
35
|
end
|
28
36
|
end
|
29
37
|
|
@@ -34,19 +42,21 @@ describe RenderConstraintsHelper do
|
|
34
42
|
end
|
35
43
|
subject { helper.render_filter_element('type', ['journal'], path) }
|
36
44
|
|
37
|
-
let(:
|
45
|
+
let(:params) { ActionController::Parameters.new q: 'biz' }
|
46
|
+
let(:path) { Blacklight::SearchState.new(params, config) }
|
38
47
|
|
39
|
-
it "
|
48
|
+
it "has a link relative to the current url" do
|
40
49
|
expect(subject).to have_link "Remove constraint Item Type: journal", href: "/catalog?q=biz"
|
41
50
|
expect(subject).to have_selector ".filterName", text: 'Item Type'
|
42
51
|
end
|
43
52
|
end
|
44
53
|
|
45
54
|
describe "#render_constraints_filters" do
|
55
|
+
let(:params) { ActionController::Parameters.new f: { 'type' => [''] } }
|
46
56
|
before do
|
47
57
|
allow(helper).to receive(:blacklight_config).and_return(config)
|
48
58
|
end
|
49
|
-
subject { helper.render_constraints_filters(
|
59
|
+
subject { helper.render_constraints_filters(params) }
|
50
60
|
|
51
61
|
it "should render nothing for empty facet limit param" do
|
52
62
|
expect(subject).to be_blank
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe BlacklightUrlHelper do
|
@@ -9,6 +10,8 @@ describe BlacklightUrlHelper do
|
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
13
|
+
let(:parameter_class) { ActionController::Parameters }
|
14
|
+
|
12
15
|
before do
|
13
16
|
allow(helper).to receive(:search_action_path) do |*args|
|
14
17
|
search_catalog_url *args
|
@@ -26,7 +29,7 @@ describe BlacklightUrlHelper do
|
|
26
29
|
before do
|
27
30
|
allow(helper).to receive_messages(controller: controller_class)
|
28
31
|
allow(helper).to receive_messages(controller_name: controller_class.controller_name)
|
29
|
-
allow(helper).to receive_messages(params:
|
32
|
+
allow(helper).to receive_messages(params: parameter_class.new)
|
30
33
|
end
|
31
34
|
|
32
35
|
it "should be a polymorphic routing-ready object" do
|
@@ -48,12 +51,14 @@ describe BlacklightUrlHelper do
|
|
48
51
|
|
49
52
|
context "within an alternative catalog controller" do
|
50
53
|
let(:controller_class) { ::AlternateController.new }
|
54
|
+
|
51
55
|
before do
|
52
56
|
helper.blacklight_config.show.route = { controller: :current }
|
53
|
-
allow(helper).to receive(:params).and_return(controller: 'alternate')
|
57
|
+
allow(helper).to receive(:params).and_return(parameter_class.new controller: 'alternate')
|
54
58
|
end
|
59
|
+
|
55
60
|
it "should support the :current controller configuration" do
|
56
|
-
expect(helper.url_for_document(doc)).to eq(
|
61
|
+
expect(helper.url_for_document(doc)).to eq(controller: 'alternate', action: :show, id: doc)
|
57
62
|
end
|
58
63
|
end
|
59
64
|
|
@@ -94,7 +99,7 @@ describe BlacklightUrlHelper do
|
|
94
99
|
expect(tag).to match /page=3/
|
95
100
|
expect(tag).to match /per_page=15/
|
96
101
|
end
|
97
|
-
|
102
|
+
|
98
103
|
it "should omit per_page if the value is the same as the default" do
|
99
104
|
allow(helper).to receive_messages(current_search_session: double(query_params: query_params))
|
100
105
|
allow(helper).to receive_messages(search_session: { 'per_page' => 10, 'counter' => 31 })
|
@@ -106,7 +111,11 @@ describe BlacklightUrlHelper do
|
|
106
111
|
|
107
112
|
context "without current search context" do
|
108
113
|
before do
|
109
|
-
|
114
|
+
if Rails.version >= '5.0.0'
|
115
|
+
controller.request.assign_parameters(Rails.application.routes, 'catalog', 'show', { id: '123' }, '/catalog/123', [:controller, :action, :id])
|
116
|
+
else
|
117
|
+
controller.request.assign_parameters(Rails.application.routes, 'catalog', 'show', id: '123')
|
118
|
+
end
|
110
119
|
allow(helper).to receive_messages(current_search_session: nil)
|
111
120
|
end
|
112
121
|
|
@@ -131,31 +140,41 @@ describe BlacklightUrlHelper do
|
|
131
140
|
end
|
132
141
|
end
|
133
142
|
|
143
|
+
describe "link_to_previous_document" do
|
144
|
+
context "when the argument is nil" do
|
145
|
+
subject { helper.link_to_previous_document(nil) }
|
146
|
+
it { is_expected.to eq '<span class="previous">« Previous</span>' }
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
134
150
|
describe "link_to_query" do
|
135
|
-
it "
|
151
|
+
it "builds a link tag to catalog using query string (no other params)" do
|
136
152
|
query = "brilliant"
|
137
|
-
allow(helper).to receive_messages(params:
|
153
|
+
allow(helper).to receive_messages(params: parameter_class.new)
|
138
154
|
tag = helper.link_to_query(query)
|
139
155
|
expect(tag).to match /q=#{query}/
|
140
156
|
expect(tag).to match />#{query}<\/a>/
|
141
157
|
end
|
142
|
-
|
158
|
+
|
159
|
+
it "builds a link tag to catalog using query string and other existing params" do
|
143
160
|
query = "wonderful"
|
144
|
-
allow(helper).to receive_messages(params:
|
161
|
+
allow(helper).to receive_messages(params: parameter_class.new(qt: "title_search", per_page: "50"))
|
145
162
|
tag = helper.link_to_query(query)
|
146
163
|
expect(tag).to match /qt=title_search/
|
147
164
|
expect(tag).to match /per_page=50/
|
148
165
|
end
|
149
|
-
|
166
|
+
|
167
|
+
it "ignores existing :page param" do
|
150
168
|
query = "yes"
|
151
|
-
allow(helper).to receive_messages(params:
|
169
|
+
allow(helper).to receive_messages(params: parameter_class.new(page: "2", qt: "author_search"))
|
152
170
|
tag = helper.link_to_query(query)
|
153
171
|
expect(tag).to match /qt=author_search/
|
154
172
|
expect(tag).to_not match /page/
|
155
173
|
end
|
156
|
-
|
174
|
+
|
175
|
+
it "is html_safe" do
|
157
176
|
query = "brilliant"
|
158
|
-
allow(helper).to receive_messages(params:
|
177
|
+
allow(helper).to receive_messages(params: parameter_class.new(page: "2", qt: "author_search"))
|
159
178
|
tag = helper.link_to_query(query)
|
160
179
|
expect(tag).to be_html_safe
|
161
180
|
end
|
@@ -176,91 +195,76 @@ describe BlacklightUrlHelper do
|
|
176
195
|
end
|
177
196
|
|
178
197
|
describe "link_to_document" do
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
end
|
198
|
+
let(:title_display) { '654321' }
|
199
|
+
let(:id) { '123456' }
|
200
|
+
let(:data) { { 'id' => id, 'title_display' => [title_display] } }
|
201
|
+
let(:document) { SolrDocument.new(data) }
|
184
202
|
|
185
|
-
it "
|
186
|
-
|
187
|
-
@document = SolrDocument.new(data)
|
188
|
-
expect(helper.link_to_document(@document, "title_display")).to have_selector("a", :text => 'title_display', :count => 1)
|
203
|
+
it "consists of the document title wrapped in a <a>" do
|
204
|
+
expect(helper.link_to_document(document, :title_display)).to have_selector("a", :text => '654321', :count => 1)
|
189
205
|
end
|
190
206
|
|
191
|
-
it "
|
192
|
-
|
193
|
-
@document = SolrDocument.new(data)
|
194
|
-
expect(helper.link_to_document(@document, Proc.new { |doc, opts| doc[:id] + ": " + doc.first(:title_display) })).to have_selector("a", :text => '123456: 654321', :count => 1)
|
207
|
+
it "accepts and returns a string label" do
|
208
|
+
expect(helper.link_to_document(document, String.new('title_display'))).to have_selector("a", :text => 'title_display', :count => 1)
|
195
209
|
end
|
196
210
|
|
197
|
-
it "
|
198
|
-
|
199
|
-
@document = SolrDocument.new(data)
|
200
|
-
expect(helper.link_to_document(@document, :title_display)).to have_selector("a", :text => '123456', :count => 1)
|
211
|
+
it "accepts and returns a Proc" do
|
212
|
+
expect(helper.link_to_document(document, Proc.new { |doc, opts| doc[:id] + ": " + doc.first(:title_display) })).to have_selector("a", :text => '123456: 654321', :count => 1)
|
201
213
|
end
|
202
214
|
|
203
|
-
|
204
|
-
data
|
205
|
-
|
206
|
-
|
207
|
-
|
215
|
+
context 'when label is missing' do
|
216
|
+
let(:data) { { 'id' => id } }
|
217
|
+
it "returns id" do
|
218
|
+
expect(helper.link_to_document(document, :title_display)).to have_selector("a", :text => '123456', :count => 1)
|
219
|
+
end
|
220
|
+
|
221
|
+
it "is html safe" do
|
222
|
+
expect(helper.link_to_document(document, :title_display)).to be_html_safe
|
223
|
+
end
|
208
224
|
|
209
|
-
|
210
|
-
|
211
|
-
|
225
|
+
it "passes on the title attribute to the link_to_with_data method" do
|
226
|
+
expect(helper.link_to_document(document, "Some crazy long label...", title: "Some crazy longer label")).to match(/title=\"Some crazy longer label\"/)
|
227
|
+
end
|
228
|
+
|
229
|
+
it "doesn't add an erroneous title attribute if one isn't provided" do
|
230
|
+
expect(helper.link_to_document(document, "Some crazy long label...")).to_not match(/title=/)
|
231
|
+
end
|
232
|
+
|
233
|
+
context "with an integer id" do
|
234
|
+
let(:id) { 123456 }
|
235
|
+
it "works" do
|
236
|
+
expect(helper.link_to_document(document)).to have_selector("a")
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
212
240
|
|
241
|
+
it "converts the counter parameter into a data- attribute" do
|
213
242
|
allow(helper).to receive(:track_test_path).with(hash_including(id: '123456', counter: 5)).and_return('tracking url')
|
214
243
|
|
215
|
-
expect(helper.link_to_document(
|
244
|
+
expect(helper.link_to_document(document, :title_display, counter: 5)).to include 'data-context-href="tracking url"'
|
216
245
|
end
|
217
246
|
|
218
247
|
it "includes the data- attributes from the options" do
|
219
|
-
|
220
|
-
@document = SolrDocument.new(data)
|
221
|
-
link = helper.link_to_document @document, { data: { x: 1 } }
|
248
|
+
link = helper.link_to_document document, { data: { x: 1 } }
|
222
249
|
expect(link).to have_selector '[data-x]'
|
223
250
|
end
|
224
251
|
|
225
252
|
it 'adds a controller-specific tracking attribute' do
|
226
|
-
data = { 'id'=>'123456', 'title_display'=>['654321'] }
|
227
|
-
@document = SolrDocument.new(data)
|
228
|
-
|
229
253
|
expect(helper).to receive(:track_test_path).and_return('/asdf')
|
230
|
-
link = helper.link_to_document
|
254
|
+
link = helper.link_to_document document, { data: { x: 1 } }
|
231
255
|
|
232
256
|
expect(link).to have_selector '[data-context-href="/asdf"]'
|
233
257
|
end
|
234
258
|
|
235
259
|
it 'adds a global tracking attribute' do
|
236
|
-
|
237
|
-
@document = SolrDocument.new(data)
|
238
|
-
|
239
|
-
link = helper.link_to_document @document, { data: { x: 1 } }
|
260
|
+
link = helper.link_to_document document, { data: { x: 1 } }
|
240
261
|
expect(link).to have_selector '[data-context-href="/catalog/123456/track"]'
|
241
262
|
end
|
242
|
-
|
243
|
-
it "passes on the title attribute to the link_to_with_data method" do
|
244
|
-
@document = SolrDocument.new('id'=>'123456')
|
245
|
-
expect(helper.link_to_document(@document, "Some crazy long label...", title: "Some crazy longer label")).to match(/title=\"Some crazy longer label\"/)
|
246
|
-
end
|
247
|
-
|
248
|
-
it "doesn't add an erroneous title attribute if one isn't provided" do
|
249
|
-
@document = SolrDocument.new('id'=>'123456')
|
250
|
-
expect(helper.link_to_document(@document, "Some crazy long label...")).to_not match(/title=/)
|
251
|
-
end
|
252
|
-
|
253
|
-
it "should work with integer ids" do
|
254
|
-
data = {'id'=> 123456 }
|
255
|
-
@document = SolrDocument.new(data)
|
256
|
-
expect(helper.link_to_document(@document)).to have_selector("a")
|
257
|
-
end
|
258
|
-
|
259
263
|
end
|
260
264
|
|
261
265
|
describe "link_to_previous_search" do
|
266
|
+
let(:params) { {} }
|
262
267
|
it "should link to the given search parameters" do
|
263
|
-
params = {}
|
264
268
|
allow(helper).to receive(:render_search_to_s).with(params).and_return "link text"
|
265
269
|
expect(helper.link_to_previous_search({})).to eq helper.link_to("link text", helper.search_action_path)
|
266
270
|
end
|