diff --git a/.travis.yml b/.travis.yml index 4c6405992a..8fd00a76b1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,16 +5,16 @@ notifications: email: false rvm: - - 2.3.1 + - 2.4.1 matrix: include: - - rvm: 2.3.3 - env: "RAILS_VERSION=4.2.8" - - rvm: 2.2.6 - env: "RAILS_VERSION=5.0.2" + - rvm: 2.2.7 + env: "RAILS_VERSION=5.0.3" + - rvm: 2.3.4 + env: "RAILS_VERSION=5.1.1" - rvm: jruby-9.1.7.0 - env: "RAILS_VERSION=5.0.2 JRUBY_OPTS=\"-J-Xms512m -J-Xmx1024m\"" + env: "RAILS_VERSION=5.0.3 JRUBY_OPTS=\"-J-Xms512m -J-Xmx1024m\"" allow_failures: - rvm: jruby-9.1.7.0 fast_finish: true @@ -24,7 +24,7 @@ before_install: - gem install bundler env: - - "RAILS_VERSION=5.0.2" + - "RAILS_VERSION=5.1.1" notifications: irc: "irc.freenode.org#blacklight" diff --git a/db/migrate/20140202020201_create_searches.rb b/db/migrate/20140202020201_create_searches.rb index e581ead787..1813fc7c15 100644 --- a/db/migrate/20140202020201_create_searches.rb +++ b/db/migrate/20140202020201_create_searches.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -class CreateSearches < ActiveRecord::Migration +class CreateSearches < ActiveRecord::Migration[4.2] def self.up create_table :searches do |t| t.binary :query_params diff --git a/db/migrate/20140202020202_create_bookmarks.rb b/db/migrate/20140202020202_create_bookmarks.rb index af1d6db290..7899d97419 100644 --- a/db/migrate/20140202020202_create_bookmarks.rb +++ b/db/migrate/20140202020202_create_bookmarks.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -class CreateBookmarks < ActiveRecord::Migration +class CreateBookmarks < ActiveRecord::Migration[4.2] def self.up create_table :bookmarks do |t| t.integer :user_id, index: true, null: false diff --git a/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb b/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb index d70620e950..4962c10de2 100644 --- a/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +++ b/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -class AddPolymorphicTypeToBookmarks < ActiveRecord::Migration +class AddPolymorphicTypeToBookmarks < ActiveRecord::Migration[4.2] def change add_column(:bookmarks, :document_type, :string) unless Bookmark.connection.column_exists? :bookmarks, :document_type diff --git a/lib/generators/blacklight/assets_generator.rb b/lib/generators/blacklight/assets_generator.rb index d4ccbb0c19..4223eb0a07 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 e70181eb9b..b6bc6207de 100644 --- a/lib/generators/blacklight/user_generator.rb +++ b/lib/generators/blacklight/user_generator.rb @@ -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" diff --git a/spec/helpers/catalog_helper_spec.rb b/spec/helpers/catalog_helper_spec.rb index 37fefed6a3..96398c6967 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, controller) } - 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, controller) } - 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/helpers/url_helper_spec.rb b/spec/helpers/url_helper_spec.rb index 003949f981..617fdc3ba4 100644 --- a/spec/helpers/url_helper_spec.rb +++ b/spec/helpers/url_helper_spec.rb @@ -127,14 +127,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/views/catalog/_facets.html.erb_spec.rb b/spec/views/catalog/_facets.html.erb_spec.rb index 0f4dbb18c8..73bcccc2eb 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