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/spec_helper.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
ENV["RAILS_ENV"] ||= 'test'
|
7
7
|
|
8
|
-
if ENV["COVERAGE"]
|
8
|
+
if ENV["COVERAGE"] || ENV["CI"]
|
9
9
|
require 'simplecov'
|
10
10
|
require 'coveralls'
|
11
11
|
|
@@ -44,11 +44,14 @@ end
|
|
44
44
|
# in spec/support/ and its subdirectories.
|
45
45
|
# Blacklight, again, make sure we're looking in the right place for em.
|
46
46
|
# Relative to HERE, NOT to Rails.root, which is off somewhere else.
|
47
|
-
Dir[Pathname.new(File.expand_path(
|
47
|
+
Dir[Pathname.new(File.expand_path('support/**/*.rb', __dir__))].each { |f| require f }
|
48
48
|
|
49
49
|
RSpec.configure do |config|
|
50
50
|
config.disable_monkey_patching!
|
51
51
|
|
52
|
+
# When we're testing the API, only run the api tests
|
53
|
+
config.filter_run api: true if ENV['BLACKLIGHT_API_TEST']
|
54
|
+
|
52
55
|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
53
56
|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
54
57
|
|
@@ -61,6 +64,7 @@ RSpec.configure do |config|
|
|
61
64
|
config.include Devise::Test::ControllerHelpers, type: :controller
|
62
65
|
else
|
63
66
|
config.include Devise::TestHelpers, type: :controller
|
67
|
+
config.include Devise::TestHelpers, type: :i18n
|
64
68
|
end
|
65
69
|
|
66
70
|
config.infer_spec_type_from_file_location!
|
data/spec/support/features.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
# spec/support/features.rb
|
3
3
|
|
4
|
-
require File.expand_path(
|
4
|
+
require File.expand_path('features/session_helpers.rb', __dir__)
|
5
5
|
|
6
6
|
RSpec.configure do |config|
|
7
7
|
config.include Features::SessionHelpers, type: :feature
|
@@ -13,11 +13,11 @@ module Features
|
|
13
13
|
|
14
14
|
def sign_in(login = 'user1')
|
15
15
|
email = "#{login}@#{login}.com"
|
16
|
-
|
16
|
+
User.create(email: email, password: "password", password_confirmation: "password")
|
17
17
|
visit new_user_session_path
|
18
|
-
fill_in("user_email", :
|
19
|
-
fill_in("user_password", :
|
20
|
-
|
18
|
+
fill_in("user_email", with: email)
|
19
|
+
fill_in("user_password", with: "password")
|
20
|
+
|
21
21
|
if has_button? "Sign in"
|
22
22
|
click_button("Sign in")
|
23
23
|
elsif has_button? "Log in"
|
@@ -2,32 +2,31 @@
|
|
2
2
|
require 'rails/generators'
|
3
3
|
|
4
4
|
class TestAppGenerator < Rails::Generators::Base
|
5
|
-
source_root File.expand_path(
|
5
|
+
source_root File.expand_path('../../../test_app_templates', __dir__)
|
6
6
|
|
7
|
-
def
|
8
|
-
if ENV['TRAVIS']
|
9
|
-
insert_into_file 'app/assets/stylesheets/application.css', :before =>'/*' do
|
10
|
-
"@charset \"UTF-8\";\n"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def remove_index
|
7
|
+
def remove_index
|
16
8
|
remove_file "public/index.html"
|
17
9
|
end
|
18
10
|
|
19
11
|
def run_blacklight_generator
|
20
|
-
say_status("warning", "GENERATING BL", :yellow)
|
12
|
+
say_status("warning", "GENERATING BL", :yellow)
|
21
13
|
|
22
14
|
Bundler.with_clean_env do
|
23
15
|
run "bundle install"
|
24
16
|
end
|
17
|
+
options = '--devise'
|
18
|
+
if ENV['BLACKLIGHT_API_TEST']
|
19
|
+
options += ' --skip-assets'
|
20
|
+
inject_into_class 'app/controllers/application_controller.rb', 'ApplicationController' do
|
21
|
+
" include ActionController::MimeResponds\n" # see https://github.com/projectblacklight/blacklight/issues/1894
|
22
|
+
end
|
23
|
+
end
|
25
24
|
|
26
|
-
generate 'blacklight:install',
|
25
|
+
generate 'blacklight:install', options
|
27
26
|
end
|
28
27
|
|
29
28
|
def run_test_support_generator
|
30
|
-
say_status("warning", "GENERATING test_support", :yellow)
|
29
|
+
say_status("warning", "GENERATING test_support", :yellow)
|
31
30
|
|
32
31
|
generate 'blacklight:test_support'
|
33
32
|
end
|
@@ -18,7 +18,7 @@ RSpec.describe "catalog/constraints" do
|
|
18
18
|
allow(view).to receive_messages(query_has_constraints?: true)
|
19
19
|
allow(view).to receive(:blacklight_config).and_return(blacklight_config)
|
20
20
|
render partial: "catalog/constraints"
|
21
|
-
expect(rendered).to have_link("Start Over", :
|
21
|
+
expect(rendered).to have_link("Start Over", href: 'http://xyz')
|
22
22
|
end
|
23
23
|
|
24
24
|
it "renders a start over link with the current view type" do
|
@@ -27,7 +27,6 @@ RSpec.describe "catalog/constraints" do
|
|
27
27
|
params[:view] = 'xyz'
|
28
28
|
allow(view).to receive(:blacklight_config).and_return(blacklight_config)
|
29
29
|
render partial: "catalog/constraints"
|
30
|
-
expect(rendered).to have_link("Start Over", :
|
30
|
+
expect(rendered).to have_link("Start Over", href: 'http://xyz?view=xyz')
|
31
31
|
end
|
32
|
-
|
33
32
|
end
|
@@ -3,12 +3,13 @@
|
|
3
3
|
RSpec.describe "catalog/_constraints_element.html.erb" do
|
4
4
|
describe "for simple display" do
|
5
5
|
before do
|
6
|
-
render :
|
6
|
+
render partial: "catalog/constraints_element", locals: { label: "my label", value: "my value" }
|
7
7
|
end
|
8
|
+
|
8
9
|
it "renders label and value" do
|
9
10
|
expect(rendered).to have_selector("span.applied-filter.constraint") do |s|
|
10
11
|
expect(s).to have_css("span.constraint-value")
|
11
|
-
expect(s).
|
12
|
+
expect(s).not_to have_css("a.constraint-value")
|
12
13
|
expect(s).to have_selector "span.filter-name", content: "my label"
|
13
14
|
expect(s).to have_selector "span.filter-value", content: "my value"
|
14
15
|
end
|
@@ -17,8 +18,9 @@ RSpec.describe "catalog/_constraints_element.html.erb" do
|
|
17
18
|
|
18
19
|
describe "with remove link" do
|
19
20
|
before do
|
20
|
-
render :
|
21
|
+
render partial: "catalog/constraints_element", locals: { label: "my label", value: "my value", options: { remove: "http://remove" } }
|
21
22
|
end
|
23
|
+
|
22
24
|
it "includes remove link" do
|
23
25
|
expect(rendered).to have_selector("span.applied-filter") do |s|
|
24
26
|
expect(s).to have_selector(".remove[href='http://remove']")
|
@@ -33,8 +35,9 @@ RSpec.describe "catalog/_constraints_element.html.erb" do
|
|
33
35
|
|
34
36
|
describe "with custom classes" do
|
35
37
|
before do
|
36
|
-
render :
|
38
|
+
render partial: "catalog/constraints_element", locals: { label: "my label", value: "my value", options: { classes: %w[class1 class2] } }
|
37
39
|
end
|
40
|
+
|
38
41
|
it "includes them" do
|
39
42
|
expect(rendered).to have_selector("span.applied-filter.constraint.class1.class2")
|
40
43
|
end
|
@@ -42,8 +45,9 @@ RSpec.describe "catalog/_constraints_element.html.erb" do
|
|
42
45
|
|
43
46
|
describe "with no escaping" do
|
44
47
|
before do
|
45
|
-
render(
|
48
|
+
render(partial: "catalog/constraints_element", locals: { label: "<span class='custom_label'>my label</span>".html_safe, value: "<span class='custom_value'>my value</span>".html_safe })
|
46
49
|
end
|
50
|
+
|
47
51
|
it "does not escape key and value" do
|
48
52
|
expect(rendered).to have_selector("span.applied-filter.constraint span.filter-name span.custom_label")
|
49
53
|
expect(rendered).to have_selector("span.applied-filter.constraint span.filter-value span.custom_value")
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe "catalog/_document" do
|
4
|
-
let(:document) { SolrDocument.new :
|
4
|
+
let(:document) { SolrDocument.new id: 'xyz', format: 'a' }
|
5
5
|
let(:blacklight_config) { Blacklight::Configuration.new }
|
6
6
|
|
7
7
|
before do
|
@@ -13,7 +13,7 @@ RSpec.describe "catalog/_document" do
|
|
13
13
|
stub_template "catalog/_index_header.html.erb" => "document_header"
|
14
14
|
stub_template "catalog/_thumbnail.html.erb" => "thumbnail_default"
|
15
15
|
stub_template "catalog/_index_default.html.erb" => "index_default"
|
16
|
-
render :
|
16
|
+
render partial: "catalog/document", locals: { document: document, document_counter: 1 }
|
17
17
|
expect(rendered).to match /document_header/
|
18
18
|
expect(rendered).to match /thumbnail_default/
|
19
19
|
expect(rendered).to match /index_default/
|
@@ -22,11 +22,11 @@ RSpec.describe "catalog/_document" do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "uses the index.partials parameter to determine the partials to render" do
|
25
|
-
blacklight_config.index.partials = [
|
25
|
+
blacklight_config.index.partials = %w[a b c]
|
26
26
|
stub_template "catalog/_a_default.html.erb" => "a_partial"
|
27
27
|
stub_template "catalog/_b_default.html.erb" => "b_partial"
|
28
28
|
stub_template "catalog/_c_default.html.erb" => "c_partial"
|
29
|
-
render :
|
29
|
+
render partial: "catalog/document", locals: { document: document, document_counter: 1 }
|
30
30
|
expect(rendered).to match /a_partial/
|
31
31
|
expect(rendered).to match /b_partial/
|
32
32
|
expect(rendered).to match /c_partial/
|
@@ -4,6 +4,7 @@ RSpec.describe "catalog/_document_list", type: :view do
|
|
4
4
|
before do
|
5
5
|
allow(view).to receive_messages(document_index_view_type: "some-view", documents: [])
|
6
6
|
end
|
7
|
+
|
7
8
|
it "includes a class for the current view" do
|
8
9
|
render
|
9
10
|
expect(rendered).to have_selector(".documents-some-view")
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
RSpec.describe 'catalog/_facet_index_navigation.html.erb', type: :view do
|
4
4
|
let(:pagination) { Blacklight::Solr::FacetPaginator.new([]) }
|
5
|
-
let(:facet) { Blacklight::Configuration::FacetField.new(
|
5
|
+
let(:facet) { Blacklight::Configuration::FacetField.new(index_range: '0'..'9') }
|
6
6
|
let(:blacklight_config) { Blacklight::Configuration.new }
|
7
7
|
|
8
8
|
before do
|
@@ -21,9 +21,9 @@ RSpec.describe 'catalog/_facet_index_navigation.html.erb', type: :view do
|
|
21
21
|
expect(rendered).to have_link '9'
|
22
22
|
end
|
23
23
|
|
24
|
-
it 'renders
|
24
|
+
it 'renders an "all" button' do
|
25
25
|
render
|
26
|
-
expect(rendered).to have_selector '.
|
26
|
+
expect(rendered).to have_selector '.page-link', text: 'All'
|
27
27
|
end
|
28
28
|
|
29
29
|
context 'with a selected index' do
|
@@ -35,7 +35,7 @@ RSpec.describe 'catalog/_facet_index_navigation.html.erb', type: :view do
|
|
35
35
|
end
|
36
36
|
it 'enables the clear facets button' do
|
37
37
|
render
|
38
|
-
expect(rendered).to have_link '
|
38
|
+
expect(rendered).to have_link 'All'
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -28,13 +28,13 @@ RSpec.describe "catalog/facet_layout" do
|
|
28
28
|
it "is collapsable" do
|
29
29
|
render partial: 'catalog/facet_layout', locals: { facet_field: facet_field }
|
30
30
|
expect(rendered).to have_selector '.card-header.collapsed'
|
31
|
-
expect(rendered).to have_selector '.collapse.card-
|
31
|
+
expect(rendered).to have_selector '.collapse.card-body'
|
32
32
|
end
|
33
33
|
|
34
34
|
it "is configured to be open by default" do
|
35
35
|
allow(facet_field).to receive_messages(collapse: false)
|
36
36
|
render partial: 'catalog/facet_layout', locals: { facet_field: facet_field }
|
37
|
-
expect(rendered).
|
38
|
-
expect(rendered).to have_selector '.show.card-
|
37
|
+
expect(rendered).not_to have_selector '.card-header.collapsed'
|
38
|
+
expect(rendered).to have_selector '.show.card-body'
|
39
39
|
end
|
40
40
|
end
|
@@ -5,34 +5,32 @@ RSpec.describe "catalog/_facets" do
|
|
5
5
|
|
6
6
|
before do
|
7
7
|
allow(view).to receive_messages(blacklight_config: blacklight_config)
|
8
|
-
allow(view).to receive(:search_action_path)
|
9
|
-
'/catalog'
|
10
|
-
end
|
8
|
+
allow(view).to receive(:search_action_path).and_return('/catalog')
|
11
9
|
end
|
12
10
|
|
13
11
|
context "without any facet fields" do
|
14
12
|
it "does not have a header if no facets are displayed" do
|
15
|
-
allow(view).to receive_messages(:
|
13
|
+
allow(view).to receive_messages(render_facet_partials: '')
|
16
14
|
render
|
17
|
-
expect(rendered).
|
15
|
+
expect(rendered).not_to have_selector('h4')
|
18
16
|
end
|
19
17
|
end
|
20
|
-
context "with facet fields" do
|
21
18
|
|
19
|
+
context "with facet fields" do
|
22
20
|
let :facet_field do
|
23
21
|
Blacklight::Configuration::FacetField.new(field: 'facet_field_1', label: 'label').normalize!
|
24
22
|
end
|
25
23
|
|
26
24
|
before do
|
27
25
|
blacklight_config.facet_fields['facet_field_1'] = facet_field
|
28
|
-
@mock_display_facet_1 = double(:
|
29
|
-
allow(view).to receive_messages(:
|
30
|
-
@response = double
|
26
|
+
@mock_display_facet_1 = double(name: 'facet_field_1', sort: nil, offset: nil, prefix: nil, items: [Blacklight::Solr::Response::Facets::FacetItem.new(value: 'Value', hits: 1234)])
|
27
|
+
allow(view).to receive_messages(facet_field_names: [:facet_field_1], facet_limit_for: 10)
|
28
|
+
@response = double
|
31
29
|
allow(@response).to receive(:aggregations).and_return("facet_field_1" => @mock_display_facet_1)
|
32
30
|
end
|
33
31
|
|
34
32
|
it "has a header" do
|
35
|
-
allow(view).to receive_messages(:
|
33
|
+
allow(view).to receive_messages(render_facet_partials: '')
|
36
34
|
render
|
37
35
|
expect(rendered).to have_selector('.facets-heading')
|
38
36
|
end
|
@@ -6,20 +6,20 @@ RSpec.describe "/catalog/_index" do
|
|
6
6
|
include BlacklightHelper
|
7
7
|
include CatalogHelper
|
8
8
|
|
9
|
-
before
|
9
|
+
before do
|
10
10
|
allow(view).to receive(:action_name).and_return('index')
|
11
11
|
@config = Blacklight::Configuration.new do |config|
|
12
12
|
config.show.display_type_field = 'asdf'
|
13
|
-
config.add_index_field 'one_field', :
|
14
|
-
config.add_index_field 'empty_field', :
|
15
|
-
config.add_index_field 'four_field', :
|
13
|
+
config.add_index_field 'one_field', label: 'One:'
|
14
|
+
config.add_index_field 'empty_field', label: 'Three:'
|
15
|
+
config.add_index_field 'four_field', label: 'Four:'
|
16
16
|
end
|
17
17
|
|
18
18
|
@fname_1 = "one_field"
|
19
19
|
@fname_2 = "solr_field_not_in_config"
|
20
20
|
@fname_3 = "empty_field"
|
21
21
|
@fname_4 = "four_field"
|
22
|
-
|
22
|
+
|
23
23
|
@document = SolrDocument.new(id: 1, @fname_1 => "val_1", @fname_2 => "val2", @fname_4 => "val_4")
|
24
24
|
|
25
25
|
@flabel_1 = "One:"
|
@@ -32,12 +32,12 @@ RSpec.describe "/catalog/_index" do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "only displays fields listed in the initializer" do
|
35
|
-
expect(@rendered).
|
36
|
-
expect(@rendered).
|
35
|
+
expect(@rendered).not_to include("val_2")
|
36
|
+
expect(@rendered).not_to include(@fname_2)
|
37
37
|
end
|
38
38
|
|
39
39
|
it "skips over fields listed in initializer that are not in solr response" do
|
40
|
-
expect(@rendered).
|
40
|
+
expect(@rendered).not_to include(@fname_3)
|
41
41
|
end
|
42
42
|
|
43
43
|
it "displays field labels from initializer and raw solr field names in the class" do
|
@@ -49,15 +49,14 @@ RSpec.describe "/catalog/_index" do
|
|
49
49
|
expect(@rendered).to include("blacklight-#{@fname_4}")
|
50
50
|
end
|
51
51
|
|
52
|
-
# this test probably belongs in a Cucumber feature
|
53
|
-
# it "should display fields in the order listed in the initializer" do
|
54
|
-
# pending
|
55
|
-
# end
|
52
|
+
# this test probably belongs in a Cucumber feature
|
53
|
+
# it "should display fields in the order listed in the initializer" do
|
54
|
+
# pending
|
55
|
+
# end
|
56
56
|
|
57
57
|
it "has values for displayed fields" do
|
58
58
|
expect(@rendered).to include("val_1")
|
59
59
|
expect(@rendered).to include("val_4")
|
60
|
-
expect(@rendered).
|
60
|
+
expect(@rendered).not_to include("val_2")
|
61
61
|
end
|
62
|
-
|
63
62
|
end
|
@@ -2,37 +2,34 @@
|
|
2
2
|
|
3
3
|
RSpec.describe "catalog/_index_header" do
|
4
4
|
let :document do
|
5
|
-
SolrDocument.new :
|
5
|
+
SolrDocument.new id: 'xyz', format: 'a'
|
6
6
|
end
|
7
7
|
|
8
8
|
let(:blacklight_config) { Blacklight::Configuration.new }
|
9
9
|
|
10
10
|
before do
|
11
|
-
allow(controller).to receive(:action_name).and_return('index')
|
12
11
|
assign :response, instance_double(Blacklight::Solr::Response, start: 0)
|
13
12
|
allow(view).to receive(:render_grouped_response?).and_return false
|
14
13
|
allow(view).to receive(:blacklight_config).and_return(blacklight_config)
|
15
|
-
allow(view).to receive(:
|
16
|
-
allow(view).to receive(:search_session).and_return({})
|
14
|
+
allow(view).to receive(:session_tracking_params).and_return({})
|
17
15
|
end
|
18
16
|
|
19
17
|
it "renders the document header" do
|
20
18
|
allow(view).to receive(:render_index_doc_actions)
|
21
|
-
render partial: "catalog/index_header", locals: {document: document, document_counter: 1}
|
19
|
+
render partial: "catalog/index_header", locals: { document: document, document_counter: 1 }
|
22
20
|
expect(rendered).to have_selector('.document-counter', text: "2")
|
23
21
|
end
|
24
22
|
|
25
23
|
it "allows the title to take the whole space if no document tools are rendered" do
|
26
24
|
allow(view).to receive(:render_index_doc_actions)
|
27
|
-
render partial: "catalog/index_header", locals: {document: document, document_counter: 1}
|
25
|
+
render partial: "catalog/index_header", locals: { document: document, document_counter: 1 }
|
28
26
|
expect(rendered).to have_selector '.index_title.col-md-12'
|
29
27
|
end
|
30
28
|
|
31
29
|
it "gives the document actions space if present" do
|
32
30
|
allow(view).to receive(:render_index_doc_actions).and_return("DOCUMENT ACTIONS")
|
33
|
-
render partial: "catalog/index_header", locals: {document: document, document_counter: 1}
|
31
|
+
render partial: "catalog/index_header", locals: { document: document, document_counter: 1 }
|
34
32
|
expect(rendered).to have_selector '.index_title.col-sm-9'
|
35
33
|
expect(rendered).to have_content "DOCUMENT ACTIONS"
|
36
34
|
end
|
37
|
-
|
38
35
|
end
|
@@ -8,14 +8,14 @@ RSpec.describe "catalog/_paginate_compact.html.erb" do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it "renders paginatable arrays" do
|
11
|
-
render :
|
11
|
+
render partial: 'catalog/paginate_compact', object: Kaminari.paginate_array([], total_count: 145).page(1).per(10)
|
12
12
|
expect(rendered).to have_selector ".page-entries"
|
13
13
|
expect(rendered).to have_selector "a[@rel=next]"
|
14
14
|
end
|
15
15
|
|
16
16
|
it "renders ActiveRecord collections" do
|
17
|
-
50.times { b = Bookmark.new;
|
18
|
-
render :
|
17
|
+
50.times { b = Bookmark.new; b.user = user; b.save! }
|
18
|
+
render partial: 'catalog/paginate_compact', object: Bookmark.page(1).per(25)
|
19
19
|
expect(rendered).to have_selector ".page-entries"
|
20
20
|
expect(rendered).to have_selector "a[@rel=next]"
|
21
21
|
end
|
@@ -3,17 +3,16 @@
|
|
3
3
|
# spec for default partial to display solr document fields in catalog show view
|
4
4
|
|
5
5
|
RSpec.describe "/catalog/_show" do
|
6
|
-
|
7
6
|
include BlacklightHelper
|
8
7
|
include CatalogHelper
|
9
8
|
|
10
|
-
before
|
9
|
+
before do
|
11
10
|
allow(controller).to receive(:action_name).and_return('show')
|
12
11
|
@config = Blacklight::Configuration.new do |config|
|
13
12
|
config.show.display_type_field = 'asdf'
|
14
|
-
config.add_show_field 'one_field', :
|
15
|
-
config.add_show_field 'empty_field', :
|
16
|
-
config.add_show_field 'four_field', :
|
13
|
+
config.add_show_field 'one_field', label: 'One:'
|
14
|
+
config.add_show_field 'empty_field', label: 'Three:'
|
15
|
+
config.add_show_field 'four_field', label: 'Four:'
|
17
16
|
end
|
18
17
|
|
19
18
|
@fname_1 = "one_field"
|
@@ -33,12 +32,12 @@ RSpec.describe "/catalog/_show" do
|
|
33
32
|
end
|
34
33
|
|
35
34
|
it "only displays fields listed in the initializer" do
|
36
|
-
expect(@rendered).
|
37
|
-
expect(@rendered).
|
35
|
+
expect(@rendered).not_to include("val_2")
|
36
|
+
expect(@rendered).not_to include(@fname_2)
|
38
37
|
end
|
39
38
|
|
40
39
|
it "skips over fields listed in initializer that are not in solr response" do
|
41
|
-
expect(@rendered).
|
40
|
+
expect(@rendered).not_to include(@fname_3)
|
42
41
|
end
|
43
42
|
|
44
43
|
it "displays field labels from initializer and raw solr field names in the class" do
|
@@ -50,14 +49,14 @@ RSpec.describe "/catalog/_show" do
|
|
50
49
|
expect(@rendered).to include("blacklight-#{@fname_4}")
|
51
50
|
end
|
52
51
|
|
53
|
-
# this test probably belongs in a Cucumber feature
|
54
|
-
# it "should display fields in the order listed in the initializer" do
|
55
|
-
# pending
|
56
|
-
# end
|
52
|
+
# this test probably belongs in a Cucumber feature
|
53
|
+
# it "should display fields in the order listed in the initializer" do
|
54
|
+
# pending
|
55
|
+
# end
|
57
56
|
|
58
57
|
it "has values for displayed fields" do
|
59
58
|
expect(@rendered).to include("val_1")
|
60
59
|
expect(@rendered).to include("val_4")
|
61
|
-
expect(@rendered).
|
60
|
+
expect(@rendered).not_to include("val_2")
|
62
61
|
end
|
63
62
|
end
|