blacklight 5.15.0 → 5.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/Gemfile +17 -8
- data/VERSION +1 -1
- data/{lib → app/controllers/concerns}/blacklight/base.rb +1 -1
- data/{lib → app/controllers/concerns}/blacklight/bookmarks.rb +0 -0
- data/{lib → app/controllers/concerns}/blacklight/catalog.rb +6 -7
- data/{lib → app/controllers/concerns}/blacklight/controller.rb +6 -0
- data/{lib/blacklight/catalog/component_configuration.rb → app/controllers/concerns/blacklight/default_component_configuration.rb} +5 -2
- data/{lib → app/controllers/concerns}/blacklight/facet.rb +0 -0
- data/{lib → app/controllers/concerns}/blacklight/request_builders.rb +0 -0
- data/{lib/blacklight/catalog → app/controllers/concerns/blacklight}/search_context.rb +1 -2
- data/{lib → app/controllers/concerns}/blacklight/search_fields.rb +0 -6
- data/{lib → app/controllers/concerns}/blacklight/search_helper.rb +4 -4
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/catalog_helper_behavior.rb +3 -3
- data/app/helpers/blacklight/facets_helper_behavior.rb +4 -5
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -1
- data/{lib → app/models}/blacklight/abstract_repository.rb +0 -0
- data/{lib → app/models}/blacklight/configuration.rb +2 -2
- data/{lib → app/models}/blacklight/configuration/facet_field.rb +0 -0
- data/{lib → app/models}/blacklight/configuration/field.rb +0 -0
- data/{lib → app/models}/blacklight/configuration/fields.rb +1 -1
- data/{lib → app/models}/blacklight/configuration/search_field.rb +0 -0
- data/{lib → app/models}/blacklight/configuration/solr_field.rb +0 -0
- data/{lib → app/models}/blacklight/configuration/sort_field.rb +0 -0
- data/{lib → app/models}/blacklight/configuration/tool_config.rb +0 -0
- data/{lib → app/models}/blacklight/configuration/view_config.rb +0 -0
- data/{lib → app/models}/blacklight/facet_paginator.rb +0 -0
- data/{lib → app/models}/blacklight/search_builder.rb +1 -1
- data/{lib → app/models}/blacklight/solr/facet_paginator.rb +0 -0
- data/{lib/blacklight/solr_repository.rb → app/models/blacklight/solr/repository.rb} +3 -3
- data/{lib → app/models}/blacklight/solr/request.rb +0 -0
- data/{lib/blacklight/solr_response.rb → app/models/blacklight/solr/response.rb} +8 -8
- data/{lib/blacklight/solr_response → app/models/blacklight/solr/response}/facets.rb +8 -8
- data/{lib/blacklight/solr_response → app/models/blacklight/solr/response}/group.rb +2 -2
- data/{lib/blacklight/solr_response → app/models/blacklight/solr/response}/group_response.rb +3 -3
- data/{lib/blacklight/solr_response → app/models/blacklight/solr/response}/more_like_this.rb +1 -1
- data/{lib/blacklight/solr_response → app/models/blacklight/solr/response}/pagination_methods.rb +1 -1
- data/{lib/blacklight/solr_response → app/models/blacklight/solr/response}/response.rb +1 -1
- data/{lib/blacklight/solr_response → app/models/blacklight/solr/response}/spelling.rb +1 -1
- data/{lib → app/models}/blacklight/solr/search_builder.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/configurable.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/document.rb +7 -10
- data/{lib → app/models/concerns}/blacklight/document/active_model_shim.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/document/cache_key.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/document/dublin_core.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/document/email.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/document/export.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/document/extensions.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/document/schema_org.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/document/semantic_fields.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/document/sms.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/solr/document.rb +3 -8
- data/{lib → app/models/concerns}/blacklight/solr/document/dublin_core.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/solr/document/email.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/solr/document/export.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/solr/document/extensions.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/solr/document/more_like_this.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/solr/document/schema_org.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/solr/document/sms.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/solr/search_builder_behavior.rb +6 -1
- data/{lib → app/models/concerns}/blacklight/token_based_user.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/user.rb +0 -0
- data/{lib → app/presenters}/blacklight/document_presenter.rb +0 -0
- data/app/views/catalog/_paginate_compact.html.erb +1 -1
- data/blacklight.gemspec +1 -1
- data/lib/blacklight.rb +7 -32
- data/lib/blacklight/engine.rb +6 -0
- data/lib/blacklight/solr.rb +5 -7
- data/lib/railties/blacklight.rake +3 -1
- data/spec/{lib → controllers}/blacklight/catalog/component_configuration_spec.rb +7 -2
- data/spec/{lib → controllers}/blacklight/facet_spec.rb +0 -0
- data/spec/{lib → controllers}/blacklight/search_fields_spec.rb +2 -2
- data/spec/{lib → controllers}/blacklight/search_helper_spec.rb +3 -3
- data/spec/controllers/catalog_controller_spec.rb +34 -32
- data/spec/controllers/saved_searches_controller_spec.rb +1 -1
- data/spec/helpers/facets_helper_spec.rb +2 -2
- data/spec/helpers/search_history_constraints_helper_spec.rb +23 -3
- data/spec/lib/{utils_spec.rb → blacklight/utils_spec.rb} +0 -0
- data/spec/lib/blacklight_spec.rb +0 -1
- data/spec/{lib → models}/blacklight/configurable_spec.rb +0 -0
- data/spec/{lib → models}/blacklight/configuration_spec.rb +1 -1
- data/spec/{lib → models}/blacklight/document/cache_key_spec.rb +0 -0
- data/spec/{lib → models}/blacklight/document/dublin_core_spec.rb +0 -0
- data/spec/{lib → models}/blacklight/document/email_spec.rb +0 -0
- data/spec/{lib → models}/blacklight/document/sms_spec.rb +0 -0
- data/spec/{lib → models}/blacklight/document_spec.rb +0 -0
- data/spec/{lib → models}/blacklight/facet_paginator_spec.rb +7 -7
- data/spec/{lib → models}/blacklight/search_builder_spec.rb +0 -0
- data/spec/{lib → models}/blacklight/solr/document/more_like_this_spec.rb +0 -0
- data/spec/{lib → models}/blacklight/solr/document_spec.rb +0 -0
- data/spec/{lib → models}/blacklight/solr/facet_paginator_spec.rb +1 -1
- data/spec/{lib/blacklight/solr_repository_spec.rb → models/blacklight/solr/repository_spec.rb} +13 -13
- data/spec/{lib → models}/blacklight/solr/request_spec.rb +0 -0
- data/spec/{lib/blacklight/solr_response → models/blacklight/solr/response}/facets_spec.rb +12 -12
- data/spec/{lib/blacklight/solr_response → models/blacklight/solr/response}/group_response_spec.rb +3 -3
- data/spec/{lib/blacklight/solr_response → models/blacklight/solr/response}/group_spec.rb +2 -2
- data/spec/{lib/blacklight/solr_response_spec.rb → models/blacklight/solr/response_spec.rb} +21 -21
- data/spec/{lib → models}/blacklight/solr/search_builder_spec.rb +0 -0
- data/spec/{lib → models}/blacklight/user_spec.rb +0 -0
- data/spec/{lib → presenters}/document_presenter_spec.rb +0 -0
- data/spec/views/catalog/_facets.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_index_default.erb_spec.rb +10 -10
- data/spec/views/catalog/_show_default.erb_spec.rb +10 -10
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +2 -2
- data/spec/views/catalog/index.atom.builder_spec.rb +30 -33
- metadata +116 -118
- data/spec/support/include_text.rb +0 -20
@@ -1,6 +1,6 @@
|
|
1
|
-
class Blacklight::
|
1
|
+
class Blacklight::Solr::Response::GroupResponse
|
2
2
|
|
3
|
-
include Blacklight::
|
3
|
+
include Blacklight::Solr::Response::PaginationMethods
|
4
4
|
|
5
5
|
attr_reader :key, :group, :response
|
6
6
|
|
@@ -14,7 +14,7 @@ class Blacklight::SolrResponse::GroupResponse
|
|
14
14
|
|
15
15
|
def groups
|
16
16
|
@groups ||= group["groups"].map do |g|
|
17
|
-
Blacklight::
|
17
|
+
Blacklight::Solr::Response::Group.new g[:groupValue], g, self
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
File without changes
|
File without changes
|
@@ -13,17 +13,14 @@
|
|
13
13
|
# transformation formats.
|
14
14
|
#
|
15
15
|
module Blacklight::Document
|
16
|
-
autoload :ActiveModelShim, 'blacklight/document/active_model_shim'
|
17
|
-
autoload :SchemaOrg, 'blacklight/document/schema_org'
|
18
|
-
autoload :CacheKey, 'blacklight/document/cache_key'
|
19
|
-
autoload :DublinCore, 'blacklight/document/dublin_core'
|
20
|
-
autoload :Email, 'blacklight/document/email'
|
21
|
-
autoload :SemanticFields, 'blacklight/document/semantic_fields'
|
22
|
-
autoload :Sms, 'blacklight/document/sms'
|
23
|
-
autoload :Extensions, 'blacklight/document/extensions'
|
24
|
-
autoload :Export, 'blacklight/document/export'
|
25
|
-
|
26
16
|
extend ActiveSupport::Concern
|
17
|
+
|
18
|
+
require_relative 'document/active_model_shim'
|
19
|
+
require_relative 'document/schema_org'
|
20
|
+
require_relative 'document/semantic_fields'
|
21
|
+
require_relative 'document/cache_key'
|
22
|
+
require_relative 'document/export'
|
23
|
+
|
27
24
|
include Blacklight::Document::SchemaOrg
|
28
25
|
include Blacklight::Document::SemanticFields
|
29
26
|
include Blacklight::Document::CacheKey
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -16,19 +16,14 @@ require 'rsolr'
|
|
16
16
|
#
|
17
17
|
|
18
18
|
module Blacklight::Solr::Document
|
19
|
-
autoload :SchemaOrg, 'blacklight/solr/document/schema_org'
|
20
|
-
autoload :DublinCore, 'blacklight/solr/document/dublin_core'
|
21
|
-
autoload :Email, 'blacklight/solr/document/email'
|
22
|
-
autoload :Sms, 'blacklight/solr/document/sms'
|
23
|
-
autoload :Extensions, 'blacklight/solr/document/extensions'
|
24
|
-
autoload :Export, 'blacklight/solr/document/export'
|
25
|
-
autoload :MoreLikeThis, 'blacklight/solr/document/more_like_this'
|
26
|
-
|
27
19
|
extend ActiveSupport::Concern
|
28
20
|
include Blacklight::Document
|
21
|
+
require_relative 'document/more_like_this'
|
22
|
+
|
29
23
|
include Blacklight::Document::ActiveModelShim
|
30
24
|
include Blacklight::Solr::Document::MoreLikeThis
|
31
25
|
|
26
|
+
|
32
27
|
def has_highlight_field? k
|
33
28
|
return false if response['highlighting'].blank? or response['highlighting'][self.id].blank?
|
34
29
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -282,7 +282,12 @@ module Blacklight::Solr
|
|
282
282
|
|
283
283
|
case
|
284
284
|
when (facet_config and facet_config.query)
|
285
|
-
facet_config.query[value]
|
285
|
+
if facet_config.query[value]
|
286
|
+
facet_config.query[value][:fq]
|
287
|
+
else
|
288
|
+
# exclude all documents if the custom facet key specified was not found
|
289
|
+
'-*:*'
|
290
|
+
end
|
286
291
|
when (facet_config and facet_config.date)
|
287
292
|
# in solr 3.2+, this could be replaced by a !term query
|
288
293
|
"#{prefix}#{solr_field}:#{RSolr.solr_escape(value)}"
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%# Call with a Blacklight::
|
1
|
+
<%# Call with a Blacklight::Solr::Response or any other kaminari-compatible collection
|
2
2
|
to render Blacklight's compact pagination info component:
|
3
3
|
|
4
4
|
<%= render :partial => "paginate_compact", :object => @response
|
data/blacklight.gemspec
CHANGED
@@ -31,6 +31,6 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.add_development_dependency "rspec-collection_matchers", ">= 1.0"
|
32
32
|
s.add_development_dependency "capybara"
|
33
33
|
s.add_development_dependency "poltergeist"
|
34
|
-
s.add_development_dependency 'engine_cart',
|
34
|
+
s.add_development_dependency 'engine_cart', '~> 0.8.0'
|
35
35
|
s.add_development_dependency "equivalent-xml"
|
36
36
|
end
|
data/lib/blacklight.rb
CHANGED
@@ -4,44 +4,19 @@ require 'deprecation'
|
|
4
4
|
require 'blacklight/utils'
|
5
5
|
|
6
6
|
module Blacklight
|
7
|
-
autoload :Configurable, 'blacklight/configurable'
|
8
|
-
autoload :Configuration, 'blacklight/configuration'
|
9
|
-
autoload :SearchFields, 'blacklight/search_fields'
|
10
|
-
autoload :SearchBuilder, 'blacklight/search_builder'
|
11
|
-
autoload :SearchBuilderBehavior, 'blacklight/search_builder_behavior'
|
12
|
-
|
13
|
-
autoload :Document, 'blacklight/document'
|
14
|
-
autoload :Solr, 'blacklight/solr'
|
15
|
-
|
16
|
-
autoload :SearchHelper, 'blacklight/search_helper'
|
17
|
-
autoload :SolrHelper, 'blacklight/solr_helper'
|
18
|
-
autoload :AbstractRepository, 'blacklight/abstract_repository'
|
19
|
-
autoload :SolrRepository, 'blacklight/solr_repository'
|
20
|
-
autoload :RequestBuilders, 'blacklight/request_builders'
|
21
|
-
|
22
7
|
autoload :Exceptions, 'blacklight/exceptions'
|
23
|
-
|
24
|
-
autoload :User, 'blacklight/user'
|
25
|
-
|
26
|
-
autoload :Controller, 'blacklight/controller'
|
27
|
-
autoload :Base, 'blacklight/base'
|
28
|
-
autoload :Catalog, 'blacklight/catalog'
|
29
|
-
autoload :TokenBasedUser, 'blacklight/token_based_user'
|
30
|
-
autoload :Bookmarks, 'blacklight/bookmarks'
|
31
|
-
autoload :DocumentPresenter, 'blacklight/document_presenter'
|
32
|
-
|
33
8
|
autoload :Routes, 'blacklight/routes'
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
9
|
+
autoload :Solr, 'blacklight/solr'
|
10
|
+
|
11
|
+
SolrRepository = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('Blacklight::SolrRepository', 'Blacklight::Solr::Repository')
|
12
|
+
SolrResponse = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('Blacklight::SolrResponse', 'Blacklight::Solr::Response')
|
13
|
+
autoload :SolrHelper, 'blacklight/solr_helper'
|
38
14
|
|
39
|
-
extend SearchFields
|
40
15
|
extend Deprecation
|
41
16
|
|
42
17
|
require 'blacklight/version'
|
43
18
|
require 'blacklight/engine' if defined?(Rails)
|
44
|
-
|
19
|
+
|
45
20
|
class << self
|
46
21
|
attr_accessor :solr, :solr_config
|
47
22
|
end
|
@@ -70,7 +45,7 @@ module Blacklight
|
|
70
45
|
end
|
71
46
|
|
72
47
|
def self.default_index
|
73
|
-
@default_index ||=
|
48
|
+
@default_index ||= Blacklight::Solr::Repository.new(Blacklight::Configuration.new)
|
74
49
|
end
|
75
50
|
|
76
51
|
def self.solr_config
|
data/lib/blacklight/engine.rb
CHANGED
@@ -11,6 +11,12 @@ module Blacklight
|
|
11
11
|
ActionView::Base.send :include, BlacklightHelper
|
12
12
|
end
|
13
13
|
|
14
|
+
config.autoload_paths += %W(
|
15
|
+
#{config.root}/app/presenters
|
16
|
+
#{config.root}/app/controllers/concerns
|
17
|
+
#{config.root}/app/models/concerns
|
18
|
+
)
|
19
|
+
|
14
20
|
# This makes our rake tasks visible.
|
15
21
|
rake_tasks do
|
16
22
|
Dir.chdir(File.expand_path(File.join(File.dirname(__FILE__), '..'))) do
|
data/lib/blacklight/solr.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
autoload :SearchBuilder, 'blacklight/solr/search_builder'
|
7
|
-
autoload :SearchBuilderBehavior, 'blacklight/solr/search_builder_behavior'
|
1
|
+
module Blacklight
|
2
|
+
module Solr
|
3
|
+
require File.join(Blacklight::Engine.config.root, 'app', 'models', 'concerns', 'blacklight', 'document')
|
4
|
+
require File.join(Blacklight::Engine.config.root, 'app', 'models', 'concerns', 'blacklight', 'solr', 'document')
|
5
|
+
end
|
8
6
|
end
|
@@ -12,7 +12,9 @@ namespace :blacklight do
|
|
12
12
|
|
13
13
|
namespace :index do
|
14
14
|
desc "Put sample data into solr"
|
15
|
-
task :seed do
|
15
|
+
task :seed => [:environment] do
|
16
|
+
require 'yaml'
|
17
|
+
|
16
18
|
docs = YAML::load(File.open(File.join(Blacklight.root, 'solr', 'sample_solr_documents.yml')))
|
17
19
|
conn = Blacklight.default_index.connection
|
18
20
|
conn.add docs
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Blacklight::
|
3
|
+
describe Blacklight::DefaultComponentConfiguration do
|
4
4
|
subject do
|
5
5
|
Class.new do
|
6
6
|
include Blacklight::Configurable
|
7
|
-
include Blacklight::
|
7
|
+
include Blacklight::DefaultComponentConfiguration
|
8
8
|
|
9
9
|
def some_existing_action
|
10
10
|
1
|
@@ -22,6 +22,11 @@ describe Blacklight::Catalog::ComponentConfiguration do
|
|
22
22
|
subject.add_show_tools_partial :some_existing_action
|
23
23
|
expect(subject.new.some_existing_action).to eq 1
|
24
24
|
end
|
25
|
+
|
26
|
+
it "should allow the configuration to opt out of creating a method" do
|
27
|
+
subject.add_show_tools_partial :some_missing_action, define_method: false
|
28
|
+
expect(subject.new).not_to respond_to :some_missing_action
|
29
|
+
end
|
25
30
|
end
|
26
31
|
|
27
32
|
|
File without changes
|
@@ -53,7 +53,7 @@ describe Blacklight::SearchFields do
|
|
53
53
|
expect { allow(@bad_config).to receive(:blacklight_config).and_return(Blacklight::Configuration.new { |config|
|
54
54
|
config.add_search_field :label => 'All Fields', :qt => 'all_fields'
|
55
55
|
config.add_search_field 'title', :qt => 'title_search'
|
56
|
-
}) }.to raise_error
|
56
|
+
}) }.to raise_error ArgumentError
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -66,7 +66,7 @@ describe Blacklight::SearchFields do
|
|
66
66
|
config.add_search_field 'my_key', :label => 'All Fields'
|
67
67
|
config.add_search_field 'my_key', :label => 'title'
|
68
68
|
|
69
|
-
}) }.to raise_error
|
69
|
+
}) }.to raise_error RuntimeError
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -24,7 +24,7 @@ describe Blacklight::SearchHelper do
|
|
24
24
|
|
25
25
|
def initialize blacklight_config, conn
|
26
26
|
self.blacklight_config = blacklight_config
|
27
|
-
self.repository = Blacklight::
|
27
|
+
self.repository = Blacklight::Solr::Repository.new(blacklight_config)
|
28
28
|
self.repository.connection = conn
|
29
29
|
end
|
30
30
|
|
@@ -163,7 +163,7 @@ describe Blacklight::SearchHelper do
|
|
163
163
|
end
|
164
164
|
|
165
165
|
it "should return a grouped response" do
|
166
|
-
expect(@solr_response).to be_a_kind_of Blacklight::
|
166
|
+
expect(@solr_response).to be_a_kind_of Blacklight::Solr::Response::GroupResponse
|
167
167
|
|
168
168
|
end
|
169
169
|
end
|
@@ -183,7 +183,7 @@ describe Blacklight::SearchHelper do
|
|
183
183
|
end
|
184
184
|
|
185
185
|
it "should return a grouped response" do
|
186
|
-
expect(@solr_response).to be_a_kind_of Blacklight::
|
186
|
+
expect(@solr_response).to be_a_kind_of Blacklight::Solr::Response::GroupResponse
|
187
187
|
expect(@solr_response.group_field).to eq "title_sort"
|
188
188
|
end
|
189
189
|
end
|
@@ -3,21 +3,6 @@ require 'spec_helper'
|
|
3
3
|
describe CatalogController do
|
4
4
|
|
5
5
|
describe "index action" do
|
6
|
-
|
7
|
-
# In Rails 3 ActionDispatch::TestProcess#assigns() converts anything that
|
8
|
-
# descends from Hash to a HashWithIndifferentAccess. Therefore our Solr
|
9
|
-
# response object gets replaced if we call assigns(:response)
|
10
|
-
# Fixed by https://github.com/rails/rails/commit/185c3dbc6ab845edfc94e8d38ef5be11c417dd81
|
11
|
-
if ::Rails.version < "4.0"
|
12
|
-
def assigns_response
|
13
|
-
controller.instance_variable_get("@response")
|
14
|
-
end
|
15
|
-
else
|
16
|
-
def assigns_response
|
17
|
-
assigns(:response)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
6
|
describe "with format :html" do
|
22
7
|
let(:user_query) { 'history' } # query that will get results
|
23
8
|
|
@@ -38,41 +23,53 @@ describe CatalogController do
|
|
38
23
|
# check each user manipulated parameter
|
39
24
|
it "should have docs and facets for query with results", :integration => true do
|
40
25
|
get :index, q: user_query
|
41
|
-
expect(
|
42
|
-
assert_facets_have_values(
|
26
|
+
expect(assigns(:response).docs).to_not be_empty
|
27
|
+
assert_facets_have_values(assigns(:response).aggregations)
|
43
28
|
end
|
44
29
|
it "should have docs and facets for existing facet value", :integration => true do
|
45
30
|
get :index, f: {"format" => 'Book'}
|
46
|
-
expect(
|
47
|
-
assert_facets_have_values(
|
31
|
+
expect(assigns(:response).docs).to_not be_empty
|
32
|
+
assert_facets_have_values(assigns(:response).aggregations)
|
48
33
|
end
|
49
34
|
it "should have docs and facets for non-default results per page", :integration => true do
|
50
35
|
num_per_page = 7
|
51
36
|
get :index, :per_page => num_per_page
|
52
|
-
expect(
|
53
|
-
assert_facets_have_values(
|
37
|
+
expect(assigns(:response).docs).to have(num_per_page).items
|
38
|
+
assert_facets_have_values(assigns(:response).aggregations)
|
54
39
|
end
|
55
40
|
|
56
41
|
it "should have docs and facets for second page", :integration => true do
|
57
42
|
page = 2
|
58
43
|
get :index, :page => page
|
59
|
-
expect(
|
60
|
-
expect(
|
61
|
-
assert_facets_have_values(
|
44
|
+
expect(assigns(:response).docs).to_not be_empty
|
45
|
+
expect(assigns(:response).params[:start].to_i).to eq (page-1) * @controller.blacklight_config[:default_solr_params][:rows]
|
46
|
+
assert_facets_have_values(assigns(:response).aggregations)
|
62
47
|
end
|
63
48
|
|
64
49
|
it "should have no docs or facet values for query without results", :integration => true do
|
65
50
|
get :index, q: 'sadfdsafasdfsadfsadfsadf' # query for no results
|
66
51
|
|
67
|
-
expect(
|
68
|
-
|
52
|
+
expect(assigns(:response).docs).to be_empty
|
53
|
+
assigns(:response).aggregations.each do |key, facet|
|
69
54
|
expect(facet.items).to be_empty
|
70
55
|
end
|
71
56
|
end
|
57
|
+
|
58
|
+
it "should show 0 results when the user asks for an invalid value to a custom facet query", :integration => true do
|
59
|
+
get :index, f: {example_query_facet_field: 'bogus'} # bogus custom facet value
|
60
|
+
expect(assigns(:response).docs).to be_empty
|
61
|
+
end
|
72
62
|
|
63
|
+
it "should return results (possibly 0) when the user asks for a valid value to a custom facet query", :integration => true do
|
64
|
+
get :index, f: {example_query_facet_field: 'years_10'} # valid custom facet value with some results
|
65
|
+
expect(assigns(:response).docs).to_not be_empty
|
66
|
+
get :index, f: {example_query_facet_field: 'years_5'} # valid custom facet value with NO results
|
67
|
+
expect(assigns(:response).docs).to be_empty
|
68
|
+
end
|
69
|
+
|
73
70
|
it "should have a spelling suggestion for an appropriately poor query", :integration => true do
|
74
71
|
get :index, :q => 'boo'
|
75
|
-
expect(
|
72
|
+
expect(assigns(:response).spelling.words).to_not be_nil
|
76
73
|
end
|
77
74
|
|
78
75
|
describe "session" do
|
@@ -93,11 +90,11 @@ describe CatalogController do
|
|
93
90
|
describe "for default query" do
|
94
91
|
it "should get documents when no query", :integration => true do
|
95
92
|
get :index
|
96
|
-
expect(
|
93
|
+
expect(assigns(:response).docs).to_not be_empty
|
97
94
|
end
|
98
95
|
it "should get facets when no query", :integration => true do
|
99
96
|
get :index
|
100
|
-
assert_facets_have_values(
|
97
|
+
assert_facets_have_values(assigns(:response).aggregations)
|
101
98
|
end
|
102
99
|
end
|
103
100
|
|
@@ -206,6 +203,11 @@ describe CatalogController do
|
|
206
203
|
|
207
204
|
describe "track action" do
|
208
205
|
doc_id = '2007020969'
|
206
|
+
|
207
|
+
it "should persist the search session id value into session[:search]" do
|
208
|
+
put :track, :id => doc_id, :counter => 3, search_id: "123"
|
209
|
+
expect(session[:search]['id']).to eq "123"
|
210
|
+
end
|
209
211
|
|
210
212
|
it "should set counter value into session[:search]" do
|
211
213
|
put :track, :id => doc_id, :counter => 3
|
@@ -524,7 +526,7 @@ describe CatalogController do
|
|
524
526
|
allow(controller).to receive(:get_search_results) { |*args| raise fake_error }
|
525
527
|
allow(controller.flash).to receive(:sweep)
|
526
528
|
allow(controller).to receive(:flash).and_return(:notice => I18n.t('blacklight.search.errors.request_error'))
|
527
|
-
expect { get :index, q: "+" }.to raise_error
|
529
|
+
expect { get :index, q: "+" }.to raise_error Blacklight::Exceptions::InvalidRequest
|
528
530
|
end
|
529
531
|
|
530
532
|
end
|
@@ -553,9 +555,9 @@ describe CatalogController do
|
|
553
555
|
it "should be successful" do
|
554
556
|
get :facet, id: 'format'
|
555
557
|
expect(response).to be_successful
|
556
|
-
expect(assigns[:response]).to be_kind_of Blacklight::
|
558
|
+
expect(assigns[:response]).to be_kind_of Blacklight::Solr::Response
|
557
559
|
expect(assigns[:facet]).to be_kind_of Blacklight::Configuration::FacetField
|
558
|
-
expect(assigns[:display_facet]).to be_kind_of Blacklight::
|
560
|
+
expect(assigns[:display_facet]).to be_kind_of Blacklight::Solr::Response::Facets::FacetField
|
559
561
|
expect(assigns[:pagination]).to be_kind_of Blacklight::Solr::FacetPaginator
|
560
562
|
end
|
561
563
|
end
|