enju_biblio 0.1.0.pre41 → 0.1.0.pre42
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/manifestations_controller.rb +22 -17
- data/app/controllers/patron_import_results_controller.rb +1 -1
- data/app/controllers/resource_import_results_controller.rb +1 -1
- data/app/models/item.rb +0 -1
- data/app/models/manifestation.rb +1 -2
- data/app/models/patron.rb +0 -8
- data/app/views/notifier/manifestation_info.en.text.erb +18 -0
- data/app/views/notifier/manifestation_info.ja.text.erb +18 -0
- data/lib/enju_biblio/version.rb +1 -1
- data/spec/cassette_library/ImportRequest/import/should_import_bibliographic_record.yml +12 -12
- data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Administrator/with_isbn_which_is_already_imported/redirects_to_the_created_import_request.yml +12 -12
- data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Administrator/with_valid_params/assigns_a_newly_created_import_request_as_import_request.yml +12 -12
- data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Administrator/with_valid_params/redirects_to_the_created_import_request.yml +13 -13
- data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Librarian/with_valid_params/assigns_a_newly_created_import_request_as_import_request.yml +13 -13
- data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Librarian/with_valid_params/redirects_to_the_created_import_request.yml +12 -12
- data/spec/cassette_library/ResourceImportFile/when_its_mode_is_create_/when_it_has_only_isbn/should_be_imported.yml +613 -0
- data/spec/cassette_library/ResourceImportFile/when_its_mode_is_create_/when_it_is_written_in_shift_jis/should_be_imported.yml +431 -0
- data/spec/cassette_library/ResourceImportFile/when_its_mode_is_create_/when_it_is_written_in_utf-8/should_be_imported.yml +431 -0
- data/spec/controllers/items_controller_spec.rb +16 -8
- data/spec/controllers/patrons_controller_spec.rb +8 -4
- data/spec/dummy/app/controllers/application_controller.rb +1 -174
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/private/system/picture_files/pictures/000/000/005/medium/spinner.gif +0 -0
- data/spec/dummy/private/system/picture_files/pictures/000/000/005/thumb/spinner.gif +0 -0
- data/spec/dummy/solr/data/test/index/_goc.fdt +0 -0
- data/spec/dummy/solr/data/test/index/_goc.fdx +0 -0
- data/spec/dummy/solr/data/test/index/_goc.fnm +7 -0
- data/spec/dummy/solr/data/test/index/_goc.frq +0 -0
- data/spec/dummy/solr/data/test/index/_goc.nrm +1 -0
- data/spec/dummy/solr/data/test/index/_goc.prx +0 -0
- data/spec/dummy/solr/data/test/index/_goc.tii +0 -0
- data/spec/dummy/solr/data/test/index/_goc.tis +0 -0
- data/spec/dummy/solr/data/test/index/_god.fdt +0 -0
- data/spec/dummy/solr/data/test/index/_god.fdx +0 -0
- data/spec/dummy/solr/data/test/index/_god.fnm +7 -0
- data/spec/dummy/solr/data/test/index/_god.frq +0 -0
- data/spec/dummy/solr/data/test/index/_god.nrm +1 -0
- data/spec/dummy/solr/data/test/index/_god.prx +0 -0
- data/spec/dummy/solr/data/test/index/_god.tii +0 -0
- data/spec/dummy/solr/data/test/index/_god.tis +0 -0
- data/spec/dummy/solr/data/test/index/_goe.fdt +0 -0
- data/spec/dummy/solr/data/test/index/_goe.fdx +0 -0
- data/spec/dummy/solr/data/test/index/_goe.fnm +8 -0
- data/spec/dummy/solr/data/test/index/_goe.frq +0 -0
- data/spec/dummy/solr/data/test/index/_goe.nrm +1 -0
- data/spec/dummy/solr/data/test/index/_goe.prx +0 -0
- data/spec/dummy/solr/data/test/index/_goe.tii +0 -0
- data/spec/dummy/solr/data/test/index/_goe.tis +0 -0
- data/spec/dummy/solr/data/test/index/segments.gen +0 -0
- data/spec/dummy/solr/data/test/index/segments_otc +0 -0
- data/spec/dummy/tmp/cache/4AD/470/country_all +0 -0
- data/spec/fixtures/manifestations.yml +1 -1
- data/spec/models/manifestation_spec.rb +1 -1
- data/spec/models/resource_import_file_spec.rb +135 -137
- metadata +73 -39
- data/spec/cassette_library/Manifestation/should_import_isbn.yml +0 -3643
- data/spec/dummy/app/models/role.rb +0 -46
- data/spec/dummy/app/models/user_group.rb +0 -40
- data/spec/dummy/app/models/user_has_role.rb +0 -5
- data/spec/dummy/solr/data/test/index/segments_nq2 +0 -0
@@ -1,183 +1,10 @@
|
|
1
1
|
class ApplicationController < ActionController::Base
|
2
2
|
protect_from_forgery
|
3
3
|
|
4
|
-
|
5
|
-
rescue_from ActiveRecord::RecordNotFound, :with => :render_404
|
6
|
-
|
7
|
-
before_filter :get_library_group, :set_locale, :set_available_languages
|
8
|
-
|
4
|
+
enju_leaf
|
9
5
|
enju_biblio
|
10
6
|
enju_library
|
11
7
|
enju_inventory
|
12
8
|
enju_event
|
13
9
|
enju_subject
|
14
|
-
|
15
|
-
private
|
16
|
-
def render_403
|
17
|
-
return if performed?
|
18
|
-
if user_signed_in?
|
19
|
-
respond_to do |format|
|
20
|
-
format.html {render :template => 'page/403', :status => 403}
|
21
|
-
format.xml {render :template => 'page/403', :status => 403}
|
22
|
-
format.json
|
23
|
-
end
|
24
|
-
else
|
25
|
-
respond_to do |format|
|
26
|
-
format.html {redirect_to new_user_session_url}
|
27
|
-
format.xml {render :template => 'page/403', :status => 403}
|
28
|
-
format.json
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def render_404
|
34
|
-
return if performed?
|
35
|
-
respond_to do |format|
|
36
|
-
format.html {render :template => 'page/404', :status => 404}
|
37
|
-
format.mobile {render :template => 'page/404', :status => 404}
|
38
|
-
format.xml {render :template => 'page/404', :status => 404}
|
39
|
-
format.json
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def access_denied
|
44
|
-
raise CanCan::AccessDenied
|
45
|
-
end
|
46
|
-
|
47
|
-
def store_location
|
48
|
-
if request.get? and request.format.try(:html?) and !request.xhr?
|
49
|
-
session[:user_return_to] = request.fullpath
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def solr_commit
|
54
|
-
Sunspot.commit
|
55
|
-
end
|
56
|
-
|
57
|
-
def move_position(resource, direction, redirect = true)
|
58
|
-
if ['higher', 'lower'].include?(direction)
|
59
|
-
resource.send("move_#{direction}")
|
60
|
-
if redirect
|
61
|
-
redirect_to url_for(:controller => resource.class.to_s.pluralize.underscore)
|
62
|
-
return
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def set_role_query(user, search)
|
68
|
-
role = user.try(:role) || Role.default_role
|
69
|
-
search.build do
|
70
|
-
with(:required_role_id).less_than_or_equal_to role.id
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def get_version
|
75
|
-
@version = params[:version_id].to_i if params[:version_id]
|
76
|
-
@version = nil if @version == 0
|
77
|
-
end
|
78
|
-
|
79
|
-
def convert_charset
|
80
|
-
case params[:format]
|
81
|
-
when 'csv'
|
82
|
-
return unless Setting.csv_charset_conversion
|
83
|
-
# TODO: 他の言語
|
84
|
-
if @locale.to_sym == :ja
|
85
|
-
headers["Content-Type"] = "text/csv; charset=Shift_JIS"
|
86
|
-
response.body = NKF::nkf('-Ws', response.body)
|
87
|
-
end
|
88
|
-
when 'xml'
|
89
|
-
if @locale.to_sym == :ja
|
90
|
-
headers["Content-Type"] = "application/xml; charset=Shift_JIS"
|
91
|
-
response.body = NKF::nkf('-Ws', response.body)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def make_internal_query(search)
|
97
|
-
# 内部的なクエリ
|
98
|
-
set_role_query(current_user, search)
|
99
|
-
|
100
|
-
unless params[:mode] == "add"
|
101
|
-
expression = @expression
|
102
|
-
patron = @patron
|
103
|
-
manifestation = @manifestation
|
104
|
-
reservable = @reservable
|
105
|
-
carrier_type = params[:carrier_type]
|
106
|
-
library = params[:library]
|
107
|
-
language = params[:language]
|
108
|
-
if defined?(EnjuSubject)
|
109
|
-
subject = params[:subject]
|
110
|
-
subject_by_term = Subject.where(:term => params[:subject]).first
|
111
|
-
@subject_by_term = subject_by_term
|
112
|
-
end
|
113
|
-
|
114
|
-
search.build do
|
115
|
-
with(:publisher_ids).equal_to patron.id if patron
|
116
|
-
with(:original_manifestation_ids).equal_to manifestation.id if manifestation
|
117
|
-
with(:reservable).equal_to reservable unless reservable.nil?
|
118
|
-
unless carrier_type.blank?
|
119
|
-
with(:carrier_type).equal_to carrier_type
|
120
|
-
end
|
121
|
-
unless library.blank?
|
122
|
-
library_list = library.split.uniq
|
123
|
-
library_list.each do |library|
|
124
|
-
with(:library).equal_to library
|
125
|
-
end
|
126
|
-
end
|
127
|
-
unless language.blank?
|
128
|
-
language_list = language.split.uniq
|
129
|
-
language_list.each do |language|
|
130
|
-
with(:language).equal_to language
|
131
|
-
end
|
132
|
-
end
|
133
|
-
if defined?(EnjuSubject)
|
134
|
-
unless subject.blank?
|
135
|
-
with(:subject).equal_to subject_by_term.term
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
return search
|
141
|
-
end
|
142
|
-
|
143
|
-
def solr_commit
|
144
|
-
Sunspot.commit
|
145
|
-
end
|
146
|
-
|
147
|
-
def clear_search_sessions
|
148
|
-
session[:query] = nil
|
149
|
-
session[:params] = nil
|
150
|
-
session[:search_params] = nil
|
151
|
-
session[:manifestation_ids] = nil
|
152
|
-
end
|
153
|
-
|
154
|
-
def set_locale
|
155
|
-
if params[:locale]
|
156
|
-
unless I18n.available_locales.include?(params[:locale].to_s.intern)
|
157
|
-
raise InvalidLocaleError
|
158
|
-
end
|
159
|
-
end
|
160
|
-
if user_signed_in?
|
161
|
-
locale = params[:locale] || session[:locale] || current_user.locale.try(:to_sym)
|
162
|
-
else
|
163
|
-
locale = params[:locale] || session[:locale]
|
164
|
-
end
|
165
|
-
if locale
|
166
|
-
I18n.locale = @locale = session[:locale] = locale.to_sym
|
167
|
-
else
|
168
|
-
I18n.locale = @locale = session[:locale] = I18n.default_locale
|
169
|
-
end
|
170
|
-
rescue InvalidLocaleError
|
171
|
-
@locale = I18n.default_locale
|
172
|
-
end
|
173
|
-
|
174
|
-
def set_available_languages
|
175
|
-
if Rails.env == 'production'
|
176
|
-
@available_languages = Rails.cache.fetch('available_languages'){
|
177
|
-
Language.where(:iso_639_1 => I18n.available_locales.map{|l| l.to_s}).select([:id, :iso_639_1, :name, :native_name, :display_name, :position]).all
|
178
|
-
}
|
179
|
-
else
|
180
|
-
@available_languages = Language.where(:iso_639_1 => I18n.available_locales.map{|l| l.to_s})
|
181
|
-
end
|
182
|
-
end
|
183
10
|
end
|
@@ -3,8 +3,3 @@
|
|
3
3
|
# Add new mime types for use in respond_to blocks:
|
4
4
|
# Mime::Type.register "text/richtext", :rtf
|
5
5
|
# Mime::Type.register_alias "text/html", :iphone
|
6
|
-
Mime::Type.register "application/octet-stream", :download
|
7
|
-
Mime::Type.register "application/rdf+xml", :rdf
|
8
|
-
Mime::Type.register "application/xml", :sru
|
9
|
-
Mime::Type.register "application/xml", :mods
|
10
|
-
Mime::Type.register_alias "text/xml", :oai
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,7 @@
|
|
1
|
+
����-idtype
|
2
|
+
class_namereservable_btitle_smconnect_title_sconnect_creator_sconnect_publisher_sisbn_smcarrier_type_s
|
3
|
+
library_sm
|
4
|
+
language_sitem_identifier_smshelf_smcreated_at_dupdated_at_dcreator_ids_imcontributor_ids_impublisher_ids_imitem_ids_imrequired_role_id_istart_page_i
|
5
|
+
end_page_inumber_of_pages_irepository_content_b
|
6
|
+
creator_smsort_title_speriodical_bseries_master_bresource_master_b
|
7
|
+
title_textcreator_textcontributor_textpublisher_textitem_identifier_textaulast_textaufirst_textau_textbtitle_text isbn_textissn_smoriginal_manifestation_ids_im
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
NRM�turxtuxutrtwsssuuvyrttrvrrtxtxswuywtrtyvywtuwwttptxy|||||||||||tuuu|||||||||||||||||||||||||||||||||wxwwx|||||||||||||||||||||||||||||||||||||||||||||wxwwx|||||||||||||||||||||||||||u|||||||||||||||||uvw|||||||x|||||||||||||||||||||||||||||||||||||||y||||||||||||w���|||||||||||||||||||||||||||||||||��|||||||||||w���|||||||||||||||||||||||||||||||||xy|||||||||||tuuu|||||||||||||||||||||||||||||||||turxtuxutrtwsssuuvyrttrvrrtxtxswuywtrtyvywtuwwttpty|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,7 @@
|
|
1
|
+
����-idtype
|
2
|
+
class_namereservable_btitle_smconnect_title_sconnect_creator_sconnect_publisher_sisbn_smcarrier_type_s
|
3
|
+
library_sm
|
4
|
+
language_sitem_identifier_smshelf_smcreated_at_dupdated_at_dcreator_ids_imcontributor_ids_impublisher_ids_imitem_ids_imrequired_role_id_istart_page_i
|
5
|
+
end_page_inumber_of_pages_irepository_content_b
|
6
|
+
creator_smsort_title_speriodical_bseries_master_bresource_master_b
|
7
|
+
title_textcreator_textcontributor_textpublisher_textitem_identifier_textaulast_textaufirst_textau_textbtitle_text isbn_textissn_smoriginal_manifestation_ids_im
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
NRM�xuuwuyutxxvxvxwtyvxwxxxvvtwwxvytwxwrwvxxyxuyxyuysx||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||xuuwuyutxxvxvxwtyvxwxxxvvtwwxvytwxwrwvxxyxuyxyuysx||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,8 @@
|
|
1
|
+
����5idtype
|
2
|
+
class_namereservable_btitle_smconnect_title_sconnect_creator_sconnect_publisher_sisbn_smcarrier_type_s
|
3
|
+
library_sm
|
4
|
+
language_sitem_identifier_smshelf_smcreated_at_dupdated_at_dcreator_ids_imcontributor_ids_impublisher_ids_imitem_ids_imrequired_role_id_istart_page_i
|
5
|
+
end_page_inumber_of_pages_irepository_content_b
|
6
|
+
creator_smsort_title_speriodical_bseries_master_bresource_master_b
|
7
|
+
title_textcreator_textcontributor_textpublisher_textitem_identifier_textaulast_textaufirst_textau_textbtitle_text isbn_textissn_smoriginal_manifestation_ids_im
|
8
|
+
pub_year_i
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
NRM�vruwvvuur|xutusttwwuuuuuuxx||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||xtt|uuutt||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||vruwvvuur|x||u|ttwwuuuuuuxx|||||y|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||ww|s||||||||||||||||||||||||||s||||||||||||
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1871,7 +1871,6 @@ manifestation_00216:
|
|
1871
1871
|
# volume_number :integer
|
1872
1872
|
# issue_number :integer
|
1873
1873
|
# serial_number :integer
|
1874
|
-
# ndc :string(255)
|
1875
1874
|
# content_type_id :integer default(1)
|
1876
1875
|
# year_of_publication :integer
|
1877
1876
|
# attachment_meta :text
|
@@ -1879,5 +1878,6 @@ manifestation_00216:
|
|
1879
1878
|
# fulltext_content :boolean
|
1880
1879
|
# doi :string(255)
|
1881
1880
|
# periodical :boolean
|
1881
|
+
# statement_of_responsibility :text
|
1882
1882
|
#
|
1883
1883
|
|
@@ -280,7 +280,6 @@ end
|
|
280
280
|
# volume_number :integer
|
281
281
|
# issue_number :integer
|
282
282
|
# serial_number :integer
|
283
|
-
# ndc :string(255)
|
284
283
|
# content_type_id :integer default(1)
|
285
284
|
# year_of_publication :integer
|
286
285
|
# attachment_meta :text
|
@@ -288,5 +287,6 @@ end
|
|
288
287
|
# fulltext_content :boolean
|
289
288
|
# doi :string(255)
|
290
289
|
# periodical :boolean
|
290
|
+
# statement_of_responsibility :text
|
291
291
|
#
|
292
292
|
|
@@ -3,153 +3,151 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
describe ResourceImportFile do
|
5
5
|
fixtures :all
|
6
|
-
VCR.use_cassette "enju_ndl/ndl_search", :record => :new_episodes do
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should be imported" do
|
15
|
-
old_manifestations_count = Manifestation.count
|
16
|
-
old_items_count = Item.count
|
17
|
-
old_patrons_count = Patron.count
|
18
|
-
old_import_results_count = ResourceImportResult.count
|
19
|
-
@file.import_start.should eq({:manifestation_imported => 9, :item_imported => 6, :manifestation_found => 3, :item_found => 3, :failed => 7})
|
20
|
-
manifestation = Item.where(:item_identifier => '11111').first.manifestation
|
21
|
-
manifestation.publishers.first.full_name.should eq 'test4'
|
22
|
-
manifestation.publishers.first.full_name_transcription.should eq 'てすと4'
|
23
|
-
manifestation.publishers.second.full_name_transcription.should eq 'てすと5'
|
24
|
-
manifestation.produces.first.produce_type.name.should eq 'publisher'
|
25
|
-
manifestation.creates.first.create_type.name.should eq 'author'
|
26
|
-
Manifestation.count.should eq old_manifestations_count + 9
|
27
|
-
Item.count.should eq old_items_count + 6
|
28
|
-
Patron.count.should eq old_patrons_count + 9
|
29
|
-
ResourceImportResult.count.should eq old_import_results_count + 17
|
30
|
-
|
31
|
-
manifestation_101 = Manifestation.where(:manifestation_identifier => '101').first
|
32
|
-
manifestation_101.series_statements.count.should eq 1
|
33
|
-
manifestation_101.series_statements.first.original_title.should eq '主シリーズ'
|
34
|
-
manifestation_101.series_statements.first.title_transcription.should eq 'しゅしりーず'
|
35
|
-
manifestation_101.series_statements.first.title_subseries.should eq '副シリーズ 1'
|
36
|
-
manifestation_101.series_statements.first.title_subseries_transcription.should eq 'ふくしりーず いち'
|
37
|
-
|
38
|
-
item_10101 = Item.where(:item_identifier => '10101').first
|
39
|
-
item_10101.manifestation.creators.size.should eq 2
|
40
|
-
item_10101.manifestation.creates.order(:id).first.create_type.name.should eq 'author'
|
41
|
-
item_10101.manifestation.creates.order(:id).second.patron.full_name.should eq 'test1'
|
42
|
-
item_10101.manifestation.creates.order(:id).second.create_type.name.should eq 'illustrator'
|
43
|
-
item_10101.manifestation.date_of_publication.should eq Time.zone.parse('2001-01-01')
|
44
|
-
item_10101.budget_type.name.should eq 'Public fund'
|
45
|
-
item_10101.bookstore.name.should eq 'Example store'
|
46
|
-
item_10101.use_restriction.name.should eq 'Not For Loan'
|
47
|
-
Item.where(:item_identifier => '10102').first.manifestation.date_of_publication.should eq Time.zone.parse('2001-01-01')
|
48
|
-
Item.where(:item_identifier => '10104').first.manifestation.date_of_publication.should eq Time.zone.parse('2001-01-01')
|
49
|
-
Manifestation.where(:manifestation_identifier => '103').first.original_title.should eq 'ダブル"クォート"を含む資料'
|
50
|
-
item = Item.where(:item_identifier => '11111').first
|
51
|
-
Shelf.find_by_name('first_shelf').should eq item.shelf
|
52
|
-
item.manifestation.price.should eq 1000
|
53
|
-
item.price.should eq 0
|
54
|
-
item.manifestation.publishers.size.should eq 2
|
55
|
-
|
56
|
-
item_10103 = Item.where(:item_identifier => '10103').first
|
57
|
-
item_10103.budget_type.should be_nil
|
58
|
-
item_10103.bookstore.name.should eq 'Example store'
|
59
|
-
|
60
|
-
item_10104 = Item.where(:item_identifier => '10104').first
|
61
|
-
item_10104.budget_type.name.should eq 'Public fund'
|
62
|
-
item_10104.bookstore.should be_nil
|
63
|
-
|
64
|
-
manifestation_104 = Manifestation.where(:manifestation_identifier => '104').first
|
65
|
-
manifestation_104.identifier_contents(:isbn).should eq ['9784797327038']
|
66
|
-
manifestation_104.original_title.should eq 'test10'
|
67
|
-
manifestation_104.creators.collect(&:full_name).should eq ['test3']
|
68
|
-
manifestation_104.publishers.collect(&:full_name).should eq ['test4']
|
69
|
-
|
70
|
-
@file.resource_import_fingerprint.should be_true
|
71
|
-
@file.executed_at.should be_true
|
72
|
-
end
|
7
|
+
describe "when its mode is 'create'" do
|
8
|
+
describe "when it is written in utf-8" do
|
9
|
+
before(:each) do
|
10
|
+
@file = ResourceImportFile.create :resource_import => File.new("#{Rails.root.to_s}/../../examples/resource_import_file_sample1.tsv")
|
73
11
|
end
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
12
|
+
|
13
|
+
it "should be imported", :vcr => true do
|
14
|
+
old_manifestations_count = Manifestation.count
|
15
|
+
old_items_count = Item.count
|
16
|
+
old_patrons_count = Patron.count
|
17
|
+
old_import_results_count = ResourceImportResult.count
|
18
|
+
@file.import_start.should eq({:manifestation_imported => 9, :item_imported => 6, :manifestation_found => 3, :item_found => 3, :failed => 7})
|
19
|
+
manifestation = Item.where(:item_identifier => '11111').first.manifestation
|
20
|
+
manifestation.publishers.first.full_name.should eq 'test4'
|
21
|
+
manifestation.publishers.first.full_name_transcription.should eq 'てすと4'
|
22
|
+
manifestation.publishers.second.full_name_transcription.should eq 'てすと5'
|
23
|
+
manifestation.produces.first.produce_type.name.should eq 'publisher'
|
24
|
+
manifestation.creates.first.create_type.name.should eq 'author'
|
25
|
+
Manifestation.count.should eq old_manifestations_count + 9
|
26
|
+
Item.count.should eq old_items_count + 6
|
27
|
+
Patron.count.should eq old_patrons_count + 9
|
28
|
+
ResourceImportResult.count.should eq old_import_results_count + 17
|
29
|
+
|
30
|
+
manifestation_101 = Manifestation.where(:manifestation_identifier => '101').first
|
31
|
+
manifestation_101.series_statements.count.should eq 1
|
32
|
+
manifestation_101.series_statements.first.original_title.should eq '主シリーズ'
|
33
|
+
manifestation_101.series_statements.first.title_transcription.should eq 'しゅしりーず'
|
34
|
+
manifestation_101.series_statements.first.title_subseries.should eq '副シリーズ 1'
|
35
|
+
manifestation_101.series_statements.first.title_subseries_transcription.should eq 'ふくしりーず いち'
|
36
|
+
|
37
|
+
item_10101 = Item.where(:item_identifier => '10101').first
|
38
|
+
item_10101.manifestation.creators.size.should eq 2
|
39
|
+
item_10101.manifestation.creates.order(:id).first.create_type.name.should eq 'author'
|
40
|
+
item_10101.manifestation.creates.order(:id).second.patron.full_name.should eq 'test1'
|
41
|
+
item_10101.manifestation.creates.order(:id).second.create_type.name.should eq 'illustrator'
|
42
|
+
item_10101.manifestation.date_of_publication.should eq Time.zone.parse('2001-01-01')
|
43
|
+
item_10101.budget_type.name.should eq 'Public fund'
|
44
|
+
item_10101.bookstore.name.should eq 'Example store'
|
45
|
+
item_10101.use_restriction.name.should eq 'Not For Loan'
|
46
|
+
Item.where(:item_identifier => '10102').first.manifestation.date_of_publication.should eq Time.zone.parse('2001-01-01')
|
47
|
+
Item.where(:item_identifier => '10104').first.manifestation.date_of_publication.should eq Time.zone.parse('2001-01-01')
|
48
|
+
Manifestation.where(:manifestation_identifier => '103').first.original_title.should eq 'ダブル"クォート"を含む資料'
|
49
|
+
item = Item.where(:item_identifier => '11111').first
|
50
|
+
Shelf.find_by_name('first_shelf').should eq item.shelf
|
51
|
+
item.manifestation.price.should eq 1000
|
52
|
+
item.price.should eq 0
|
53
|
+
item.manifestation.publishers.size.should eq 2
|
54
|
+
|
55
|
+
item_10103 = Item.where(:item_identifier => '10103').first
|
56
|
+
item_10103.budget_type.should be_nil
|
57
|
+
item_10103.bookstore.name.should eq 'Example store'
|
58
|
+
|
59
|
+
item_10104 = Item.where(:item_identifier => '10104').first
|
60
|
+
item_10104.budget_type.name.should eq 'Public fund'
|
61
|
+
item_10104.bookstore.should be_nil
|
62
|
+
|
63
|
+
manifestation_104 = Manifestation.where(:manifestation_identifier => '104').first
|
64
|
+
manifestation_104.identifier_contents(:isbn).should eq ['9784797327038']
|
65
|
+
manifestation_104.original_title.should eq 'test10'
|
66
|
+
manifestation_104.creators.collect(&:full_name).should eq ['test3']
|
67
|
+
manifestation_104.publishers.collect(&:full_name).should eq ['test4']
|
68
|
+
|
69
|
+
@file.resource_import_fingerprint.should be_true
|
70
|
+
@file.executed_at.should be_true
|
122
71
|
end
|
123
72
|
end
|
124
|
-
|
125
|
-
describe "when
|
126
|
-
|
127
|
-
@file = ResourceImportFile.create :resource_import => File.new("#{Rails.root.to_s}/../../examples/
|
128
|
-
@file.modify
|
129
|
-
Item.where(:item_identifier => '00001').first.manifestation.creators.order('patrons.id').collect(&:full_name).should eq ['たなべ', 'こうすけ']
|
130
|
-
Item.where(:item_identifier => '00002').first.manifestation.publishers.collect(&:full_name).should eq ['test2']
|
131
|
-
Item.where(:item_identifier => '00003').first.manifestation.original_title.should eq 'テスト3'
|
132
|
-
Item.where(:item_identifier => '00003').first.acquired_at.should eq Time.zone.parse('2012-01-01')
|
73
|
+
|
74
|
+
describe "when it is written in shift_jis" do
|
75
|
+
before(:each) do
|
76
|
+
@file = ResourceImportFile.create :resource_import => File.new("#{Rails.root.to_s}/../../examples/resource_import_file_sample2.tsv")
|
133
77
|
end
|
134
|
-
|
135
|
-
it "should
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
78
|
+
|
79
|
+
it "should be imported", :vcr => true do
|
80
|
+
old_manifestations_count = Manifestation.count
|
81
|
+
old_items_count = Item.count
|
82
|
+
old_patrons_count = Patron.count
|
83
|
+
old_import_results_count = ResourceImportResult.count
|
84
|
+
@file.import_start.should eq({:manifestation_imported => 9, :item_imported => 6, :manifestation_found => 3, :item_found => 3, :failed => 7})
|
85
|
+
manifestation = Item.where(:item_identifier => '11111').first.manifestation
|
86
|
+
manifestation.publishers.first.full_name.should eq 'test4'
|
87
|
+
manifestation.publishers.first.full_name_transcription.should eq 'てすと4'
|
88
|
+
manifestation.publishers.second.full_name_transcription.should eq 'てすと5'
|
89
|
+
Manifestation.count.should eq old_manifestations_count + 9
|
90
|
+
Item.count.should eq old_items_count + 6
|
91
|
+
Patron.count.should eq old_patrons_count + 9
|
92
|
+
ResourceImportResult.count.should eq old_import_results_count + 17
|
93
|
+
Item.find_by_item_identifier('10101').manifestation.creators.size.should eq 2
|
94
|
+
Item.find_by_item_identifier('10101').manifestation.date_of_publication.should eq Time.zone.parse('2001-01-01')
|
95
|
+
Item.find_by_item_identifier('10102').manifestation.date_of_publication.should eq Time.zone.parse('2001-01-01')
|
96
|
+
Item.find_by_item_identifier('10104').manifestation.date_of_publication.should eq Time.zone.parse('2001-01-01')
|
97
|
+
Manifestation.find_by_manifestation_identifier('103').original_title.should eq 'ダブル"クォート"を含む資料'
|
98
|
+
item = Item.find_by_item_identifier('11111')
|
99
|
+
Shelf.find_by_name('first_shelf').should eq item.shelf
|
100
|
+
item.manifestation.price.should eq 1000
|
101
|
+
item.price.should eq 0
|
102
|
+
item.manifestation.publishers.size.should eq 2
|
103
|
+
|
104
|
+
@file.resource_import_fingerprint.should be_true
|
105
|
+
@file.executed_at.should be_true
|
141
106
|
end
|
142
107
|
end
|
143
|
-
|
144
|
-
describe "when
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
108
|
+
|
109
|
+
describe "when it has only isbn" do
|
110
|
+
before(:each) do
|
111
|
+
@file = ResourceImportFile.create :resource_import => File.new("#{Rails.root.to_s}/../../examples/isbn_sample.txt")
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should be imported", :vcr => true do
|
115
|
+
old_manifestations_count = Manifestation.count
|
116
|
+
old_patrons_count = Patron.count
|
117
|
+
@file.import_start
|
118
|
+
Manifestation.count.should eq old_manifestations_count + 1
|
119
|
+
Patron.count.should eq old_patrons_count + 4
|
150
120
|
end
|
151
121
|
end
|
152
122
|
end
|
123
|
+
|
124
|
+
describe "when its mode is 'update'" do
|
125
|
+
it "should update items", :vcr => true do
|
126
|
+
@file = ResourceImportFile.create :resource_import => File.new("#{Rails.root.to_s}/../../examples/item_update_file.tsv"), :edit_mode => 'update'
|
127
|
+
@file.modify
|
128
|
+
Item.where(:item_identifier => '00001').first.manifestation.creators.order('patrons.id').collect(&:full_name).should eq ['たなべ', 'こうすけ']
|
129
|
+
Item.where(:item_identifier => '00002').first.manifestation.publishers.collect(&:full_name).should eq ['test2']
|
130
|
+
Item.where(:item_identifier => '00003').first.manifestation.original_title.should eq 'テスト3'
|
131
|
+
Item.where(:item_identifier => '00003').first.acquired_at.should eq Time.zone.parse('2012-01-01')
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should update series_statement", :vcr => true do
|
135
|
+
manifestation = Manifestation.find(10)
|
136
|
+
file = ResourceImportFile.create :resource_import => File.new("#{Rails.root.to_s}/../../examples/update_series_statement.tsv"), :edit_mode => 'update'
|
137
|
+
file.modify
|
138
|
+
#manifestation.reload
|
139
|
+
#manifestation.series_statements.should eq [SeriesStatement.find(2)]
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe "when its mode is 'destroy'" do
|
144
|
+
it "should remove items", :vcr => true do
|
145
|
+
old_count = Item.count
|
146
|
+
@file = ResourceImportFile.create :resource_import => File.new("#{Rails.root.to_s}/../../examples/item_delete_file.tsv"), :edit_mode => 'destroy'
|
147
|
+
@file.remove
|
148
|
+
Item.count.should eq old_count - 2
|
149
|
+
end
|
150
|
+
end
|
153
151
|
end
|
154
152
|
|
155
153
|
# == Schema Information
|