blacklight 3.0pre1 → 3.0pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitmodules +0 -6
- data/README.rdoc +94 -87
- data/blacklight.gemspec +1 -1
- data/config/routes.rb +1 -1
- data/lib/blacklight.rb +2 -2
- data/lib/blacklight/catalog.rb +10 -12
- data/lib/blacklight/controller.rb +2 -2
- data/lib/blacklight/engine.rb +5 -2
- data/lib/blacklight/solr/document.rb +1 -1
- data/lib/blacklight/solr/document/marc.rb +1 -16
- data/lib/blacklight/solr_helper.rb +43 -14
- data/lib/blacklight/version.rb +1 -1
- data/lib/generators/blacklight/assets_generator.rb +25 -0
- data/lib/generators/blacklight/blacklight_generator.rb +16 -1
- data/lib/generators/blacklight/jetty_generator.rb +101 -0
- data/lib/generators/blacklight/solr_conf_generator.rb +25 -0
- data/lib/generators/blacklight/templates/catalog_controller.rb +0 -1
- data/lib/generators/blacklight/templates/config/solr.yml +14 -2
- data/lib/generators/blacklight/templates/public/images/{blacklight/bg.png → bg.png} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/border.png → border.png} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/bul_sq_gry.gif → bul_sq_gry.gif} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/checkmark.gif → checkmark.gif} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/logo.png → logo.png} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/magnifying_glass.gif → magnifying_glass.gif} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/remove.gif → remove.gif} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/separator.gif → separator.gif} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/start_over.gif → start_over.gif} +0 -0
- data/lib/generators/blacklight/templates/public/javascripts/blacklight.js +5 -0
- data/lib/generators/blacklight/templates/public/stylesheets/blacklight.css +9 -3
- data/lib/generators/blacklight/templates/solr_conf/schema.xml +339 -0
- data/lib/generators/blacklight/templates/solr_conf/solrconfig.xml +578 -0
- data/lib/railties/all_tests.rake +11 -0
- data/lib/railties/blacklight.rake +0 -52
- data/lib/railties/blacklight_cucumber.rake +125 -0
- data/lib/railties/blacklight_rspec.rake +128 -0
- data/lib/railties/{test_solr_server.rb → jetty_solr_server.rb} +22 -45
- data/lib/railties/solr_marc.rake +24 -5
- data/test_support/.rspec +1 -0
- data/test_support/data/test_data.utf8.mrc +1 -0
- data/test_support/features/bookmarks.feature +88 -0
- data/test_support/features/did_you_mean.feature +129 -0
- data/test_support/features/folder.feature +67 -0
- data/test_support/features/librarian_view.feature +17 -0
- data/test_support/features/record_view.feature +34 -0
- data/test_support/features/saved_searches.feature +49 -0
- data/test_support/features/search.feature +86 -0
- data/test_support/features/search_filters.feature +121 -0
- data/test_support/features/search_history.feature +95 -0
- data/test_support/features/search_results.feature +61 -0
- data/test_support/features/search_sort.feature +29 -0
- data/test_support/features/step_definitions/bookmarks_steps.rb +5 -0
- data/test_support/features/step_definitions/error_steps.rb +4 -0
- data/test_support/features/step_definitions/folder_steps.rb +26 -0
- data/test_support/features/step_definitions/general_steps.rb +49 -0
- data/test_support/features/step_definitions/record_view_steps.rb +11 -0
- data/test_support/features/step_definitions/saved_searches_steps.rb +21 -0
- data/test_support/features/step_definitions/search_facets_steps.rb +28 -0
- data/test_support/features/step_definitions/search_history_steps.rb +8 -0
- data/test_support/features/step_definitions/search_result_steps.rb +113 -0
- data/test_support/features/step_definitions/search_steps.rb +102 -0
- data/test_support/features/step_definitions/user_steps.rb +4 -0
- data/test_support/features/step_definitions/web_steps.rb +211 -0
- data/test_support/features/support/env.rb +49 -0
- data/test_support/features/support/paths.rb +55 -0
- data/test_support/features/support/selectors.rb +39 -0
- data/test_support/features/unapi.feature +30 -0
- data/test_support/spec/controllers/application_controller_spec.rb +22 -0
- data/test_support/spec/controllers/catalog_controller_spec.rb +480 -0
- data/test_support/spec/controllers/folder_controller_spec.rb +40 -0
- data/test_support/spec/controllers/search_history_controller_spec.rb +45 -0
- data/test_support/spec/data/sample_docs.yml +655 -0
- data/test_support/spec/data/test_data.utf8.mrc +1 -0
- data/test_support/spec/helpers/blacklight_helper_spec.rb +482 -0
- data/test_support/spec/helpers/hash_as_hidden_fields_spec.rb +23 -0
- data/test_support/spec/helpers/render_constraints_helper_spec.rb +64 -0
- data/test_support/spec/helpers/search_history_helper_spec.rb +11 -0
- data/test_support/spec/helpers/solr_helper_spec.rb +873 -0
- data/test_support/spec/lib/blacklight_email_spec.rb +23 -0
- data/test_support/spec/lib/blacklight_sms_spec.rb +23 -0
- data/test_support/spec/lib/blacklight_solr_document_dublin_core_spec.rb +41 -0
- data/test_support/spec/lib/blacklight_solr_document_marc_spec.rb +88 -0
- data/test_support/spec/lib/blacklight_solr_document_spec.rb +173 -0
- data/test_support/spec/lib/blacklight_spec.rb +39 -0
- data/test_support/spec/lib/configurable_spec.rb +97 -0
- data/test_support/spec/lib/facet_paginator_spec.rb +93 -0
- data/test_support/spec/lib/marc_export_spec.rb +444 -0
- data/test_support/spec/lib/search_fields_spec.rb +105 -0
- data/test_support/spec/lib/tasks/blacklight_task_spec.rb +21 -0
- data/test_support/spec/lib/tasks/solr_marc_task_spec.rb +59 -0
- data/test_support/spec/models/bookmark_spec.rb +37 -0
- data/test_support/spec/models/record_mailer_spec.rb +67 -0
- data/test_support/spec/models/search_spec.rb +55 -0
- data/test_support/spec/models/solr_docment_spec.rb +111 -0
- data/test_support/spec/rcov.opts +3 -0
- data/test_support/spec/spec.opts +4 -0
- data/test_support/spec/spec_helper.rb +38 -0
- data/test_support/spec/support/action_controller.rb +42 -0
- data/test_support/spec/support/assert_difference.rb +16 -0
- data/test_support/spec/support/include_text.rb +20 -0
- data/test_support/spec/views/catalog/_constraints_element.html.erb_spec.rb +59 -0
- data/test_support/spec/views/catalog/_document_list.html.erb_spec.rb +8 -0
- data/test_support/spec/views/catalog/_facets.html.erb_spec.rb +182 -0
- data/test_support/spec/views/catalog/_index_partials/_default.erb_spec.rb +70 -0
- data/test_support/spec/views/catalog/_show_partials/_default.html.erb_spec.rb +70 -0
- data/test_support/spec/views/catalog/index.atom.builder_spec.rb +141 -0
- data/test_support/spec/views/catalog/show.html.erb_spec.rb +100 -0
- data/test_support/spec/views/catalog/unapi.xml.builder_spec.rb +45 -0
- metadata +95 -98
- data/lib/blacklight/marc.rb +0 -46
- data/lib/blacklight/marc/citation.rb +0 -251
- data/lib/railties/cucumber.rake +0 -53
- data/lib/railties/rspec.rake +0 -188
- data/spec/helpers/catalog_helper_spec.rb +0 -111
- data/spec/views/catalog/_sms_form.html.erb_spec.rb +0 -19
@@ -0,0 +1,93 @@
|
|
1
|
+
# Spec tests for Paginator class found in lib/blacklight/solr/facet_paginator.rb
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
4
|
+
|
5
|
+
describe 'Blacklight::Solr::FacetPaginator' do
|
6
|
+
before(:all) do
|
7
|
+
require 'yaml'
|
8
|
+
@seven_facet_values = YAML::load("--- \n- !ruby/object:RSolr::Ext::Response::Facets::FacetItem \n hits: 792\n value: Book\n- !ruby/object:RSolr::Ext::Response::Facets::FacetItem \n hits: 65\n value: Musical Score\n- !ruby/object:RSolr::Ext::Response::Facets::FacetItem \n hits: 58\n value: Serial\n- !ruby/object:RSolr::Ext::Response::Facets::FacetItem \n hits: 48\n value: Musical Recording\n- !ruby/object:RSolr::Ext::Response::Facets::FacetItem \n hits: 37\n value: Microform\n- !ruby/object:RSolr::Ext::Response::Facets::FacetItem \n hits: 27\n value: Thesis\n- !ruby/object:RSolr::Ext::Response::Facets::FacetItem \n hits: 0\n value: \n")
|
9
|
+
@six_facet_values = @seven_facet_values.slice(1,6)
|
10
|
+
@limit = 6
|
11
|
+
|
12
|
+
@sort_key = Blacklight::Solr::FacetPaginator.request_keys[:sort]
|
13
|
+
@offset_key = Blacklight::Solr::FacetPaginator.request_keys[:offset]
|
14
|
+
@limit_key = Blacklight::Solr::FacetPaginator.request_keys[:limit]
|
15
|
+
end
|
16
|
+
context 'when there are limit+1 results' do
|
17
|
+
before(:each) do
|
18
|
+
@paginator = Blacklight::Solr::FacetPaginator.new(@seven_facet_values, @offset_key => 0, :limit => 6)
|
19
|
+
end
|
20
|
+
it 'should have next' do
|
21
|
+
@paginator.should be_has_next
|
22
|
+
end
|
23
|
+
it 'should generate proper next params' do
|
24
|
+
next_params = @paginator.params_for_next_url(:original1 => "original1", :original2 => "original2")
|
25
|
+
|
26
|
+
next_params[:original1].should == "original1"
|
27
|
+
next_params[:original2].should == "original2"
|
28
|
+
next_params[@offset_key].should == 0 + @limit
|
29
|
+
end
|
30
|
+
end
|
31
|
+
it 'should not have next when there are fewer results' do
|
32
|
+
paginator = Blacklight::Solr::FacetPaginator.new(@six_facet_values, :offset => 0, :limit => @limit)
|
33
|
+
|
34
|
+
paginator.should_not be_has_next
|
35
|
+
end
|
36
|
+
context 'when offset is greater than 0' do
|
37
|
+
before(:each) do
|
38
|
+
@offset = 100
|
39
|
+
@paginator = Blacklight::Solr::FacetPaginator.new(@seven_facet_values, :offset => @offset, :limit => @limit)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should have previous' do
|
43
|
+
@paginator.should be_has_previous
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should generate proper previous params' do
|
47
|
+
next_params = @paginator.params_for_previous_url(:original1 => "original1", :original2 => "original2")
|
48
|
+
|
49
|
+
next_params[:original1].should == "original1"
|
50
|
+
next_params[:original2].should == "original2"
|
51
|
+
next_params[@offset_key].should == @offset - @limit
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
it 'should not have previous when offset is 0' do
|
56
|
+
paginator = Blacklight::Solr::FacetPaginator.new(@seven_facet_values, :offset => 0, :limit => @limit)
|
57
|
+
|
58
|
+
paginator.should_not be_has_previous
|
59
|
+
end
|
60
|
+
it 'should know a manually set sort, and produce proper sort url' do
|
61
|
+
paginator = Blacklight::Solr::FacetPaginator.new(@seven_facet_values, :offset => 100, :limit => @limit, :sort => 'index')
|
62
|
+
|
63
|
+
paginator.sort.should == 'index'
|
64
|
+
|
65
|
+
click_params = paginator.params_for_resort_url('count', {})
|
66
|
+
|
67
|
+
click_params[ @sort_key ].should == 'count'
|
68
|
+
click_params[ @offset_key ].to_s.should == "0"
|
69
|
+
end
|
70
|
+
it 'should limit items to limit, if limit is smaller than items.length' do
|
71
|
+
paginator = Blacklight::Solr::FacetPaginator.new(@seven_facet_values, :offset => 100, :limit => 6, :sort => 'index')
|
72
|
+
paginator.items.length.should == 6
|
73
|
+
end
|
74
|
+
it 'should return all items when limit is greater than items.length' do
|
75
|
+
paginator = Blacklight::Solr::FacetPaginator.new(@six_facet_values, :offset => 100, :limit => 6, :sort => 'index')
|
76
|
+
paginator.items.length.should == 6
|
77
|
+
end
|
78
|
+
describe "for a nil :limit" do
|
79
|
+
before(:all) do
|
80
|
+
@paginator = Blacklight::Solr::FacetPaginator.new(@seven_facet_values, :offset => 100, :limit => nil, :sort => 'index')
|
81
|
+
end
|
82
|
+
it 'should return all items' do
|
83
|
+
@paginator.items.should == @seven_facet_values
|
84
|
+
end
|
85
|
+
it 'should not has_next?' do
|
86
|
+
@paginator.should_not be_has_next
|
87
|
+
end
|
88
|
+
it 'should not has_previous?' do
|
89
|
+
@paginator.should_not be_has_previous
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,444 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
3
|
+
require 'rubygems'
|
4
|
+
require 'marc'
|
5
|
+
|
6
|
+
def marc_from_xml(string)
|
7
|
+
reader = MARC::XMLReader.new(StringIO.new(string))
|
8
|
+
reader.each {|rec| return rec }
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
def standard_citation
|
13
|
+
"<record>
|
14
|
+
<leader>01182pam a22003014a 4500</leader>
|
15
|
+
<controlfield tag=\"001\">a4802615</controlfield>
|
16
|
+
<controlfield tag=\"003\">SIRSI</controlfield>
|
17
|
+
<controlfield tag=\"008\">020828s2003 enkaf b 001 0 eng </controlfield>
|
18
|
+
|
19
|
+
<datafield tag=\"110\" ind1=\"1\" ind2=\" \">
|
20
|
+
<subfield code=\"a\">Bobs</subfield>
|
21
|
+
<subfield code=\"b\">Your Uncle</subfield>
|
22
|
+
</datafield>
|
23
|
+
|
24
|
+
<datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
|
25
|
+
<subfield code=\"a\">Apples :</subfield>
|
26
|
+
<subfield code=\"b\">botany, production, and uses /</subfield>
|
27
|
+
<subfield code=\"c\">edited by D.C. Ferree and I.J. Warrington.</subfield>
|
28
|
+
</datafield>
|
29
|
+
|
30
|
+
<datafield tag=\"260\" ind1=\" \" ind2=\" \">
|
31
|
+
<subfield code=\"a\">Oxon, U.K. ;</subfield>
|
32
|
+
<subfield code=\"a\">Cambridge, MA :</subfield>
|
33
|
+
<subfield code=\"b\">CABI Pub.,</subfield>
|
34
|
+
<subfield code=\"c\">c2003.</subfield>
|
35
|
+
</datafield>
|
36
|
+
|
37
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
38
|
+
<subfield code=\"a\">Ferree, David C.</subfield>
|
39
|
+
<subfield code=\"q\">(David Curtis),</subfield>
|
40
|
+
<subfield code=\"d\">1943-</subfield>
|
41
|
+
</datafield>
|
42
|
+
|
43
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
44
|
+
<subfield code=\"a\">Warrington, I. J.</subfield>
|
45
|
+
<subfield code=\"q\">(Ian J.)</subfield>
|
46
|
+
</datafield>
|
47
|
+
</record>"
|
48
|
+
end
|
49
|
+
|
50
|
+
def music_record
|
51
|
+
"<record>
|
52
|
+
<leader>01828cjm a2200409 a 4500</leader>
|
53
|
+
<controlfield tag=\"001\">a4768316</controlfield>
|
54
|
+
<controlfield tag=\"003\">SIRSI</controlfield>
|
55
|
+
<controlfield tag=\"007\">sd fungnnmmned</controlfield>
|
56
|
+
<controlfield tag=\"008\">020117p20011990xxuzz h d</controlfield>
|
57
|
+
|
58
|
+
<datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
|
59
|
+
<subfield code=\"a\">Music for horn</subfield>
|
60
|
+
<subfield code=\"h\">[sound recording] /</subfield>
|
61
|
+
<subfield code=\"c\">Brahms, Beethoven, von Krufft.</subfield>
|
62
|
+
</datafield>
|
63
|
+
|
64
|
+
<datafield tag=\"260\" ind1=\" \" ind2=\" \">
|
65
|
+
<subfield code=\"a\">[United States] :</subfield>
|
66
|
+
<subfield code=\"b\">Harmonia Mundi USA,</subfield>
|
67
|
+
<subfield code=\"c\">p2001.</subfield>
|
68
|
+
</datafield>
|
69
|
+
|
70
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
71
|
+
<subfield code=\"a\">Greer, Lowell.</subfield>
|
72
|
+
</datafield>
|
73
|
+
|
74
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
75
|
+
<subfield code=\"a\">Lubin, Steven.</subfield>
|
76
|
+
</datafield>
|
77
|
+
|
78
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
79
|
+
<subfield code=\"a\">Chase, Stephanie,</subfield>
|
80
|
+
<subfield code=\"d\">1957-</subfield>
|
81
|
+
</datafield>
|
82
|
+
|
83
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
|
84
|
+
<subfield code=\"a\">Brahms, Johannes,</subfield>
|
85
|
+
<subfield code=\"d\">1833-1897.</subfield>
|
86
|
+
<subfield code=\"t\">Trios,</subfield>
|
87
|
+
<subfield code=\"m\">piano, violin, horn,</subfield>
|
88
|
+
<subfield code=\"n\">op. 40,</subfield>
|
89
|
+
<subfield code=\"r\">E? major.</subfield>
|
90
|
+
</datafield>
|
91
|
+
|
92
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
|
93
|
+
<subfield code=\"a\">Beethoven, Ludwig van,</subfield>
|
94
|
+
<subfield code=\"d\">1770-1827.</subfield>
|
95
|
+
<subfield code=\"t\">Sonatas,</subfield>
|
96
|
+
<subfield code=\"m\">horn, piano,</subfield>
|
97
|
+
<subfield code=\"n\">op. 17,</subfield>
|
98
|
+
<subfield code=\"r\">F major.</subfield>
|
99
|
+
</datafield>
|
100
|
+
|
101
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
|
102
|
+
<subfield code=\"a\">Krufft, Nikolaus von,</subfield>
|
103
|
+
<subfield code=\"d\">1779-1818.</subfield>
|
104
|
+
<subfield code=\"t\">Sonata,</subfield>
|
105
|
+
<subfield code=\"m\">horn, piano,</subfield>
|
106
|
+
<subfield code=\"r\">F major.</subfield>
|
107
|
+
</datafield>
|
108
|
+
</record>"
|
109
|
+
end
|
110
|
+
|
111
|
+
def utf8_decomposed_record_xml
|
112
|
+
"<record>
|
113
|
+
<leader>01341nam 2200301 a 450 </leader>
|
114
|
+
<controlfield tag=\"005\">19971120234400.0</controlfield>
|
115
|
+
<controlfield tag=\"008\">890316s1988 caua b 101 0 eng </controlfield>
|
116
|
+
<datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
|
117
|
+
<subfield code=\"a\">Sharīʻat and ambiguity in South Asian Islam /</subfield>
|
118
|
+
<subfield code=\"c\">edited by Katherine P. Ewing.</subfield>
|
119
|
+
</datafield>
|
120
|
+
</record>"
|
121
|
+
end
|
122
|
+
|
123
|
+
# 1:100,1:700,245a,0:245b,
|
124
|
+
def record1_xml
|
125
|
+
"<record>
|
126
|
+
<leader>01021cam a2200277 a 4500</leader>
|
127
|
+
<controlfield tag=\"001\">a1711966</controlfield>
|
128
|
+
<controlfield tag=\"003\">SIRSI</controlfield>
|
129
|
+
<controlfield tag=\"008\">890421s1988 enka 001 0 eng d</controlfield>
|
130
|
+
|
131
|
+
<datafield tag=\"100\" ind1=\"1\" ind2=\" \">
|
132
|
+
<subfield code=\"a\">Janetzky, Kurt.</subfield>
|
133
|
+
</datafield>
|
134
|
+
|
135
|
+
<datafield tag=\"245\" ind1=\"1\" ind2=\"4\">
|
136
|
+
<subfield code=\"a\">The horn /</subfield>
|
137
|
+
<subfield code=\"c\">Kurt Janetzky and Bernhard Bruchle ; translated from the German by James Chater.</subfield>
|
138
|
+
</datafield>
|
139
|
+
|
140
|
+
<datafield tag=\"260\" ind1=\" \" ind2=\" \">
|
141
|
+
<subfield code=\"a\">London :</subfield>
|
142
|
+
<subfield code=\"b\">Batsford,</subfield>
|
143
|
+
<subfield code=\"c\">1988.</subfield>
|
144
|
+
</datafield>
|
145
|
+
|
146
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
147
|
+
<subfield code=\"a\">Brüchle, Bernhard.</subfield>
|
148
|
+
</datafield>
|
149
|
+
</record>"
|
150
|
+
end
|
151
|
+
|
152
|
+
# 0:100,0:700,245a,0:245b
|
153
|
+
def record2_xml
|
154
|
+
"<record>
|
155
|
+
<leader>00903nam a2200253 4500</leader>
|
156
|
+
<controlfield tag=\"001\">a543347</controlfield>
|
157
|
+
<controlfield tag=\"003\">SIRSI</controlfield>
|
158
|
+
<controlfield tag=\"008\">730111s1971 ohu b 000 0 eng </controlfield>
|
159
|
+
|
160
|
+
<datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
|
161
|
+
<subfield code=\"a\">Final report to the Honorable John J. Gilligan, Governor.</subfield>
|
162
|
+
</datafield>
|
163
|
+
|
164
|
+
<datafield tag=\"260\" ind1=\" \" ind2=\" \">
|
165
|
+
<subfield code=\"a\">[Columbus,</subfield>
|
166
|
+
<subfield code=\"b\">Printed by the State of Ohio, Dept. of Urban Affairs,</subfield>
|
167
|
+
<subfield code=\"c\">1971]</subfield>
|
168
|
+
</datafield>
|
169
|
+
</record>"
|
170
|
+
end
|
171
|
+
|
172
|
+
# 4+:athors
|
173
|
+
def record3_xml
|
174
|
+
"<record>
|
175
|
+
<leader>01828cjm a2200409 a 4500</leader>
|
176
|
+
<controlfield tag=\"001\">a4768316</controlfield>
|
177
|
+
<controlfield tag=\"003\">SIRSI</controlfield>
|
178
|
+
<controlfield tag=\"007\">sd fungnnmmned</controlfield>
|
179
|
+
<controlfield tag=\"008\">020117p20011990xxuzz h d</controlfield>
|
180
|
+
|
181
|
+
<datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
|
182
|
+
<subfield code=\"a\">Music for horn</subfield>
|
183
|
+
<subfield code=\"h\">[sound recording] /</subfield>
|
184
|
+
<subfield code=\"c\">Brahms, Beethoven, von Krufft.</subfield>
|
185
|
+
</datafield>
|
186
|
+
|
187
|
+
<datafield tag=\"260\" ind1=\" \" ind2=\" \">
|
188
|
+
<subfield code=\"a\">[United States] :</subfield>
|
189
|
+
<subfield code=\"b\">Harmonia Mundi USA,</subfield>
|
190
|
+
<subfield code=\"c\">p2001.</subfield>
|
191
|
+
</datafield>
|
192
|
+
|
193
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
194
|
+
<subfield code=\"a\">Greer, Lowell.</subfield>
|
195
|
+
</datafield>
|
196
|
+
|
197
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
198
|
+
<subfield code=\"a\">Lubin, Steven.</subfield>
|
199
|
+
</datafield>
|
200
|
+
|
201
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
202
|
+
<subfield code=\"a\">Chase, Stephanie,</subfield>
|
203
|
+
<subfield code=\"d\">1957-</subfield>
|
204
|
+
</datafield>
|
205
|
+
|
206
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
|
207
|
+
<subfield code=\"a\">Brahms, Johannes,</subfield>
|
208
|
+
<subfield code=\"d\">1833-1897.</subfield>
|
209
|
+
<subfield code=\"t\">Trios,</subfield>
|
210
|
+
<subfield code=\"m\">piano, violin, horn,</subfield>
|
211
|
+
<subfield code=\"n\">op. 40,</subfield>
|
212
|
+
<subfield code=\"r\">E? major.</subfield>
|
213
|
+
</datafield>
|
214
|
+
|
215
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
|
216
|
+
<subfield code=\"a\">Beethoven, Ludwig van,</subfield>
|
217
|
+
<subfield code=\"d\">1770-1827.</subfield>
|
218
|
+
<subfield code=\"t\">Sonatas,</subfield>
|
219
|
+
<subfield code=\"m\">horn, piano,</subfield>
|
220
|
+
<subfield code=\"n\">op. 17,</subfield>
|
221
|
+
<subfield code=\"r\">F major.</subfield>
|
222
|
+
</datafield>
|
223
|
+
|
224
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
|
225
|
+
<subfield code=\"a\">Krufft, Nikolaus von,</subfield>
|
226
|
+
<subfield code=\"d\">1779-1818.</subfield>
|
227
|
+
<subfield code=\"t\">Sonata,</subfield>
|
228
|
+
<subfield code=\"m\">horn, piano,</subfield>
|
229
|
+
<subfield code=\"r\">F major.</subfield>
|
230
|
+
</datafield>
|
231
|
+
</record>"
|
232
|
+
end
|
233
|
+
|
234
|
+
# No elements that can be put into a citation
|
235
|
+
def no_good_data_xml
|
236
|
+
"<record>
|
237
|
+
<leader>01828cjm a2200409 a 4500</leader>
|
238
|
+
<controlfield tag=\"001\">a4768316</controlfield>
|
239
|
+
<controlfield tag=\"003\">SIRSI</controlfield>
|
240
|
+
<controlfield tag=\"007\">sd fungnnmmned</controlfield>
|
241
|
+
<controlfield tag=\"008\">020117p20011990xxuzz h d</controlfield>
|
242
|
+
|
243
|
+
<datafield tag=\"024\" ind1=\"1\" ind2=\" \">
|
244
|
+
<subfield code=\"a\">713746703721</subfield>
|
245
|
+
</datafield>
|
246
|
+
|
247
|
+
<datafield tag=\"028\" ind1=\"0\" ind2=\"0\">
|
248
|
+
<subfield code=\"a\">HCX 3957037</subfield>
|
249
|
+
<subfield code=\"b\">Harmonia Mundi USA</subfield>
|
250
|
+
</datafield>
|
251
|
+
|
252
|
+
<datafield tag=\"033\" ind1=\"2\" ind2=\"0\">
|
253
|
+
<subfield code=\"a\">19901203</subfield>
|
254
|
+
<subfield code=\"a\">19901206</subfield>
|
255
|
+
</datafield>
|
256
|
+
|
257
|
+
<datafield tag=\"035\" ind1=\" \" ind2=\" \">
|
258
|
+
<subfield code=\"a\">(OCoLC-M)48807235</subfield>
|
259
|
+
</datafield>
|
260
|
+
|
261
|
+
<datafield tag=\"040\" ind1=\" \" ind2=\" \">
|
262
|
+
<subfield code=\"a\">WC4</subfield>
|
263
|
+
<subfield code=\"c\">WC4</subfield>
|
264
|
+
<subfield code=\"d\">CSt</subfield>
|
265
|
+
</datafield>
|
266
|
+
|
267
|
+
<datafield tag=\"041\" ind1=\"0\" ind2=\" \">
|
268
|
+
<subfield code=\"g\">engfre</subfield>
|
269
|
+
</datafield>
|
270
|
+
</record>"
|
271
|
+
end
|
272
|
+
|
273
|
+
# Bad author name
|
274
|
+
def bad_author_xml
|
275
|
+
"<record>
|
276
|
+
<leader>01021cam a2200277 a 4500</leader>
|
277
|
+
<controlfield tag=\"001\">a1711966</controlfield>
|
278
|
+
<controlfield tag=\"003\">SIRSI</controlfield>
|
279
|
+
<controlfield tag=\"008\">890421s1988 enka 001 0 eng d</controlfield>
|
280
|
+
|
281
|
+
<datafield tag=\"100\" ind1=\"1\" ind2=\" \">
|
282
|
+
<subfield code=\"a\"></subfield>
|
283
|
+
</datafield>
|
284
|
+
|
285
|
+
<datafield tag=\"245\" ind1=\"1\" ind2=\"4\">
|
286
|
+
<subfield code=\"a\">The horn /</subfield>
|
287
|
+
<subfield code=\"c\">Kurt Janetzky and Bernhard Bruchle ; translated from the German by James Chater.</subfield>
|
288
|
+
</datafield>
|
289
|
+
|
290
|
+
<datafield tag=\"260\" ind1=\" \" ind2=\" \">
|
291
|
+
<subfield code=\"a\">London :</subfield>
|
292
|
+
<subfield code=\"b\">Batsford,</subfield>
|
293
|
+
<subfield code=\"c\">1988.</subfield>
|
294
|
+
</datafield>
|
295
|
+
|
296
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
297
|
+
<subfield code=\"a\">Brüchle, Bernhard.</subfield>
|
298
|
+
</datafield>
|
299
|
+
</record>"
|
300
|
+
end
|
301
|
+
|
302
|
+
describe Blacklight::Solr::Document::MarcExport do
|
303
|
+
|
304
|
+
before(:all) do
|
305
|
+
dclass = Class.new do
|
306
|
+
include Blacklight::Solr::Document::MarcExport
|
307
|
+
attr_accessor :to_marc
|
308
|
+
def initialize(marc_xml_str)
|
309
|
+
self.to_marc = marc_from_xml(marc_xml_str)
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
@typical_record = dclass.new( standard_citation )
|
314
|
+
@music_record = dclass.new( music_record )
|
315
|
+
@record_without_245b = dclass.new( record1_xml )
|
316
|
+
@record_without_authors = dclass.new( record2_xml )
|
317
|
+
@record_with_4plus_authors = dclass.new( record3_xml )
|
318
|
+
@record_without_citable_data = dclass.new( no_good_data_xml )
|
319
|
+
@record_with_bad_author = dclass.new( bad_author_xml )
|
320
|
+
@record_utf8_decomposed = dclass.new( utf8_decomposed_record_xml )
|
321
|
+
|
322
|
+
end
|
323
|
+
|
324
|
+
describe "export_as_apa_citation_txt" do
|
325
|
+
it "should format a standard citation correctly" do
|
326
|
+
@typical_record.export_as_apa_citation_txt.should == "Ferree, D. C, & Warrington, I. J. (2003). <i>Apples : botany, production, and uses.</i> Oxon, U.K.: CABI Pub."
|
327
|
+
end
|
328
|
+
|
329
|
+
it "should format a citation without a 245b field correctly" do
|
330
|
+
@record_without_245b.export_as_apa_citation_txt.should == "Janetzky, K., & Brüchle, B. (1988). <i>The horn.</i> London: Batsford."
|
331
|
+
end
|
332
|
+
|
333
|
+
it "should format a citation without any authors correctly" do
|
334
|
+
@record_without_authors.export_as_apa_citation_txt.should == "(1971). <i>Final report to the Honorable John J. Gilligan, Governor.</i> [Columbus: Printed by the State of Ohio, Dept. of Urban Affairs."
|
335
|
+
end
|
336
|
+
|
337
|
+
it "should not fail if there is no citation data" do
|
338
|
+
@record_without_citable_data.export_as_apa_citation_txt.should == ""
|
339
|
+
end
|
340
|
+
|
341
|
+
it "should not bomb with a null pointer if there if author data is empty" do
|
342
|
+
@record_with_bad_author.export_as_apa_citation_txt.should == "Brüchle, B. (1988). <i>The horn.</i> London: Batsford."
|
343
|
+
end
|
344
|
+
|
345
|
+
end
|
346
|
+
|
347
|
+
describe "export_as_mla_citation_txt" do
|
348
|
+
it "should format a standard citation correctly" do
|
349
|
+
@typical_record.export_as_mla_citation_txt.should == "Ferree, David C, and I. J Warrington. <i>Apples : Botany, Production, and Uses.</i> Oxon, U.K.: CABI Pub., 2003."
|
350
|
+
end
|
351
|
+
|
352
|
+
it "should format a citation without a 245b field correctly" do
|
353
|
+
@record_without_245b.export_as_mla_citation_txt.should == "Janetzky, Kurt, and Bernhard Brüchle. <i>The Horn.</i> London: Batsford, 1988."
|
354
|
+
end
|
355
|
+
|
356
|
+
it "should format a citation without any authors correctly" do
|
357
|
+
@record_without_authors.export_as_mla_citation_txt.should == "<i>Final Report to the Honorable John J. Gilligan, Governor.</i> [Columbus: Printed by the State of Ohio, Dept. of Urban Affairs, 1971."
|
358
|
+
end
|
359
|
+
|
360
|
+
it "should format a citation with 4+ authors correctly" do
|
361
|
+
@record_with_4plus_authors.export_as_mla_citation_txt.should == "Greer, Lowell, et al. <i>Music for Horn.</i> [United States]: Harmonia Mundi USA, 2001."
|
362
|
+
end
|
363
|
+
|
364
|
+
it "should not fail if there is no citation data" do
|
365
|
+
@record_without_citable_data.export_as_mla_citation_txt.should == ""
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
describe "export_as_openurl_ctx_kev" do
|
370
|
+
it "should create the appropriate context object for books" do
|
371
|
+
record = @typical_record.export_as_openurl_ctx_kev('Book')
|
372
|
+
record.should match(/.*mtx%3Abook.*rft.genre=book.*rft.btitle=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.aucorp=Bobs\+Your\+Uncle.*rft.date=c2003.*rft.place=Oxon%2C\+U.K.*rft.pub=CABI\+Pub.*rft.isbn=/) and
|
373
|
+
record.should_not match(/.*rft.genre=article.*rft.issn=.*/)
|
374
|
+
end
|
375
|
+
it "should create the appropriate context object for journals" do
|
376
|
+
record = @typical_record.export_as_openurl_ctx_kev('Journal')
|
377
|
+
record_journal_other = @typical_record.export_as_openurl_ctx_kev('Journal/Magazine')
|
378
|
+
record.should match(/.*mtx%3Ajournal.*rft.genre=article.*rft.title=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.atitle=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.aucorp=Bobs\+Your\+Uncle.*rft.date=c2003.*rft.issn=/) and
|
379
|
+
record_journal_other.should == record and
|
380
|
+
record.should_not match(/.*rft.genre=book.*rft.isbn=.*/)
|
381
|
+
end
|
382
|
+
it "should create the appropriate context object for other content" do
|
383
|
+
record = @typical_record.export_as_openurl_ctx_kev('NotARealFormat')
|
384
|
+
record.should match(/.*mtx%3Adc.*rft.title=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.creator=.*rft.aucorp=Bobs\+Your\+Uncle.*rft.date=c2003.*rft.place=Oxon%2C\+U.K.*rft.pub=CABI\+Pub.*rft.format=notarealformat/) and
|
385
|
+
record.should_not match(/.*rft.isbn=.*/) and
|
386
|
+
record.should_not match(/.*rft.issn=.*/)
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
390
|
+
describe "export_as_marc binary" do
|
391
|
+
it "should export_as_marc" do
|
392
|
+
@typical_record.export_as_marc.should == @typical_record.to_marc.to_marc
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
describe "export_as_marcxml" do
|
397
|
+
it "should export_as_marcxml" do
|
398
|
+
marc_from_xml(@typical_record.export_as_marcxml).should == marc_from_xml(@typical_record.to_marc.to_xml.to_s)
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
402
|
+
describe "export_as_xml" do
|
403
|
+
it "should export marcxml as xml" do
|
404
|
+
marc_from_xml(@typical_record.export_as_xml).should == marc_from_xml(@typical_record.export_as_marcxml)
|
405
|
+
end
|
406
|
+
end
|
407
|
+
|
408
|
+
describe "export_as_refworks_marc_txt" do
|
409
|
+
it "should export correctly" do
|
410
|
+
@music_record.export_as_refworks_marc_txt.should == "LEADER 01828cjm a2200409 a 4500001 a4768316\n003 SIRSI\n007 sd fungnnmmned\n008 020117p20011990xxuzz h d\n245 00 Music for horn |h[sound recording] / |cBrahms, Beethoven, von Krufft.\n260 [United States] : |bHarmonia Mundi USA, |cp2001.\n700 1 Greer, Lowell.\n700 1 Lubin, Steven.\n700 1 Chase, Stephanie, |d1957-\n700 12 Brahms, Johannes, |d1833-1897. |tTrios, |mpiano, violin, horn, |nop. 40, |rE? major.\n700 12 Beethoven, Ludwig van, |d1770-1827. |tSonatas, |mhorn, piano, |nop. 17, |rF major.\n700 12 Krufft, Nikolaus von, |d1779-1818. |tSonata, |mhorn, piano, |rF major.\n"
|
411
|
+
end
|
412
|
+
describe "for UTF-8 record" do
|
413
|
+
before do
|
414
|
+
@utf8_exported = @record_utf8_decomposed.export_as_refworks_marc_txt
|
415
|
+
end
|
416
|
+
it "should export in Unicode normalized C form" do
|
417
|
+
@utf8_exported.should_not include("\314\204\312\273") # decomposed
|
418
|
+
@utf8_exported.should include("\304\253\312\273") # C-form normalized
|
419
|
+
end
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
423
|
+
describe "export_as_endnote" do
|
424
|
+
it "should export_correctly" do
|
425
|
+
endnote_file = @music_record.export_as_endnote
|
426
|
+
# We have to parse it a bit to check it.
|
427
|
+
endnote_entries = Hash.new {|hash, key| hash[key] = Set.new }
|
428
|
+
endnote_file.each_line do |line|
|
429
|
+
line =~ /\%(..?) (.*)$/
|
430
|
+
endnote_entries[$1] << $2
|
431
|
+
end
|
432
|
+
|
433
|
+
endnote_entries["0"].should == Set.new("Format") # I have no idea WHY this is correct, it is definitely not legal, but taking from earlier test for render_endnote in applicationhelper, the previous version of this. jrochkind.
|
434
|
+
endnote_entries["D"].should == Set.new("p2001. ")
|
435
|
+
endnote_entries["C"].should == Set.new("[United States] : ")
|
436
|
+
endnote_entries["E"].should == Set.new(["Greer, Lowell. ", "Lubin, Steven. ", "Chase, Stephanie, ", "Brahms, Johannes, ", "Beethoven, Ludwig van, ", "Krufft, Nikolaus von, "])
|
437
|
+
endnote_entries["I"].should == Set.new("Harmonia Mundi USA, ")
|
438
|
+
endnote_entries["T"].should == Set.new("Music for horn ")
|
439
|
+
|
440
|
+
#nothing extra
|
441
|
+
Set.new(endnote_entries.keys).should == Set.new(["0", "C", "D", "E", "I", "T"])
|
442
|
+
end
|
443
|
+
end
|
444
|
+
end
|