blacklight 4.7.0 → 4.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +13 -12
  4. data/Gemfile +37 -2
  5. data/VERSION +1 -1
  6. data/app/assets/stylesheets/blacklight/{_blacklight_base.css.scss → _blacklight_base.scss} +0 -0
  7. data/app/assets/stylesheets/blacklight/{_bookmark.css.scss → _bookmark.scss} +0 -0
  8. data/app/assets/stylesheets/blacklight/{_catalog.css.scss → _catalog.scss} +0 -0
  9. data/app/assets/stylesheets/blacklight/{_dropdown.css.scss → _dropdown.scss} +0 -0
  10. data/app/assets/stylesheets/blacklight/{_facets.css.scss → _facets.scss} +0 -0
  11. data/app/assets/stylesheets/blacklight/{_footer.css.scss → _footer.scss} +0 -0
  12. data/app/assets/stylesheets/blacklight/{_group.css.scss → _group.scss} +0 -0
  13. data/app/assets/stylesheets/blacklight/{_header.css.scss → _header.scss} +0 -0
  14. data/app/assets/stylesheets/blacklight/{_layout.css.scss → _layout.scss} +0 -0
  15. data/app/assets/stylesheets/blacklight/{_mixins.css.scss → _mixins.scss} +0 -0
  16. data/app/assets/stylesheets/blacklight/{_modal.css.scss → _modal.scss} +0 -0
  17. data/app/assets/stylesheets/blacklight/{_print.css.scss → _print.scss} +0 -0
  18. data/app/assets/stylesheets/blacklight/{_responsive.css.scss → _responsive.scss} +0 -0
  19. data/app/assets/stylesheets/blacklight/{_search_history.css.scss → _search_history.scss} +0 -0
  20. data/app/assets/stylesheets/blacklight/{blacklight.css.scss → blacklight.scss} +0 -0
  21. data/app/assets/stylesheets/blacklight/{blacklight_defaults.css.scss → blacklight_defaults.scss} +0 -0
  22. data/app/assets/stylesheets/blacklight/responsive_partials/{_catalog.css.scss → _catalog.scss} +0 -0
  23. data/app/assets/stylesheets/blacklight/responsive_partials/{_facets.css.scss → _facets.scss} +0 -0
  24. data/app/assets/stylesheets/blacklight/responsive_partials/{_header.css.scss → _header.scss} +0 -0
  25. data/app/helpers/blacklight/blacklight_helper_behavior.rb +2 -2
  26. data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -1
  27. data/app/helpers/blacklight/facets_helper_behavior.rb +1 -0
  28. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +2 -2
  29. data/blacklight.gemspec +5 -6
  30. data/lib/blacklight/catalog.rb +1 -1
  31. data/lib/blacklight/catalog/search_context.rb +6 -6
  32. data/lib/blacklight/solr/document.rb +29 -21
  33. data/lib/blacklight/solr_helper.rb +6 -4
  34. data/lib/generators/blacklight/templates/{blacklight.css.scss → blacklight.scss} +0 -0
  35. data/spec/controllers/application_controller_spec.rb +3 -3
  36. data/spec/controllers/bookmarks_controller_spec.rb +11 -11
  37. data/spec/controllers/catalog_controller_spec.rb +117 -117
  38. data/spec/controllers/search_history_controller_spec.rb +8 -8
  39. data/spec/features/alternate_controller_spec.rb +7 -5
  40. data/spec/features/record_view_spec.rb +4 -1
  41. data/spec/features/search_filters_spec.rb +37 -24
  42. data/spec/features/search_pagination_spec.rb +11 -7
  43. data/spec/features/search_results_spec.rb +22 -14
  44. data/spec/features/search_sort_spec.rb +3 -1
  45. data/spec/features/search_spec.rb +6 -0
  46. data/spec/helpers/blacklight_helper_spec.rb +175 -166
  47. data/spec/helpers/catalog_helper_spec.rb +59 -59
  48. data/spec/helpers/facets_helper_spec.rb +118 -118
  49. data/spec/helpers/hash_as_hidden_fields_spec.rb +14 -8
  50. data/spec/helpers/html_head_helper_spec.rb +51 -45
  51. data/spec/helpers/render_constraints_helper_spec.rb +5 -6
  52. data/spec/helpers/search_history_constraints_helper_spec.rb +21 -21
  53. data/spec/lib/blacklight/solr_response/group_response_spec.rb +2 -2
  54. data/spec/lib/blacklight_configurable_spec.rb +16 -16
  55. data/spec/lib/blacklight_configuration_spec.rb +132 -132
  56. data/spec/lib/blacklight_email_spec.rb +4 -4
  57. data/spec/lib/blacklight_sms_spec.rb +4 -4
  58. data/spec/lib/blacklight_solr_document_dublin_core_spec.rb +6 -6
  59. data/spec/lib/blacklight_solr_document_marc_spec.rb +3 -3
  60. data/spec/lib/blacklight_solr_document_more_like_this_spec.rb +4 -4
  61. data/spec/lib/blacklight_solr_document_spec.rb +36 -36
  62. data/spec/lib/blacklight_solr_response_spec.rb +42 -42
  63. data/spec/lib/blacklight_spec.rb +5 -5
  64. data/spec/lib/blacklight_user_spec.rb +5 -5
  65. data/spec/lib/facet_paginator_spec.rb +12 -12
  66. data/spec/lib/marc_export_spec.rb +746 -746
  67. data/spec/lib/search_fields_spec.rb +13 -13
  68. data/spec/lib/solr_helper_spec.rb +255 -250
  69. data/spec/lib/tasks/blacklight_task_spec.rb +1 -1
  70. data/spec/lib/tasks/solr_marc_task_spec.rb +6 -6
  71. data/spec/lib/utils_spec.rb +11 -11
  72. data/spec/models/bookmark_spec.rb +7 -6
  73. data/spec/models/record_mailer_spec.rb +16 -16
  74. data/spec/models/search_spec.rb +8 -8
  75. data/spec/models/solr_document_spec.rb +7 -7
  76. data/spec/requests/alternate_controller_spec.rb +3 -3
  77. data/spec/routing/catalog_routing_spec.rb +10 -15
  78. data/spec/spec_helper.rb +6 -4
  79. data/spec/support/assert_difference.rb +2 -2
  80. data/spec/support/features.rb +11 -0
  81. data/spec/support/features/session_helpers.rb +3 -3
  82. data/spec/support/include_text.rb +2 -2
  83. data/spec/test_app_templates/Gemfile.extra +2 -15
  84. data/spec/test_app_templates/lib/generators/test_app_generator.rb +17 -6
  85. data/spec/views/catalog/_constraints.html.erb_spec.rb +7 -7
  86. data/spec/views/catalog/_constraints_element.html.erb_spec.rb +12 -12
  87. data/spec/views/catalog/_document.html.erb_spec.rb +1 -1
  88. data/spec/views/catalog/_facets.html.erb_spec.rb +13 -13
  89. data/spec/views/catalog/_index_default.erb_spec.rb +20 -20
  90. data/spec/views/catalog/_show_default.erb_spec.rb +20 -20
  91. data/spec/views/catalog/_show_sidebar.erb_spec.rb +6 -6
  92. data/spec/views/catalog/_thumbnail_default.erb_spec.rb +3 -3
  93. data/spec/views/catalog/index.atom.builder_spec.rb +28 -28
  94. data/spec/views/catalog/index.html.erb_spec.rb +6 -6
  95. metadata +35 -57
  96. data/gemfiles/rails3.gemfile +0 -25
  97. data/gemfiles/rails4.gemfile +0 -24
@@ -13,12 +13,12 @@ describe Blacklight do
13
13
 
14
14
  it "should find app/controllers/application_controller.rb" do
15
15
  result = Blacklight.locate_path 'app', 'controllers', 'application_controller.rb'
16
- result.should_not == nil
16
+ expect(result).not_to eq(nil)
17
17
  end
18
18
 
19
19
  it "should not find blah.rb" do
20
20
  result = Blacklight.locate_path 'blah.rb'
21
- result.should == nil
21
+ expect(result).to eq(nil)
22
22
  end
23
23
 
24
24
  end
@@ -30,15 +30,15 @@ describe Blacklight do
30
30
  end
31
31
 
32
32
  it 'should return the full path to the BL plugin' do
33
- Blacklight.root.should == @blroot
33
+ expect(Blacklight.root).to eq(@blroot)
34
34
  end
35
35
 
36
36
  it 'should return the full path to the model directory' do
37
- Blacklight.models_dir.should == @blroot + "/app/models"
37
+ expect(Blacklight.models_dir).to eq(@blroot + "/app/models")
38
38
  end
39
39
 
40
40
  it 'should return the full path to the controllers directory' do
41
- Blacklight.controllers_dir.should == @blroot + "/app/controllers"
41
+ expect(Blacklight.controllers_dir).to eq(@blroot + "/app/controllers")
42
42
  end
43
43
 
44
44
  end
@@ -26,7 +26,7 @@ describe "Blacklight::User" do
26
26
 
27
27
  it "should know if it has a bookmarked document" do
28
28
  subject.bookmarks << mock_bookmark(1)
29
- expect(subject.document_is_bookmarked?(1)).to be_true
29
+ expect(subject.document_is_bookmarked?(1)).to eq true
30
30
  end
31
31
 
32
32
  it "should be able to create bookmarks in batches" do
@@ -35,7 +35,7 @@ describe "Blacklight::User" do
35
35
  @md3 = { :document_id => 3 }
36
36
 
37
37
  subject.documents_to_bookmark= [@md1,@md2,@md3]
38
- expect(subject.bookmarks).to have(3).bookmarks
38
+ expect(subject.bookmarks.size).to eq(3)
39
39
  expect(subject.bookmarked_document_ids).to include("1","2","3")
40
40
 
41
41
  end
@@ -44,19 +44,19 @@ describe "Blacklight::User" do
44
44
  subject.bookmarks << mock_bookmark(1)
45
45
 
46
46
  @md1 = { :document_id => 1 }
47
- subject.bookmarks.should_not_receive(:create).with(@md1)
47
+ expect(subject.bookmarks).not_to receive(:create).with(@md1)
48
48
 
49
49
  subject.bookmarks.push(mock_bookmark(1))
50
50
  subject.documents_to_bookmark=[@md1]
51
51
  end
52
52
 
53
53
  it "should know if it doesn't have a search" do
54
- subject.has_searches?.should == false
54
+ expect(subject.has_searches?).to eq(false)
55
55
  end
56
56
 
57
57
  it "should know if it has a search" do
58
58
  subject.searches << Search.new
59
- subject.has_searches?.should == true
59
+ expect(subject.has_searches?).to eq(true)
60
60
  end
61
61
 
62
62
  end
@@ -18,14 +18,14 @@ describe 'Blacklight::Solr::FacetPaginator' do
18
18
  @paginator = Blacklight::Solr::FacetPaginator.new(@seven_facet_values, :limit => 6)
19
19
  end
20
20
  it 'should have next' do
21
- @paginator.should be_has_next
21
+ expect(@paginator).to be_has_next
22
22
  end
23
23
 
24
24
  end
25
25
  it 'should not have next when there are fewer results' do
26
26
  paginator = Blacklight::Solr::FacetPaginator.new(@six_facet_values, :offset => 0, :limit => @limit)
27
27
 
28
- paginator.should_not be_has_next
28
+ expect(paginator).not_to be_has_next
29
29
  end
30
30
  context 'when offset is greater than 0' do
31
31
  before(:each) do
@@ -34,45 +34,45 @@ describe 'Blacklight::Solr::FacetPaginator' do
34
34
  end
35
35
 
36
36
  it 'should have previous' do
37
- @paginator.should be_has_previous
37
+ expect(@paginator).to be_has_previous
38
38
  end
39
39
 
40
40
  end
41
41
  it 'should not have previous when offset is 0' do
42
42
  paginator = Blacklight::Solr::FacetPaginator.new(@seven_facet_values, :offset => 0, :limit => @limit)
43
43
 
44
- paginator.should_not be_has_previous
44
+ expect(paginator).not_to be_has_previous
45
45
  end
46
46
  it 'should know a manually set sort, and produce proper sort url' do
47
47
  paginator = Blacklight::Solr::FacetPaginator.new(@seven_facet_values, :offset => 100, :limit => @limit, :sort => 'index')
48
48
 
49
- paginator.sort.should == 'index'
49
+ expect(paginator.sort).to eq('index')
50
50
 
51
51
  click_params = paginator.params_for_resort_url('count', {})
52
52
 
53
- click_params[ @sort_key ].should == 'count'
54
- click_params[ @page_key ].should be_nil
53
+ expect(click_params[ @sort_key ]).to eq('count')
54
+ expect(click_params[ @page_key ]).to be_nil
55
55
  end
56
56
  it 'should limit items to limit, if limit is smaller than items.length' do
57
57
  paginator = Blacklight::Solr::FacetPaginator.new(@seven_facet_values, :offset => 100, :limit => 6, :sort => 'index')
58
- paginator.items.length.should == 6
58
+ expect(paginator.items.length).to eq(6)
59
59
  end
60
60
  it 'should return all items when limit is greater than items.length' do
61
61
  paginator = Blacklight::Solr::FacetPaginator.new(@six_facet_values, :offset => 100, :limit => 6, :sort => 'index')
62
- paginator.items.length.should == 6
62
+ expect(paginator.items.length).to eq(6)
63
63
  end
64
64
  describe "for a nil :limit" do
65
65
  before(:all) do
66
66
  @paginator = Blacklight::Solr::FacetPaginator.new(@seven_facet_values, :offset => 100, :limit => nil, :sort => 'index')
67
67
  end
68
68
  it 'should return all items' do
69
- @paginator.items.should == @seven_facet_values
69
+ expect(@paginator.items).to eq(@seven_facet_values)
70
70
  end
71
71
  it 'should not has_next?' do
72
- @paginator.should_not be_has_next
72
+ expect(@paginator).not_to be_has_next
73
73
  end
74
74
  it 'should not has_previous?' do
75
- @paginator.should_not be_has_previous
75
+ expect(@paginator).not_to be_has_previous
76
76
  end
77
77
  end
78
78
 
@@ -1,746 +1,746 @@
1
- # -*- encoding : utf-8 -*-
2
- # -*- coding: utf-8 -*-
3
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
- require 'rubygems'
5
- require 'marc'
6
-
7
- def marc_from_xml(string)
8
- reader = MARC::XMLReader.new(StringIO.new(string))
9
- reader.each {|rec| return rec }
10
- end
11
-
12
-
13
- def standard_citation
14
- "<record>
15
- <leader>01182pam a22003014a 4500</leader>
16
- <controlfield tag=\"001\">a4802615</controlfield>
17
- <controlfield tag=\"003\">SIRSI</controlfield>
18
- <controlfield tag=\"008\">020828s2003 enkaf b 001 0 eng </controlfield>
19
-
20
- <datafield tag=\"110\" ind1=\"1\" ind2=\" \">
21
- <subfield code=\"a\">Bobs</subfield>
22
- <subfield code=\"b\">Your Uncle</subfield>
23
- </datafield>
24
-
25
- <datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
26
- <subfield code=\"a\">Apples :</subfield>
27
- <subfield code=\"b\">botany, production, and uses /</subfield>
28
- <subfield code=\"c\">edited by D.C. Ferree and I.J. Warrington.</subfield>
29
- </datafield>
30
-
31
- <datafield tag=\"260\" ind1=\" \" ind2=\" \">
32
- <subfield code=\"a\">Oxon, U.K. ;</subfield>
33
- <subfield code=\"a\">Cambridge, MA :</subfield>
34
- <subfield code=\"b\">CABI Pub.,</subfield>
35
- <subfield code=\"c\">c2003.</subfield>
36
- </datafield>
37
-
38
- <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
39
- <subfield code=\"a\">Ferree, David C.</subfield>
40
- <subfield code=\"q\">(David Curtis),</subfield>
41
- <subfield code=\"d\">1943-</subfield>
42
- </datafield>
43
-
44
- <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
45
- <subfield code=\"a\">Warrington, I. J.</subfield>
46
- <subfield code=\"q\">(Ian J.)</subfield>
47
- </datafield>
48
- </record>"
49
- end
50
-
51
- def music_record
52
- "<record>
53
- <leader>01828cjm a2200409 a 4500</leader>
54
- <controlfield tag=\"001\">a4768316</controlfield>
55
- <controlfield tag=\"003\">SIRSI</controlfield>
56
- <controlfield tag=\"007\">sd fungnnmmned</controlfield>
57
- <controlfield tag=\"008\">020117p20011990xxuzz h d</controlfield>
58
-
59
- <datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
60
- <subfield code=\"a\">Music for horn</subfield>
61
- <subfield code=\"h\">[sound recording] /</subfield>
62
- <subfield code=\"c\">Brahms, Beethoven, von Krufft.</subfield>
63
- </datafield>
64
-
65
- <datafield tag=\"260\" ind1=\" \" ind2=\" \">
66
- <subfield code=\"a\">[United States] :</subfield>
67
- <subfield code=\"b\">Harmonia Mundi USA,</subfield>
68
- <subfield code=\"c\">p2001.</subfield>
69
- </datafield>
70
-
71
- <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
72
- <subfield code=\"a\">Greer, Lowell.</subfield>
73
- </datafield>
74
-
75
- <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
76
- <subfield code=\"a\">Lubin, Steven.</subfield>
77
- </datafield>
78
-
79
- <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
80
- <subfield code=\"a\">Chase, Stephanie,</subfield>
81
- <subfield code=\"d\">1957-</subfield>
82
- </datafield>
83
-
84
- <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
85
- <subfield code=\"a\">Brahms, Johannes,</subfield>
86
- <subfield code=\"d\">1833-1897.</subfield>
87
- <subfield code=\"t\">Trios,</subfield>
88
- <subfield code=\"m\">piano, violin, horn,</subfield>
89
- <subfield code=\"n\">op. 40,</subfield>
90
- <subfield code=\"r\">E? major.</subfield>
91
- </datafield>
92
-
93
- <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
94
- <subfield code=\"a\">Beethoven, Ludwig van,</subfield>
95
- <subfield code=\"d\">1770-1827.</subfield>
96
- <subfield code=\"t\">Sonatas,</subfield>
97
- <subfield code=\"m\">horn, piano,</subfield>
98
- <subfield code=\"n\">op. 17,</subfield>
99
- <subfield code=\"r\">F major.</subfield>
100
- </datafield>
101
-
102
- <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
103
- <subfield code=\"a\">Krufft, Nikolaus von,</subfield>
104
- <subfield code=\"d\">1779-1818.</subfield>
105
- <subfield code=\"t\">Sonata,</subfield>
106
- <subfield code=\"m\">horn, piano,</subfield>
107
- <subfield code=\"r\">F major.</subfield>
108
- </datafield>
109
- </record>"
110
- end
111
-
112
- def utf8_decomposed_record_xml
113
- "<record>
114
- <leader>01341nam 2200301 a 450 </leader>
115
- <controlfield tag=\"005\">19971120234400.0</controlfield>
116
- <controlfield tag=\"008\">890316s1988 caua b 101 0 eng </controlfield>
117
- <datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
118
- <subfield code=\"a\">Sharīʻat and ambiguity in South Asian Islam /</subfield>
119
- <subfield code=\"c\">edited by Katherine P. Ewing.</subfield>
120
- </datafield>
121
- </record>"
122
- end
123
-
124
- # 1:100,1:700,245a,0:245b,
125
- def record1_xml
126
- "<record>
127
- <leader>01021cam a2200277 a 4500</leader>
128
- <controlfield tag=\"001\">a1711966</controlfield>
129
- <controlfield tag=\"003\">SIRSI</controlfield>
130
- <controlfield tag=\"008\">890421s1988 enka 001 0 eng d</controlfield>
131
-
132
- <datafield tag=\"100\" ind1=\"1\" ind2=\" \">
133
- <subfield code=\"a\">Janetzky, Kurt.</subfield>
134
- </datafield>
135
-
136
- <datafield tag=\"245\" ind1=\"1\" ind2=\"4\">
137
- <subfield code=\"a\">The horn /</subfield>
138
- <subfield code=\"c\">Kurt Janetzky and Bernhard Bruchle ; translated from the German by James Chater.</subfield>
139
- </datafield>
140
-
141
- <datafield tag=\"260\" ind1=\" \" ind2=\" \">
142
- <subfield code=\"a\">London :</subfield>
143
- <subfield code=\"b\">Batsford,</subfield>
144
- <subfield code=\"c\">1988.</subfield>
145
- </datafield>
146
-
147
- <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
148
- <subfield code=\"a\">Brüchle, Bernhard.</subfield>
149
- </datafield>
150
- </record>"
151
- end
152
-
153
- # 0:100,0:700,245a,0:245b
154
- def record2_xml
155
- "<record>
156
- <leader>00903nam a2200253 4500</leader>
157
- <controlfield tag=\"001\">a543347</controlfield>
158
- <controlfield tag=\"003\">SIRSI</controlfield>
159
- <controlfield tag=\"008\">730111s1971 ohu b 000 0 eng </controlfield>
160
-
161
- <datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
162
- <subfield code=\"a\">Final report to the Honorable John J. Gilligan, Governor.</subfield>
163
- </datafield>
164
-
165
- <datafield tag=\"260\" ind1=\" \" ind2=\" \">
166
- <subfield code=\"a\">[Columbus,</subfield>
167
- <subfield code=\"b\">Printed by the State of Ohio, Dept. of Urban Affairs,</subfield>
168
- <subfield code=\"c\">1971]</subfield>
169
- </datafield>
170
- </record>"
171
- end
172
-
173
- def year_range_xml
174
- "<record>
175
- <leader>01021cam a2200277 a 4500</leader>
176
- <controlfield tag=\"001\">a1711966</controlfield>
177
- <controlfield tag=\"003\">SIRSI</controlfield>
178
- <controlfield tag=\"008\">890421s1988 enka 001 0 eng d</controlfield>
179
-
180
- <datafield tag=\"100\" ind1=\"1\" ind2=\" \">
181
- <subfield code=\"a\">Schmoe, Joe</subfield>
182
- </datafield>
183
-
184
- <datafield tag=\"245\" ind1=\"1\" ind2=\"4\">
185
- <subfield code=\"a\">Main title /</subfield>
186
- <subfield code=\"c\">Subtitle</subfield>
187
- </datafield>
188
-
189
- <datafield tag=\"260\" ind1=\" \" ind2=\" \">
190
- <subfield code=\"a\">London :</subfield>
191
- <subfield code=\"b\">Batsford,</subfield>
192
- <subfield code=\"c\">1988-2000</subfield>
193
- </datafield>
194
-
195
- </record>"
196
- end
197
-
198
- def no_date_xml
199
- "<record>
200
- <leader>01021cam a2200277 a 4500</leader>
201
- <controlfield tag=\"001\">a1711966</controlfield>
202
- <controlfield tag=\"003\">SIRSI</controlfield>
203
- <controlfield tag=\"008\">890421s1988 enka 001 0 eng d</controlfield>
204
-
205
- <datafield tag=\"100\" ind1=\"1\" ind2=\" \">
206
- <subfield code=\"a\">Schmoe, Joe</subfield>
207
- </datafield>
208
-
209
- <datafield tag=\"245\" ind1=\"1\" ind2=\"4\">
210
- <subfield code=\"a\">Main title /</subfield>
211
- <subfield code=\"c\">Subtitle</subfield>
212
- </datafield>
213
-
214
- <datafield tag=\"260\" ind1=\" \" ind2=\" \">
215
- <subfield code=\"a\">London :</subfield>
216
- <subfield code=\"b\">Batsford,</subfield>
217
- <subfield code=\"c\">n.d.</subfield>
218
- </datafield>
219
-
220
- </record>"
221
- end
222
-
223
- def section_title_xml
224
- "<record>
225
- <leader>01021cam a2200277 a 4500</leader>
226
- <controlfield tag=\"001\">a1711966</controlfield>
227
- <controlfield tag=\"003\">SIRSI</controlfield>
228
- <controlfield tag=\"008\">890421s1988 enka 001 0 eng d</controlfield>
229
-
230
- <datafield tag=\"100\" ind1=\"1\" ind2=\" \">
231
- <subfield code=\"a\">Schmoe, Joe</subfield>
232
- </datafield>
233
-
234
- <datafield tag=\"245\" ind1=\"1\" ind2=\"4\">
235
- <subfield code=\"a\">Main title /</subfield>
236
- <subfield code=\"b\">Subtitle</subfield>
237
- <subfield code=\"n\">Number of part.</subfield>
238
- <subfield code=\"p\">Name of part.</subfield>
239
- </datafield>
240
-
241
- <datafield tag=\"260\" ind1=\" \" ind2=\" \">
242
- <subfield code=\"a\">London :</subfield>
243
- <subfield code=\"b\">Batsford,</subfield>
244
- <subfield code=\"c\">2001</subfield>
245
- </datafield>
246
-
247
- </record>"
248
- end
249
-
250
- def dissertation_note_xml
251
- "<record>
252
- <leader>00903nam a2200253 4500</leader>
253
- <controlfield tag=\"008\">730111s1971 ohu b 000 0 eng </controlfield>
254
-
255
- <datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
256
- <subfield code=\"a\">Thesis on some subject.</subfield>
257
- </datafield>
258
-
259
- <datafield tag=\"260\" ind1=\" \" ind2=\" \">
260
- <subfield code=\"c\">2009</subfield>
261
- </datafield>
262
-
263
- <datafield tag=\"502\" ind1=\"0\" ind2=\"0\">
264
- <subfield code=\"a\">Phd Thesis -- Goodenough College, 2009</subfield>
265
- </datafield>
266
- </record>"
267
- end
268
-
269
- def special_contributor_with_author_xml
270
- "<record>
271
- <leader>00903nam a2200253 4500</leader>
272
- <controlfield tag=\"008\">730111s1971 ohu b 000 0 eng </controlfield>
273
-
274
- <datafield tag=\"100\" ind1=\"0\" ind2=\"0\">
275
- <subfield code=\"a\">Doe, John</subfield>
276
- </datafield>
277
-
278
- <datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
279
- <subfield code=\"a\">Title of item.</subfield>
280
- </datafield>
281
-
282
- <datafield tag=\"260\" ind1=\" \" ind2=\" \">
283
- <subfield code=\"a\">Publisher</subfield>
284
- <subfield code=\"b\">Place</subfield>
285
- <subfield code=\"c\">2009</subfield>
286
- </datafield>
287
-
288
- <datafield tag=\"700\" ind1=\" \" ind2=\" \">
289
- <subfield code=\"a\">Schmoe, Joe</subfield>
290
- <subfield code=\"e\">trl.</subfield>
291
- </datafield>
292
-
293
- <datafield tag=\"700\" ind1=\" \" ind2=\" \">
294
- <subfield code=\"a\">Schmoe, Bill</subfield>
295
- <subfield code=\"4\">edt</subfield>
296
- </datafield>
297
-
298
- <datafield tag=\"700\" ind1=\" \" ind2=\" \">
299
- <subfield code=\"a\">Schmoe, Susie</subfield>
300
- <subfield code=\"e\">com.</subfield>
301
- </datafield>
302
-
303
- </record>"
304
- end
305
-
306
- def three_authors_xml
307
- "<record>
308
- <leader>00903nam a2200253 4500</leader>
309
- <controlfield tag=\"008\">730111s1971 ohu b 000 0 eng </controlfield>
310
-
311
- <datafield tag=\"100\" ind1=\"0\" ind2=\"0\">
312
- <subfield code=\"a\">Doe, John</subfield>
313
- </datafield>
314
-
315
- <datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
316
- <subfield code=\"a\">Title of item.</subfield>
317
- </datafield>
318
-
319
- <datafield tag=\"260\" ind1=\" \" ind2=\" \">
320
- <subfield code=\"a\">Publisher</subfield>
321
- <subfield code=\"b\">Place</subfield>
322
- <subfield code=\"c\">2009</subfield>
323
- </datafield>
324
-
325
- <datafield tag=\"700\" ind1=\" \" ind2=\" \">
326
- <subfield code=\"a\">Schmoe, Joe</subfield>
327
- </datafield>
328
-
329
- <datafield tag=\"700\" ind1=\" \" ind2=\" \">
330
- <subfield code=\"a\">Schmoe, Bill</subfield>
331
- </datafield>
332
-
333
- </record>"
334
- end
335
-
336
- def special_contributor_no_author_xml
337
- "<record>
338
- <leader>00903nam a2200253 4500</leader>
339
- <controlfield tag=\"008\">730111s1971 ohu b 000 0 eng </controlfield>
340
-
341
- <datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
342
- <subfield code=\"a\">Title of item.</subfield>
343
- </datafield>
344
-
345
- <datafield tag=\"260\" ind1=\" \" ind2=\" \">
346
- <subfield code=\"a\">Publisher</subfield>
347
- <subfield code=\"b\">Place</subfield>
348
- <subfield code=\"c\">2009</subfield>
349
- </datafield>
350
-
351
- <datafield tag=\"700\" ind1=\" \" ind2=\" \">
352
- <subfield code=\"a\">Schmoe, Joe</subfield>
353
- <subfield code=\"e\">trl.</subfield>
354
- </datafield>
355
-
356
- <datafield tag=\"700\" ind1=\" \" ind2=\" \">
357
- <subfield code=\"a\">Schmoe, Bill</subfield>
358
- <subfield code=\"4\">edt</subfield>
359
- </datafield>
360
-
361
- <datafield tag=\"700\" ind1=\" \" ind2=\" \">
362
- <subfield code=\"a\">Schmoe, Susie</subfield>
363
- <subfield code=\"e\">com.</subfield>
364
- </datafield>
365
-
366
- </record>"
367
- end
368
-
369
- # 4+:athors
370
- def record3_xml
371
- "<record>
372
- <leader>01828cjm a2200409 a 4500</leader>
373
- <controlfield tag=\"001\">a4768316</controlfield>
374
- <controlfield tag=\"003\">SIRSI</controlfield>
375
- <controlfield tag=\"007\">sd fungnnmmned</controlfield>
376
- <controlfield tag=\"008\">020117p20011990xxuzz h d</controlfield>
377
-
378
- <datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
379
- <subfield code=\"a\">Music for horn</subfield>
380
- <subfield code=\"h\">[sound recording] /</subfield>
381
- <subfield code=\"c\">Brahms, Beethoven, von Krufft.</subfield>
382
- </datafield>
383
-
384
- <datafield tag=\"260\" ind1=\" \" ind2=\" \">
385
- <subfield code=\"a\">[United States] :</subfield>
386
- <subfield code=\"b\">Harmonia Mundi USA,</subfield>
387
- <subfield code=\"c\">p2001.</subfield>
388
- </datafield>
389
-
390
- <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
391
- <subfield code=\"a\">Greer, Lowell.</subfield>
392
- </datafield>
393
-
394
- <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
395
- <subfield code=\"a\">Lubin, Steven.</subfield>
396
- </datafield>
397
-
398
- <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
399
- <subfield code=\"a\">Chase, Stephanie,</subfield>
400
- <subfield code=\"d\">1957-</subfield>
401
- </datafield>
402
-
403
- <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
404
- <subfield code=\"a\">Brahms, Johannes,</subfield>
405
- <subfield code=\"d\">1833-1897.</subfield>
406
- <subfield code=\"t\">Trios,</subfield>
407
- <subfield code=\"m\">piano, violin, horn,</subfield>
408
- <subfield code=\"n\">op. 40,</subfield>
409
- <subfield code=\"r\">E? major.</subfield>
410
- </datafield>
411
-
412
- <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
413
- <subfield code=\"a\">Beethoven, Ludwig van,</subfield>
414
- <subfield code=\"d\">1770-1827.</subfield>
415
- <subfield code=\"t\">Sonatas,</subfield>
416
- <subfield code=\"m\">horn, piano,</subfield>
417
- <subfield code=\"n\">op. 17,</subfield>
418
- <subfield code=\"r\">F major.</subfield>
419
- </datafield>
420
-
421
- <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
422
- <subfield code=\"a\">Krufft, Nikolaus von,</subfield>
423
- <subfield code=\"d\">1779-1818.</subfield>
424
- <subfield code=\"t\">Sonata,</subfield>
425
- <subfield code=\"m\">horn, piano,</subfield>
426
- <subfield code=\"r\">F major.</subfield>
427
- </datafield>
428
-
429
- <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
430
- <subfield code=\"a\">Doe, John</subfield>
431
- </datafield>
432
-
433
- <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
434
- <subfield code=\"a\">Doe, Jane</subfield>
435
- </datafield>
436
-
437
- <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
438
- <subfield code=\"a\">Smith, John</subfield>
439
- </datafield>
440
-
441
- <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
442
- <subfield code=\"a\">Smith, Jane</subfield>
443
- </datafield>
444
-
445
- <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
446
- <subfield code=\"a\">Smith, James</subfield>
447
- </datafield>
448
- </record>"
449
- end
450
-
451
- # No elements that can be put into a citation
452
- def no_good_data_xml
453
- "<record>
454
- <leader>01828cjm a2200409 a 4500</leader>
455
- <controlfield tag=\"001\">a4768316</controlfield>
456
- <controlfield tag=\"003\">SIRSI</controlfield>
457
- <controlfield tag=\"007\">sd fungnnmmned</controlfield>
458
- <controlfield tag=\"008\">020117p20011990xxuzz h d</controlfield>
459
-
460
- <datafield tag=\"024\" ind1=\"1\" ind2=\" \">
461
- <subfield code=\"a\">713746703721</subfield>
462
- </datafield>
463
-
464
- <datafield tag=\"028\" ind1=\"0\" ind2=\"0\">
465
- <subfield code=\"a\">HCX 3957037</subfield>
466
- <subfield code=\"b\">Harmonia Mundi USA</subfield>
467
- </datafield>
468
-
469
- <datafield tag=\"033\" ind1=\"2\" ind2=\"0\">
470
- <subfield code=\"a\">19901203</subfield>
471
- <subfield code=\"a\">19901206</subfield>
472
- </datafield>
473
-
474
- <datafield tag=\"035\" ind1=\" \" ind2=\" \">
475
- <subfield code=\"a\">(OCoLC-M)48807235</subfield>
476
- </datafield>
477
-
478
- <datafield tag=\"040\" ind1=\" \" ind2=\" \">
479
- <subfield code=\"a\">WC4</subfield>
480
- <subfield code=\"c\">WC4</subfield>
481
- <subfield code=\"d\">CSt</subfield>
482
- </datafield>
483
-
484
- <datafield tag=\"041\" ind1=\"0\" ind2=\" \">
485
- <subfield code=\"g\">engfre</subfield>
486
- </datafield>
487
- </record>"
488
- end
489
-
490
- # Bad author name
491
- def bad_author_xml
492
- "<record>
493
- <leader>01021cam a2200277 a 4500</leader>
494
- <controlfield tag=\"001\">a1711966</controlfield>
495
- <controlfield tag=\"003\">SIRSI</controlfield>
496
- <controlfield tag=\"008\">890421s1988 enka 001 0 eng d</controlfield>
497
-
498
- <datafield tag=\"100\" ind1=\"1\" ind2=\" \">
499
- <subfield code=\"a\"></subfield>
500
- </datafield>
501
-
502
- <datafield tag=\"245\" ind1=\"1\" ind2=\"4\">
503
- <subfield code=\"a\">The horn /</subfield>
504
- <subfield code=\"c\">Kurt Janetzky and Bernhard Bruchle ; translated from the German by James Chater.</subfield>
505
- </datafield>
506
-
507
- <datafield tag=\"260\" ind1=\" \" ind2=\" \">
508
- <subfield code=\"a\">London :</subfield>
509
- <subfield code=\"b\">Batsford,</subfield>
510
- <subfield code=\"c\">1988.</subfield>
511
- </datafield>
512
-
513
- <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
514
- <subfield code=\"a\">Brüchle, Bernhard.</subfield>
515
- </datafield>
516
- </record>"
517
- end
518
-
519
- describe Blacklight::Solr::Document::MarcExport do
520
-
521
- before(:all) do
522
- dclass = Class.new do
523
- include Blacklight::Solr::Document::MarcExport
524
- attr_accessor :to_marc
525
- def initialize(marc_xml_str)
526
- self.to_marc = marc_from_xml(marc_xml_str)
527
- end
528
- end
529
-
530
- @typical_record = dclass.new( standard_citation )
531
- @music_record = dclass.new( music_record )
532
- @dissertation_record = dclass.new( dissertation_note_xml )
533
- @record_without_245b = dclass.new( record1_xml )
534
- @three_authors_record = dclass.new( three_authors_xml )
535
- @record_without_authors = dclass.new( record2_xml )
536
- @record_with_10plus_authors = dclass.new( record3_xml )
537
- @year_range_record = dclass.new( year_range_xml )
538
- @no_date_record = dclass.new( no_date_xml )
539
- @section_title_record = dclass.new( section_title_xml )
540
- @special_contributor_record = dclass.new( special_contributor_with_author_xml )
541
- @record_without_citable_data = dclass.new( no_good_data_xml )
542
- @record_with_bad_author = dclass.new( bad_author_xml )
543
- @special_contributor_no_auth_record = dclass.new( special_contributor_no_author_xml )
544
- @record_utf8_decomposed = dclass.new( utf8_decomposed_record_xml )
545
-
546
- end
547
-
548
- describe "export_as_chicago_citation_txt" do
549
- it "should handle a typical record correclty" do
550
- @typical_record.export_as_chicago_citation_txt.should == "Ferree, David C., and I. J Warrington. <i>Apples: Botany, Production, and Uses.</i> Oxon, U.K.: CABI Pub., 2003."
551
- end
552
- it "should format a record w/o authors correctly" do
553
- @record_without_authors.export_as_chicago_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."
554
- end
555
- it "should format a citation without a 245b field correctly" do
556
- @record_without_245b.export_as_chicago_citation_txt.should == "Janetzky, Kurt., and Bernhard Brüchle. <i>The Horn.</i> London: Batsford, 1988."
557
- end
558
- it "should format a citation with 4+ authors correctly" do
559
- chicago_text = @record_with_10plus_authors.export_as_chicago_citation_txt
560
- chicago_text.should == "Greer, Lowell., Steven Lubin, Stephanie Chase, Johannes Brahms, Ludwig van Beethoven, Nikolaus von Krufft, John Doe, et al. <i>Music for Horn.</i> [United States]: Harmonia Mundi USA, 2001."
561
- chicago_text.should match(/John Doe, et al\./)
562
- chicago_text.should_not match(/Jane Doe/)
563
- end
564
- it "should handle dissertation data correctly" do
565
- @dissertation_record.export_as_chicago_citation_txt.should == "<i>Thesis On Some Subject.</i> Phd Thesis -- Goodenough College, 2009."
566
- end
567
- it "should handle 3 authors correctly" do
568
- @three_authors_record.export_as_chicago_citation_txt.should match(/^Doe, John, Joe Schmoe, and Bill Schmoe\./)
569
- end
570
- it "should handle editors, translators, and compilers correctly" do
571
- @special_contributor_record.export_as_chicago_citation_txt.should == "Doe, John <i>Title of Item.</i> Translated by Joe Schmoe. Edited by Bill Schmoe. Compiled by Susie Schmoe. Publisher: Place, 2009."
572
- end
573
- it "should handle editors, translators, and compilers correctly when there is no author present" do
574
- @special_contributor_no_auth_record.export_as_chicago_citation_txt.should == "Schmoe, Joe trans., Bill Schmoe ed., and Susie Schmoe comp. <i>Title of Item.</i> Publisher: Place, 2009."
575
- end
576
- it "should handle year ranges properly" do
577
- @year_range_record.export_as_chicago_citation_txt.should_not match(/2000/)
578
- end
579
- it "should handle n.d. in the 260$c properly" do
580
- @no_date_record.export_as_chicago_citation_txt.should match(/n\.d\.$/)
581
- end
582
- it "should handle section title appropriately" do
583
- @section_title_record.export_as_chicago_citation_txt.should == "Schmoe, Joe <i>Main Title: Subtitle\.<\/i> Number of Part, <i>Name of Part\.<\/i> London: Batsford, 2001."
584
- end
585
- it "should not fail if there is no citation data" do
586
- @record_without_citable_data.export_as_chicago_citation_txt.should == ""
587
- end
588
- end
589
-
590
- describe "export_as_apa_citation_txt" do
591
- it "should format a standard citation correctly" do
592
- @typical_record.export_as_apa_citation_txt.should == "Ferree, D. C, &amp; Warrington, I. J. (2003). <i>Apples : botany, production, and uses.</i> Oxon, U.K.: CABI Pub."
593
- end
594
-
595
- it "should format a citation without a 245b field correctly" do
596
- @record_without_245b.export_as_apa_citation_txt.should == "Janetzky, K., &amp; Brüchle, B. (1988). <i>The horn.</i> London: Batsford."
597
- end
598
-
599
- it "should format a citation without any authors correctly" do
600
- @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."
601
- end
602
-
603
- it "should not fail if there is no citation data" do
604
- @record_without_citable_data.export_as_apa_citation_txt.should == ""
605
- end
606
-
607
- it "should not bomb with a null pointer if there if author data is empty" do
608
- @record_with_bad_author.export_as_apa_citation_txt.should == "Brüchle, B. (1988). <i>The horn.</i> London: Batsford."
609
- end
610
-
611
- end
612
-
613
- describe "export_as_mla_citation_txt" do
614
- it "should format a standard citation correctly" do
615
- @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."
616
- end
617
-
618
- it "should format a citation without a 245b field correctly" do
619
- @record_without_245b.export_as_mla_citation_txt.should == "Janetzky, Kurt, and Bernhard Brüchle. <i>The Horn.</i> London: Batsford, 1988."
620
- end
621
-
622
- it "should format a citation without any authors correctly" do
623
- @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."
624
- end
625
-
626
- it "should format a citation with 4+ authors correctly" do
627
- @record_with_10plus_authors.export_as_mla_citation_txt.should == "Greer, Lowell, et al. <i>Music for Horn.</i> [United States]: Harmonia Mundi USA, 2001."
628
- end
629
-
630
- it "should not fail if there is no citation data" do
631
- @record_without_citable_data.export_as_mla_citation_txt.should == ""
632
- end
633
- end
634
-
635
- describe "export_as_openurl_ctx_kev" do
636
- it "should create the appropriate context object for books" do
637
- record = @typical_record.export_as_openurl_ctx_kev('Book')
638
- 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
639
- record.should_not match(/.*rft.genre=article.*rft.issn=.*/)
640
- end
641
- it "should create the appropriate context object for journals" do
642
- record = @typical_record.export_as_openurl_ctx_kev('Journal')
643
- record_journal_other = @typical_record.export_as_openurl_ctx_kev('Journal/Magazine')
644
- 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
645
- record_journal_other.should == record and
646
- record.should_not match(/.*rft.genre=book.*rft.isbn=.*/)
647
- end
648
- it "should create the appropriate context object for other content" do
649
- record = @typical_record.export_as_openurl_ctx_kev('NotARealFormat')
650
- 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
651
- record.should_not match(/.*rft.isbn=.*/) and
652
- record.should_not match(/.*rft.issn=.*/)
653
- end
654
- end
655
-
656
- describe "export_as_marc binary" do
657
- it "should export_as_marc" do
658
- @typical_record.export_as_marc.should == @typical_record.to_marc.to_marc
659
- end
660
- end
661
-
662
- describe "export_as_marcxml" do
663
- it "should export_as_marcxml" do
664
- marc_from_xml(@typical_record.export_as_marcxml).should == marc_from_xml(@typical_record.to_marc.to_xml.to_s)
665
- end
666
- end
667
-
668
- describe "export_as_xml" do
669
- it "should export marcxml as xml" do
670
- marc_from_xml(@typical_record.export_as_xml).should == marc_from_xml(@typical_record.export_as_marcxml)
671
- end
672
- end
673
-
674
- describe "export_as_refworks_marc_txt" do
675
- it "should export correctly" do
676
- @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"
677
- end
678
- describe "for UTF-8 record" do
679
- it "should export in Unicode normalized C form" do
680
- @utf8_exported = @record_utf8_decomposed.export_as_refworks_marc_txt
681
-
682
- if defined? Unicode
683
- @utf8_exported.should_not include("\314\204\312\273") # decomposed
684
- @utf8_exported.should include("\304\253\312\273") # C-form normalized
685
- end
686
- end
687
- end
688
- end
689
-
690
- describe "export_as_endnote" do
691
- it "should export_correctly" do
692
- endnote_file = @music_record.export_as_endnote
693
- # We have to parse it a bit to check it.
694
- endnote_entries = Hash.new {|hash, key| hash[key] = Set.new }
695
- endnote_file.each_line do |line|
696
- line =~ /\%(..?) (.*)$/
697
- endnote_entries[$1] << $2
698
- end
699
-
700
- endnote_entries["0"].should == Set.new(["Generic"]) # 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.
701
- endnote_entries["D"].should == Set.new(["p2001. "])
702
- endnote_entries["C"].should == Set.new(["[United States] : "])
703
- endnote_entries["E"].should == Set.new(["Greer, Lowell. ", "Lubin, Steven. ", "Chase, Stephanie, ", "Brahms, Johannes, ", "Beethoven, Ludwig van, ", "Krufft, Nikolaus von, "])
704
- endnote_entries["I"].should == Set.new(["Harmonia Mundi USA, "])
705
- endnote_entries["T"].should == Set.new(["Music for horn "])
706
-
707
- #nothing extra
708
- Set.new(endnote_entries.keys).should == Set.new(["0", "C", "D", "E", "I", "T"])
709
- end
710
- end
711
-
712
- describe "Citation title transformation" do
713
- before(:each) do
714
- class CitationTitleTest
715
- include Blacklight::Solr::Document::MarcExport
716
- def transform_title(text)
717
- citation_title(text)
718
- end
719
- end
720
- @citation_title = CitationTitleTest.new
721
- end
722
- it "should tranform a normal title properlly" do
723
- @citation_title.transform_title("This is just a test").should == "This Is Just a Test"
724
- end
725
- it "should not attempt to capatilize words in all-caps (e.g. acronyms)" do
726
- @citation_title.transform_title("IBM PC applications").should == "IBM PC Applications"
727
- end
728
- it "should capitalize a preposition if it is the first word in a title" do
729
- @citation_title.transform_title("of mice and men").should == "Of Mice and Men"
730
- end
731
- it "should handle hyphenated words properly" do
732
- @citation_title.transform_title("Testing hyphenated-words and how they get capitalized").should == "Testing Hyphenated-Words and How They Get Capitalized"
733
- end
734
- it "should handle normal prepositions properly" do
735
- @citation_title.transform_title("A little learning is a dangerous thing").should == "A Little Learning Is a Dangerous Thing"
736
- @citation_title.transform_title("Four theories concerning the Gospel according to Matthew").should == "Four Theories Concerning the Gospel According to Matthew"
737
- @citation_title.transform_title("Tired but happy").should == "Tired but Happy"
738
- @citation_title.transform_title("Mnemonics that work are better than rules that do not").should == "Mnemonics That Work Are Better Than Rules That Do Not"
739
- @citation_title.transform_title("This is just a test").should == "This Is Just a Test"
740
- @citation_title.transform_title("the mind of the Renaissance").should == "The Mind of the Renaissance"
741
- @citation_title.transform_title("Are you considering psychoanalysis?").should == "Are You Considering Psychoanalysis?"
742
- @citation_title.transform_title("Not without laughter").should == "Not without Laughter"
743
- end
744
- end
745
-
746
- end
1
+ # -*- encoding : utf-8 -*-
2
+ # -*- coding: utf-8 -*-
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+ require 'rubygems'
5
+ require 'marc'
6
+
7
+ def marc_from_xml(string)
8
+ reader = MARC::XMLReader.new(StringIO.new(string))
9
+ reader.each {|rec| return rec }
10
+ end
11
+
12
+
13
+ def standard_citation
14
+ "<record>
15
+ <leader>01182pam a22003014a 4500</leader>
16
+ <controlfield tag=\"001\">a4802615</controlfield>
17
+ <controlfield tag=\"003\">SIRSI</controlfield>
18
+ <controlfield tag=\"008\">020828s2003 enkaf b 001 0 eng </controlfield>
19
+
20
+ <datafield tag=\"110\" ind1=\"1\" ind2=\" \">
21
+ <subfield code=\"a\">Bobs</subfield>
22
+ <subfield code=\"b\">Your Uncle</subfield>
23
+ </datafield>
24
+
25
+ <datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
26
+ <subfield code=\"a\">Apples :</subfield>
27
+ <subfield code=\"b\">botany, production, and uses /</subfield>
28
+ <subfield code=\"c\">edited by D.C. Ferree and I.J. Warrington.</subfield>
29
+ </datafield>
30
+
31
+ <datafield tag=\"260\" ind1=\" \" ind2=\" \">
32
+ <subfield code=\"a\">Oxon, U.K. ;</subfield>
33
+ <subfield code=\"a\">Cambridge, MA :</subfield>
34
+ <subfield code=\"b\">CABI Pub.,</subfield>
35
+ <subfield code=\"c\">c2003.</subfield>
36
+ </datafield>
37
+
38
+ <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
39
+ <subfield code=\"a\">Ferree, David C.</subfield>
40
+ <subfield code=\"q\">(David Curtis),</subfield>
41
+ <subfield code=\"d\">1943-</subfield>
42
+ </datafield>
43
+
44
+ <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
45
+ <subfield code=\"a\">Warrington, I. J.</subfield>
46
+ <subfield code=\"q\">(Ian J.)</subfield>
47
+ </datafield>
48
+ </record>"
49
+ end
50
+
51
+ def music_record
52
+ "<record>
53
+ <leader>01828cjm a2200409 a 4500</leader>
54
+ <controlfield tag=\"001\">a4768316</controlfield>
55
+ <controlfield tag=\"003\">SIRSI</controlfield>
56
+ <controlfield tag=\"007\">sd fungnnmmned</controlfield>
57
+ <controlfield tag=\"008\">020117p20011990xxuzz h d</controlfield>
58
+
59
+ <datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
60
+ <subfield code=\"a\">Music for horn</subfield>
61
+ <subfield code=\"h\">[sound recording] /</subfield>
62
+ <subfield code=\"c\">Brahms, Beethoven, von Krufft.</subfield>
63
+ </datafield>
64
+
65
+ <datafield tag=\"260\" ind1=\" \" ind2=\" \">
66
+ <subfield code=\"a\">[United States] :</subfield>
67
+ <subfield code=\"b\">Harmonia Mundi USA,</subfield>
68
+ <subfield code=\"c\">p2001.</subfield>
69
+ </datafield>
70
+
71
+ <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
72
+ <subfield code=\"a\">Greer, Lowell.</subfield>
73
+ </datafield>
74
+
75
+ <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
76
+ <subfield code=\"a\">Lubin, Steven.</subfield>
77
+ </datafield>
78
+
79
+ <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
80
+ <subfield code=\"a\">Chase, Stephanie,</subfield>
81
+ <subfield code=\"d\">1957-</subfield>
82
+ </datafield>
83
+
84
+ <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
85
+ <subfield code=\"a\">Brahms, Johannes,</subfield>
86
+ <subfield code=\"d\">1833-1897.</subfield>
87
+ <subfield code=\"t\">Trios,</subfield>
88
+ <subfield code=\"m\">piano, violin, horn,</subfield>
89
+ <subfield code=\"n\">op. 40,</subfield>
90
+ <subfield code=\"r\">E? major.</subfield>
91
+ </datafield>
92
+
93
+ <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
94
+ <subfield code=\"a\">Beethoven, Ludwig van,</subfield>
95
+ <subfield code=\"d\">1770-1827.</subfield>
96
+ <subfield code=\"t\">Sonatas,</subfield>
97
+ <subfield code=\"m\">horn, piano,</subfield>
98
+ <subfield code=\"n\">op. 17,</subfield>
99
+ <subfield code=\"r\">F major.</subfield>
100
+ </datafield>
101
+
102
+ <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
103
+ <subfield code=\"a\">Krufft, Nikolaus von,</subfield>
104
+ <subfield code=\"d\">1779-1818.</subfield>
105
+ <subfield code=\"t\">Sonata,</subfield>
106
+ <subfield code=\"m\">horn, piano,</subfield>
107
+ <subfield code=\"r\">F major.</subfield>
108
+ </datafield>
109
+ </record>"
110
+ end
111
+
112
+ def utf8_decomposed_record_xml
113
+ "<record>
114
+ <leader>01341nam 2200301 a 450 </leader>
115
+ <controlfield tag=\"005\">19971120234400.0</controlfield>
116
+ <controlfield tag=\"008\">890316s1988 caua b 101 0 eng </controlfield>
117
+ <datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
118
+ <subfield code=\"a\">Sharīʻat and ambiguity in South Asian Islam /</subfield>
119
+ <subfield code=\"c\">edited by Katherine P. Ewing.</subfield>
120
+ </datafield>
121
+ </record>"
122
+ end
123
+
124
+ # 1:100,1:700,245a,0:245b,
125
+ def record1_xml
126
+ "<record>
127
+ <leader>01021cam a2200277 a 4500</leader>
128
+ <controlfield tag=\"001\">a1711966</controlfield>
129
+ <controlfield tag=\"003\">SIRSI</controlfield>
130
+ <controlfield tag=\"008\">890421s1988 enka 001 0 eng d</controlfield>
131
+
132
+ <datafield tag=\"100\" ind1=\"1\" ind2=\" \">
133
+ <subfield code=\"a\">Janetzky, Kurt.</subfield>
134
+ </datafield>
135
+
136
+ <datafield tag=\"245\" ind1=\"1\" ind2=\"4\">
137
+ <subfield code=\"a\">The horn /</subfield>
138
+ <subfield code=\"c\">Kurt Janetzky and Bernhard Bruchle ; translated from the German by James Chater.</subfield>
139
+ </datafield>
140
+
141
+ <datafield tag=\"260\" ind1=\" \" ind2=\" \">
142
+ <subfield code=\"a\">London :</subfield>
143
+ <subfield code=\"b\">Batsford,</subfield>
144
+ <subfield code=\"c\">1988.</subfield>
145
+ </datafield>
146
+
147
+ <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
148
+ <subfield code=\"a\">Brüchle, Bernhard.</subfield>
149
+ </datafield>
150
+ </record>"
151
+ end
152
+
153
+ # 0:100,0:700,245a,0:245b
154
+ def record2_xml
155
+ "<record>
156
+ <leader>00903nam a2200253 4500</leader>
157
+ <controlfield tag=\"001\">a543347</controlfield>
158
+ <controlfield tag=\"003\">SIRSI</controlfield>
159
+ <controlfield tag=\"008\">730111s1971 ohu b 000 0 eng </controlfield>
160
+
161
+ <datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
162
+ <subfield code=\"a\">Final report to the Honorable John J. Gilligan, Governor.</subfield>
163
+ </datafield>
164
+
165
+ <datafield tag=\"260\" ind1=\" \" ind2=\" \">
166
+ <subfield code=\"a\">[Columbus,</subfield>
167
+ <subfield code=\"b\">Printed by the State of Ohio, Dept. of Urban Affairs,</subfield>
168
+ <subfield code=\"c\">1971]</subfield>
169
+ </datafield>
170
+ </record>"
171
+ end
172
+
173
+ def year_range_xml
174
+ "<record>
175
+ <leader>01021cam a2200277 a 4500</leader>
176
+ <controlfield tag=\"001\">a1711966</controlfield>
177
+ <controlfield tag=\"003\">SIRSI</controlfield>
178
+ <controlfield tag=\"008\">890421s1988 enka 001 0 eng d</controlfield>
179
+
180
+ <datafield tag=\"100\" ind1=\"1\" ind2=\" \">
181
+ <subfield code=\"a\">Schmoe, Joe</subfield>
182
+ </datafield>
183
+
184
+ <datafield tag=\"245\" ind1=\"1\" ind2=\"4\">
185
+ <subfield code=\"a\">Main title /</subfield>
186
+ <subfield code=\"c\">Subtitle</subfield>
187
+ </datafield>
188
+
189
+ <datafield tag=\"260\" ind1=\" \" ind2=\" \">
190
+ <subfield code=\"a\">London :</subfield>
191
+ <subfield code=\"b\">Batsford,</subfield>
192
+ <subfield code=\"c\">1988-2000</subfield>
193
+ </datafield>
194
+
195
+ </record>"
196
+ end
197
+
198
+ def no_date_xml
199
+ "<record>
200
+ <leader>01021cam a2200277 a 4500</leader>
201
+ <controlfield tag=\"001\">a1711966</controlfield>
202
+ <controlfield tag=\"003\">SIRSI</controlfield>
203
+ <controlfield tag=\"008\">890421s1988 enka 001 0 eng d</controlfield>
204
+
205
+ <datafield tag=\"100\" ind1=\"1\" ind2=\" \">
206
+ <subfield code=\"a\">Schmoe, Joe</subfield>
207
+ </datafield>
208
+
209
+ <datafield tag=\"245\" ind1=\"1\" ind2=\"4\">
210
+ <subfield code=\"a\">Main title /</subfield>
211
+ <subfield code=\"c\">Subtitle</subfield>
212
+ </datafield>
213
+
214
+ <datafield tag=\"260\" ind1=\" \" ind2=\" \">
215
+ <subfield code=\"a\">London :</subfield>
216
+ <subfield code=\"b\">Batsford,</subfield>
217
+ <subfield code=\"c\">n.d.</subfield>
218
+ </datafield>
219
+
220
+ </record>"
221
+ end
222
+
223
+ def section_title_xml
224
+ "<record>
225
+ <leader>01021cam a2200277 a 4500</leader>
226
+ <controlfield tag=\"001\">a1711966</controlfield>
227
+ <controlfield tag=\"003\">SIRSI</controlfield>
228
+ <controlfield tag=\"008\">890421s1988 enka 001 0 eng d</controlfield>
229
+
230
+ <datafield tag=\"100\" ind1=\"1\" ind2=\" \">
231
+ <subfield code=\"a\">Schmoe, Joe</subfield>
232
+ </datafield>
233
+
234
+ <datafield tag=\"245\" ind1=\"1\" ind2=\"4\">
235
+ <subfield code=\"a\">Main title /</subfield>
236
+ <subfield code=\"b\">Subtitle</subfield>
237
+ <subfield code=\"n\">Number of part.</subfield>
238
+ <subfield code=\"p\">Name of part.</subfield>
239
+ </datafield>
240
+
241
+ <datafield tag=\"260\" ind1=\" \" ind2=\" \">
242
+ <subfield code=\"a\">London :</subfield>
243
+ <subfield code=\"b\">Batsford,</subfield>
244
+ <subfield code=\"c\">2001</subfield>
245
+ </datafield>
246
+
247
+ </record>"
248
+ end
249
+
250
+ def dissertation_note_xml
251
+ "<record>
252
+ <leader>00903nam a2200253 4500</leader>
253
+ <controlfield tag=\"008\">730111s1971 ohu b 000 0 eng </controlfield>
254
+
255
+ <datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
256
+ <subfield code=\"a\">Thesis on some subject.</subfield>
257
+ </datafield>
258
+
259
+ <datafield tag=\"260\" ind1=\" \" ind2=\" \">
260
+ <subfield code=\"c\">2009</subfield>
261
+ </datafield>
262
+
263
+ <datafield tag=\"502\" ind1=\"0\" ind2=\"0\">
264
+ <subfield code=\"a\">Phd Thesis -- Goodenough College, 2009</subfield>
265
+ </datafield>
266
+ </record>"
267
+ end
268
+
269
+ def special_contributor_with_author_xml
270
+ "<record>
271
+ <leader>00903nam a2200253 4500</leader>
272
+ <controlfield tag=\"008\">730111s1971 ohu b 000 0 eng </controlfield>
273
+
274
+ <datafield tag=\"100\" ind1=\"0\" ind2=\"0\">
275
+ <subfield code=\"a\">Doe, John</subfield>
276
+ </datafield>
277
+
278
+ <datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
279
+ <subfield code=\"a\">Title of item.</subfield>
280
+ </datafield>
281
+
282
+ <datafield tag=\"260\" ind1=\" \" ind2=\" \">
283
+ <subfield code=\"a\">Publisher</subfield>
284
+ <subfield code=\"b\">Place</subfield>
285
+ <subfield code=\"c\">2009</subfield>
286
+ </datafield>
287
+
288
+ <datafield tag=\"700\" ind1=\" \" ind2=\" \">
289
+ <subfield code=\"a\">Schmoe, Joe</subfield>
290
+ <subfield code=\"e\">trl.</subfield>
291
+ </datafield>
292
+
293
+ <datafield tag=\"700\" ind1=\" \" ind2=\" \">
294
+ <subfield code=\"a\">Schmoe, Bill</subfield>
295
+ <subfield code=\"4\">edt</subfield>
296
+ </datafield>
297
+
298
+ <datafield tag=\"700\" ind1=\" \" ind2=\" \">
299
+ <subfield code=\"a\">Schmoe, Susie</subfield>
300
+ <subfield code=\"e\">com.</subfield>
301
+ </datafield>
302
+
303
+ </record>"
304
+ end
305
+
306
+ def three_authors_xml
307
+ "<record>
308
+ <leader>00903nam a2200253 4500</leader>
309
+ <controlfield tag=\"008\">730111s1971 ohu b 000 0 eng </controlfield>
310
+
311
+ <datafield tag=\"100\" ind1=\"0\" ind2=\"0\">
312
+ <subfield code=\"a\">Doe, John</subfield>
313
+ </datafield>
314
+
315
+ <datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
316
+ <subfield code=\"a\">Title of item.</subfield>
317
+ </datafield>
318
+
319
+ <datafield tag=\"260\" ind1=\" \" ind2=\" \">
320
+ <subfield code=\"a\">Publisher</subfield>
321
+ <subfield code=\"b\">Place</subfield>
322
+ <subfield code=\"c\">2009</subfield>
323
+ </datafield>
324
+
325
+ <datafield tag=\"700\" ind1=\" \" ind2=\" \">
326
+ <subfield code=\"a\">Schmoe, Joe</subfield>
327
+ </datafield>
328
+
329
+ <datafield tag=\"700\" ind1=\" \" ind2=\" \">
330
+ <subfield code=\"a\">Schmoe, Bill</subfield>
331
+ </datafield>
332
+
333
+ </record>"
334
+ end
335
+
336
+ def special_contributor_no_author_xml
337
+ "<record>
338
+ <leader>00903nam a2200253 4500</leader>
339
+ <controlfield tag=\"008\">730111s1971 ohu b 000 0 eng </controlfield>
340
+
341
+ <datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
342
+ <subfield code=\"a\">Title of item.</subfield>
343
+ </datafield>
344
+
345
+ <datafield tag=\"260\" ind1=\" \" ind2=\" \">
346
+ <subfield code=\"a\">Publisher</subfield>
347
+ <subfield code=\"b\">Place</subfield>
348
+ <subfield code=\"c\">2009</subfield>
349
+ </datafield>
350
+
351
+ <datafield tag=\"700\" ind1=\" \" ind2=\" \">
352
+ <subfield code=\"a\">Schmoe, Joe</subfield>
353
+ <subfield code=\"e\">trl.</subfield>
354
+ </datafield>
355
+
356
+ <datafield tag=\"700\" ind1=\" \" ind2=\" \">
357
+ <subfield code=\"a\">Schmoe, Bill</subfield>
358
+ <subfield code=\"4\">edt</subfield>
359
+ </datafield>
360
+
361
+ <datafield tag=\"700\" ind1=\" \" ind2=\" \">
362
+ <subfield code=\"a\">Schmoe, Susie</subfield>
363
+ <subfield code=\"e\">com.</subfield>
364
+ </datafield>
365
+
366
+ </record>"
367
+ end
368
+
369
+ # 4+:athors
370
+ def record3_xml
371
+ "<record>
372
+ <leader>01828cjm a2200409 a 4500</leader>
373
+ <controlfield tag=\"001\">a4768316</controlfield>
374
+ <controlfield tag=\"003\">SIRSI</controlfield>
375
+ <controlfield tag=\"007\">sd fungnnmmned</controlfield>
376
+ <controlfield tag=\"008\">020117p20011990xxuzz h d</controlfield>
377
+
378
+ <datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
379
+ <subfield code=\"a\">Music for horn</subfield>
380
+ <subfield code=\"h\">[sound recording] /</subfield>
381
+ <subfield code=\"c\">Brahms, Beethoven, von Krufft.</subfield>
382
+ </datafield>
383
+
384
+ <datafield tag=\"260\" ind1=\" \" ind2=\" \">
385
+ <subfield code=\"a\">[United States] :</subfield>
386
+ <subfield code=\"b\">Harmonia Mundi USA,</subfield>
387
+ <subfield code=\"c\">p2001.</subfield>
388
+ </datafield>
389
+
390
+ <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
391
+ <subfield code=\"a\">Greer, Lowell.</subfield>
392
+ </datafield>
393
+
394
+ <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
395
+ <subfield code=\"a\">Lubin, Steven.</subfield>
396
+ </datafield>
397
+
398
+ <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
399
+ <subfield code=\"a\">Chase, Stephanie,</subfield>
400
+ <subfield code=\"d\">1957-</subfield>
401
+ </datafield>
402
+
403
+ <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
404
+ <subfield code=\"a\">Brahms, Johannes,</subfield>
405
+ <subfield code=\"d\">1833-1897.</subfield>
406
+ <subfield code=\"t\">Trios,</subfield>
407
+ <subfield code=\"m\">piano, violin, horn,</subfield>
408
+ <subfield code=\"n\">op. 40,</subfield>
409
+ <subfield code=\"r\">E? major.</subfield>
410
+ </datafield>
411
+
412
+ <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
413
+ <subfield code=\"a\">Beethoven, Ludwig van,</subfield>
414
+ <subfield code=\"d\">1770-1827.</subfield>
415
+ <subfield code=\"t\">Sonatas,</subfield>
416
+ <subfield code=\"m\">horn, piano,</subfield>
417
+ <subfield code=\"n\">op. 17,</subfield>
418
+ <subfield code=\"r\">F major.</subfield>
419
+ </datafield>
420
+
421
+ <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
422
+ <subfield code=\"a\">Krufft, Nikolaus von,</subfield>
423
+ <subfield code=\"d\">1779-1818.</subfield>
424
+ <subfield code=\"t\">Sonata,</subfield>
425
+ <subfield code=\"m\">horn, piano,</subfield>
426
+ <subfield code=\"r\">F major.</subfield>
427
+ </datafield>
428
+
429
+ <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
430
+ <subfield code=\"a\">Doe, John</subfield>
431
+ </datafield>
432
+
433
+ <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
434
+ <subfield code=\"a\">Doe, Jane</subfield>
435
+ </datafield>
436
+
437
+ <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
438
+ <subfield code=\"a\">Smith, John</subfield>
439
+ </datafield>
440
+
441
+ <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
442
+ <subfield code=\"a\">Smith, Jane</subfield>
443
+ </datafield>
444
+
445
+ <datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
446
+ <subfield code=\"a\">Smith, James</subfield>
447
+ </datafield>
448
+ </record>"
449
+ end
450
+
451
+ # No elements that can be put into a citation
452
+ def no_good_data_xml
453
+ "<record>
454
+ <leader>01828cjm a2200409 a 4500</leader>
455
+ <controlfield tag=\"001\">a4768316</controlfield>
456
+ <controlfield tag=\"003\">SIRSI</controlfield>
457
+ <controlfield tag=\"007\">sd fungnnmmned</controlfield>
458
+ <controlfield tag=\"008\">020117p20011990xxuzz h d</controlfield>
459
+
460
+ <datafield tag=\"024\" ind1=\"1\" ind2=\" \">
461
+ <subfield code=\"a\">713746703721</subfield>
462
+ </datafield>
463
+
464
+ <datafield tag=\"028\" ind1=\"0\" ind2=\"0\">
465
+ <subfield code=\"a\">HCX 3957037</subfield>
466
+ <subfield code=\"b\">Harmonia Mundi USA</subfield>
467
+ </datafield>
468
+
469
+ <datafield tag=\"033\" ind1=\"2\" ind2=\"0\">
470
+ <subfield code=\"a\">19901203</subfield>
471
+ <subfield code=\"a\">19901206</subfield>
472
+ </datafield>
473
+
474
+ <datafield tag=\"035\" ind1=\" \" ind2=\" \">
475
+ <subfield code=\"a\">(OCoLC-M)48807235</subfield>
476
+ </datafield>
477
+
478
+ <datafield tag=\"040\" ind1=\" \" ind2=\" \">
479
+ <subfield code=\"a\">WC4</subfield>
480
+ <subfield code=\"c\">WC4</subfield>
481
+ <subfield code=\"d\">CSt</subfield>
482
+ </datafield>
483
+
484
+ <datafield tag=\"041\" ind1=\"0\" ind2=\" \">
485
+ <subfield code=\"g\">engfre</subfield>
486
+ </datafield>
487
+ </record>"
488
+ end
489
+
490
+ # Bad author name
491
+ def bad_author_xml
492
+ "<record>
493
+ <leader>01021cam a2200277 a 4500</leader>
494
+ <controlfield tag=\"001\">a1711966</controlfield>
495
+ <controlfield tag=\"003\">SIRSI</controlfield>
496
+ <controlfield tag=\"008\">890421s1988 enka 001 0 eng d</controlfield>
497
+
498
+ <datafield tag=\"100\" ind1=\"1\" ind2=\" \">
499
+ <subfield code=\"a\"></subfield>
500
+ </datafield>
501
+
502
+ <datafield tag=\"245\" ind1=\"1\" ind2=\"4\">
503
+ <subfield code=\"a\">The horn /</subfield>
504
+ <subfield code=\"c\">Kurt Janetzky and Bernhard Bruchle ; translated from the German by James Chater.</subfield>
505
+ </datafield>
506
+
507
+ <datafield tag=\"260\" ind1=\" \" ind2=\" \">
508
+ <subfield code=\"a\">London :</subfield>
509
+ <subfield code=\"b\">Batsford,</subfield>
510
+ <subfield code=\"c\">1988.</subfield>
511
+ </datafield>
512
+
513
+ <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
514
+ <subfield code=\"a\">Brüchle, Bernhard.</subfield>
515
+ </datafield>
516
+ </record>"
517
+ end
518
+
519
+ describe Blacklight::Solr::Document::MarcExport do
520
+
521
+ before(:all) do
522
+ dclass = Class.new do
523
+ include Blacklight::Solr::Document::MarcExport
524
+ attr_accessor :to_marc
525
+ def initialize(marc_xml_str)
526
+ self.to_marc = marc_from_xml(marc_xml_str)
527
+ end
528
+ end
529
+
530
+ @typical_record = dclass.new( standard_citation )
531
+ @music_record = dclass.new( music_record )
532
+ @dissertation_record = dclass.new( dissertation_note_xml )
533
+ @record_without_245b = dclass.new( record1_xml )
534
+ @three_authors_record = dclass.new( three_authors_xml )
535
+ @record_without_authors = dclass.new( record2_xml )
536
+ @record_with_10plus_authors = dclass.new( record3_xml )
537
+ @year_range_record = dclass.new( year_range_xml )
538
+ @no_date_record = dclass.new( no_date_xml )
539
+ @section_title_record = dclass.new( section_title_xml )
540
+ @special_contributor_record = dclass.new( special_contributor_with_author_xml )
541
+ @record_without_citable_data = dclass.new( no_good_data_xml )
542
+ @record_with_bad_author = dclass.new( bad_author_xml )
543
+ @special_contributor_no_auth_record = dclass.new( special_contributor_no_author_xml )
544
+ @record_utf8_decomposed = dclass.new( utf8_decomposed_record_xml )
545
+
546
+ end
547
+
548
+ describe "export_as_chicago_citation_txt" do
549
+ it "should handle a typical record correclty" do
550
+ expect(@typical_record.export_as_chicago_citation_txt).to eq("Ferree, David C., and I. J Warrington. <i>Apples: Botany, Production, and Uses.</i> Oxon, U.K.: CABI Pub., 2003.")
551
+ end
552
+ it "should format a record w/o authors correctly" do
553
+ expect(@record_without_authors.export_as_chicago_citation_txt).to eq("<i>Final Report to the Honorable John J. Gilligan, Governor.</i> [Columbus: Printed by the State of Ohio, Dept. of Urban Affairs, 1971.")
554
+ end
555
+ it "should format a citation without a 245b field correctly" do
556
+ expect(@record_without_245b.export_as_chicago_citation_txt).to eq("Janetzky, Kurt., and Bernhard Brüchle. <i>The Horn.</i> London: Batsford, 1988.")
557
+ end
558
+ it "should format a citation with 4+ authors correctly" do
559
+ chicago_text = @record_with_10plus_authors.export_as_chicago_citation_txt
560
+ expect(chicago_text).to eq("Greer, Lowell., Steven Lubin, Stephanie Chase, Johannes Brahms, Ludwig van Beethoven, Nikolaus von Krufft, John Doe, et al. <i>Music for Horn.</i> [United States]: Harmonia Mundi USA, 2001.")
561
+ expect(chicago_text).to match(/John Doe, et al\./)
562
+ expect(chicago_text).not_to match(/Jane Doe/)
563
+ end
564
+ it "should handle dissertation data correctly" do
565
+ expect(@dissertation_record.export_as_chicago_citation_txt).to eq("<i>Thesis On Some Subject.</i> Phd Thesis -- Goodenough College, 2009.")
566
+ end
567
+ it "should handle 3 authors correctly" do
568
+ expect(@three_authors_record.export_as_chicago_citation_txt).to match(/^Doe, John, Joe Schmoe, and Bill Schmoe\./)
569
+ end
570
+ it "should handle editors, translators, and compilers correctly" do
571
+ expect(@special_contributor_record.export_as_chicago_citation_txt).to eq("Doe, John <i>Title of Item.</i> Translated by Joe Schmoe. Edited by Bill Schmoe. Compiled by Susie Schmoe. Publisher: Place, 2009.")
572
+ end
573
+ it "should handle editors, translators, and compilers correctly when there is no author present" do
574
+ expect(@special_contributor_no_auth_record.export_as_chicago_citation_txt).to eq("Schmoe, Joe trans., Bill Schmoe ed., and Susie Schmoe comp. <i>Title of Item.</i> Publisher: Place, 2009.")
575
+ end
576
+ it "should handle year ranges properly" do
577
+ expect(@year_range_record.export_as_chicago_citation_txt).not_to match(/2000/)
578
+ end
579
+ it "should handle n.d. in the 260$c properly" do
580
+ expect(@no_date_record.export_as_chicago_citation_txt).to match(/n\.d\.$/)
581
+ end
582
+ it "should handle section title appropriately" do
583
+ expect(@section_title_record.export_as_chicago_citation_txt).to eq("Schmoe, Joe <i>Main Title: Subtitle\.<\/i> Number of Part, <i>Name of Part\.<\/i> London: Batsford, 2001.")
584
+ end
585
+ it "should not fail if there is no citation data" do
586
+ expect(@record_without_citable_data.export_as_chicago_citation_txt).to eq("")
587
+ end
588
+ end
589
+
590
+ describe "export_as_apa_citation_txt" do
591
+ it "should format a standard citation correctly" do
592
+ expect(@typical_record.export_as_apa_citation_txt).to eq("Ferree, D. C, &amp; Warrington, I. J. (2003). <i>Apples : botany, production, and uses.</i> Oxon, U.K.: CABI Pub.")
593
+ end
594
+
595
+ it "should format a citation without a 245b field correctly" do
596
+ expect(@record_without_245b.export_as_apa_citation_txt).to eq("Janetzky, K., &amp; Brüchle, B. (1988). <i>The horn.</i> London: Batsford.")
597
+ end
598
+
599
+ it "should format a citation without any authors correctly" do
600
+ expect(@record_without_authors.export_as_apa_citation_txt).to eq("(1971). <i>Final report to the Honorable John J. Gilligan, Governor.</i> [Columbus: Printed by the State of Ohio, Dept. of Urban Affairs.")
601
+ end
602
+
603
+ it "should not fail if there is no citation data" do
604
+ expect(@record_without_citable_data.export_as_apa_citation_txt).to eq("")
605
+ end
606
+
607
+ it "should not bomb with a null pointer if there if author data is empty" do
608
+ expect(@record_with_bad_author.export_as_apa_citation_txt).to eq("Brüchle, B. (1988). <i>The horn.</i> London: Batsford.")
609
+ end
610
+
611
+ end
612
+
613
+ describe "export_as_mla_citation_txt" do
614
+ it "should format a standard citation correctly" do
615
+ expect(@typical_record.export_as_mla_citation_txt).to eq("Ferree, David C, and I. J Warrington. <i>Apples : Botany, Production, and Uses.</i> Oxon, U.K.: CABI Pub., 2003.")
616
+ end
617
+
618
+ it "should format a citation without a 245b field correctly" do
619
+ expect(@record_without_245b.export_as_mla_citation_txt).to eq("Janetzky, Kurt, and Bernhard Brüchle. <i>The Horn.</i> London: Batsford, 1988.")
620
+ end
621
+
622
+ it "should format a citation without any authors correctly" do
623
+ expect(@record_without_authors.export_as_mla_citation_txt).to eq("<i>Final Report to the Honorable John J. Gilligan, Governor.</i> [Columbus: Printed by the State of Ohio, Dept. of Urban Affairs, 1971.")
624
+ end
625
+
626
+ it "should format a citation with 4+ authors correctly" do
627
+ expect(@record_with_10plus_authors.export_as_mla_citation_txt).to eq("Greer, Lowell, et al. <i>Music for Horn.</i> [United States]: Harmonia Mundi USA, 2001.")
628
+ end
629
+
630
+ it "should not fail if there is no citation data" do
631
+ expect(@record_without_citable_data.export_as_mla_citation_txt).to eq("")
632
+ end
633
+ end
634
+
635
+ describe "export_as_openurl_ctx_kev" do
636
+ it "should create the appropriate context object for books" do
637
+ record = @typical_record.export_as_openurl_ctx_kev('Book')
638
+ expect(record).to 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
639
+ expect(record).not_to match(/.*rft.genre=article.*rft.issn=.*/)
640
+ end
641
+ it "should create the appropriate context object for journals" do
642
+ record = @typical_record.export_as_openurl_ctx_kev('Journal')
643
+ record_journal_other = @typical_record.export_as_openurl_ctx_kev('Journal/Magazine')
644
+ expect(record).to 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
645
+ expect(record_journal_other).to eq(record) and
646
+ expect(record).not_to match(/.*rft.genre=book.*rft.isbn=.*/)
647
+ end
648
+ it "should create the appropriate context object for other content" do
649
+ record = @typical_record.export_as_openurl_ctx_kev('NotARealFormat')
650
+ expect(record).to 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
651
+ expect(record).not_to match(/.*rft.isbn=.*/) and
652
+ expect(record).not_to match(/.*rft.issn=.*/)
653
+ end
654
+ end
655
+
656
+ describe "export_as_marc binary" do
657
+ it "should export_as_marc" do
658
+ expect(@typical_record.export_as_marc).to eq(@typical_record.to_marc.to_marc)
659
+ end
660
+ end
661
+
662
+ describe "export_as_marcxml" do
663
+ it "should export_as_marcxml" do
664
+ expect(marc_from_xml(@typical_record.export_as_marcxml)).to eq(marc_from_xml(@typical_record.to_marc.to_xml.to_s))
665
+ end
666
+ end
667
+
668
+ describe "export_as_xml" do
669
+ it "should export marcxml as xml" do
670
+ expect(marc_from_xml(@typical_record.export_as_xml)).to eq(marc_from_xml(@typical_record.export_as_marcxml))
671
+ end
672
+ end
673
+
674
+ describe "export_as_refworks_marc_txt" do
675
+ it "should export correctly" do
676
+ expect(@music_record.export_as_refworks_marc_txt).to eq("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")
677
+ end
678
+ describe "for UTF-8 record" do
679
+ it "should export in Unicode normalized C form" do
680
+ @utf8_exported = @record_utf8_decomposed.export_as_refworks_marc_txt
681
+
682
+ if defined? Unicode
683
+ expect(@utf8_exported).not_to include("\314\204\312\273") # decomposed
684
+ expect(@utf8_exported).to include("\304\253\312\273") # C-form normalized
685
+ end
686
+ end
687
+ end
688
+ end
689
+
690
+ describe "export_as_endnote" do
691
+ it "should export_correctly" do
692
+ endnote_file = @music_record.export_as_endnote
693
+ # We have to parse it a bit to check it.
694
+ endnote_entries = Hash.new {|hash, key| hash[key] = Set.new }
695
+ endnote_file.each_line do |line|
696
+ line =~ /\%(..?) (.*)$/
697
+ endnote_entries[$1] << $2
698
+ end
699
+
700
+ expect(endnote_entries["0"]).to eq(Set.new(["Generic"])) # 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.
701
+ expect(endnote_entries["D"]).to eq(Set.new(["p2001. "]))
702
+ expect(endnote_entries["C"]).to eq(Set.new(["[United States] : "]))
703
+ expect(endnote_entries["E"]).to eq(Set.new(["Greer, Lowell. ", "Lubin, Steven. ", "Chase, Stephanie, ", "Brahms, Johannes, ", "Beethoven, Ludwig van, ", "Krufft, Nikolaus von, "]))
704
+ expect(endnote_entries["I"]).to eq(Set.new(["Harmonia Mundi USA, "]))
705
+ expect(endnote_entries["T"]).to eq(Set.new(["Music for horn "]))
706
+
707
+ #nothing extra
708
+ expect(Set.new(endnote_entries.keys)).to eq(Set.new(["0", "C", "D", "E", "I", "T"]))
709
+ end
710
+ end
711
+
712
+ describe "Citation title transformation" do
713
+ before(:each) do
714
+ class CitationTitleTest
715
+ include Blacklight::Solr::Document::MarcExport
716
+ def transform_title(text)
717
+ citation_title(text)
718
+ end
719
+ end
720
+ @citation_title = CitationTitleTest.new
721
+ end
722
+ it "should tranform a normal title properlly" do
723
+ expect(@citation_title.transform_title("This is just a test")).to eq("This Is Just a Test")
724
+ end
725
+ it "should not attempt to capatilize words in all-caps (e.g. acronyms)" do
726
+ expect(@citation_title.transform_title("IBM PC applications")).to eq("IBM PC Applications")
727
+ end
728
+ it "should capitalize a preposition if it is the first word in a title" do
729
+ expect(@citation_title.transform_title("of mice and men")).to eq("Of Mice and Men")
730
+ end
731
+ it "should handle hyphenated words properly" do
732
+ expect(@citation_title.transform_title("Testing hyphenated-words and how they get capitalized")).to eq("Testing Hyphenated-Words and How They Get Capitalized")
733
+ end
734
+ it "should handle normal prepositions properly" do
735
+ expect(@citation_title.transform_title("A little learning is a dangerous thing")).to eq("A Little Learning Is a Dangerous Thing")
736
+ expect(@citation_title.transform_title("Four theories concerning the Gospel according to Matthew")).to eq("Four Theories Concerning the Gospel According to Matthew")
737
+ expect(@citation_title.transform_title("Tired but happy")).to eq("Tired but Happy")
738
+ expect(@citation_title.transform_title("Mnemonics that work are better than rules that do not")).to eq("Mnemonics That Work Are Better Than Rules That Do Not")
739
+ expect(@citation_title.transform_title("This is just a test")).to eq("This Is Just a Test")
740
+ expect(@citation_title.transform_title("the mind of the Renaissance")).to eq("The Mind of the Renaissance")
741
+ expect(@citation_title.transform_title("Are you considering psychoanalysis?")).to eq("Are You Considering Psychoanalysis?")
742
+ expect(@citation_title.transform_title("Not without laughter")).to eq("Not without Laughter")
743
+ end
744
+ end
745
+
746
+ end