enju_biblio 0.2.0.beta.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/enju_biblio/version.rb +1 -1
- metadata +452 -454
- data/spec/models/manifestation_spec.rb.mod +0 -337
@@ -1,337 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
require 'rails_helper'
|
3
|
-
|
4
|
-
describe Manifestation, :solr => true do
|
5
|
-
fixtures :all
|
6
|
-
before do
|
7
|
-
Manifestation.reindex
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should set year_of_publication" do
|
11
|
-
manifestation = FactoryGirl.create(:manifestation, :pub_date => '2000')
|
12
|
-
manifestation.year_of_publication.should eq 2000
|
13
|
-
manifestation.date_of_publication.should eq Time.zone.parse('2000-01-01')
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should set date_of_publication" do
|
17
|
-
manifestation = FactoryGirl.create(:manifestation, :pub_date => '2000-01')
|
18
|
-
manifestation.year_of_publication.should eq 2000
|
19
|
-
manifestation.month_of_publication.should eq 1
|
20
|
-
manifestation.date_of_publication.should eq Time.zone.parse('2000-01-01')
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should set volume_number" do
|
24
|
-
manifestation = FactoryGirl.create(:manifestation, :volume_number_string => '第1巻', :issue_number_string => '20号分冊1', :edition_string => '第3版')
|
25
|
-
manifestation.volume_number.should eq 1
|
26
|
-
manifestation.issue_number.should eq 20
|
27
|
-
manifestation.edition.should eq 3
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should search title in openurl" do
|
31
|
-
openurl = Openurl.new({:title => "プログラミング"})
|
32
|
-
results = openurl.search
|
33
|
-
openurl.query_text.should eq "btitle_text:プログラミング"
|
34
|
-
results.size.should eq 7
|
35
|
-
openurl = Openurl.new({:jtitle => "テスト"})
|
36
|
-
results = openurl.search
|
37
|
-
results.size.should eq 3
|
38
|
-
openurl.query_text.should eq "jtitle_text:テスト"
|
39
|
-
openurl = Openurl.new({:atitle => "2005"})
|
40
|
-
results = openurl.search
|
41
|
-
results.size.should eq 1
|
42
|
-
openurl.query_text.should eq "atitle_text:2005"
|
43
|
-
openurl = Openurl.new({:atitle => "テスト", :jtitle => "テスト雑誌"})
|
44
|
-
results = openurl.search
|
45
|
-
results.size.should eq 2
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should search agent in openurl" do
|
49
|
-
openurl = Openurl.new({:aulast => "Administrator"})
|
50
|
-
results = openurl.search
|
51
|
-
openurl.query_text.should eq "au_text:Administrator"
|
52
|
-
results.size.should eq 2
|
53
|
-
openurl = Openurl.new({:aufirst => "名称"})
|
54
|
-
results = openurl.search
|
55
|
-
openurl.query_text.should eq "au_text:名称"
|
56
|
-
results.size.should eq 1
|
57
|
-
openurl = Openurl.new({:au => "テスト"})
|
58
|
-
results = openurl.search
|
59
|
-
openurl.query_text.should eq "au_text:テスト"
|
60
|
-
results.size.should eq 1
|
61
|
-
openurl = Openurl.new({:pub => "Administrator"})
|
62
|
-
results = openurl.search
|
63
|
-
openurl.query_text.should eq "publisher_text:Administrator"
|
64
|
-
results.size.should eq 4
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should search isbn in openurl" do
|
68
|
-
openurl = Openurl.new({:api => "openurl", :isbn => "4798"})
|
69
|
-
results = openurl.search
|
70
|
-
openurl.query_text.should eq "isbn_sm:4798*"
|
71
|
-
results.size.should eq 2
|
72
|
-
end
|
73
|
-
|
74
|
-
it "should search issn in openurl" do
|
75
|
-
openurl = Openurl.new({:api => "openurl", :issn => "0913"})
|
76
|
-
results = openurl.search
|
77
|
-
openurl.query_text.should eq "issn_sm:0913*"
|
78
|
-
results.size.should eq 1
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should search any in openurl" do
|
82
|
-
openurl = Openurl.new({:any => "テスト"})
|
83
|
-
results = openurl.search
|
84
|
-
results.size.should eq 9
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should search multi in openurl" do
|
88
|
-
openurl = Openurl.new({:btitle => "CGI Perl プログラミング"})
|
89
|
-
results = openurl.search
|
90
|
-
results.size.should eq 2
|
91
|
-
openurl = Openurl.new({:jtitle => "テスト", :pub => "テスト"})
|
92
|
-
results = openurl.search
|
93
|
-
results.size.should eq 2
|
94
|
-
end
|
95
|
-
|
96
|
-
it "shoulld get search_error in openurl" do
|
97
|
-
lambda{Openurl.new({:isbn => "12345678901234"})}.should raise_error(OpenurlQuerySyntaxError)
|
98
|
-
lambda{Openurl.new({:issn => "1234abcd"})}.should raise_error(OpenurlQuerySyntaxError)
|
99
|
-
lambda{Openurl.new({:aufirst => "テスト 名称"})}.should raise_error(OpenurlQuerySyntaxError)
|
100
|
-
end
|
101
|
-
|
102
|
-
it "should search in sru" do
|
103
|
-
sru = Sru.new({:query => "title=Ruby"})
|
104
|
-
sru.search
|
105
|
-
sru.manifestations.size.should eq 18
|
106
|
-
sru.manifestations.first.titles.first.should eq 'Ruby'
|
107
|
-
sru = Sru.new({:query => "title=^ruby"})
|
108
|
-
sru.search
|
109
|
-
sru.manifestations.size.should eq 9
|
110
|
-
sru = Sru.new({:query => 'title ALL "awk sed"'})
|
111
|
-
sru.search
|
112
|
-
sru.manifestations.size.should eq 2
|
113
|
-
sru.manifestations.collect{|m| m.id}.should eq [184, 116]
|
114
|
-
sru = Sru.new({:query => 'title ANY "ruby awk sed"'})
|
115
|
-
sru.search
|
116
|
-
sru.manifestations.size.should eq 22
|
117
|
-
sru = Sru.new({:query => 'isbn=9784756137470'})
|
118
|
-
sru.search
|
119
|
-
sru.manifestations.first.id.should eq 114
|
120
|
-
sru = Sru.new({:query => "creator=テスト"})
|
121
|
-
sru.search
|
122
|
-
sru.manifestations.size.should eq 1
|
123
|
-
end
|
124
|
-
|
125
|
-
it "should search date in sru" do
|
126
|
-
sru = Sru.new({:query => "from = 2000-09 AND until = 2000-11-01"})
|
127
|
-
sru.search
|
128
|
-
sru.manifestations.size.should eq 1
|
129
|
-
sru.manifestations.first.id.should eq 120
|
130
|
-
sru = Sru.new({:query => "from = 1993-02-24"})
|
131
|
-
sru.search
|
132
|
-
sru.manifestations.size.should eq 5
|
133
|
-
sru = Sru.new({:query => "until = 2006-08-06"})
|
134
|
-
sru.search
|
135
|
-
sru.manifestations.size.should eq 4
|
136
|
-
end
|
137
|
-
|
138
|
-
it "should accept sort_by in sru" do
|
139
|
-
sru = Sru.new({:query => "title=Ruby"})
|
140
|
-
sru.sort_by.should eq({:sort_by => 'created_at', :order => 'desc'})
|
141
|
-
sru = Sru.new({:query => 'title=Ruby AND sortBy="title/sort.ascending"', :sortKeys => 'creator,0', :version => '1.2'})
|
142
|
-
sru.sort_by.should eq({:sort_by => 'sort_title', :order => 'asc'})
|
143
|
-
sru = Sru.new({:query => 'title=Ruby AND sortBy="title/sort.ascending"', :sortKeys => 'creator,0', :version => '1.1'})
|
144
|
-
sru.sort_by.should eq({:sort_by => 'creator', :order => 'desc'})
|
145
|
-
sru = Sru.new({:query => 'title=Ruby AND sortBy="title/sort.ascending"', :sortKeys => 'creator,1', :version => '1.1'})
|
146
|
-
sru.sort_by.should eq({:sort_by => 'creator', :order => 'asc'})
|
147
|
-
sru = Sru.new({:query => 'title=Ruby AND sortBy="title'})
|
148
|
-
sru.sort_by.should eq({:sort_by => 'sort_title', :order => 'asc'})
|
149
|
-
#TODO ソート基準が入手しやすさの場合の処理
|
150
|
-
end
|
151
|
-
|
152
|
-
it "should accept ranges in sru" do
|
153
|
-
sru = Sru.new({:query => "from = 1993-02-24 AND until = 2006-08-06 AND title=プログラミング"})
|
154
|
-
sru.search
|
155
|
-
sru.manifestations.size.should eq 2
|
156
|
-
sru = Sru.new({:query => "until = 2000 AND title=プログラミング"})
|
157
|
-
sru.search
|
158
|
-
sru.manifestations.size.should eq 1
|
159
|
-
sru = Sru.new({:query => "from = 2006 AND title=プログラミング"})
|
160
|
-
sru.search
|
161
|
-
sru.manifestations.size.should eq 1
|
162
|
-
sru = Sru.new({:query => "from = 2007 OR title=awk"})
|
163
|
-
sru.search
|
164
|
-
sru.manifestations.size.should eq 6
|
165
|
-
end
|
166
|
-
|
167
|
-
it "should be reserved" do
|
168
|
-
manifestations(:manifestation_00007).is_reserved_by?(users(:admin)).should be_truthy
|
169
|
-
end
|
170
|
-
|
171
|
-
it "should not be reserved" do
|
172
|
-
manifestations(:manifestation_00007).is_reserved_by?(users(:user1)).should be_falsy
|
173
|
-
end
|
174
|
-
|
175
|
-
it "should_get_number_of_pages" do
|
176
|
-
manifestations(:manifestation_00001).number_of_pages.should eq 100
|
177
|
-
end
|
178
|
-
|
179
|
-
it "should get youtube_id" do
|
180
|
-
manifestations(:manifestation_00022).youtube_id.should eq 'BSHBzd9ftDE'
|
181
|
-
end
|
182
|
-
|
183
|
-
it "should get nicovideo_id" do
|
184
|
-
manifestations(:manifestation_00023).nicovideo_id.should eq 'sm3015373'
|
185
|
-
end
|
186
|
-
|
187
|
-
it "should have parent_of_series" do
|
188
|
-
manifestations(:manifestation_00001).parent_of_series.should be_truthy
|
189
|
-
end
|
190
|
-
|
191
|
-
it "should respond to extract_text" do
|
192
|
-
manifestations(:manifestation_00001).extract_text.should be_nil
|
193
|
-
end
|
194
|
-
|
195
|
-
it "should not be reserved it it has no item" do
|
196
|
-
manifestations(:manifestation_00008).is_reservable_by?(users(:admin)).should be_falsy
|
197
|
-
end
|
198
|
-
|
199
|
-
it "should respond to title" do
|
200
|
-
manifestations(:manifestation_00001).title.should be_truthy
|
201
|
-
end
|
202
|
-
|
203
|
-
it "should respond to pickup" do
|
204
|
-
lambda{Manifestation.pickup}.should_not raise_error #(ActiveRecord::RecordNotFound)
|
205
|
-
end
|
206
|
-
|
207
|
-
it "should be periodical if its series_statement is periodical" do
|
208
|
-
manifestations(:manifestation_00202).serial?.should be_truthy
|
209
|
-
end
|
210
|
-
|
211
|
-
it "should validate access_address" do
|
212
|
-
manifestation = manifestations(:manifestation_00202)
|
213
|
-
manifestation.access_address = 'http:/www.example.jp'
|
214
|
-
manifestation.should_not be_valid
|
215
|
-
end
|
216
|
-
|
217
|
-
#it "should set series_statement if the manifestation is periodical" do
|
218
|
-
# manifestation = series_statements(:two).manifestations.new
|
219
|
-
# manifestation.set_series_statements([series_statements(:two)])
|
220
|
-
# #manifestation.original_title.should eq 'テスト雑誌2月号'
|
221
|
-
# #manifestation.serial_number.should eq 3
|
222
|
-
# #manifestation.issue_number.should eq 3
|
223
|
-
# #manifestation.volume_number.should eq 1
|
224
|
-
#end
|
225
|
-
|
226
|
-
context ".export" do
|
227
|
-
it "should export a header line" do
|
228
|
-
lines = Manifestation.export
|
229
|
-
csv = CSV.parse(lines, headers: true, col_sep: "\t")
|
230
|
-
csv["manifestation_id"].compact.should_not be_empty
|
231
|
-
csv["manifestation_identifier"].compact.should_not be_empty
|
232
|
-
csv["manifestation_created_at"].compact.should_not be_empty
|
233
|
-
csv["manifestation_updated_at"].compact.should_not be_empty
|
234
|
-
csv["item_id"].compact.should_not be_empty
|
235
|
-
csv["item_created_at"].compact.should_not be_empty
|
236
|
-
csv["item_updated_at"].compact.should_not be_empty
|
237
|
-
csv["subject:unknown"].compact.should eq manifestations(:manifestation_00001).items.count.times.map{"next-l"}
|
238
|
-
csv["classification:ndc9"].compact.should eq manifestations(:manifestation_00001).items.count.times.map{"400"}
|
239
|
-
end
|
240
|
-
|
241
|
-
it "should respect the role of the user" do
|
242
|
-
FactoryGirl.create(:item, bookstore_id: 1, price: 100, budget_type_id: 1)
|
243
|
-
lines = Manifestation.export
|
244
|
-
csv = CSV.parse(lines, headers: true, col_sep: "\t")
|
245
|
-
expect(csv["bookstore"].compact).to be_empty
|
246
|
-
expect(csv["item_price"].compact).to be_empty
|
247
|
-
expect(csv["budget_type"].compact).to be_empty
|
248
|
-
|
249
|
-
lines = Manifestation.export(format: :txt, role: :Librarian)
|
250
|
-
csv = CSV.parse(lines, headers: true, col_sep: "\t")
|
251
|
-
expect(csv["bookstore"].compact).not_to be_empty
|
252
|
-
expect(csv["item_price"].compact).not_to be_empty
|
253
|
-
expect(csv["budget_type"].compact).not_to be_empty
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
if defined?(EnjuCirculation)
|
258
|
-
it "should respond to is_checked_out_by?" do
|
259
|
-
manifestations(:manifestation_00001).is_checked_out_by?(users(:admin)).should be_truthy
|
260
|
-
manifestations(:manifestation_00001).is_checked_out_by?(users(:librarian2)).should be_falsy
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
|
-
it "should search with ignoring ideographic variation selectors" do
|
265
|
-
FactoryGirl.create(:manifestation, original_title: "葛#{0xE0103.chr(Encoding::UTF_8)}飾区") #葛飾区
|
266
|
-
search = Manifestation.search do
|
267
|
-
fulltext "葛飾区"
|
268
|
-
end
|
269
|
-
results = search.execute.results
|
270
|
-
expect(results).not_to be_empty
|
271
|
-
end
|
272
|
-
end
|
273
|
-
|
274
|
-
# == Schema Information
|
275
|
-
#
|
276
|
-
# Table name: manifestations
|
277
|
-
#
|
278
|
-
# id :integer not null, primary key
|
279
|
-
# original_title :text not null
|
280
|
-
# title_alternative :text
|
281
|
-
# title_transcription :text
|
282
|
-
# classification_number :string
|
283
|
-
# manifestation_identifier :string
|
284
|
-
# date_of_publication :datetime
|
285
|
-
# date_copyrighted :datetime
|
286
|
-
# created_at :datetime
|
287
|
-
# updated_at :datetime
|
288
|
-
# deleted_at :datetime
|
289
|
-
# access_address :string
|
290
|
-
# language_id :integer default(1), not null
|
291
|
-
# carrier_type_id :integer default(1), not null
|
292
|
-
# start_page :integer
|
293
|
-
# end_page :integer
|
294
|
-
# height :integer
|
295
|
-
# width :integer
|
296
|
-
# depth :integer
|
297
|
-
# price :integer
|
298
|
-
# fulltext :text
|
299
|
-
# volume_number_string :string
|
300
|
-
# issue_number_string :string
|
301
|
-
# serial_number_string :string
|
302
|
-
# edition :integer
|
303
|
-
# note :text
|
304
|
-
# repository_content :boolean default(FALSE), not null
|
305
|
-
# lock_version :integer default(0), not null
|
306
|
-
# required_role_id :integer default(1), not null
|
307
|
-
# required_score :integer default(0), not null
|
308
|
-
# frequency_id :integer default(1), not null
|
309
|
-
# subscription_master :boolean default(FALSE), not null
|
310
|
-
# attachment_file_name :string
|
311
|
-
# attachment_content_type :string
|
312
|
-
# attachment_file_size :integer
|
313
|
-
# attachment_updated_at :datetime
|
314
|
-
# title_alternative_transcription :text
|
315
|
-
# description :text
|
316
|
-
# abstract :text
|
317
|
-
# available_at :datetime
|
318
|
-
# valid_until :datetime
|
319
|
-
# date_submitted :datetime
|
320
|
-
# date_accepted :datetime
|
321
|
-
# date_captured :datetime
|
322
|
-
# pub_date :string
|
323
|
-
# edition_string :string
|
324
|
-
# volume_number :integer
|
325
|
-
# issue_number :integer
|
326
|
-
# serial_number :integer
|
327
|
-
# content_type_id :integer default(1)
|
328
|
-
# year_of_publication :integer
|
329
|
-
# attachment_meta :text
|
330
|
-
# month_of_publication :integer
|
331
|
-
# fulltext_content :boolean
|
332
|
-
# serial :boolean
|
333
|
-
# statement_of_responsibility :text
|
334
|
-
# publication_place :text
|
335
|
-
# extent :text
|
336
|
-
# dimensions :text
|
337
|
-
#
|