diff --git a/.travis.yml b/.travis.yml index a1a706a57f..8a4e05c3d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ rvm: matrix: include: - rvm: 2.3.3 - env: "RAILS_VERSION=5.0.2" + env: "RAILS_VERSION=5.1.0" - rvm: jruby-9.1.7.0 env: "RAILS_VERSION=5.0.2 JRUBY_OPTS=\"-J-Xms512m -J-Xmx1024m\"" allow_failures: diff --git a/app/assets/javascripts/blacklight/blacklight.js b/app/assets/javascripts/blacklight/blacklight.js index 02475dbb6e..86db03cde4 100644 --- a/app/assets/javascripts/blacklight/blacklight.js +++ b/app/assets/javascripts/blacklight/blacklight.js @@ -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 diff --git a/lib/generators/blacklight/assets_generator.rb b/lib/generators/blacklight/assets_generator.rb index 1733003b14..29fa469423 100644 --- a/lib/generators/blacklight/assets_generator.rb +++ b/lib/generators/blacklight/assets_generator.rb @@ -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 diff --git a/lib/generators/blacklight/templates/alternate_controller.rb b/lib/generators/blacklight/templates/alternate_controller.rb index b2819d6334..91891b6dd5 100644 --- a/lib/generators/blacklight/templates/alternate_controller.rb +++ b/lib/generators/blacklight/templates/alternate_controller.rb @@ -5,7 +5,7 @@ class AlternateController < CatalogController end def xyz *args - view_context.image_tag "asdfg" + view_context.tag "img" end helper_method :xyz diff --git a/lib/generators/blacklight/user_generator.rb b/lib/generators/blacklight/user_generator.rb index b77288d33c..b7dc84ce6f 100644 --- a/lib/generators/blacklight/user_generator.rb +++ b/lib/generators/blacklight/user_generator.rb @@ -19,8 +19,15 @@ class UserGenerator < Rails::Generators::Base def generate_devise_assets return unless options[:devise] - gem "devise" - gem "devise-guests", "~> 0.5" + if Rails.version < '5.1' + gem "devise" + else + # This is temporary until a new version of devise and responders are released + gem "devise", github: 'jcoyne/devise', branch: 'rails-5.1' + gem "responders", github: 'plataformatec/responders' + end + + gem "devise-guests", "~> 0.6" Bundler.with_clean_env do run "bundle install" diff --git a/spec/helpers/blacklight/url_helper_behavior_spec.rb b/spec/helpers/blacklight/url_helper_behavior_spec.rb index 4f4120103a..baee9ebf16 100644 --- a/spec/helpers/blacklight/url_helper_behavior_spec.rb +++ b/spec/helpers/blacklight/url_helper_behavior_spec.rb @@ -123,14 +123,18 @@ context "when an alternate scope is passed in" do let(:my_engine) { double("Engine") } + subject(:tag) { helper.link_back_to_catalog(route_set: my_engine) } - it "calls url_for on the engine scope" do + before do allow(helper).to receive(:current_search_session).and_return double(:query_params => query_params) - expect(my_engine).to receive(:url_for).and_return(url_for(query_params)) - tag = helper.link_back_to_catalog(route_set: my_engine) + end + + it "calls url_for on the engine scope" do + expect(my_engine).to receive(:url_for) + .with(q:"query", f: "facets", controller: "catalog") + .and_return('link-url') expect(tag).to match /Back to Search/ - expect(tag).to match /q=query/ - expect(tag).to match /f=facets/ + expect(tag).to match /link-url/ end end end diff --git a/spec/helpers/catalog_helper_spec.rb b/spec/helpers/catalog_helper_spec.rb index 4c2b3c279f..e2f7e8b6b5 100644 --- a/spec/helpers/catalog_helper_spec.rb +++ b/spec/helpers/catalog_helper_spec.rb @@ -131,15 +131,19 @@ def render_grouped_response? describe "rss_feed_link_tag" do context "when an alternate scope is passed in" do + subject(:tag) { helper.rss_feed_link_tag(route_set: my_engine) } + let(:my_engine) { double("Engine") } let(:query_params) { { controller: 'catalog', action: 'index' } } let(:config) { Blacklight::Configuration.new } let(:search_state) { Blacklight::SearchState.new(query_params, config) } - it "calls url_for on the engine scope" do + before do allow(helper).to receive(:search_state).and_return search_state - expect(my_engine).to receive(:url_for).and_return(url_for(query_params)) - tag = helper.rss_feed_link_tag(route_set: my_engine) + end + + it "calls url_for on the engine scope" do + expect(my_engine).to receive(:url_for).and_return('/rss-path') expect(tag).to match /title="RSS for results"/ expect(tag).to match /rel="alternate"/ expect(tag).to match %r{type="application/rss\+xml"} @@ -149,15 +153,19 @@ def render_grouped_response? describe "atom_feed_link_tag" do context "when an alternate scope is passed in" do + subject(:tag) { helper.atom_feed_link_tag(route_set: my_engine) } + let(:my_engine) { double("Engine") } let(:query_params) { { controller: 'catalog', action: 'index' } } let(:config) { Blacklight::Configuration.new } let(:search_state) { Blacklight::SearchState.new(query_params, config) } - it "calls url_for on the engine scope" do + before do allow(helper).to receive(:search_state).and_return search_state - expect(my_engine).to receive(:url_for).and_return(url_for(query_params)) - tag = helper.atom_feed_link_tag(route_set: my_engine) + end + + it "calls url_for on the engine scope" do + expect(my_engine).to receive(:url_for).and_return('/atom-path') expect(tag).to match /title="Atom for results"/ expect(tag).to match /rel="alternate"/ expect(tag).to match %r{type="application/atom\+xml"} diff --git a/spec/views/catalog/_facets.html.erb_spec.rb b/spec/views/catalog/_facets.html.erb_spec.rb index d1c65a8c3c..2472ff25bc 100644 --- a/spec/views/catalog/_facets.html.erb_spec.rb +++ b/spec/views/catalog/_facets.html.erb_spec.rb @@ -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