Skip to content

Commit

Permalink
Merge 0b5db45 into e7764c1
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Dec 13, 2018
2 parents e7764c1 + 0b5db45 commit fbff315
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 28 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ notifications:
email: false

rvm:
- 2.3.1
- 2.3.8

matrix:
include:
- rvm: 2.5.3
env: "RAILS_VERSION=5.2.2"
- rvm: 2.2.5
env: "RAILS_VERSION=4.1.13"
- rvm: 2.1.5
Expand Down
2 changes: 1 addition & 1 deletion blacklight.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

s.add_dependency "rails", ">= 3.2.6", "< 5"
s.add_dependency "rails", ">= 3.2.6", "< 6"
s.add_dependency "nokogiri", "~>1.6" # XML Parser
s.add_dependency "kaminari", ">= 0.15" # the pagination (page 1,2,3, etc..) of our search results
s.add_dependency "rsolr", "~> 1.0", ">= 1.0.11" # Library for interacting with rSolr.
Expand Down
8 changes: 7 additions & 1 deletion db/migrate/20140202020201_create_searches.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# -*- encoding : utf-8 -*-
class CreateSearches < ActiveRecord::Migration
from = if Rails.version > '5'
ActiveRecord::Migration[5.0]
else
ActiveRecord::Migration
end

class CreateSearches < from
def self.up
create_table :searches do |t|
t.text :query_params
Expand Down
11 changes: 9 additions & 2 deletions db/migrate/20140202020202_create_bookmarks.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# -*- encoding : utf-8 -*-
class CreateBookmarks < ActiveRecord::Migration

from = if Rails.version > '5'
ActiveRecord::Migration[5.0]
else
ActiveRecord::Migration
end

class CreateBookmarks < from
def self.up
create_table :bookmarks do |t|
t.integer :user_id, :null=>false
Expand All @@ -13,5 +20,5 @@ def self.up
def self.down
drop_table :bookmarks
end

end
11 changes: 9 additions & 2 deletions db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# -*- encoding : utf-8 -*-
class AddPolymorphicTypeToBookmarks < ActiveRecord::Migration

from = if Rails.version > '5'
ActiveRecord::Migration[5.0]
else
ActiveRecord::Migration
end

class AddPolymorphicTypeToBookmarks < from
def change
add_column(:bookmarks, :document_type, :string)

add_index :bookmarks, :user_id
end
end
19 changes: 12 additions & 7 deletions lib/blacklight.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ class SolrRepository < Solr::Repository
def initialize blacklight_config
Deprecation.warn(self, 'Blacklight::SolrRepository is deprecated; use Blacklight::Solr::Repository instead')
super
end
end
end

class SolrResponse < Solr::Response
extend Deprecation
def initialize(data, request_params, options = {})
Deprecation.warn(self, 'Blacklight::SolrResponse is deprecated; use Blacklight::Solr::Response instead')
super
end
end
end

# Secret key used to share session information with
Expand Down Expand Up @@ -144,7 +144,7 @@ def self.solr_yml

return @solr_yml if @solr_yml
unless File.exists?(solr_file)
raise "You are missing a solr configuration file: #{solr_file}. Have you run \"rails generate blacklight:install\"?"
raise "You are missing a solr configuration file: #{solr_file}. Have you run \"rails generate blacklight:install\"?"
end

begin
Expand Down Expand Up @@ -176,17 +176,22 @@ def self.logger= logger
@logger = logger
end

#############
#############
# Methods for figuring out path to BL plugin, and then locate various files
# either in the app itself or defaults in the plugin -- whether you are running
# from the plugin itself or from an actual app using te plugin.
# In a seperate module so it can be used by both Blacklight class, and
# by rake tasks without loading the whole Rails environment.
# by rake tasks without loading the whole Rails environment.
#############

# returns the full path the the blacklight plugin installation
def self.root
@root ||= File.expand_path(File.dirname(File.dirname(__FILE__)))
end


end

# Backport for Rails 4:
if Rails.version < '5'
ActiveSupport::HashWithIndifferentAccess = HashWithIndifferentAccess
end
2 changes: 1 addition & 1 deletion lib/blacklight/solr/request.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Blacklight::Solr::InvalidParameter < ArgumentError; end

class Blacklight::Solr::Request < HashWithIndifferentAccess
class Blacklight::Solr::Request < ActiveSupport::HashWithIndifferentAccess

SINGULAR_KEYS = %w{facet fl q qt rows start spellcheck spellcheck.q sort per_page wt hl group defType}
ARRAY_KEYS = %w{facet.field facet.query facet.pivot fq hl.fl}
Expand Down
4 changes: 2 additions & 2 deletions lib/blacklight/solr/response.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Blacklight::Solr::Response < HashWithIndifferentAccess
class Blacklight::Solr::Response < ActiveSupport::HashWithIndifferentAccess
extend Deprecation

require 'blacklight/solr/response/pagination_methods'
Expand Down Expand Up @@ -89,7 +89,7 @@ def force_to_utf8(value)
when Array
value.each { |v| force_to_utf8(v) }
when String
value.force_encoding("utf-8") if value.respond_to?(:force_encoding)
value.force_encoding("utf-8") if value.respond_to?(:force_encoding)
end
value
end
Expand Down
10 changes: 4 additions & 6 deletions lib/generators/blacklight/test_support_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@


# Need the requires here so we can call the generator from environment.rb
# as suggested above.
# as suggested above.
require 'rails/generators'
require 'rails/generators/base'
module Blacklight
class TestSupport < Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__)
desc """
Generate blacklight testing configurations for blacklight's own tests, or for blacklight plugins to use for testing
desc """
Generate blacklight testing configurations for blacklight's own tests, or for blacklight plugins to use for testing
"""
def alternate_controller
copy_file "alternate_controller.rb", "app/controllers/alternate_controller.rb"
Expand All @@ -19,9 +19,7 @@ def alternate_controller
member do
get :facet
end
end")


end\n") # the trailing CR is important (in Rails 5) so that any other additional routes get added on the next line.
end

def configure_action_mailer
Expand Down
10 changes: 5 additions & 5 deletions spec/models/blacklight/solr/repository_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
allow(subject.connection).to receive(:send_and_receive).with('select', hash_including(params: { id: '123', qt: 'abc'})).and_return(mock_response)
expect(subject.find("123", {qt: 'abc'})).to be_a_kind_of Blacklight::Solr::Response
end

it "should use the :qt parameter from the default_document_solr_params" do
blacklight_config.default_document_solr_params[:qt] = 'abc'
blacklight_config.document_solr_request_handler = 'xyz'
Expand All @@ -51,11 +51,11 @@
end

it "should preserve the class of the incoming params" do
doc_params = HashWithIndifferentAccess.new
doc_params = ActiveSupport::HashWithIndifferentAccess.new
allow(subject.connection).to receive(:send_and_receive).with('select', anything).and_return(mock_response)
response = subject.find("123", doc_params)
expect(response).to be_a_kind_of Blacklight::Solr::Response
expect(response.params).to be_a_kind_of HashWithIndifferentAccess
expect(response.params).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess
end
end

Expand All @@ -82,12 +82,12 @@
allow(subject.connection).to receive(:send_and_receive).with('select', hash_including(params: { qt: 'abc'})).and_return(mock_response)
expect(subject.search({qt: 'abc'})).to be_a_kind_of Blacklight::Solr::Response
end

it "should preserve the class of the incoming params" do
search_params = HashWithIndifferentAccess.new
search_params[:q] = "query"
allow(subject.connection).to receive(:send_and_receive).with('select', anything).and_return(mock_response)

response = subject.search(search_params)
expect(response).to be_a_kind_of Blacklight::Solr::Response
expect(response.params).to be_a_kind_of HashWithIndifferentAccess
Expand Down

0 comments on commit fbff315

Please sign in to comment.