Skip to content

Commit d401654

Browse files
authored
Merge pull request #1869 from projectblacklight/release-6.x-backports
Release 6.x backports
2 parents bf97ad0 + 60d0766 commit d401654

File tree

12 files changed

+65
-22
lines changed

12 files changed

+65
-22
lines changed

.travis.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@ notifications:
55
email: false
66

77
rvm:
8-
- 2.4.1
8+
- 2.5.0
99

1010
matrix:
1111
include:
12-
- rvm: 2.4.1
13-
env: "RAILS_VERSION=4.2.8"
14-
- rvm: 2.2.7
15-
env: "RAILS_VERSION=5.0.3"
16-
- rvm: 2.3.4
17-
env: "RAILS_VERSION=5.1.1"
18-
- rvm: jruby-9.1.7.0
19-
env: "RAILS_VERSION=5.0.3 JRUBY_OPTS=\"-J-Xms512m -J-Xmx1024m\""
12+
- rvm: 2.5.0
13+
env: "RAILS_VERSION=5.2.0"
14+
- rvm: 2.4.4
15+
env: "RAILS_VERSION=4.2.10"
16+
- rvm: 2.2.10
17+
env: "RAILS_VESION=5.0.7"
18+
- rvm: 2.3.7
19+
env: "RAILS_VERSION=5.1.6"
20+
- rvm: jruby-9.1.17.0
21+
env: "RAILS_VERSION=5.2.0 JRUBY_OPTS=\"-J-Xms512m -J-Xmx1024m\""
2022
allow_failures:
21-
- rvm: jruby-9.1.7.0
23+
- rvm: jruby-9.1.17.0
2224
fast_finish: true
2325

2426
before_install:

app/controllers/concerns/blacklight/catalog.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def track
5656
search_session['id'] = params[:search_id]
5757
search_session['per_page'] = params[:per_page]
5858

59-
if params[:redirect] and (params[:redirect].starts_with?('/') or params[:redirect] =~ URI.regexp)
59+
if params[:redirect] and (params[:redirect].starts_with?('/') or params[:redirect] =~ URI::DEFAULT_PARSER.make_regexp)
6060
uri = URI.parse(params[:redirect])
6161
path = uri.query ? "#{uri.path}?#{uri.query}" : uri.path
6262
redirect_to path, status: 303

app/controllers/concerns/blacklight/token_based_user.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,22 @@ def encrypt_user_id(user_id, current_time = nil)
4242
end
4343

4444
def export_secret_token
45-
ActiveSupport::KeyGenerator.new(Rails.application.secrets.secret_key_base).generate_key('encrypted user session key')[0..(key_len - 1)]
45+
secret_key_generator.generate_key('encrypted user session key')[0..(key_len - 1)]
46+
end
47+
48+
def secret_key_generator
49+
@secret_key_generator ||= begin
50+
app = Rails.application
51+
52+
secret_key_base = if app.respond_to?(:credentials)
53+
# Rails 5.2+
54+
app.credentials.secret_key_base
55+
else
56+
# Rails <= 5.1
57+
app.secrets.secret_key_base
58+
end
59+
ActiveSupport::KeyGenerator.new(secret_key_base)
60+
end
4661
end
4762

4863
def message_encryptor

app/helpers/blacklight/blacklight_helper_behavior.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ def document_has_value? document, field_config
116116
# @param [Blacklight::Solr::Response] response
117117
# @return [Boolean]
118118
def should_show_spellcheck_suggestions? response
119-
response.total <= spell_check_max and response.spelling.words.any?
119+
response.total <= spell_check_max &&
120+
!response.spelling.nil? &&
121+
response.spelling.words.any?
120122
end
121123

122124
##

app/helpers/blacklight/component_helper_behavior.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ def document_action_path action_opts, url_opts = nil
1818
##
1919
# Render "document actions" area for navigation header
2020
# (normally renders "Saved Searches", "History", "Bookmarks")
21+
# These things are added by add_nav_action and the default config is
22+
# provided by DefaultComponentConfiguration
2123
#
2224
# @param [Hash] options
2325
# @return [String]

app/models/concerns/blacklight/document/active_model_shim.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ module ActiveModelShim
88
include ::ActiveModel::Conversion
99

1010
module ClassMethods
11+
# This is actually an ActiveRecord method starting in Rails 5.2
12+
def polymorphic_name
13+
base_class.name
14+
end
15+
1116
def primary_key
1217
unique_key
1318
end

app/views/catalog/_facet_layout.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="panel panel-default facet_limit blacklight-<%= facet_field.key.parameterize %> <%= 'facet_limit-active' if facet_field_in_params?(facet_field.key) %>">
22
<div class="<%= "collapsed" if should_collapse_facet?(facet_field) %> collapse-toggle panel-heading" data-toggle="collapse" data-target="#<%= facet_field_id(facet_field) %>">
33
<h3 class="panel-title facet-field-heading">
4-
<%= link_to facet_field_label(facet_field.key), "#", :"data-no-turbolink" => true %>
4+
<%= link_to facet_field_label(facet_field.key), "#", :"data-turbolinks" => false, :"data-no-turbolink" => true %>
55
</h3>
66
</div>
77
<div id="<%= facet_field_id(facet_field) %>" class="panel-collapse facet-content <%= should_collapse_facet?(facet_field) ? 'collapse' : 'in' %>">

lib/blacklight/configuration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def default_values
3939
##
4040
# === Single document request configuration
4141
##
42-
# The solr rqeuest handler to use when requesting only a single document
42+
# The solr request handler to use when requesting only a single document
4343
document_solr_request_handler: 'document',
4444
# THe path to send single document requests to solr
4545
document_solr_path: nil,

lib/generators/blacklight/assets_generator.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ def assets
99
return if has_blacklight_assets?
1010

1111
contents = "\n//\n// Required by Blacklight\n"
12-
contents += "//= require jquery\n" if rails_5_1?
12+
contents += "//= require jquery\n" if needs_jquery?
1313
contents += "//= require blacklight/blacklight\n"
1414

1515
marker = if turbolinks?
1616
'//= require turbolinks'
17-
elsif rails_5_1?
17+
elsif needs_jquery?
1818
'//= require rails-ujs'
1919
else
2020
'//= require jquery_ujs'
@@ -27,13 +27,13 @@ def assets
2727

2828
# This is not a default in Rails 5.1
2929
def add_jquery
30-
gem 'jquery-rails' if rails_5_1?
30+
gem 'jquery-rails' if needs_jquery?
3131
end
3232

3333
private
3434

35-
def rails_5_1?
36-
Rails.version =~ /5\.1/
35+
def needs_jquery?
36+
Rails.version >= '5.1'
3737
end
3838

3939
def turbolinks?

spec/features/facets_spec.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,19 @@
5050
expect(page).to have_selector '.facet-values li:first', text: "Japanese drama"
5151
expect(page).to have_css '.facet-values li', count: 20
5252
end
53-
53+
54+
it 'is able to expand facets when javascript is enabled', js: true do
55+
visit root_path
56+
57+
expect(page).to have_css('#facet-format', visible: false)
58+
59+
page.find('h3.facet-field-heading a', text: 'Format').click
60+
61+
sleep(1) # let facet animation finish and wait for it to potentially re-collapse
62+
63+
expect(page).to have_css('#facet-format', visible: true) # assert that it didn't re-collapse
64+
end
65+
5466
describe '"More" links' do
5567
it 'has default more link with sr-only text' do
5668
visit root_path

0 commit comments

Comments
 (0)