Skip to content

Commit

Permalink
Add Rails 5.2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Apr 25, 2017
1 parent 38d454a commit acb2e3e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/assets/javascripts/blacklight/blacklight.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// which over-rides things in this JS file, as described below.
//
// These javascript files are compiled in via the Rails asset pipeline:
//= require jquery
//= require blacklight/core
//= require blacklight/autofocus
//= require blacklight/bookmark_toggle
Expand Down
21 changes: 16 additions & 5 deletions lib/generators/blacklight/assets_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,34 @@ def assets

return if has_blacklight_assets?

contents = "\n//\n// Required by Blacklight\n"
contents += "//= require jquery\n" if rails_5_1?
contents += "//= require blacklight/blacklight\n"

marker = if turbolinks?
'//= require turbolinks'
elsif rails_5_1?
'//= require rails-ujs'
else
'//= require jquery_ujs'
end

insert_into_file "app/assets/javascripts/application.js", :after => marker do
<<-EOF
//
// Required by Blacklight
//= require blacklight/blacklight
EOF
contents
end
end

# This is not a default in Rails 5.1
def add_jquery
gem 'jquery-rails' if rails_5_1?
end

private

def rails_5_1?
Rails.version =~ /5\.1/
end

def turbolinks?
@turbolinks ||= IO.read("app/assets/javascripts/application.js").include?('turbolinks')
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class AlternateController < CatalogController
end

def xyz *args
view_context.image_tag "asdfg"
view_context.tag "img"
end

helper_method :xyz
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/blacklight/user_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def generate_devise_assets
return unless options[:devise]

gem "devise"
gem "devise-guests", "~> 0.5"
gem "devise-guests", "~> 0.6"

Bundler.with_clean_env do
run "bundle install"
Expand Down
2 changes: 1 addition & 1 deletion spec/views/catalog/_facets.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
before do
allow(view).to receive_messages(blacklight_config: blacklight_config)
allow(view).to receive(:search_action_path) do |*args|
search_catalog_url *args
'/catalog'
end
end

Expand Down

0 comments on commit acb2e3e

Please sign in to comment.