blacklight 5.9.4 → 5.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/_facets.scss +11 -10
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +14 -14
- data/app/helpers/blacklight/configuration_helper_behavior.rb +16 -10
- data/app/helpers/blacklight/facets_helper_behavior.rb +15 -14
- data/app/helpers/blacklight/url_helper_behavior.rb +1 -1
- data/app/models/bookmark.rb +1 -4
- data/app/models/search.rb +3 -6
- data/app/views/catalog/_facet_layout.html.erb +2 -2
- data/app/views/catalog/_facet_limit.html.erb +5 -3
- data/app/views/catalog/_facet_pivot.html.erb +4 -4
- data/app/views/catalog/_home_text.html.erb +8 -48
- data/app/views/catalog/_index_default.html.erb +3 -3
- data/app/views/catalog/_show_default.html.erb +3 -3
- data/app/views/catalog/_sms_form.html.erb +1 -1
- data/app/views/catalog/facet.html.erb +1 -1
- data/blacklight.gemspec +1 -1
- data/config/jetty.yml +0 -3
- data/config/locales/blacklight.de.yml +2 -0
- data/config/locales/blacklight.en.yml +2 -0
- data/config/locales/blacklight.es.yml +2 -0
- data/config/locales/blacklight.fr.yml +2 -0
- data/config/locales/blacklight.pt-BR.yml +2 -0
- data/lib/blacklight.rb +70 -26
- data/lib/blacklight/abstract_repository.rb +29 -0
- data/lib/blacklight/base.rb +7 -7
- data/lib/blacklight/bookmarks.rb +5 -5
- data/lib/blacklight/catalog.rb +34 -19
- data/lib/blacklight/catalog/search_context.rb +1 -1
- data/lib/blacklight/configuration.rb +112 -46
- data/lib/blacklight/configuration/facet_field.rb +9 -7
- data/lib/blacklight/configuration/field.rb +27 -0
- data/lib/blacklight/configuration/fields.rb +25 -20
- data/lib/blacklight/configuration/search_field.rb +6 -8
- data/lib/blacklight/configuration/solr_field.rb +3 -18
- data/lib/blacklight/configuration/sort_field.rb +6 -7
- data/lib/blacklight/document.rb +156 -0
- data/lib/blacklight/document/dublin_core.rb +41 -0
- data/lib/blacklight/document/email.rb +16 -0
- data/lib/blacklight/document/export.rb +107 -0
- data/lib/blacklight/document/extensions.rb +56 -0
- data/lib/blacklight/document/schema_org.rb +7 -0
- data/lib/blacklight/document/semantic_fields.rb +51 -0
- data/lib/blacklight/document/sms.rb +14 -0
- data/lib/blacklight/document_presenter.rb +3 -3
- data/lib/blacklight/exceptions.rb +9 -2
- data/lib/blacklight/facet.rb +21 -16
- data/lib/blacklight/request_builders.rb +60 -284
- data/lib/blacklight/routes.rb +1 -1
- data/lib/blacklight/search_builder.rb +130 -0
- data/lib/blacklight/search_helper.rb +316 -0
- data/lib/blacklight/solr.rb +1 -0
- data/lib/blacklight/solr/document.rb +4 -187
- data/lib/blacklight/solr/document/dublin_core.rb +3 -37
- data/lib/blacklight/solr/document/email.rb +4 -13
- data/lib/blacklight/solr/document/export.rb +3 -103
- data/lib/blacklight/solr/document/extensions.rb +4 -52
- data/lib/blacklight/solr/document/more_like_this.rb +1 -1
- data/lib/blacklight/solr/document/schema_org.rb +4 -4
- data/lib/blacklight/solr/document/sms.rb +4 -11
- data/lib/blacklight/solr/facet_paginator.rb +2 -2
- data/lib/blacklight/solr/search_builder.rb +264 -0
- data/lib/blacklight/solr_helper.rb +6 -261
- data/lib/blacklight/solr_repository.rb +30 -24
- data/lib/blacklight/solr_response.rb +3 -3
- data/lib/blacklight/user.rb +1 -2
- data/lib/blacklight/utils.rb +0 -23
- data/lib/generators/blacklight/controller_generator.rb +38 -0
- data/lib/generators/blacklight/document_generator.rb +20 -0
- data/lib/generators/blacklight/install_generator.rb +38 -39
- data/lib/generators/blacklight/models_generator.rb +2 -62
- data/lib/generators/blacklight/templates/catalog_controller.rb +3 -4
- data/lib/generators/blacklight/templates/config/{solr.yml → blacklight.yml} +3 -0
- data/lib/generators/blacklight/templates/config/jetty.yml +0 -3
- data/lib/generators/blacklight/templates/solr_document.rb +6 -6
- data/lib/generators/blacklight/test_support_generator.rb +1 -6
- data/lib/generators/blacklight/user_generator.rb +59 -0
- data/lib/railties/blacklight.rake +16 -7
- data/spec/controllers/catalog_controller_spec.rb +9 -15
- data/spec/features/facets_spec.rb +8 -0
- data/spec/helpers/configuration_helper_spec.rb +6 -13
- data/spec/helpers/facets_helper_spec.rb +3 -2
- data/spec/lib/blacklight/configuration_spec.rb +11 -38
- data/spec/lib/blacklight/{solr/document → document}/dublin_core_spec.rb +4 -4
- data/spec/lib/blacklight/{solr/document → document}/email_spec.rb +2 -2
- data/spec/lib/blacklight/{solr/document → document}/sms_spec.rb +2 -2
- data/spec/lib/blacklight/search_builder_spec.rb +145 -0
- data/spec/lib/blacklight/search_helper_spec.rb +775 -0
- data/spec/lib/blacklight/solr/document/more_like_this_spec.rb +1 -1
- data/spec/lib/blacklight/solr/search_builder_spec.rb +561 -0
- data/spec/lib/blacklight/solr_helper_spec.rb +5 -1291
- data/spec/lib/blacklight/solr_repository_spec.rb +13 -13
- data/spec/models/record_mailer_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
- data/spec/views/catalog/_constraints.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +2 -2
- data/spec/views/catalog/index.atom.builder_spec.rb +1 -1
- data/tasks/blacklight.rake +1 -1
- data/template.demo.rb +1 -1
- metadata +33 -45
- data/doc/Adding-new-document-actions.md +0 -94
- data/doc/Atom-Responses.md +0 -90
- data/doc/Blacklight-Add-ons.md +0 -23
- data/doc/Blacklight-configuration.md +0 -411
- data/doc/Blacklight-on-Heroku.md +0 -100
- data/doc/Blacklight-out-of-the-box.md +0 -47
- data/doc/Bookmarks.md +0 -1
- data/doc/Code4Lib-2014.md +0 -94
- data/doc/Configuration---Facet-Fields.md +0 -130
- data/doc/Configuration---Results-View.md +0 -224
- data/doc/Configuration---Solr-fields.md +0 -106
- data/doc/Configuring-and-Customizing-Blacklight.md +0 -257
- data/doc/Configuring-rails-routes.md +0 -13
- data/doc/Contributing-to-Blacklight.md +0 -43
- data/doc/Examples.md +0 -120
- data/doc/Extending-or-Modifying-Blacklight-Search-Behavior.md +0 -141
- data/doc/Home.md +0 -100
- data/doc/How-to-release-a-version.md +0 -45
- data/doc/Indexing-your-data-into-solr.md +0 -36
- data/doc/Internationalization.md +0 -32
- data/doc/JSON-API.md +0 -83
- data/doc/Pagination.md +0 -52
- data/doc/Providing-your-own-view-templates.md +0 -69
- data/doc/Quickstart.md +0 -153
- data/doc/README_SOLR.md +0 -245
- data/doc/Saved-Searches.md +0 -5
- data/doc/Solr-Configuration.md +0 -154
- data/doc/Sunspot-for-indexing.md +0 -46
- data/doc/Support.md +0 -33
- data/doc/Theming.md +0 -62
- data/doc/Understanding-Rails-and-Blacklight.md +0 -75
- data/doc/User-Authentication.md +0 -60
- data/doc/_Sidebar.md +0 -9
- data/doc/testing.md +0 -58
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
development:
|
|
2
2
|
startup_wait: 15
|
|
3
3
|
jetty_port: 8983
|
|
4
|
-
java_version: ">= 1.7"
|
|
5
4
|
test:
|
|
6
5
|
startup_wait: 60
|
|
7
6
|
jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8888 %>
|
|
8
7
|
<%= ENV['TEST_JETTY_PATH'] ? "jetty_home: " + ENV['TEST_JETTY_PATH'] : '' %>
|
|
9
|
-
java_version: ">= 1.7"
|
|
10
8
|
production:
|
|
11
9
|
startup_wait: 15
|
|
12
10
|
jetty_port: 8983
|
|
13
|
-
java_version: ">= 1.7"
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
|
2
|
-
class
|
|
2
|
+
class <%= model_name.classify %>
|
|
3
3
|
|
|
4
4
|
include Blacklight::Solr::Document
|
|
5
5
|
|
|
6
6
|
# self.unique_key = 'id'
|
|
7
7
|
|
|
8
8
|
# Email uses the semantic field mappings below to generate the body of an email.
|
|
9
|
-
SolrDocument.use_extension( Blacklight::
|
|
9
|
+
SolrDocument.use_extension( Blacklight::Document::Email )
|
|
10
10
|
|
|
11
11
|
# SMS uses the semantic field mappings below to generate the body of an SMS email.
|
|
12
|
-
SolrDocument.use_extension( Blacklight::
|
|
12
|
+
SolrDocument.use_extension( Blacklight::Document::Sms )
|
|
13
13
|
|
|
14
14
|
# DublinCore uses the semantic field mappings below to assemble an OAI-compliant Dublin Core document
|
|
15
15
|
# Semantic mappings of solr stored fields. Fields may be multi or
|
|
16
|
-
# single valued. See Blacklight::
|
|
17
|
-
# and Blacklight::
|
|
16
|
+
# single valued. See Blacklight::Document::SemanticFields#field_semantics
|
|
17
|
+
# and Blacklight::Document::SemanticFields#to_semantic_values
|
|
18
18
|
# Recommendation: Use field names from Dublin Core
|
|
19
|
-
use_extension( Blacklight::
|
|
19
|
+
use_extension( Blacklight::Document::DublinCore)
|
|
20
20
|
|
|
21
21
|
end
|
|
@@ -10,12 +10,7 @@ module Blacklight
|
|
|
10
10
|
class TestSupport < Rails::Generators::Base
|
|
11
11
|
source_root File.expand_path('../templates', __FILE__)
|
|
12
12
|
desc """
|
|
13
|
-
|
|
14
|
-
good with default blacklight setup, including solr conf files for out
|
|
15
|
-
of the box blacklight.
|
|
16
|
-
|
|
17
|
-
Also adds jetty_path key to solr.yml for selected environment, to refer
|
|
18
|
-
to this install.
|
|
13
|
+
Generate blacklight testing configurations for blacklight's own tests, or for blacklight plugins to use for testing
|
|
19
14
|
"""
|
|
20
15
|
def alternate_controller
|
|
21
16
|
copy_file "alternate_controller.rb", "app/controllers/alternate_controller.rb"
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
require 'rails/generators'
|
|
2
|
+
require 'rails/generators/migration'
|
|
3
|
+
|
|
4
|
+
module Blacklight
|
|
5
|
+
class UserGenerator < Rails::Generators::Base
|
|
6
|
+
include Rails::Generators::Migration
|
|
7
|
+
|
|
8
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
9
|
+
|
|
10
|
+
argument :model_name, :type => :string , :default => "user"
|
|
11
|
+
class_option :devise , :type => :boolean, :default => false, :aliases => "-d", :desc => "Use Devise as authentication logic (this is default)."
|
|
12
|
+
|
|
13
|
+
desc """
|
|
14
|
+
This generator makes the following changes to your application:
|
|
15
|
+
1. Creates a devise-based user model
|
|
16
|
+
2. Injects blacklight-specific behavior into your user model
|
|
17
|
+
"""
|
|
18
|
+
# Install Devise?
|
|
19
|
+
def generate_devise_assets
|
|
20
|
+
if options[:devise]
|
|
21
|
+
gem "devise"
|
|
22
|
+
gem "devise-guests", "~> 0.3"
|
|
23
|
+
|
|
24
|
+
Bundler.with_clean_env do
|
|
25
|
+
run "bundle install"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
generate "devise:install"
|
|
29
|
+
generate "devise", model_name.classify
|
|
30
|
+
generate "devise_guests", model_name.classify
|
|
31
|
+
|
|
32
|
+
# add the #to_s to the model.
|
|
33
|
+
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" +
|
|
39
|
+
" end\n"
|
|
40
|
+
end
|
|
41
|
+
gsub_file("config/initializers/devise.rb", "config.sign_out_via = :delete", "config.sign_out_via = :get")
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Add Blacklight to the user model
|
|
46
|
+
def inject_blacklight_user_behavior
|
|
47
|
+
file_path = "app/models/#{model_name.underscore}.rb"
|
|
48
|
+
if File.exists?(file_path)
|
|
49
|
+
inject_into_class file_path, model_name.classify do
|
|
50
|
+
"\n attr_accessible :email, :password, :password_confirmation if Rails::VERSION::MAJOR < 4\n" +
|
|
51
|
+
"# Connects this user object to Blacklights Bookmarks. " +
|
|
52
|
+
"\n include Blacklight::User\n"
|
|
53
|
+
end
|
|
54
|
+
else
|
|
55
|
+
say_status("warning", "Blacklight authenticated user functionality not installed, as a user model could not be found at /app/models/user.rb. If you used a different name, please re-run the migration and provide that name as an argument. Such as `rails -g blacklight:user client`", :yellow)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -10,12 +10,20 @@ namespace :blacklight do
|
|
|
10
10
|
Search.delete_old_searches(args[:days_old].to_i)
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
namespace :
|
|
13
|
+
namespace :index do
|
|
14
14
|
desc "Put sample data into solr"
|
|
15
15
|
task :seed do
|
|
16
16
|
docs = YAML::load(File.open(File.join(Blacklight.root, 'solr', 'sample_solr_documents.yml')))
|
|
17
|
-
Blacklight.
|
|
18
|
-
|
|
17
|
+
conn = Blacklight.default_index.connection
|
|
18
|
+
conn.add docs
|
|
19
|
+
conn.commit
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
namespace :solr do
|
|
24
|
+
task :seed do
|
|
25
|
+
Deprecation.warn Blacklight, "blacklight:solr:seed is deprecated; use blacklight:index:seed instead"
|
|
26
|
+
Rake::Task['blacklight:index:seed'].invoke
|
|
19
27
|
end
|
|
20
28
|
end
|
|
21
29
|
|
|
@@ -25,11 +33,12 @@ namespace :blacklight do
|
|
|
25
33
|
errors = 0
|
|
26
34
|
verbose = ENV.fetch('VERBOSE', false).present?
|
|
27
35
|
|
|
28
|
-
|
|
36
|
+
conn = Blacklight.default_index.connection
|
|
37
|
+
puts "[#{conn.uri}]"
|
|
29
38
|
|
|
30
39
|
print " - admin/ping: "
|
|
31
40
|
begin
|
|
32
|
-
response =
|
|
41
|
+
response = conn.send_and_receive 'admin/ping', {}
|
|
33
42
|
puts response['status']
|
|
34
43
|
errors += 1 unless response['status'] == "OK"
|
|
35
44
|
rescue Exception => e
|
|
@@ -91,11 +100,11 @@ namespace :blacklight do
|
|
|
91
100
|
puts e.to_s
|
|
92
101
|
end
|
|
93
102
|
|
|
94
|
-
print " -
|
|
103
|
+
print " - fetch: "
|
|
95
104
|
|
|
96
105
|
begin
|
|
97
106
|
doc_id = response.docs.first[SolrDocument.unique_key]
|
|
98
|
-
response, doc = controller.
|
|
107
|
+
response, doc = controller.fetch doc_id
|
|
99
108
|
|
|
100
109
|
if response.header['status'] == 0 and doc
|
|
101
110
|
puts "OK"
|
|
@@ -264,7 +264,7 @@ describe CatalogController do
|
|
|
264
264
|
@mock_response = double()
|
|
265
265
|
@mock_document = double()
|
|
266
266
|
allow(@mock_document).to receive_messages(:export_formats => {})
|
|
267
|
-
allow(controller).to receive_messages(:
|
|
267
|
+
allow(controller).to receive_messages(fetch: [@mock_response, @mock_document],
|
|
268
268
|
:get_previous_and_next_documents_for_search => [double(:total => 5), [double("a"), @mock_document, double("b")]])
|
|
269
269
|
|
|
270
270
|
current_search = Search.create(:query_params => { :q => ""})
|
|
@@ -313,7 +313,7 @@ describe CatalogController do
|
|
|
313
313
|
@mock_response = double()
|
|
314
314
|
@mock_document = double()
|
|
315
315
|
allow(@mock_document).to receive_messages(:export_formats => {})
|
|
316
|
-
allow(controller).to receive_messages(:
|
|
316
|
+
allow(controller).to receive_messages(fetch: [@mock_response, @mock_document])
|
|
317
317
|
get :show, :id => doc_id
|
|
318
318
|
expect(response).to render_template(:show)
|
|
319
319
|
end
|
|
@@ -416,8 +416,8 @@ describe CatalogController do
|
|
|
416
416
|
before do
|
|
417
417
|
allow(controller).to receive_messages(find: mock_response)
|
|
418
418
|
request.env["HTTP_REFERER"] = "/catalog/#{doc_id}"
|
|
419
|
-
SolrDocument.use_extension( Blacklight::
|
|
420
|
-
SolrDocument.use_extension( Blacklight::
|
|
419
|
+
SolrDocument.use_extension( Blacklight::Document::Email )
|
|
420
|
+
SolrDocument.use_extension( Blacklight::Document::Sms )
|
|
421
421
|
end
|
|
422
422
|
describe "email" do
|
|
423
423
|
it "should give error if no TO parameter" do
|
|
@@ -507,11 +507,9 @@ describe CatalogController do
|
|
|
507
507
|
end
|
|
508
508
|
|
|
509
509
|
it "should redirect the user to the root url for a bad search" do
|
|
510
|
-
|
|
511
|
-
res = {}
|
|
512
|
-
fake_error = RSolr::Error::Http.new(req, res)
|
|
510
|
+
fake_error = Blacklight::Exceptions::InvalidRequest.new
|
|
513
511
|
allow(Rails.env).to receive_messages(:test? => false)
|
|
514
|
-
allow(controller).to receive(:
|
|
512
|
+
allow(controller).to receive(:search_results) { |*args| raise fake_error }
|
|
515
513
|
expect(controller.logger).to receive(:error).with(fake_error)
|
|
516
514
|
get :index, :q=>"+"
|
|
517
515
|
|
|
@@ -520,17 +518,13 @@ describe CatalogController do
|
|
|
520
518
|
expect(response).to_not be_success
|
|
521
519
|
expect(response.status).to eq 302
|
|
522
520
|
end
|
|
523
|
-
it "should return status 500 if the catalog path is raising an exception" do
|
|
524
521
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
fake_error = RSolr::Error::Http.new(req, res)
|
|
522
|
+
it "should return status 500 if the catalog path is raising an exception" do
|
|
523
|
+
fake_error = Blacklight::Exceptions::InvalidRequest.new
|
|
528
524
|
allow(controller).to receive(:get_search_results) { |*args| raise fake_error }
|
|
529
525
|
allow(controller.flash).to receive(:sweep)
|
|
530
526
|
allow(controller).to receive(:flash).and_return(:notice => I18n.t('blacklight.search.errors.request_error'))
|
|
531
|
-
expect {
|
|
532
|
-
get :index, :q=>"+"
|
|
533
|
-
}.to raise_error
|
|
527
|
+
expect { get :index, q: "+" }.to raise_error
|
|
534
528
|
end
|
|
535
529
|
|
|
536
530
|
end
|
|
@@ -32,4 +32,12 @@ describe "Facets" do
|
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
end
|
|
35
|
+
describe '"More" links' do
|
|
36
|
+
it 'has default more link with sr-only text' do
|
|
37
|
+
visit root_path
|
|
38
|
+
within '#facet-language_facet' do
|
|
39
|
+
expect(page).to have_css 'li.more_facets_link', text: 'more Language'
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
35
43
|
end
|
|
@@ -114,7 +114,7 @@ describe BlacklightConfigurationHelper do
|
|
|
114
114
|
let(:document) { double }
|
|
115
115
|
it "should look up the label to display for the given document and field" do
|
|
116
116
|
allow(helper).to receive(:index_fields).and_return({ "my_field" => double(label: "some label") })
|
|
117
|
-
allow(helper).to receive(:
|
|
117
|
+
allow(helper).to receive(:field_label).with(:"blacklight.search.fields.index.my_field", :"blacklight.search.fields.my_field", "some label", "My field")
|
|
118
118
|
helper.index_field_label document, "my_field"
|
|
119
119
|
end
|
|
120
120
|
end
|
|
@@ -123,7 +123,7 @@ describe BlacklightConfigurationHelper do
|
|
|
123
123
|
let(:document) { double }
|
|
124
124
|
it "should look up the label to display for the given document and field" do
|
|
125
125
|
allow(helper).to receive(:document_show_fields).and_return({ "my_field" => double(label: "some label") })
|
|
126
|
-
allow(helper).to receive(:
|
|
126
|
+
allow(helper).to receive(:field_label).with(:"blacklight.search.fields.show.my_field", :"blacklight.search.fields.my_field", "some label", "My field")
|
|
127
127
|
helper.document_show_field_label document, "my_field"
|
|
128
128
|
end
|
|
129
129
|
end
|
|
@@ -132,15 +132,15 @@ describe BlacklightConfigurationHelper do
|
|
|
132
132
|
let(:document) { double }
|
|
133
133
|
it "should look up the label to display for the given document and field" do
|
|
134
134
|
allow(blacklight_config).to receive(:facet_fields).and_return({ "my_field" => double(label: "some label") })
|
|
135
|
-
allow(helper).to receive(:
|
|
135
|
+
allow(helper).to receive(:field_label).with(:"blacklight.search.fields.facet.my_field", :"blacklight.search.fields.my_field", "some label", "My field")
|
|
136
136
|
helper.facet_field_label "my_field"
|
|
137
137
|
end
|
|
138
138
|
end
|
|
139
139
|
|
|
140
|
-
describe "#
|
|
140
|
+
describe "#field_label" do
|
|
141
141
|
it "should look up the label as an i18n string" do
|
|
142
142
|
allow(helper).to receive(:t).with(:some_key, default: []).and_return "my label"
|
|
143
|
-
label = helper.
|
|
143
|
+
label = helper.field_label :some_key
|
|
144
144
|
|
|
145
145
|
expect(label).to eq "my label"
|
|
146
146
|
end
|
|
@@ -148,14 +148,7 @@ describe BlacklightConfigurationHelper do
|
|
|
148
148
|
it "should pass the provided i18n keys to I18n.t" do
|
|
149
149
|
allow(helper).to receive(:t).with(:key_a, default: [:key_b, "default text"])
|
|
150
150
|
|
|
151
|
-
label = helper.
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
it "should compact nil keys (fixes rails/rails#19419)" do
|
|
155
|
-
allow(helper).to receive(:t).with(:key_a, default: [:key_b])
|
|
156
|
-
|
|
157
|
-
label = helper.solr_field_label :key_a, nil, :key_b
|
|
158
|
-
|
|
151
|
+
label = helper.field_label :key_a, :key_b, "default text"
|
|
159
152
|
end
|
|
160
153
|
end
|
|
161
154
|
|
|
@@ -120,7 +120,7 @@ describe FacetsHelper do
|
|
|
120
120
|
it "should also work for facet query fields" do
|
|
121
121
|
facet_config = double(:query => {})
|
|
122
122
|
allow(helper).to receive(:facet_configuration_for_field).with('a_query_facet_field').and_return(facet_config)
|
|
123
|
-
allow(helper).to receive(:
|
|
123
|
+
allow(helper).to receive(:create_facet_field_response_for_query_facet_field).with('a_query_facet_field', facet_config)
|
|
124
124
|
|
|
125
125
|
helper.facet_by_field_name 'a_query_facet_field'
|
|
126
126
|
end
|
|
@@ -238,6 +238,7 @@ describe FacetsHelper do
|
|
|
238
238
|
allow(helper).to receive(:render).with(hash_including(:partial => 'facet_limit',
|
|
239
239
|
:locals => {
|
|
240
240
|
:solr_field => 'basic_field',
|
|
241
|
+
:field_name => 'basic_field',
|
|
241
242
|
:facet_field => helper.blacklight_config.facet_fields['basic_field'],
|
|
242
243
|
:display_facet => @mock_facet }
|
|
243
244
|
))
|
|
@@ -382,7 +383,7 @@ describe FacetsHelper do
|
|
|
382
383
|
|
|
383
384
|
describe "#facet_field_id" do
|
|
384
385
|
it "should be the parameterized version of the facet field" do
|
|
385
|
-
expect(helper.facet_field_id double(
|
|
386
|
+
expect(helper.facet_field_id double(key: 'some field')).to eq "facet-some-field"
|
|
386
387
|
end
|
|
387
388
|
end
|
|
388
389
|
end
|
|
@@ -84,14 +84,14 @@ describe "Blacklight::Configuration" do
|
|
|
84
84
|
expect(@config.facet_fields).to_not include(@mock_facet)
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
-
it "should not dup
|
|
88
|
-
@config.
|
|
89
|
-
@config.
|
|
87
|
+
it "should not dup response_model or document_model" do
|
|
88
|
+
@config.response_model = Blacklight::SolrResponse
|
|
89
|
+
@config.document_model = SolrDocument
|
|
90
90
|
|
|
91
91
|
config_copy = @config.inheritable_copy
|
|
92
92
|
|
|
93
|
-
expect(config_copy.
|
|
94
|
-
expect(config_copy.
|
|
93
|
+
expect(config_copy.response_model).to eq Blacklight::SolrResponse
|
|
94
|
+
expect(config_copy.document_model).to eq SolrDocument
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
it "should provide cloned copies of mutable data structures" do
|
|
@@ -213,25 +213,11 @@ describe "Blacklight::Configuration" do
|
|
|
213
213
|
"another_field_facet" => {},
|
|
214
214
|
"a_facet_field" => {},
|
|
215
215
|
})
|
|
216
|
-
expect { |b| @config.
|
|
217
|
-
expect(@config.facet_fields.keys).to eq ["some_field_facet", "another_field_facet"]
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
describe "if/unless conditions with legacy show parameter" do
|
|
221
|
-
it "should be hidden if the if condition is false" do
|
|
222
|
-
expect(@config.add_facet_field("hidden", if: false).if).to eq false
|
|
223
|
-
expect(@config.add_facet_field("hidden_with_legacy", if: false, show: true).if).to eq false
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
it "should be true if the if condition is true" do
|
|
227
|
-
expect(@config.add_facet_field("hidden", if: true).if).to eq true
|
|
228
|
-
expect(@config.add_facet_field("hidden_with_legacy", if: true, show: false).if).to eq true
|
|
229
|
-
end
|
|
216
|
+
expect { |b| @config.add_index_field "*_facet", &b }.to yield_control.twice
|
|
230
217
|
|
|
231
|
-
|
|
232
|
-
expect(@config.add_facet_field("hidden", show: true).if).to eq true
|
|
233
|
-
end
|
|
218
|
+
expect(@config.index_fields.keys).to eq ["some_field_facet", "another_field_facet"]
|
|
234
219
|
end
|
|
220
|
+
|
|
235
221
|
end
|
|
236
222
|
|
|
237
223
|
describe "add_index_field" do
|
|
@@ -275,6 +261,7 @@ describe "Blacklight::Configuration" do
|
|
|
275
261
|
|
|
276
262
|
expect(@config.index_fields.keys).to eq ["some_field_display", "another_field_display"]
|
|
277
263
|
end
|
|
264
|
+
|
|
278
265
|
end
|
|
279
266
|
|
|
280
267
|
describe "add_show_field" do
|
|
@@ -383,22 +370,8 @@ describe "Blacklight::Configuration" do
|
|
|
383
370
|
|
|
384
371
|
expect(@config.search_fields["author_name"].label).to eq "Author Name"
|
|
385
372
|
end
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
it "should be hidden if the if condition is false" do
|
|
389
|
-
expect(@config.add_search_field("hidden", if: false).if).to eq false
|
|
390
|
-
expect(@config.add_search_field("hidden_with_legacy", if: false, include_in_simple_search: true).if).to eq false
|
|
391
|
-
end
|
|
392
|
-
|
|
393
|
-
it "should be true if the if condition is true" do
|
|
394
|
-
expect(@config.add_search_field("hidden", if: true).if).to eq true
|
|
395
|
-
expect(@config.add_search_field("hidden_with_legacy", if: true, include_in_simple_search: false).if).to eq true
|
|
396
|
-
end
|
|
397
|
-
|
|
398
|
-
it "should be true if the if condition is missing" do
|
|
399
|
-
expect(@config.add_search_field("hidden", include_in_simple_search: true).if).to eq true
|
|
400
|
-
end
|
|
401
|
-
end
|
|
373
|
+
|
|
374
|
+
|
|
402
375
|
end
|
|
403
376
|
|
|
404
377
|
describe "add_sort_field" do
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe "Blacklight::
|
|
3
|
+
describe "Blacklight::Document::DublinCore" do
|
|
4
4
|
before(:all) do
|
|
5
5
|
@mock_class = Class.new do
|
|
6
|
-
include Blacklight::
|
|
6
|
+
include Blacklight::Document
|
|
7
7
|
end
|
|
8
|
-
@mock_class.use_extension( Blacklight::
|
|
8
|
+
@mock_class.use_extension( Blacklight::Document::DublinCore )
|
|
9
9
|
@mock_class.field_semantics.merge!(
|
|
10
10
|
:title => :title_display,
|
|
11
11
|
:non_dc_title => :title_display
|
|
@@ -15,7 +15,7 @@ describe "Blacklight::Solr::Document::DublinCore" do
|
|
|
15
15
|
|
|
16
16
|
it "should register all its export formats" do
|
|
17
17
|
document = @mock_class.new
|
|
18
|
-
expect(
|
|
18
|
+
expect(document.export_formats.keys).to include :oai_dc_xml, :dc_xml, :xml
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
it "should export oai_dc with the proper namespaces" do
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe "Blacklight::
|
|
3
|
+
describe "Blacklight::Document::Email" do
|
|
4
4
|
before(:all) do
|
|
5
|
-
SolrDocument.use_extension( Blacklight::
|
|
5
|
+
SolrDocument.use_extension( Blacklight::Document::Email )
|
|
6
6
|
end
|
|
7
7
|
it "should only return values that are available in the field semantics" do
|
|
8
8
|
doc = SolrDocument.new({:id=>"1234", :title_display=>"My Title"})
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe "Blacklight::
|
|
3
|
+
describe "Blacklight::Document::Email" do
|
|
4
4
|
before(:all) do
|
|
5
|
-
SolrDocument.use_extension( Blacklight::
|
|
5
|
+
SolrDocument.use_extension( Blacklight::Document::Sms )
|
|
6
6
|
end
|
|
7
7
|
it "should only return values that are available in the field semantics" do
|
|
8
8
|
doc = SolrDocument.new({:id=>"1234", :title_display=>"My Title", :author_display=>"Joe Schmoe"})
|