blacklight 6.0.0.pre5 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -8
- data/Gemfile +11 -2
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/_facets.scss +1 -10
- data/app/controllers/bookmarks_controller.rb +1 -0
- data/app/controllers/catalog_controller.rb +1 -0
- data/app/controllers/concerns/blacklight/base.rb +1 -0
- data/app/controllers/concerns/blacklight/bookmarks.rb +13 -1
- data/app/controllers/concerns/blacklight/catalog.rb +7 -1
- data/app/controllers/concerns/blacklight/controller.rb +7 -6
- data/app/controllers/concerns/blacklight/default_component_configuration.rb +1 -0
- data/app/controllers/concerns/blacklight/facet.rb +1 -0
- data/app/controllers/concerns/blacklight/request_builders.rb +1 -0
- data/app/controllers/concerns/blacklight/search_context.rb +8 -12
- data/app/controllers/concerns/blacklight/search_fields.rb +1 -0
- data/app/controllers/concerns/blacklight/search_helper.rb +2 -1
- data/app/controllers/concerns/blacklight/search_history.rb +32 -0
- data/app/controllers/concerns/blacklight/suggest.rb +1 -0
- data/app/controllers/concerns/blacklight/suggest_search.rb +1 -0
- data/app/controllers/concerns/blacklight/token_based_user.rb +1 -0
- data/app/controllers/saved_searches_controller.rb +20 -9
- data/app/controllers/search_history_controller.rb +2 -18
- data/app/controllers/suggest_controller.rb +1 -0
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/catalog_helper_behavior.rb +15 -1
- data/app/helpers/blacklight/component_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/configuration_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/deprecated_url_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/facets_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/layout_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +9 -6
- data/app/helpers/blacklight/render_partials_helper.rb +15 -4
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/suggest_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/url_helper_behavior.rb +6 -6
- data/app/helpers/blacklight_configuration_helper.rb +1 -0
- data/app/helpers/blacklight_helper.rb +1 -0
- data/app/helpers/blacklight_url_helper.rb +1 -0
- data/app/helpers/catalog_helper.rb +1 -0
- data/app/helpers/component_helper.rb +1 -0
- data/app/helpers/facets_helper.rb +1 -0
- data/app/helpers/hash_as_hidden_fields_helper.rb +1 -0
- data/app/helpers/layout_helper.rb +1 -0
- data/app/helpers/render_constraints_helper.rb +1 -0
- data/app/helpers/search_history_constraints_helper.rb +1 -0
- data/app/helpers/suggest_helper.rb +1 -0
- data/app/models/blacklight/facet_paginator.rb +6 -2
- data/app/models/blacklight/solr/facet_paginator.rb +1 -0
- data/app/models/bookmark.rb +1 -0
- data/app/models/concerns/blacklight/configurable.rb +1 -0
- data/app/models/concerns/blacklight/document.rb +1 -0
- data/app/models/concerns/blacklight/document/active_model_shim.rb +1 -0
- data/app/models/concerns/blacklight/document/cache_key.rb +1 -0
- data/app/models/concerns/blacklight/document/dublin_core.rb +1 -0
- data/app/models/concerns/blacklight/document/email.rb +1 -0
- data/app/models/concerns/blacklight/document/export.rb +1 -0
- data/app/models/concerns/blacklight/document/extensions.rb +1 -0
- data/app/models/concerns/blacklight/document/schema_org.rb +1 -0
- data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -0
- data/app/models/concerns/blacklight/document/sms.rb +1 -0
- data/app/models/concerns/blacklight/solr/document.rb +1 -0
- data/app/models/concerns/blacklight/solr/document/more_like_this.rb +1 -0
- data/app/models/concerns/blacklight/suggest/response.rb +1 -0
- data/app/models/concerns/blacklight/user.rb +1 -0
- data/app/models/record_mailer.rb +1 -0
- data/app/models/search.rb +4 -1
- data/app/models/solr_document.rb +1 -0
- data/app/presenters/blacklight/document_presenter.rb +17 -1
- data/app/presenters/blacklight/json_presenter.rb +1 -0
- data/app/views/bookmarks/_tools.html.erb +1 -1
- data/app/views/catalog/_facet_index_navigation.html.erb +2 -2
- data/app/views/catalog/_facet_pagination.html.erb +4 -4
- data/app/views/catalog/_search_results.html.erb +3 -5
- data/app/views/catalog/_view_type_group.html.erb +1 -1
- data/app/views/catalog/index.atom.builder +7 -7
- data/app/views/catalog/index.json.jbuilder +0 -1
- data/app/views/catalog/index.rss.builder +1 -4
- data/config/locales/blacklight.de.yml +0 -2
- data/config/locales/blacklight.es.yml +0 -2
- data/config/locales/blacklight.it.yml +0 -2
- data/config/locales/blacklight.pt-BR.yml +0 -6
- data/config/routes.rb +1 -0
- data/db/migrate/20140202020201_create_searches.rb +1 -0
- data/db/migrate/20140202020202_create_bookmarks.rb +1 -0
- data/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +1 -0
- data/lib/blacklight.rb +3 -1
- data/lib/blacklight/abstract_repository.rb +1 -0
- data/lib/blacklight/configuration.rb +1 -0
- data/lib/blacklight/configuration/context.rb +1 -0
- data/lib/blacklight/configuration/facet_field.rb +1 -0
- data/lib/blacklight/configuration/field.rb +1 -0
- data/lib/blacklight/configuration/fields.rb +1 -0
- data/lib/blacklight/configuration/search_field.rb +1 -0
- data/lib/blacklight/configuration/sort_field.rb +1 -0
- data/lib/blacklight/configuration/tool_config.rb +1 -0
- data/lib/blacklight/configuration/view_config.rb +1 -0
- data/lib/blacklight/engine.rb +1 -0
- data/lib/blacklight/exceptions.rb +1 -0
- data/lib/blacklight/parameters.rb +4 -4
- data/lib/blacklight/routes.rb +1 -0
- data/lib/blacklight/routes/exportable.rb +1 -0
- data/lib/blacklight/routes/searchable.rb +1 -0
- data/lib/blacklight/search_builder.rb +1 -0
- data/lib/blacklight/search_state.rb +22 -5
- data/lib/blacklight/solr.rb +1 -0
- data/lib/blacklight/solr/repository.rb +1 -0
- data/lib/blacklight/solr/request.rb +1 -0
- data/lib/blacklight/solr/response.rb +7 -1
- data/lib/blacklight/solr/response/facets.rb +1 -0
- data/lib/blacklight/solr/response/group.rb +1 -0
- data/lib/blacklight/solr/response/group_response.rb +1 -0
- data/lib/blacklight/solr/response/more_like_this.rb +1 -0
- data/lib/blacklight/solr/response/pagination_methods.rb +1 -0
- data/lib/blacklight/solr/response/response.rb +1 -0
- data/lib/blacklight/solr/response/spelling.rb +1 -0
- data/lib/blacklight/solr/search_builder_behavior.rb +19 -14
- data/lib/blacklight/utils.rb +1 -0
- data/lib/blacklight/version.rb +1 -0
- data/lib/generators/blacklight/assets_generator.rb +1 -0
- data/lib/generators/blacklight/controller_generator.rb +1 -0
- data/lib/generators/blacklight/document_generator.rb +1 -0
- data/lib/generators/blacklight/install_generator.rb +1 -0
- data/lib/generators/blacklight/models_generator.rb +1 -0
- data/lib/generators/blacklight/search_builder_generator.rb +1 -0
- data/lib/generators/blacklight/solr4_generator.rb +1 -0
- data/lib/generators/blacklight/solr5_generator.rb +2 -2
- data/lib/generators/blacklight/templates/alternate_controller.rb +1 -0
- data/lib/generators/blacklight/templates/catalog_controller.rb +1 -0
- data/lib/generators/blacklight/templates/search_builder.rb +1 -0
- data/lib/generators/blacklight/templates/solr_document.rb +1 -0
- data/lib/generators/blacklight/test_support_generator.rb +1 -0
- data/lib/generators/blacklight/user_generator.rb +10 -6
- data/lib/railties/blacklight.rake +3 -3
- data/spec/controllers/alternate_controller_spec.rb +1 -0
- data/spec/controllers/application_controller_spec.rb +1 -0
- data/spec/controllers/blacklight/base_spec.rb +5 -3
- data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +1 -0
- data/spec/controllers/blacklight/facet_spec.rb +1 -0
- data/spec/controllers/blacklight/search_fields_spec.rb +1 -0
- data/spec/controllers/blacklight/search_helper_spec.rb +1 -0
- data/spec/controllers/blacklight/suggest_search_spec.rb +1 -0
- data/spec/controllers/bookmarks_controller_spec.rb +1 -0
- data/spec/controllers/catalog_controller_spec.rb +17 -14
- data/spec/controllers/saved_searches_controller_spec.rb +1 -0
- data/spec/controllers/search_history_controller_spec.rb +1 -0
- data/spec/controllers/suggest_controller_spec.rb +1 -0
- data/spec/features/alternate_controller_spec.rb +1 -0
- data/spec/features/bookmarks_spec.rb +1 -0
- data/spec/features/did_you_mean_spec.rb +1 -0
- data/spec/features/facets_spec.rb +1 -0
- data/spec/features/record_view_spec.rb +1 -0
- data/spec/features/saved_searches_spec.rb +1 -0
- data/spec/features/search_context_spec.rb +1 -0
- data/spec/features/search_filters_spec.rb +2 -1
- data/spec/features/search_formats_spec.rb +1 -0
- data/spec/features/search_history_spec.rb +1 -0
- data/spec/features/search_pagination_spec.rb +1 -0
- data/spec/features/search_results_spec.rb +1 -0
- data/spec/features/search_sort_spec.rb +1 -0
- data/spec/features/search_spec.rb +1 -0
- data/spec/features/sitelinks_search_box.rb +1 -0
- data/spec/helpers/blacklight_helper_spec.rb +3 -2
- data/spec/helpers/catalog_helper_spec.rb +11 -16
- data/spec/helpers/configuration_helper_spec.rb +1 -0
- data/spec/helpers/deprecated_url_helper_behavior_spec.rb +18 -9
- data/spec/helpers/facets_helper_spec.rb +1 -0
- data/spec/helpers/hash_as_hidden_fields_spec.rb +1 -0
- data/spec/helpers/layout_helper_spec.rb +1 -0
- data/spec/helpers/render_constraints_helper_spec.rb +18 -8
- data/spec/helpers/search_history_constraints_helper_spec.rb +1 -0
- data/spec/helpers/suggest_helper_spec.rb +1 -0
- data/spec/helpers/url_helper_spec.rb +72 -68
- data/spec/lib/blacklight/parameters_spec.rb +3 -2
- data/spec/lib/blacklight/search_state_spec.rb +44 -32
- data/spec/lib/blacklight/utils_spec.rb +1 -0
- data/spec/lib/blacklight_spec.rb +11 -3
- data/spec/lib/tasks/blacklight_task_spec.rb +1 -0
- data/spec/models/blacklight/configurable_spec.rb +1 -0
- data/spec/models/blacklight/configuration/context_spec.rb +1 -0
- data/spec/models/blacklight/configuration_spec.rb +1 -0
- data/spec/models/blacklight/document/active_model_shim_spec.rb +1 -0
- data/spec/models/blacklight/document/cache_key_spec.rb +1 -0
- data/spec/models/blacklight/document/dublin_core_spec.rb +1 -0
- data/spec/models/blacklight/document/email_spec.rb +1 -0
- data/spec/models/blacklight/document/sms_spec.rb +1 -0
- data/spec/models/blacklight/document_spec.rb +1 -0
- data/spec/models/blacklight/facet_paginator_spec.rb +21 -8
- data/spec/models/blacklight/search_builder_spec.rb +1 -0
- data/spec/models/blacklight/solr/document/more_like_this_spec.rb +1 -0
- data/spec/models/blacklight/solr/document_spec.rb +1 -0
- data/spec/models/blacklight/solr/facet_paginator_spec.rb +1 -0
- data/spec/models/blacklight/solr/repository_spec.rb +1 -0
- data/spec/models/blacklight/solr/request_spec.rb +1 -0
- data/spec/models/blacklight/solr/response/facets_spec.rb +1 -0
- data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -0
- data/spec/models/blacklight/solr/response/group_spec.rb +1 -0
- data/spec/models/blacklight/solr/response_spec.rb +1 -0
- data/spec/models/blacklight/solr/search_builder_spec.rb +21 -30
- data/spec/models/blacklight/suggest/response_spec.rb +1 -0
- data/spec/models/blacklight/user_spec.rb +1 -0
- data/spec/models/bookmark_spec.rb +4 -3
- data/spec/models/record_mailer_spec.rb +1 -0
- data/spec/models/search_spec.rb +22 -38
- data/spec/models/solr_document_spec.rb +1 -0
- data/spec/presenters/document_presenter_spec.rb +7 -3
- data/spec/routing/catalog_routing_spec.rb +1 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/controller_level_helpers.rb +2 -1
- data/spec/support/features.rb +1 -0
- data/spec/support/features/session_helpers.rb +1 -0
- data/spec/test_app_templates/Gemfile.extra +14 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -0
- data/spec/views/_user_util_links.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_constraints.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_constraints_element.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_document.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +4 -1
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_facets.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_index_default.erb_spec.rb +1 -0
- data/spec/views/catalog/_index_header_default.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_search_header.erb_spec.rb +1 -0
- data/spec/views/catalog/_show_default.erb_spec.rb +1 -0
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -0
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_thumbnail_default.erb_spec.rb +1 -0
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +1 -0
- data/spec/views/catalog/facet.html.erb_spec.rb +1 -0
- data/spec/views/catalog/facet.json.jbuilder_spec.rb +1 -0
- data/spec/views/catalog/index.atom.builder_spec.rb +19 -27
- data/spec/views/catalog/index.html.erb_spec.rb +1 -0
- data/spec/views/catalog/index.json.jbuilder_spec.rb +1 -0
- data/spec/views/catalog/opensearch.xml.builder_spec.rb +1 -0
- data/spec/views/catalog/show.html.erb_spec.rb +1 -0
- data/template.demo.rb +1 -0
- metadata +7 -5
- data/app/views/catalog/show.refworks.erb +0 -1
data/lib/blacklight/solr.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
class Blacklight::Solr::Response < ActiveSupport::HashWithIndifferentAccess
|
2
3
|
extend Deprecation
|
3
4
|
|
@@ -91,7 +92,12 @@ class Blacklight::Solr::Response < ActiveSupport::HashWithIndifferentAccess
|
|
91
92
|
when Array
|
92
93
|
value.each { |v| force_to_utf8(v) }
|
93
94
|
when String
|
94
|
-
|
95
|
+
if value.encoding != Encoding::UTF_8
|
96
|
+
Rails.logger.warn "Found a non utf-8 value in Blacklight::Solr::Response. \"#{value}\" Encoding is #{value.encoding}"
|
97
|
+
value.dup.force_encoding('UTF-8')
|
98
|
+
else
|
99
|
+
value
|
100
|
+
end
|
95
101
|
end
|
96
102
|
value
|
97
103
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Blacklight::Solr
|
2
3
|
module SearchBuilderBehavior
|
3
4
|
extend ActiveSupport::Concern
|
@@ -107,16 +108,6 @@ module Blacklight::Solr
|
|
107
108
|
# taking account of our facet paging/'more'. This is not
|
108
109
|
# about solr 'fq', this is about solr facet.* params.
|
109
110
|
def add_facetting_to_solr(solr_parameters)
|
110
|
-
# While not used by BL core behavior, legacy behavior seemed to be
|
111
|
-
# to accept incoming params as "facet.field" or "facets", and add them
|
112
|
-
# on to any existing facet.field sent to Solr. Legacy behavior seemed
|
113
|
-
# to be accepting these incoming params as arrays (in Rails URL with []
|
114
|
-
# on end), or single values. At least one of these is used by
|
115
|
-
# Stanford for "faux hieararchial facets".
|
116
|
-
if blacklight_params.has_key?("facet.field") || blacklight_params.has_key?("facets")
|
117
|
-
solr_parameters[:"facet.field"].concat( [blacklight_params["facet.field"], blacklight_params["facets"]].flatten.compact ).uniq!
|
118
|
-
end
|
119
|
-
|
120
111
|
facet_fields_to_include_in_request.each do |field_name, facet|
|
121
112
|
solr_parameters[:facet] ||= true
|
122
113
|
|
@@ -139,10 +130,8 @@ module Blacklight::Solr
|
|
139
130
|
end
|
140
131
|
end
|
141
132
|
|
142
|
-
|
143
|
-
|
144
|
-
# want to page at, according to configured facet limits.
|
145
|
-
solr_parameters[:"f.#{facet.field}.facet.limit"] = (facet_limit_for(field_name) + 1) if facet_limit_for(field_name)
|
133
|
+
limit = facet_limit_with_pagination(field_name)
|
134
|
+
solr_parameters[:"f.#{facet.field}.facet.limit"] = limit if limit
|
146
135
|
end
|
147
136
|
end
|
148
137
|
|
@@ -254,6 +243,22 @@ module Blacklight::Solr
|
|
254
243
|
end
|
255
244
|
end
|
256
245
|
|
246
|
+
# Support facet paging and 'more'
|
247
|
+
# links, by sending a facet.limit one more than what we
|
248
|
+
# want to page at, according to configured facet limits.
|
249
|
+
def facet_limit_with_pagination(field_name)
|
250
|
+
limit = facet_limit_for(field_name)
|
251
|
+
|
252
|
+
return if limit.nil?
|
253
|
+
|
254
|
+
if limit > 0
|
255
|
+
limit + 1
|
256
|
+
else
|
257
|
+
limit
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
|
257
262
|
##
|
258
263
|
# A helper method used for generating solr LocalParams, put quotes
|
259
264
|
# around the term unless it's a bare-word. Escape internal quotes
|
data/lib/blacklight/utils.rb
CHANGED
data/lib/blacklight/version.rb
CHANGED
@@ -18,7 +18,11 @@ This generator makes the following changes to your application:
|
|
18
18
|
# Install Devise?
|
19
19
|
def generate_devise_assets
|
20
20
|
if options[:devise]
|
21
|
-
|
21
|
+
if ENV['RAILS_VERSION'] =~ /^5\.0/ || ENV['RAILS_VERSION'] == 'edge'
|
22
|
+
gem 'devise', github: 'plataformatec/devise' # Need > 3.5.3
|
23
|
+
else
|
24
|
+
gem "devise"
|
25
|
+
end
|
22
26
|
gem "devise-guests", "~> 0.3"
|
23
27
|
|
24
28
|
Bundler.with_clean_env do
|
@@ -31,11 +35,11 @@ This generator makes the following changes to your application:
|
|
31
35
|
|
32
36
|
# add the #to_s to the model.
|
33
37
|
insert_into_file("app/models/#{model_name}.rb", before: /end(\n| )*$/) do
|
34
|
-
"\n # Method added by Blacklight; Blacklight uses #to_s on your\n"
|
35
|
-
" # user class to get a user-displayable login/identifier for\n"
|
36
|
-
" # the account.\n"
|
37
|
-
" def to_s\n"
|
38
|
-
" email\n"
|
38
|
+
"\n # Method added by Blacklight; Blacklight uses #to_s on your\n" \
|
39
|
+
" # user class to get a user-displayable login/identifier for\n" \
|
40
|
+
" # the account.\n" \
|
41
|
+
" def to_s\n" \
|
42
|
+
" email\n" \
|
39
43
|
" end\n"
|
40
44
|
end
|
41
45
|
gsub_file("config/initializers/devise.rb", "config.sign_out_via = :delete", "config.sign_out_via = :get")
|
@@ -73,10 +73,10 @@ namespace :blacklight do
|
|
73
73
|
puts e.to_s
|
74
74
|
end
|
75
75
|
|
76
|
-
print " -
|
77
|
-
|
76
|
+
print " - search_results: "
|
77
|
+
|
78
78
|
begin
|
79
|
-
response, docs = controller.
|
79
|
+
response, docs = controller.search_results(q: '{!lucene}*:*')
|
80
80
|
|
81
81
|
if response.header['status'] == 0 and docs.length > 0
|
82
82
|
puts "OK"
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe Blacklight::Base do
|
@@ -5,13 +6,14 @@ describe Blacklight::Base do
|
|
5
6
|
subject { controller}
|
6
7
|
|
7
8
|
describe "#search_state" do
|
8
|
-
let(:
|
9
|
+
let(:raw_params) { HashWithIndifferentAccess.new a: 1 }
|
10
|
+
let(:params) { ActionController::Parameters.new raw_params }
|
9
11
|
before { allow(controller).to receive_messages(params: params) }
|
10
12
|
subject { controller.send(:search_state) }
|
11
13
|
|
12
14
|
it "creates a path object" do
|
13
15
|
expect(subject).to be_kind_of Blacklight::SearchState
|
14
|
-
expect(subject.params).to
|
16
|
+
expect(subject.params).to eq raw_params
|
15
17
|
end
|
16
18
|
end
|
17
|
-
end
|
19
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe CatalogController do
|
@@ -6,8 +7,8 @@ describe CatalogController do
|
|
6
7
|
describe "with format :html" do
|
7
8
|
let(:user_query) { 'history' } # query that will get results
|
8
9
|
|
9
|
-
it "
|
10
|
-
allow(controller).to receive(:
|
10
|
+
it "has no search history if no search criteria" do
|
11
|
+
allow(controller).to receive(:search_results)
|
11
12
|
session[:history] = []
|
12
13
|
get :index
|
13
14
|
expect(session[:history]).to be_empty
|
@@ -74,13 +75,13 @@ describe CatalogController do
|
|
74
75
|
|
75
76
|
describe "session" do
|
76
77
|
before do
|
77
|
-
allow(controller).to receive(:
|
78
|
+
allow(controller).to receive(:search_results)
|
78
79
|
end
|
79
|
-
it "
|
80
|
+
it "includes search hash with key :q" do
|
80
81
|
get :index, q: user_query
|
81
82
|
expect(session[:search]).to_not be_nil
|
82
83
|
expect(session[:search].keys).to include 'id'
|
83
|
-
|
84
|
+
|
84
85
|
search = Search.find(session[:search]['id'])
|
85
86
|
expect(search.query_params['q']).to eq user_query
|
86
87
|
end
|
@@ -98,8 +99,8 @@ describe CatalogController do
|
|
98
99
|
end
|
99
100
|
end
|
100
101
|
|
101
|
-
it "
|
102
|
-
allow(controller).to receive(:
|
102
|
+
it "renders index.html.erb" do
|
103
|
+
allow(controller).to receive(:search_results)
|
103
104
|
get :index
|
104
105
|
expect(response).to render_template(:index)
|
105
106
|
end
|
@@ -162,7 +163,7 @@ describe CatalogController do
|
|
162
163
|
|
163
164
|
before :each do
|
164
165
|
allow(@controller).to receive_messages blacklight_config: blacklight_config
|
165
|
-
allow(@controller).to receive_messages
|
166
|
+
allow(@controller).to receive_messages search_results: [double, double]
|
166
167
|
end
|
167
168
|
|
168
169
|
it "should not render when the config is false" do
|
@@ -170,7 +171,7 @@ describe CatalogController do
|
|
170
171
|
expect { get :index, format: 'yaml' }.to raise_error ActionController::RoutingError
|
171
172
|
end
|
172
173
|
|
173
|
-
it "
|
174
|
+
it "renders the default when the config is true" do
|
174
175
|
# TODO: this should really stub a template and see if it gets rendered,
|
175
176
|
# but how to do that is non-obvious..
|
176
177
|
blacklight_config.index.respond_to.yaml = true
|
@@ -524,7 +525,7 @@ describe CatalogController do
|
|
524
525
|
|
525
526
|
it "should return status 500 if the catalog path is raising an exception" do
|
526
527
|
fake_error = Blacklight::Exceptions::InvalidRequest.new
|
527
|
-
allow(controller).to receive(:
|
528
|
+
allow(controller).to receive(:search_results) { |*args| raise fake_error }
|
528
529
|
allow(controller.flash).to receive(:sweep)
|
529
530
|
allow(controller).to receive(:flash).and_return(:notice => I18n.t('blacklight.search.errors.request_error'))
|
530
531
|
expect { get :index, q: "+" }.to raise_error Blacklight::Exceptions::InvalidRequest
|
@@ -598,16 +599,18 @@ describe CatalogController do
|
|
598
599
|
end
|
599
600
|
|
600
601
|
describe "current_search_session" do
|
602
|
+
let(:parameter_class) { ActionController::Parameters }
|
603
|
+
|
601
604
|
it "should create a session if we're on an search action" do
|
602
605
|
allow(controller).to receive_messages(:action_name => "index")
|
603
|
-
allow(controller).to receive_messages(:
|
606
|
+
allow(controller).to receive_messages(params: parameter_class.new(q: "x", page: 5))
|
604
607
|
session = controller.send(:current_search_session)
|
605
608
|
expect(session.query_params).to include(:q => "x")
|
606
609
|
expect(session.query_params).to_not include(:page => 5)
|
607
610
|
end
|
608
611
|
|
609
612
|
it "should create a session if a search context was provided" do
|
610
|
-
allow(controller).to receive_messages(:
|
613
|
+
allow(controller).to receive_messages(params: parameter_class.new(search_context: JSON.dump(:q => "x")))
|
611
614
|
session = controller.send(:current_search_session)
|
612
615
|
expect(session.query_params).to include("q" => "x")
|
613
616
|
end
|
@@ -616,7 +619,7 @@ describe CatalogController do
|
|
616
619
|
s = Search.create(:query_params => { :q => "x" })
|
617
620
|
session[:history] ||= []
|
618
621
|
session[:history] << s.id
|
619
|
-
allow(controller).to receive_messages(:
|
622
|
+
allow(controller).to receive_messages(params: parameter_class.new(search_id: s.id))
|
620
623
|
session = controller.send(:current_search_session)
|
621
624
|
expect(session.query_params).to include(:q => "x")
|
622
625
|
expect(session).to eq(s)
|
@@ -660,7 +663,7 @@ describe CatalogController do
|
|
660
663
|
get 'catalog/like', as: :catalog_like
|
661
664
|
end
|
662
665
|
end
|
663
|
-
|
666
|
+
|
664
667
|
after do
|
665
668
|
CatalogController.blacklight_config.show.document_actions.delete(:like)
|
666
669
|
Rails.application.reload_routes!
|