blacklight 4.0.1 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +6 -6
  2. checksums.yaml.gz.sig +2 -0
  3. data.tar.gz.sig +0 -0
  4. data/.gitignore +1 -0
  5. data/.travis.yml +14 -6
  6. data/Gemfile +2 -3
  7. data/README.md +3 -1
  8. data/VERSION +1 -1
  9. data/app/assets/stylesheets/blacklight/_blacklight_base.css.scss +1 -0
  10. data/app/assets/stylesheets/blacklight/_dropdown.css.scss +2 -1
  11. data/app/assets/stylesheets/blacklight/_search_history.css.scss +1 -1
  12. data/app/assets/stylesheets/blacklight/blacklight.css.scss +2 -0
  13. data/app/assets/stylesheets/improved-modal/bootstrap-modal.css +2 -0
  14. data/app/helpers/blacklight/blacklight_helper_behavior.rb +199 -48
  15. data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -1
  16. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -1
  17. data/app/views/catalog/_document_header.html.erb +1 -1
  18. data/app/views/catalog/_index_default.html.erb +3 -3
  19. data/app/views/catalog/_per_page_widget.html.erb +1 -1
  20. data/app/views/catalog/_show_default.html.erb +3 -3
  21. data/app/views/catalog/_sort_widget.html.erb +1 -1
  22. data/app/views/catalog/show.html.erb +29 -32
  23. data/app/views/layouts/blacklight.html.erb +1 -1
  24. data/blacklight.gemspec +1 -1
  25. data/config/locales/blacklight.fr.yml +236 -0
  26. data/gemfiles/rails3.gemfile +9 -0
  27. data/gemfiles/rails4.gemfile +10 -0
  28. data/lib/blacklight/catalog.rb +22 -10
  29. data/lib/blacklight/configurable.rb +2 -3
  30. data/lib/blacklight/configuration/fields.rb +5 -4
  31. data/lib/blacklight/mash.rb +7 -139
  32. data/lib/blacklight/routes.rb +19 -18
  33. data/lib/blacklight/solr_helper.rb +14 -11
  34. data/lib/blacklight/solr_response.rb +1 -1
  35. data/lib/generators/blacklight/blacklight_generator.rb +9 -1
  36. data/lib/generators/blacklight/test_support_generator.rb +15 -0
  37. data/test_support/bin/setup-test-app.sh +8 -12
  38. data/test_support/bin/test.sh +20 -24
  39. data/test_support/features/search.feature +0 -3
  40. data/test_support/features/search_pagination.feature +53 -0
  41. data/test_support/features/step_definitions/search_pagination_steps.rb +29 -0
  42. data/test_support/features/step_definitions/search_steps.rb +0 -11
  43. data/test_support/spec/controllers/catalog_controller_spec.rb +15 -80
  44. data/test_support/spec/helpers/blacklight_helper_spec.rb +75 -22
  45. data/test_support/spec/helpers/catalog_helper_spec.rb +8 -1
  46. data/test_support/spec/helpers/html_head_helper_spec.rb +21 -7
  47. data/test_support/spec/lib/blacklight_configurable_spec.rb +18 -4
  48. data/test_support/spec/lib/blacklight_configuration_spec.rb +28 -0
  49. data/test_support/spec/lib/solr_helper_spec.rb +14 -4
  50. data/test_support/spec/routing/catalog_routing_spec.rb +67 -0
  51. data/test_support/spec/views/catalog/index.atom.builder_spec.rb +3 -7
  52. metadata +42 -15
  53. metadata.gz.sig +0 -0
@@ -80,6 +80,34 @@ describe "Blacklight::Configuration" do
80
80
  @config.facet_fields.should_not include(@mock_facet)
81
81
  end
82
82
  end
83
+
84
+ describe "add alternative solr fields" do
85
+ it "should let you define any arbitrary solr field" do
86
+ Blacklight::Configuration.define_field_access :my_custom_field
87
+
88
+ config = Blacklight::Configuration.new do |config|
89
+ config.add_my_custom_field 'qwerty', :label => "asdf"
90
+ end
91
+
92
+
93
+
94
+ config.my_custom_fields.keys.should include('qwerty')
95
+ end
96
+
97
+ it "should let you define a field accessor that uses an existing field-type" do
98
+
99
+ Blacklight::Configuration.define_field_access :my_custom_facet_field, :class => Blacklight::Configuration::FacetField
100
+
101
+ config = Blacklight::Configuration.new do |config|
102
+ config.add_my_custom_facet_field 'qwerty', :label => "asdf"
103
+ end
104
+
105
+
106
+
107
+ config.my_custom_facet_fields['qwerty'].should be_a_kind_of(Blacklight::Configuration::FacetField)
108
+ end
109
+
110
+ end
83
111
 
84
112
  describe "add_facet_field" do
85
113
  it "should accept field name and hash form arg" do
@@ -31,6 +31,10 @@ describe 'Blacklight::SolrHelper' do
31
31
  @config = config
32
32
  end
33
33
 
34
+ def blacklight_solr
35
+ Blacklight.solr
36
+ end
37
+
34
38
  include Blacklight::SolrHelper
35
39
 
36
40
  before(:each) do
@@ -547,11 +551,9 @@ describe 'Blacklight::SolrHelper' do
547
551
 
548
552
  it "should use the configured request handler " do
549
553
  blacklight_config.stub(:solr_request_handler => 'custom_request_handler')
550
- Blacklight.solr.should_receive(:paginate) do |page, rows, path, params|
551
- page.should == 1
552
- rows.should == 10
554
+ Blacklight.solr.should_receive(:send_and_receive) do |path, params|
553
555
  path.should == 'select'
554
- params[:params].should include(:qt=>"custom_request_handler", :q=>"", "spellcheck.q"=>"", :"facet.field"=>["format", "{!ex=pub_date_single}pub_date", "subject_topic_facet", "language_facet", "lc_1letter_facet", "subject_geo_facet", "subject_era_facet"], :"facet.query"=>["pub_date:[2007 TO *]", "pub_date:[2002 TO *]", "pub_date:[1987 TO *]"], :"f.subject_topic_facet.facet.limit"=>21, :sort=>"score desc, pub_date_sort desc, title_sort asc")
556
+ params[:params].should include(:start => 0, :rows => 10, :qt=>"custom_request_handler", :q=>"", "spellcheck.q"=>"", :"facet.field"=>["format", "{!ex=pub_date_single}pub_date", "subject_topic_facet", "language_facet", "lc_1letter_facet", "subject_geo_facet", "subject_era_facet"], :"facet.query"=>["pub_date:[2007 TO *]", "pub_date:[2002 TO *]", "pub_date:[1987 TO *]"], :"f.subject_topic_facet.facet.limit"=>21, :sort=>"score desc, pub_date_sort desc, title_sort asc")
555
557
  end.and_return({'response'=>{'docs'=>[]}})
556
558
  get_search_results(:q => @all_docs_query)
557
559
  end
@@ -579,6 +581,7 @@ describe 'Blacklight::SolrHelper' do
579
581
  solr_response = query_solr(:q => @single_word_query)
580
582
  solr_response.docs.size.should > 0
581
583
  end
584
+
582
585
  end
583
586
 
584
587
  describe 'for All Docs Query, No Facets' do
@@ -749,6 +752,13 @@ describe 'Blacklight::SolrHelper' do
749
752
  solr_response1.docs.size.should == num_results
750
753
  end
751
754
 
755
+ it 'should get number of rows requested' do
756
+ num_results = 4 # non-default value
757
+ (solr_response1, document_list1) = get_search_results(:q => @all_docs_query, :rows => num_results)
758
+ solr_response1.docs.size.should == document_list1.size
759
+ solr_response1.docs.size.should == num_results
760
+ end
761
+
752
762
  it 'should skip appropriate number of results when requested - default per page' do
753
763
  page = 3
754
764
  (solr_response2, document_list2) = get_search_results(:q => @all_docs_query, :page => page)
@@ -0,0 +1,67 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe "Routing" do
4
+ describe "Paths Generated by Custom Routes:" do
5
+ # paths generated by custom routes
6
+ it "should map {:controller => 'catalog', :action => 'email'} to /catalog/email" do
7
+ { :get => "/catalog/email" }.should route_to(:controller => 'catalog', :action => 'email')
8
+
9
+ end
10
+ it "should map {:controller => 'catalog', :action => 'sms'} to /catalog/sms" do
11
+ { :get => "/catalog/sms" }.should route_to(:controller => 'catalog', :action => 'sms')
12
+ end
13
+ it "should map { :controller => 'catalog', :action => 'show', :id => 666 } to /catalog/666" do
14
+ { :get => "/catalog/666" }.should route_to(:controller => 'catalog', :action => 'show', :id => "666")
15
+ end
16
+ it "should map {:controller => 'catalog', :id => '111', :action => 'librarian_view'} to /catalog/111/librarian_view" do
17
+ { :get => "/catalog/111/librarian_view" }.should route_to(:controller => 'catalog', :action => 'librarian_view', :id => "111")
18
+ end
19
+ end
20
+
21
+ # parameters generated from routes
22
+ describe "Parameters Generated from Routes:" do
23
+ it "should map /catalog/email to {:controller => 'catalog', :action => 'email'}" do
24
+ { :get => "/catalog/email" }.should route_to(:controller => 'catalog', :action => 'email')
25
+ end
26
+ it "should map /catalog/sms to {:controller => 'catalog', :action => 'sms'}" do
27
+ { :get => "/catalog/sms" }.should route_to(:controller => 'catalog', :action => 'sms')
28
+ end
29
+ it "should map /catalog/666 to {:controller => 'catalog', :action => 'show', :id => 666}" do
30
+ { :get => "/catalog/666" }.should route_to(:controller => 'catalog', :action => 'show', :id => "666")
31
+ end
32
+ it "should map /catalog/111/librarian_view to {:controller => 'catalog', :action => 'librarian_view', :id => 111}" do
33
+ { :get => "/catalog/111/librarian_view" }.should route_to(:controller => 'catalog', :action => 'librarian_view', :id => "111")
34
+ end
35
+ end
36
+
37
+ describe "catalog_path for SolrDocument", :test => true do
38
+ it "should route correctly" do
39
+ { :get => catalog_path(SolrDocument.new(:id => 'asdf')) }.should route_to(:controller => 'catalog', :action => 'show', :id => 'asdf')
40
+ end
41
+
42
+ context "should escape solr document ids" do
43
+
44
+ it "should pass-through url-valid ids" do
45
+ { :get => catalog_path(SolrDocument.new(:id => 'qwerty'))}.should route_to(:controller => 'catalog', :action => 'show', :id => 'qwerty')
46
+ end
47
+
48
+ it "should route url-like ids" do
49
+ pending "This works if you configure your routing to have very liberal constraints on :id.. not sure how to go about testing it though"
50
+ { :get => catalog_path(SolrDocument.new(:id => 'http://example.com'))}.should route_to(:controller => 'catalog', :action => 'show', :id => 'http://example.com')
51
+ end
52
+
53
+ it "should route ids with whitespace" do
54
+ { :get => catalog_path(SolrDocument.new(:id => 'mm 123')) }.should route_to(:controller => 'catalog', :action => 'show', :id => 'mm 123')
55
+ end
56
+
57
+ it "should route ids with a literal '+'" do
58
+ { :get => catalog_path(SolrDocument.new(:id => 'this+that')) }.should route_to(:controller => 'catalog', :action => 'show', :id => 'this+that')
59
+ end
60
+
61
+ it "should route ids with a literal '/" do
62
+ pending "This works if you configure your routing to have very liberal constraints on :id.. not sure how to go about testing it though"
63
+ { :get => catalog_path(SolrDocument.new(:id => 'and/or')) }.should route_to(:controller => 'catalog', :action => 'show', :id => 'and/or')
64
+ end
65
+ end
66
+ end
67
+ end
@@ -19,8 +19,8 @@ describe "catalog/index" do
19
19
  @response, @document_list = c.get_search_results(@params)
20
20
 
21
21
  # munge the solr response to match test expectations
22
- @document_list[1] = SolrDocument.new(@document_list[1].to_mash.reject! { |k,v| k == "author_display" })
23
- @document_list[5] = SolrDocument.new(@document_list[1].to_mash.reject! { |k,v| k == "marc_display" })
22
+ @document_list[1] = SolrDocument.new(@document_list[1].with_indifferent_access.reject! { |k,v| k == "author_display" })
23
+ @document_list[5] = SolrDocument.new(@document_list[1].with_indifferent_access.reject! { |k,v| k == "marc_display" })
24
24
  end
25
25
  before(:each) do
26
26
  # Not sure what Assigns was doing here ... dhf
@@ -33,11 +33,7 @@ describe "catalog/index" do
33
33
  view.stub!(:blacklight_config).and_return(@config)
34
34
  view.stub!(:search_field_options_for_select).and_return([])
35
35
 
36
- if Rails.version >= "3.2.0"
37
- render :template => 'catalog/index', :formats => [:atom]
38
- else
39
- render :template => 'catalog/index.atom'
40
- end
36
+ render :template => 'catalog/index', :formats => [:atom]
41
37
 
42
38
  # We need to use rexml to test certain things that have_tag wont' test
43
39
  # note that response is depricated rails 3, use "redered" instead.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Rochkind
@@ -15,21 +15,43 @@ authors:
15
15
  - Naomi Dushay
16
16
  autorequire:
17
17
  bindir: bin
18
- cert_chain: []
19
- date: 2012-12-11 00:00:00.000000000 Z
18
+ cert_chain:
19
+ - |
20
+ -----BEGIN CERTIFICATE-----
21
+ MIIDaDCCAlCgAwIBAgIBATANBgkqhkiG9w0BAQUFADA9MQ4wDAYDVQQDDAVjaHJp
22
+ czEVMBMGCgmSJomT8ixkARkWBWNiZWVyMRQwEgYKCZImiZPyLGQBGRYEaW5mbzAe
23
+ Fw0xMzAzMDcwNDI1MzRaFw0xNDAzMDcwNDI1MzRaMD0xDjAMBgNVBAMMBWNocmlz
24
+ MRUwEwYKCZImiZPyLGQBGRYFY2JlZXIxFDASBgoJkiaJk/IsZAEZFgRpbmZvMIIB
25
+ IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2UC2Jw9BQ7bNTyVHaxGKbCqV
26
+ H+BggkU9CWOBB8YA7j2ebcAjRlj6AemKWHB0fPEi9qmGaE1bMbus8IJbFcjkZNqG
27
+ 6yHVdOq9tacSH4iiEdH3QioWSte0zY7vwD9u92QLaNzUAm9yjIYF6ZDNM/dl25Hb
28
+ UYDURJXfLOKe3AivodRujsHRxDLFpS6FjdmwB9m8N2JBs/uOrUULB48aaa36pWWE
29
+ w4rhqT9kOpZl8BRdE/pTrePlQGDZ8Oe74gVWJth4lavtMaPP+UqHigmlnFvWO9+D
30
+ a+9q1qwvQ3ySYRJIACIsYaY6rlhZ6i+PGKhbCnG6at6bC9TVu2JfKbC/LBP9mwID
31
+ AQABo3MwcTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU61dLp5FY
32
+ qfqrGhr0V8WPGwAIEKQwGwYDVR0RBBQwEoEQY2hyaXNAY2JlZXIuaW5mbzAbBgNV
33
+ HRIEFDASgRBjaHJpc0BjYmVlci5pbmZvMA0GCSqGSIb3DQEBBQUAA4IBAQBuQW5N
34
+ 6NaEla5fJftOPCecLSB5z8oS+fAO8LbfcUqHSo+y/1ZkN8kF8Y1SaoqPpqxuOZ4g
35
+ zX+X6k0gJHLKHTNufTaLhORd66Tp1raoW2qqKEcoshOcoQyw/mh9KYLVaQEX8US8
36
+ 0yZ9dRMWFtRjwvkvueNMzLZidH+GsaDq/bxR9/9PAv+4RxQRYw+nrAglf2DxINSI
37
+ o8CdBnIKvzS1JRgM172NHIwScyJdDFWxfBh1CTG9VRXTwQfyQmM0h1GThWYcdNw7
38
+ W4KPvarE4dgxT4TXIIKkh/K/Z9yaYt73biInVukEI9H2HHWkuAyblxg1jcR/zy+w
39
+ K27NJ2vhSpx2PPhb
40
+ -----END CERTIFICATE-----
41
+ date: 2013-03-07 00:00:00.000000000 Z
20
42
  dependencies:
21
43
  - !ruby/object:Gem::Dependency
22
44
  name: rails
23
45
  requirement: !ruby/object:Gem::Requirement
24
46
  requirements:
25
- - - ~>
47
+ - - '>='
26
48
  - !ruby/object:Gem::Version
27
49
  version: '3.2'
28
50
  type: :runtime
29
51
  prerelease: false
30
52
  version_requirements: !ruby/object:Gem::Requirement
31
53
  requirements:
32
- - - ~>
54
+ - - '>='
33
55
  - !ruby/object:Gem::Version
34
56
  version: '3.2'
35
57
  - !ruby/object:Gem::Dependency
@@ -50,7 +72,7 @@ dependencies:
50
72
  name: marc
51
73
  requirement: !ruby/object:Gem::Requirement
52
74
  requirements:
53
- - - ! '>='
75
+ - - '>='
54
76
  - !ruby/object:Gem::Version
55
77
  version: 0.4.3
56
78
  - - <
@@ -60,7 +82,7 @@ dependencies:
60
82
  prerelease: false
61
83
  version_requirements: !ruby/object:Gem::Requirement
62
84
  requirements:
63
- - - ! '>='
85
+ - - '>='
64
86
  - !ruby/object:Gem::Version
65
87
  version: 0.4.3
66
88
  - - <
@@ -98,14 +120,14 @@ dependencies:
98
120
  name: sass-rails
99
121
  requirement: !ruby/object:Gem::Requirement
100
122
  requirements:
101
- - - ! '>='
123
+ - - '>='
102
124
  - !ruby/object:Gem::Version
103
125
  version: '0'
104
126
  type: :runtime
105
127
  prerelease: false
106
128
  version_requirements: !ruby/object:Gem::Requirement
107
129
  requirements:
108
- - - ! '>='
130
+ - - '>='
109
131
  - !ruby/object:Gem::Version
110
132
  version: '0'
111
133
  - !ruby/object:Gem::Dependency
@@ -126,14 +148,14 @@ dependencies:
126
148
  name: jettywrapper
127
149
  requirement: !ruby/object:Gem::Requirement
128
150
  requirements:
129
- - - ! '>='
151
+ - - '>='
130
152
  - !ruby/object:Gem::Version
131
153
  version: 1.2.0
132
154
  type: :development
133
155
  prerelease: false
134
156
  version_requirements: !ruby/object:Gem::Requirement
135
157
  requirements:
136
- - - ! '>='
158
+ - - '>='
137
159
  - !ruby/object:Gem::Version
138
160
  version: 1.2.0
139
161
  description: Blacklight is an open source Solr user interface discovery platform.
@@ -291,7 +313,10 @@ files:
291
313
  - app/views/shared/_header_navbar.html.erb
292
314
  - blacklight.gemspec
293
315
  - config/locales/blacklight.en.yml
316
+ - config/locales/blacklight.fr.yml
294
317
  - config/routes.rb
318
+ - gemfiles/rails3.gemfile
319
+ - gemfiles/rails4.gemfile
295
320
  - lib/SolrMarc.jar
296
321
  - lib/blacklight.rb
297
322
  - lib/blacklight/catalog.rb
@@ -372,6 +397,7 @@ files:
372
397
  - test_support/features/search.feature
373
398
  - test_support/features/search_filters.feature
374
399
  - test_support/features/search_history.feature
400
+ - test_support/features/search_pagination.feature
375
401
  - test_support/features/search_results.feature
376
402
  - test_support/features/search_sort.feature
377
403
  - test_support/features/step_definitions/bookmarks_steps.rb
@@ -381,6 +407,7 @@ files:
381
407
  - test_support/features/step_definitions/saved_searches_steps.rb
382
408
  - test_support/features/step_definitions/search_facets_steps.rb
383
409
  - test_support/features/step_definitions/search_history_steps.rb
410
+ - test_support/features/step_definitions/search_pagination_steps.rb
384
411
  - test_support/features/step_definitions/search_result_steps.rb
385
412
  - test_support/features/step_definitions/search_steps.rb
386
413
  - test_support/features/step_definitions/user_steps.rb
@@ -424,6 +451,7 @@ files:
424
451
  - test_support/spec/models/solr_docment_spec.rb
425
452
  - test_support/spec/rcov.opts
426
453
  - test_support/spec/requests/alternate_controller_spec.rb
454
+ - test_support/spec/routing/catalog_routing_spec.rb
427
455
  - test_support/spec/spec.opts
428
456
  - test_support/spec/spec_helper.rb
429
457
  - test_support/spec/support/assert_difference.rb
@@ -444,20 +472,19 @@ require_paths:
444
472
  - lib
445
473
  required_ruby_version: !ruby/object:Gem::Requirement
446
474
  requirements:
447
- - - ! '>='
475
+ - - '>='
448
476
  - !ruby/object:Gem::Version
449
477
  version: '0'
450
478
  required_rubygems_version: !ruby/object:Gem::Requirement
451
479
  requirements:
452
- - - ! '>='
480
+ - - '>='
453
481
  - !ruby/object:Gem::Version
454
482
  version: '0'
455
483
  requirements: []
456
484
  rubyforge_project: blacklight
457
- rubygems_version: 2.0.0.preview2
485
+ rubygems_version: 2.0.0
458
486
  signing_key:
459
487
  specification_version: 4
460
488
  summary: Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr)
461
489
  index.
462
490
  test_files: []
463
- has_rdoc:
Binary file