blacklight 3.0.0pre4 → 3.0.0pre6
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.
- data/VERSION +1 -1
- data/app/controllers/bookmarks_controller.rb +1 -1
- data/app/controllers/folder_controller.rb +1 -1
- data/app/helpers/blacklight_helper.rb +5 -4
- data/app/helpers/catalog_helper.rb +22 -18
- data/app/views/bookmarks/index.html.erb +1 -1
- data/app/views/catalog/_citation.html.erb +6 -1
- data/app/views/catalog/_results_pagination.html.erb +2 -7
- data/app/views/catalog/_sms_form.html.erb +1 -1
- data/app/views/catalog/index.html.erb +1 -1
- data/app/views/kaminari/blacklight/_first_page.html.erb +11 -0
- data/app/views/kaminari/blacklight/_gap.html.erb +8 -0
- data/app/views/kaminari/blacklight/_last_page.html.erb +11 -0
- data/app/views/kaminari/blacklight/_next_page.html.erb +11 -0
- data/app/views/kaminari/blacklight/_page.html.erb +12 -0
- data/app/views/kaminari/blacklight/_paginator.html.erb +23 -0
- data/app/views/kaminari/blacklight/_prev_page.html.erb +11 -0
- data/app/views/record_mailer/email_record.text.erb +5 -0
- data/app/views/record_mailer/sms_record.text.erb +4 -0
- data/blacklight.gemspec +4 -5
- data/config/locales/kaminari.yml +10 -0
- data/config/routes.rb +8 -46
- data/features/default_setup.feature +2 -1
- data/lib/blacklight.rb +5 -7
- data/lib/blacklight/catalog.rb +7 -24
- data/lib/blacklight/controller.rb +7 -1
- data/lib/blacklight/engine.rb +0 -11
- data/lib/blacklight/routes.rb +91 -0
- data/lib/blacklight/solr/document.rb +16 -1
- data/lib/blacklight/solr/document/marc_export.rb +174 -4
- data/lib/blacklight/solr_helper.rb +7 -2
- data/lib/generators/blacklight/blacklight_generator.rb +6 -0
- data/lib/generators/blacklight/templates/public/stylesheets/blacklight/blacklight.css +3 -3
- data/lib/railties/all_tests.rake +18 -6
- data/lib/railties/blacklight.rake +3 -2
- data/lib/railties/blacklight_cucumber.rake +1 -1
- data/lib/railties/blacklight_rspec.rake +1 -1
- data/lib/railties/solr_marc.rake +1 -1
- data/test_support/spec/controllers/application_controller_spec.rb +2 -2
- data/test_support/spec/controllers/catalog_controller_spec.rb +0 -24
- data/test_support/spec/helpers/blacklight_helper_spec.rb +4 -4
- data/test_support/spec/helpers/catalog_helper_spec.rb +22 -18
- data/test_support/spec/helpers/solr_helper_spec.rb +22 -5
- data/test_support/spec/lib/blacklight_solr_document_spec.rb +16 -9
- data/test_support/spec/lib/marc_export_spec.rb +308 -8
- data/test_support/spec/lib/tasks/solr_marc_task_spec.rb +1 -1
- data/test_support/spec/views/catalog/index.atom.builder_spec.rb +1 -1
- data/test_support/spec/views/catalog/show.html.erb_spec.rb +3 -3
- metadata +26 -18
- data/app/views/record_mailer/email_record.erb +0 -6
- data/app/views/record_mailer/sms_record.erb +0 -4
@@ -196,6 +196,8 @@ module Blacklight::SolrHelper
|
|
196
196
|
|
197
197
|
solr_parameters[:fq] ||= []
|
198
198
|
f_request_params.each_pair do |facet_field, value_list|
|
199
|
+
value_list ||= []
|
200
|
+
value_list = [value_list] unless value_list.respond_to? :each
|
199
201
|
value_list.each do |value|
|
200
202
|
solr_parameters[:fq] << "{!raw f=#{facet_field}}#{value}"
|
201
203
|
end
|
@@ -261,13 +263,12 @@ module Blacklight::SolrHelper
|
|
261
263
|
# just to be consistent with the other solr param methods:
|
262
264
|
{
|
263
265
|
:qt => :document,
|
264
|
-
:id => id
|
266
|
+
:id => id # this assumes the document request handler will map the 'id' param to the unique key field
|
265
267
|
}
|
266
268
|
end
|
267
269
|
|
268
270
|
# a solr query method
|
269
271
|
# retrieve a solr document, given the doc id
|
270
|
-
# TODO: shouldn't hardcode id field; should be setable to unique_key field in schema.xml
|
271
272
|
def get_solr_response_for_doc_id(id=nil, extra_controller_params={})
|
272
273
|
solr_response = Blacklight.solr.find solr_doc_params(id).merge(extra_controller_params)
|
273
274
|
raise Blacklight::Exceptions::InvalidSolrID.new if solr_response.docs.empty?
|
@@ -277,6 +278,8 @@ module Blacklight::SolrHelper
|
|
277
278
|
|
278
279
|
# given a field name and array of values, get the matching SOLR documents
|
279
280
|
def get_solr_response_for_field_values(field, values, extra_solr_params = {})
|
281
|
+
values ||= []
|
282
|
+
values = [values] unless values.respond_to? :each
|
280
283
|
value_str = "(\"" + values.to_a.join("\" OR \"") + "\")"
|
281
284
|
solr_params = {
|
282
285
|
:defType => "lucene", # need boolean for OR
|
@@ -368,6 +371,8 @@ module Blacklight::SolrHelper
|
|
368
371
|
def get_single_doc_via_search(index, request_params)
|
369
372
|
solr_params = solr_search_params(request_params)
|
370
373
|
solr_params[:start] = index - 1 # start at 0 to get 1st doc, 1 to get 2nd.
|
374
|
+
# FIXME: we must set page because of a bug posted here: https://github.com/mwmitchell/rsolr-ext/issues/16
|
375
|
+
solr_params[:page] = index - 1 # start at 0 to get 1st doc, 1 to get 2nd.
|
371
376
|
solr_params[:per_page] = 1
|
372
377
|
solr_params[:rows] = 1
|
373
378
|
solr_params[:fl] = '*'
|
@@ -22,6 +22,7 @@ This generator makes the following changes to your application:
|
|
22
22
|
9. Injects behavior into your user model
|
23
23
|
10. Creates a blacklight catalog controller in your /app/controllers directory
|
24
24
|
11. Creates a blacklight document in your /app/models directory
|
25
|
+
12. Adds Blacklight routes to your ./config/routes.rb
|
25
26
|
Thank you for Installing Blacklight.
|
26
27
|
"""
|
27
28
|
# Implement the required interface for Rails::Generators::Migration.
|
@@ -134,6 +135,11 @@ EOF
|
|
134
135
|
copy_file "catalog_controller.rb", "app/controllers/catalog_controller.rb"
|
135
136
|
end
|
136
137
|
|
138
|
+
def inject_blacklight_routes
|
139
|
+
route('root :to => "catalog#index"')
|
140
|
+
route('Blacklight.add_routes(self)')
|
141
|
+
end
|
142
|
+
|
137
143
|
private
|
138
144
|
|
139
145
|
def better_migration_template (file)
|
@@ -218,7 +218,7 @@ font-weight:bold;
|
|
218
218
|
text-align: center;
|
219
219
|
}
|
220
220
|
|
221
|
-
#startOverLink{display:block; position:absolute; top:50%; right:0.66em; margin-top:-12px; padding:0 7px 3px 12px; line-height:22px; text-decoration:none; color:#fff; background:url(
|
221
|
+
#startOverLink{display:block; position:absolute; top:50%; right:0.66em; margin-top:-12px; padding:0 7px 3px 12px; line-height:22px; text-decoration:none; color:#fff; background:url(../../images/blacklight/start_over.gif) no-repeat center center; border-bottom: none;}
|
222
222
|
|
223
223
|
|
224
224
|
#sortAndPerPage {
|
@@ -460,7 +460,7 @@ Search Parameters
|
|
460
460
|
top:0;
|
461
461
|
width:32px;
|
462
462
|
height:100%;
|
463
|
-
background:url(
|
463
|
+
background:url(../../images/blacklight/remove.gif) no-repeat center center;
|
464
464
|
border-left:1px solid #d0daea;
|
465
465
|
border-bottom: none;
|
466
466
|
text-indent:-99999px; /* text there for screen readers, hidden visually */
|
@@ -475,7 +475,7 @@ Search Parameters
|
|
475
475
|
.appliedFilter .queryName, .appliedFilter .filterName {
|
476
476
|
/* ">" image */
|
477
477
|
padding-right:14px;
|
478
|
-
background:url(
|
478
|
+
background:url(../../images/blacklight/separator.gif) no-repeat right center;
|
479
479
|
}
|
480
480
|
|
481
481
|
.filterValue {
|
data/lib/railties/all_tests.rake
CHANGED
@@ -1,11 +1,23 @@
|
|
1
1
|
namespace :blacklight do
|
2
|
-
|
3
|
-
|
2
|
+
begin
|
3
|
+
require 'cucumber/rake/task'
|
4
|
+
require 'rspec/core'
|
5
|
+
require 'rspec/core/rake_task'
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
desc "Run Blacklight cucumber and rspec, with test solr"
|
8
|
+
task :all_tests => ['blacklight:spec:with_solr', 'blacklight:cucumber:with_solr']
|
9
|
+
|
10
|
+
namespace :all_tests do
|
11
|
+
desc "Run Blacklight rspec and cucumber tests with rcov"
|
12
|
+
rm "blacklight-coverage.data" if File.exist?("blacklight-coverage.data")
|
13
|
+
task :rcov => ['blacklight:spec:rcov', 'blacklight:cucumber:rcov']
|
14
|
+
end
|
15
|
+
|
16
|
+
rescue LoadError
|
17
|
+
desc "Not available! (cucumber and rspec not avail)"
|
18
|
+
task :all_tests do
|
19
|
+
abort 'Not available. Both cucumber and rspec need to be installed to run blacklight:all_tests'
|
20
|
+
end
|
9
21
|
end
|
10
22
|
end
|
11
23
|
|
@@ -1,11 +1,12 @@
|
|
1
|
+
|
1
2
|
namespace :blacklight do
|
2
|
-
|
3
3
|
# task to clean out old, unsaved searches
|
4
4
|
# rake blacklight:delete_old_searches[days_old]
|
5
5
|
# example cron entry to delete searches older than 7 days at 2:00 AM every day:
|
6
6
|
# 0 2 * * * cd /path/to/your/app && /path/to/rake blacklight:delete_old_searches[7] RAILS_ENV=your_env
|
7
7
|
desc "Removes entries in the searches table that are older than the number of days given."
|
8
|
-
task :delete_old_searches, :days_old
|
8
|
+
task :delete_old_searches, [:days_old] => [:environment] do |t, args|
|
9
|
+
args.with_defaults(:days_old => 7)
|
9
10
|
Search.delete_old_searches(args[:days_old].to_i)
|
10
11
|
end
|
11
12
|
|
@@ -7,7 +7,7 @@
|
|
7
7
|
# Blacklight customization, trick Cucumber into looking in our current
|
8
8
|
# location for Rails.root, even though we're going to give it features
|
9
9
|
# from elsewhere.
|
10
|
-
ENV['RAILS_ROOT'] = Rails.root
|
10
|
+
ENV['RAILS_ROOT'] = Rails.root.to_s
|
11
11
|
|
12
12
|
# blacklight_features, where to find features inside blacklight source?
|
13
13
|
blacklight_features = File.expand_path("./test_support/features", Blacklight.root)
|
@@ -23,7 +23,7 @@ begin
|
|
23
23
|
# since we allow spec_dir to be in a remote location. spec_helper.rb
|
24
24
|
# needs it before Rails.root is defined there, even though we can
|
25
25
|
# oddly get it here, i dunno.
|
26
|
-
ENV['RAILS_ROOT'] = Rails.root
|
26
|
+
ENV['RAILS_ROOT'] = Rails.root.to_s
|
27
27
|
|
28
28
|
namespace :blacklight do
|
29
29
|
|
data/lib/railties/solr_marc.rake
CHANGED
@@ -9,11 +9,11 @@ describe ApplicationController do
|
|
9
9
|
controller.send(:default_html_head)
|
10
10
|
end
|
11
11
|
it "should setup js and css defaults" do
|
12
|
-
controller.javascript_includes.should include(["
|
12
|
+
controller.javascript_includes.should include(["jquery-1.4.2.min.js", "jquery-ui-1.8.1.custom.min.js", "blacklight/blacklight"])#find do |item|
|
13
13
|
# item == ["jquery-1.4.2.min.js", "jquery-ui-1.7.2.custom.min.js", "blacklight", "application", "accordion", "lightbox", {:plugin=>:blacklight}]
|
14
14
|
#end
|
15
15
|
|
16
|
-
controller.stylesheet_links.should include(["
|
16
|
+
controller.stylesheet_links.should include(["yui", "jquery/ui-lightness/jquery-ui-1.8.1.custom.css", "blacklight/blacklight", {:media=>"all"}])
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -20,18 +20,6 @@ describe CatalogController do
|
|
20
20
|
# RSpec <1.2.9: route_for(:controller => 'catalog', :action => 'show', :id => '666').should == '/catalog/666'
|
21
21
|
{ :get => "/catalog/666" }.should route_to(:controller => 'catalog', :action => 'show', :id => "666")
|
22
22
|
end
|
23
|
-
it "should map {:controller => 'catalog', :id = '444', :action => 'image'} to /catalog/444/image" do
|
24
|
-
# RSpec <1.2.9: route_for(:controller => 'catalog', :action => 'image', :id => '444').should == '/catalog/444/image'
|
25
|
-
{ :get => "/catalog/444/image" }.should route_to(:controller => "catalog", :action => "image", :id => "444")
|
26
|
-
end
|
27
|
-
it "should map {:controller => 'catalog', :id = '333', :action => 'status'} to /catalog/333/status" do
|
28
|
-
# RSpec <1.2.9: route_for(:controller => 'catalog', :action => 'status', :id => '333').should == '/catalog/333/status'
|
29
|
-
{ :get => "/catalog/333/status" }.should route_to(:controller => 'catalog', :action => 'status', :id => "333")
|
30
|
-
end
|
31
|
-
it "should map {:controller => 'catalog', :id => '222', :action => 'availability'} to /catalog/222/availability" do
|
32
|
-
# RSpec <1.2.9: route_for(:controller => 'catalog', :action => 'availability', :id => '222').should == '/catalog/222/availability'
|
33
|
-
{ :get => "/catalog/222/availability" }.should route_to(:controller => 'catalog', :action => 'availability', :id => "222")
|
34
|
-
end
|
35
23
|
it "should map {:controller => 'catalog', :id => '111', :action => 'librarian_view'} to /catalog/111/librarian_view" do
|
36
24
|
# RSpec <1.2.9: route_for(:controller => 'catalog', :action => 'librarian_view', :id => '111').should == '/catalog/111/librarian_view'
|
37
25
|
{ :get => "/catalog/111/librarian_view" }.should route_to(:controller => 'catalog', :action => 'librarian_view', :id => "111")
|
@@ -52,18 +40,6 @@ describe CatalogController do
|
|
52
40
|
#RSPEC <1.2.9 params_from(:get, '/catalog/666').should == {:controller => 'catalog', :action => 'show', :id => '666'}
|
53
41
|
{ :get => "/catalog/666" }.should route_to(:controller => 'catalog', :action => 'show', :id => "666")
|
54
42
|
end
|
55
|
-
it "should map /catalog/444/image to {:controller => 'catalog', :action => 'image', :id => 444}" do
|
56
|
-
# params_from(:get, '/catalog/444/image').should == {:controller => 'catalog', :action => 'image', :id => '444'}
|
57
|
-
{ :get => "/catalog/444/image" }.should route_to(:controller => 'catalog', :action => 'image', :id => "444")
|
58
|
-
end
|
59
|
-
it "should map /catalog/333/status to {:controller => 'catalog', :action => 'status', :id => 333}" do
|
60
|
-
#params_from(:get, '/catalog/333/status').should == {:controller => 'catalog', :action => 'status', :id => '333'}
|
61
|
-
{ :get => "/catalog/333/status" }.should route_to(:controller => 'catalog', :action => 'status', :id => "333")
|
62
|
-
end
|
63
|
-
it "should map /catalog/222/availability to {:controller => 'catalog', :action => 'availability', :id => 222}" do
|
64
|
-
# params_from(:get, '/catalog/222/availability').should == {:controller => 'catalog', :action => 'availability', :id => '222'}
|
65
|
-
{ :get => "/catalog/222/availability" }.should route_to(:controller => 'catalog', :action => 'availability', :id => "222")
|
66
|
-
end
|
67
43
|
it "should map /catalog/111/librarian_view to {:controller => 'catalog', :action => 'librarian_view', :id => 111}" do
|
68
44
|
# params_from(:get, '/catalog/111/librarian_view').should == {:controller => 'catalog', :action => 'librarian_view', :id => '111'}
|
69
45
|
{ :get => "/catalog/111/librarian_view" }.should route_to(:controller => 'catalog', :action => 'librarian_view', :id => "111")
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# -*- coding:
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
2
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
3
3
|
require 'marc'
|
4
4
|
def exportable_record
|
@@ -419,7 +419,7 @@ describe BlacklightHelper do
|
|
419
419
|
end
|
420
420
|
|
421
421
|
describe "render_link_rel_alternates" do
|
422
|
-
class
|
422
|
+
class MockDocumentAppHelper
|
423
423
|
include Blacklight::Solr::Document
|
424
424
|
end
|
425
425
|
module MockExtension
|
@@ -432,10 +432,10 @@ describe BlacklightHelper do
|
|
432
432
|
def export_as_weirder ; "weirder" ; end
|
433
433
|
def export_as_weird_dup ; "weird_dup" ; end
|
434
434
|
end
|
435
|
-
|
435
|
+
MockDocumentAppHelper.use_extension(MockExtension)
|
436
436
|
before(:each) do
|
437
437
|
@doc_id = "MOCK_ID1"
|
438
|
-
@document =
|
438
|
+
@document = MockDocumentAppHelper.new(:id => @doc_id)
|
439
439
|
render_params = {:controller => "controller", :action => "action"}
|
440
440
|
helper.stub!(:params).and_return(render_params)
|
441
441
|
end
|
@@ -2,65 +2,69 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
2
|
describe CatalogHelper do
|
3
3
|
include CatalogHelper
|
4
4
|
|
5
|
-
def
|
5
|
+
def mock_response args
|
6
6
|
current_page = args[:current_page] || 1
|
7
7
|
per_page = args[:per_page] || 10
|
8
8
|
total = args[:total]
|
9
|
-
|
9
|
+
start = (current_page - 1) * per_page
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
mock_response = mock("RSolr::Ext::Response")
|
12
|
+
mock_response.stub!(:total).and_return(total)
|
13
|
+
mock_response.stub!(:rows).and_return(per_page)
|
14
|
+
mock_response.stub!(:start).and_return(start)
|
15
|
+
mock_response.stub!(:docs).and_return((1..total).to_a.slice(start, per_page))
|
16
|
+
|
17
|
+
mock_response
|
14
18
|
end
|
15
19
|
|
16
|
-
describe "
|
20
|
+
describe "render_pagination_info" do
|
17
21
|
before(:all) do
|
18
22
|
end
|
19
23
|
|
20
24
|
it "with no results" do
|
21
|
-
@
|
25
|
+
@response = mock_response :total => 0
|
22
26
|
|
23
|
-
html =
|
27
|
+
html = render_pagination_info(@response, { :entry_name => 'entry_name' })
|
24
28
|
html.should == "No entry_names found"
|
25
29
|
html.html_safe?.should == true
|
26
30
|
end
|
27
31
|
|
28
32
|
it "with a single result" do
|
29
|
-
@
|
33
|
+
@response = mock_response :total => 1
|
30
34
|
|
31
|
-
html =
|
35
|
+
html = render_pagination_info(@response, { :entry_name => 'entry_name' })
|
32
36
|
html.should == "Displaying <b>1</b> entry_name"
|
33
37
|
html.html_safe?.should == true
|
34
38
|
end
|
35
39
|
|
36
40
|
it "with a single page of results" do
|
37
|
-
@
|
41
|
+
@response = mock_response :total => 7
|
38
42
|
|
39
|
-
html =
|
43
|
+
html = render_pagination_info(@response, { :entry_name => 'entry_name' })
|
40
44
|
html.should == "Displaying <b>all 7</b> entry_names"
|
41
45
|
html.html_safe?.should == true
|
42
46
|
end
|
43
47
|
|
44
48
|
it "on the first page of multiple pages of results" do
|
45
|
-
@
|
49
|
+
@response = mock_response :total => 15, :per_page => 10
|
46
50
|
|
47
|
-
html =
|
51
|
+
html = render_pagination_info(@response, { :entry_name => 'entry_name' })
|
48
52
|
html.should == "Displaying entry_names <b>1 - 10</b> of <b>15</b>"
|
49
53
|
html.html_safe?.should == true
|
50
54
|
end
|
51
55
|
|
52
56
|
it "on the second page of multiple pages of results" do
|
53
|
-
@
|
57
|
+
@response = mock_response :total => 47, :per_page => 10, :current_page => 2
|
54
58
|
|
55
|
-
html =
|
59
|
+
html = render_pagination_info(@response, { :entry_name => 'entry_name' })
|
56
60
|
html.should == "Displaying entry_names <b>11 - 20</b> of <b>47</b>"
|
57
61
|
html.html_safe?.should == true
|
58
62
|
end
|
59
63
|
|
60
64
|
it "on the last page of results" do
|
61
|
-
@
|
65
|
+
@response = mock_response :total => 47, :per_page => 10, :current_page => 5
|
62
66
|
|
63
|
-
html =
|
67
|
+
html = render_pagination_info(@response, { :entry_name => 'entry_name' })
|
64
68
|
html.should == "Displaying entry_names <b>41 - 47</b> of <b>47</b>"
|
65
69
|
html.html_safe?.should == true
|
66
70
|
end
|
@@ -151,6 +151,8 @@ describe 'Blacklight::SolrHelper' do
|
|
151
151
|
params = @solr_helper.solr_search_params(:f => @multi_facets)
|
152
152
|
|
153
153
|
@multi_facets.each_pair do |facet_field, value_list|
|
154
|
+
value_list ||= []
|
155
|
+
value_list = [value_list] unless value_list.respond_to? :each
|
154
156
|
value_list.each do |value|
|
155
157
|
params[:fq].should include("{!raw f=#{facet_field}}#{value}" )
|
156
158
|
end
|
@@ -164,6 +166,8 @@ describe 'Blacklight::SolrHelper' do
|
|
164
166
|
params = @solr_helper.solr_search_params(:q => @mult_word_query, :f => @multi_facets)
|
165
167
|
|
166
168
|
@multi_facets.each_pair do |facet_field, value_list|
|
169
|
+
value_list ||= []
|
170
|
+
value_list = [value_list] unless value_list.respond_to? :each
|
167
171
|
value_list.each do |value|
|
168
172
|
params[:fq].should include("{!raw f=#{facet_field}}#{value}" )
|
169
173
|
end
|
@@ -686,7 +690,7 @@ describe 'Blacklight::SolrHelper' do
|
|
686
690
|
@response2.docs.size.should == 1
|
687
691
|
end
|
688
692
|
it 'should have the expected value in the id field' do
|
689
|
-
@document.
|
693
|
+
@document.id.should == @doc_id
|
690
694
|
end
|
691
695
|
it 'should have non-nil values for required fields set in initializer' do
|
692
696
|
@document.get(Blacklight.config[:show][:html_title]).should_not == nil
|
@@ -699,9 +703,22 @@ describe 'Blacklight::SolrHelper' do
|
|
699
703
|
Blacklight.config[:show_fields][:field_names].length.should > 0
|
700
704
|
Blacklight.config[:show_fields][:field_names][0].should_not == nil
|
701
705
|
end
|
706
|
+
end
|
702
707
|
|
703
|
-
|
704
|
-
|
708
|
+
describe "Get Document by custom unique id" do
|
709
|
+
=begin
|
710
|
+
# Can't test this properly without updating the "document" request handler in solr
|
711
|
+
it "should respect the configuration-supplied unique id" do
|
712
|
+
SolrDocument.should_receive(:unique_key).and_return("title_display")
|
713
|
+
@response, @document = @solr_helper.get_solr_response_for_doc_id('"Strong Medicine speaks"')
|
714
|
+
@document.id.should == '"Strong Medicine speaks"'
|
715
|
+
@document.get(:id).should == 2007020969
|
716
|
+
end
|
717
|
+
=end
|
718
|
+
it "should respect the configuration-supplied unique id" do
|
719
|
+
doc_params = @solr_helper.solr_doc_params('"Strong Medicine speaks"')
|
720
|
+
doc_params[:id].should == '"Strong Medicine speaks"'
|
721
|
+
end
|
705
722
|
end
|
706
723
|
|
707
724
|
# NOTE: some of these repeated fields could be in a shared behavior, but the
|
@@ -731,7 +748,7 @@ describe 'Blacklight::SolrHelper' do
|
|
731
748
|
=end
|
732
749
|
|
733
750
|
it 'should have a doc id field' do
|
734
|
-
@doc.
|
751
|
+
@doc.id.should_not == nil
|
735
752
|
end
|
736
753
|
|
737
754
|
it 'should have non-nil values for required fields set in initializer' do
|
@@ -742,7 +759,7 @@ describe 'Blacklight::SolrHelper' do
|
|
742
759
|
|
743
760
|
it "should limit search result by facets when supplied" do
|
744
761
|
doc2 = @solr_helper.get_single_doc_via_search(@doc_row , :q => @all_docs_query, :f => @multi_facets)
|
745
|
-
doc2.
|
762
|
+
doc2.id.should_not == nil
|
746
763
|
end
|
747
764
|
|
748
765
|
end
|
@@ -18,6 +18,13 @@ describe "Blacklight::Solr::Document" do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
context "Unique Key" do
|
22
|
+
it "should use a configuration-defined document unique key" do
|
23
|
+
MockDocument.should_receive(:unique_key).and_return(:my_unique_key)
|
24
|
+
@document = MockDocument.new :id => 'asdf', :my_unique_key => '1234'
|
25
|
+
@document.id.should == '1234'
|
26
|
+
end
|
27
|
+
end
|
21
28
|
|
22
29
|
context "Extendability" do
|
23
30
|
before(:each) do
|
@@ -27,7 +34,7 @@ describe "Blacklight::Solr::Document" do
|
|
27
34
|
|
28
35
|
it "should let you register an extension" do
|
29
36
|
MockDocument.use_extension(MockExtension) { |doc| true }
|
30
|
-
|
37
|
+
|
31
38
|
MockDocument.registered_extensions.find {|a| a[:module_obj] == MockExtension}.should_not be_nil
|
32
39
|
end
|
33
40
|
it "should let you register an extension with a nil condition proc" do
|
@@ -37,39 +44,39 @@ describe "Blacklight::Solr::Document" do
|
|
37
44
|
it "should apply an extension whose condition is met" do
|
38
45
|
MockDocument.use_extension(MockExtension) {|doc| true}
|
39
46
|
doc = MockDocument.new()
|
40
|
-
|
41
|
-
doc.methods.find {|name| name =="my_extension_method"}.should_not be_nil
|
42
|
-
doc.my_extension_method.should == "my_extension_results"
|
47
|
+
|
48
|
+
doc.methods.find {|name| name.to_s == "my_extension_method"}.should_not be_nil
|
49
|
+
doc.my_extension_method.to_s.should == "my_extension_results"
|
43
50
|
end
|
44
51
|
it "should apply an extension based on a Solr field" do
|
45
52
|
MockDocument.use_extension(MockExtension) {|doc| doc.key?(:required_key)}
|
46
53
|
|
47
54
|
with_extension = MockDocument.new(:required_key => "value")
|
48
|
-
with_extension.my_extension_method.should == "my_extension_results"
|
55
|
+
with_extension.my_extension_method.to_s.should == "my_extension_results"
|
49
56
|
|
50
57
|
without_extension = MockDocument.new(:other_key => "value")
|
51
|
-
without_extension.methods.find {|name| name == "my_extension_method"}.should be_nil
|
58
|
+
without_extension.methods.find {|name| name.to_s == "my_extension_method"}.should be_nil
|
52
59
|
|
53
60
|
end
|
54
61
|
it "should not apply an extension whose condition is not met" do
|
55
62
|
MockDocument.use_extension(MockExtension) {|doc| false}
|
56
63
|
doc = MockDocument.new()
|
57
64
|
|
58
|
-
doc.methods.find {|name| name == "my_extension_method"}.should be_nil
|
65
|
+
doc.methods.find {|name| name.to_s == "my_extension_method"}.should be_nil
|
59
66
|
end
|
60
67
|
it "should treat a nil condition as always applyable" do
|
61
68
|
MockDocument.use_extension(MockExtension)
|
62
69
|
|
63
70
|
doc = MockDocument.new()
|
64
71
|
|
65
|
-
doc.methods.find {|name | name=="my_extension_method"}.should_not be_nil
|
72
|
+
doc.methods.find {|name | name.to_s =="my_extension_method"}.should_not be_nil
|
66
73
|
doc.my_extension_method.should == "my_extension_results"
|
67
74
|
end
|
68
75
|
it "should let last extension applied override earlier extensions" do
|
69
76
|
MockDocument.use_extension(MockExtension)
|
70
77
|
MockDocument.use_extension(MockSecondExtension)
|
71
78
|
|
72
|
-
MockDocument.new().my_extension_method.should == "override"
|
79
|
+
MockDocument.new().my_extension_method.to_s.should == "override"
|
73
80
|
end
|
74
81
|
|
75
82
|
describe "extension_parameters class-level hash" do
|