enju_ndl 0.1.1 → 0.2.0.beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +3 -3
- data/app/controllers/ndl_books_controller.rb +3 -6
- data/app/policies/ndl_book_policy.rb +9 -0
- data/app/views/ndl_books/index.html.erb +5 -0
- data/config/locales/en.yml +1 -0
- data/config/locales/ja.yml +1 -0
- data/lib/enju_ndl/ndl_search.rb +7 -0
- data/lib/enju_ndl/version.rb +1 -1
- data/spec/cassette_library/NdlBook/import/should_import_edition.yml +191 -0
- data/spec/cassette_library/NdlBook/import/should_import_series_statement_if_the_resource_is_serial.yml +30 -26
- data/spec/cassette_library/NdlBook/import/should_import_volume_title.yml +182 -0
- data/spec/cassette_library/ndl_books/index/ndl_search_menu/should_reflect_query_params_for_views.yml +422 -0
- data/spec/dummy/app/controllers/application_controller.rb +7 -0
- data/spec/dummy/app/models/user.rb +1 -2
- data/spec/dummy/config/application.rb +7 -26
- data/spec/dummy/config/environments/development.rb +25 -14
- data/spec/dummy/config/environments/production.rb +50 -31
- data/spec/dummy/config/environments/test.rb +23 -18
- data/spec/dummy/config/initializers/enju_leaf.rb +1 -0
- data/spec/dummy/db/migrate/059_create_libraries.rb +28 -0
- data/spec/dummy/db/migrate/069_create_shelves.rb +15 -0
- data/spec/dummy/db/migrate/080_create_library_groups.rb +17 -0
- data/spec/dummy/db/migrate/120_create_baskets.rb +12 -0
- data/spec/dummy/db/migrate/124_create_bookstores.rb +17 -0
- data/spec/dummy/db/migrate/130_create_request_status_types.rb +12 -0
- data/spec/dummy/db/migrate/131_create_request_types.rb +12 -0
- data/spec/dummy/db/migrate/20081006090811_create_subscriptions.rb +17 -0
- data/spec/dummy/db/migrate/20081006093246_create_subscribes.rb +14 -0
- data/spec/dummy/db/migrate/20081023092436_create_search_engines.rb +17 -0
- data/spec/dummy/db/migrate/20100211105551_add_admin_networks_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20100314190054_add_opening_hour_to_library.rb +9 -0
- data/spec/dummy/db/migrate/20110222073537_add_url_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20120105074911_add_isil_to_library.rb +5 -0
- data/spec/dummy/db/migrate/20120129014038_create_budget_types.rb +12 -0
- data/spec/dummy/db/migrate/20120319173203_create_accepts.rb +14 -0
- data/spec/dummy/db/migrate/20120510140958_add_closed_to_shelf.rb +5 -0
- data/spec/dummy/db/migrate/20130412083556_add_latitude_and_longitude_to_library.rb +6 -0
- data/spec/dummy/db/migrate/20140821151023_create_colors.rb +14 -0
- data/spec/dummy/db/schema.rb +175 -0
- data/spec/fixtures/library_groups.yml +31 -0
- data/spec/fixtures/users.yml +1 -1
- data/spec/models/ndl_book_spec.rb +20 -1
- data/spec/requests/ndl_books_spec.rb +2 -1
- data/spec/spec_helper.rb +12 -0
- data/spec/support/devise.rb +2 -2
- data/spec/views/ndl_books/index.html.erb_spec.rb +17 -0
- metadata +117 -26
- data/spec/dummy/config/application.yml +0 -38
data/spec/dummy/db/schema.rb
CHANGED
@@ -13,6 +13,17 @@
|
|
13
13
|
|
14
14
|
ActiveRecord::Schema.define(version: 20141014065831) do
|
15
15
|
|
16
|
+
create_table "accepts", force: :cascade do |t|
|
17
|
+
t.integer "basket_id"
|
18
|
+
t.integer "item_id"
|
19
|
+
t.integer "librarian_id"
|
20
|
+
t.datetime "created_at"
|
21
|
+
t.datetime "updated_at"
|
22
|
+
end
|
23
|
+
|
24
|
+
add_index "accepts", ["basket_id"], name: "index_accepts_on_basket_id"
|
25
|
+
add_index "accepts", ["item_id"], name: "index_accepts_on_item_id"
|
26
|
+
|
16
27
|
create_table "agent_import_file_transitions", force: :cascade do |t|
|
17
28
|
t.string "to_state"
|
18
29
|
t.text "metadata", default: "{}"
|
@@ -155,6 +166,39 @@ ActiveRecord::Schema.define(version: 20141014065831) do
|
|
155
166
|
add_index "agents", ["language_id"], name: "index_agents_on_language_id"
|
156
167
|
add_index "agents", ["required_role_id"], name: "index_agents_on_required_role_id"
|
157
168
|
|
169
|
+
create_table "baskets", force: :cascade do |t|
|
170
|
+
t.integer "user_id"
|
171
|
+
t.text "note"
|
172
|
+
t.integer "lock_version", default: 0, null: false
|
173
|
+
t.datetime "created_at"
|
174
|
+
t.datetime "updated_at"
|
175
|
+
end
|
176
|
+
|
177
|
+
add_index "baskets", ["user_id"], name: "index_baskets_on_user_id"
|
178
|
+
|
179
|
+
create_table "bookstores", force: :cascade do |t|
|
180
|
+
t.text "name", null: false
|
181
|
+
t.string "zip_code"
|
182
|
+
t.text "address"
|
183
|
+
t.text "note"
|
184
|
+
t.string "telephone_number"
|
185
|
+
t.string "fax_number"
|
186
|
+
t.string "url"
|
187
|
+
t.integer "position"
|
188
|
+
t.datetime "deleted_at"
|
189
|
+
t.datetime "created_at"
|
190
|
+
t.datetime "updated_at"
|
191
|
+
end
|
192
|
+
|
193
|
+
create_table "budget_types", force: :cascade do |t|
|
194
|
+
t.string "name"
|
195
|
+
t.text "display_name"
|
196
|
+
t.text "note"
|
197
|
+
t.integer "position"
|
198
|
+
t.datetime "created_at"
|
199
|
+
t.datetime "updated_at"
|
200
|
+
end
|
201
|
+
|
158
202
|
create_table "carrier_type_has_checkout_types", force: :cascade do |t|
|
159
203
|
t.integer "carrier_type_id", null: false
|
160
204
|
t.integer "checkout_type_id", null: false
|
@@ -291,6 +335,17 @@ ActiveRecord::Schema.define(version: 20141014065831) do
|
|
291
335
|
add_index "classifications", ["manifestation_id"], name: "index_classifications_on_manifestation_id"
|
292
336
|
add_index "classifications", ["parent_id"], name: "index_classifications_on_parent_id"
|
293
337
|
|
338
|
+
create_table "colors", force: :cascade do |t|
|
339
|
+
t.integer "library_group_id"
|
340
|
+
t.string "property"
|
341
|
+
t.string "code"
|
342
|
+
t.integer "position"
|
343
|
+
t.datetime "created_at"
|
344
|
+
t.datetime "updated_at"
|
345
|
+
end
|
346
|
+
|
347
|
+
add_index "colors", ["library_group_id"], name: "index_colors_on_library_group_id"
|
348
|
+
|
294
349
|
create_table "content_types", force: :cascade do |t|
|
295
350
|
t.string "name", null: false
|
296
351
|
t.text "display_name"
|
@@ -598,6 +653,53 @@ ActiveRecord::Schema.define(version: 20141014065831) do
|
|
598
653
|
|
599
654
|
add_index "lending_policies", ["item_id", "user_group_id"], name: "index_lending_policies_on_item_id_and_user_group_id", unique: true
|
600
655
|
|
656
|
+
create_table "libraries", force: :cascade do |t|
|
657
|
+
t.string "name", null: false
|
658
|
+
t.text "display_name"
|
659
|
+
t.string "short_display_name", null: false
|
660
|
+
t.string "zip_code"
|
661
|
+
t.text "street"
|
662
|
+
t.text "locality"
|
663
|
+
t.text "region"
|
664
|
+
t.string "telephone_number_1"
|
665
|
+
t.string "telephone_number_2"
|
666
|
+
t.string "fax_number"
|
667
|
+
t.text "note"
|
668
|
+
t.integer "call_number_rows", default: 1, null: false
|
669
|
+
t.string "call_number_delimiter", default: "|", null: false
|
670
|
+
t.integer "library_group_id", default: 1, null: false
|
671
|
+
t.integer "users_count", default: 0, null: false
|
672
|
+
t.integer "position"
|
673
|
+
t.integer "country_id"
|
674
|
+
t.datetime "created_at"
|
675
|
+
t.datetime "updated_at"
|
676
|
+
t.datetime "deleted_at"
|
677
|
+
t.text "opening_hour"
|
678
|
+
t.string "isil"
|
679
|
+
t.float "latitude"
|
680
|
+
t.float "longitude"
|
681
|
+
end
|
682
|
+
|
683
|
+
add_index "libraries", ["library_group_id"], name: "index_libraries_on_library_group_id"
|
684
|
+
add_index "libraries", ["name"], name: "index_libraries_on_name", unique: true
|
685
|
+
|
686
|
+
create_table "library_groups", force: :cascade do |t|
|
687
|
+
t.string "name", null: false
|
688
|
+
t.text "display_name"
|
689
|
+
t.string "short_name", null: false
|
690
|
+
t.text "my_networks"
|
691
|
+
t.text "login_banner"
|
692
|
+
t.text "note"
|
693
|
+
t.integer "country_id"
|
694
|
+
t.integer "position"
|
695
|
+
t.datetime "created_at"
|
696
|
+
t.datetime "updated_at"
|
697
|
+
t.text "admin_networks"
|
698
|
+
t.string "url", default: "http://localhost:3000/"
|
699
|
+
end
|
700
|
+
|
701
|
+
add_index "library_groups", ["short_name"], name: "index_library_groups_on_short_name"
|
702
|
+
|
601
703
|
create_table "licenses", force: :cascade do |t|
|
602
704
|
t.string "name", null: false
|
603
705
|
t.string "display_name"
|
@@ -928,6 +1030,24 @@ ActiveRecord::Schema.define(version: 20141014065831) do
|
|
928
1030
|
add_index "realizes", ["agent_id"], name: "index_realizes_on_agent_id"
|
929
1031
|
add_index "realizes", ["expression_id"], name: "index_realizes_on_expression_id"
|
930
1032
|
|
1033
|
+
create_table "request_status_types", force: :cascade do |t|
|
1034
|
+
t.string "name", null: false
|
1035
|
+
t.text "display_name"
|
1036
|
+
t.text "note"
|
1037
|
+
t.integer "position"
|
1038
|
+
t.datetime "created_at"
|
1039
|
+
t.datetime "updated_at"
|
1040
|
+
end
|
1041
|
+
|
1042
|
+
create_table "request_types", force: :cascade do |t|
|
1043
|
+
t.string "name", null: false
|
1044
|
+
t.text "display_name"
|
1045
|
+
t.text "note"
|
1046
|
+
t.integer "position"
|
1047
|
+
t.datetime "created_at"
|
1048
|
+
t.datetime "updated_at"
|
1049
|
+
end
|
1050
|
+
|
931
1051
|
create_table "reserve_stat_has_manifestations", force: :cascade do |t|
|
932
1052
|
t.integer "manifestation_reserve_stat_id", null: false
|
933
1053
|
t.integer "manifestation_id", null: false
|
@@ -1067,6 +1187,20 @@ ActiveRecord::Schema.define(version: 20141014065831) do
|
|
1067
1187
|
t.integer "position"
|
1068
1188
|
end
|
1069
1189
|
|
1190
|
+
create_table "search_engines", force: :cascade do |t|
|
1191
|
+
t.string "name", null: false
|
1192
|
+
t.text "display_name"
|
1193
|
+
t.string "url", null: false
|
1194
|
+
t.text "base_url", null: false
|
1195
|
+
t.text "http_method", null: false
|
1196
|
+
t.text "query_param", null: false
|
1197
|
+
t.text "additional_param"
|
1198
|
+
t.text "note"
|
1199
|
+
t.integer "position"
|
1200
|
+
t.datetime "created_at"
|
1201
|
+
t.datetime "updated_at"
|
1202
|
+
end
|
1203
|
+
|
1070
1204
|
create_table "series_statement_merge_lists", force: :cascade do |t|
|
1071
1205
|
t.string "title"
|
1072
1206
|
t.datetime "created_at"
|
@@ -1108,6 +1242,21 @@ ActiveRecord::Schema.define(version: 20141014065831) do
|
|
1108
1242
|
add_index "series_statements", ["root_manifestation_id"], name: "index_series_statements_on_root_manifestation_id"
|
1109
1243
|
add_index "series_statements", ["series_statement_identifier"], name: "index_series_statements_on_series_statement_identifier"
|
1110
1244
|
|
1245
|
+
create_table "shelves", force: :cascade do |t|
|
1246
|
+
t.string "name", null: false
|
1247
|
+
t.text "display_name"
|
1248
|
+
t.text "note"
|
1249
|
+
t.integer "library_id", default: 1, null: false
|
1250
|
+
t.integer "items_count", default: 0, null: false
|
1251
|
+
t.integer "position"
|
1252
|
+
t.datetime "created_at"
|
1253
|
+
t.datetime "updated_at"
|
1254
|
+
t.datetime "deleted_at"
|
1255
|
+
t.boolean "closed", default: false, null: false
|
1256
|
+
end
|
1257
|
+
|
1258
|
+
add_index "shelves", ["library_id"], name: "index_shelves_on_library_id"
|
1259
|
+
|
1111
1260
|
create_table "subject_heading_types", force: :cascade do |t|
|
1112
1261
|
t.string "name", null: false
|
1113
1262
|
t.text "display_name"
|
@@ -1151,6 +1300,32 @@ ActiveRecord::Schema.define(version: 20141014065831) do
|
|
1151
1300
|
add_index "subjects", ["term"], name: "index_subjects_on_term"
|
1152
1301
|
add_index "subjects", ["use_term_id"], name: "index_subjects_on_use_term_id"
|
1153
1302
|
|
1303
|
+
create_table "subscribes", force: :cascade do |t|
|
1304
|
+
t.integer "subscription_id", null: false
|
1305
|
+
t.integer "work_id", null: false
|
1306
|
+
t.datetime "start_at", null: false
|
1307
|
+
t.datetime "end_at", null: false
|
1308
|
+
t.datetime "created_at"
|
1309
|
+
t.datetime "updated_at"
|
1310
|
+
end
|
1311
|
+
|
1312
|
+
add_index "subscribes", ["subscription_id"], name: "index_subscribes_on_subscription_id"
|
1313
|
+
add_index "subscribes", ["work_id"], name: "index_subscribes_on_work_id"
|
1314
|
+
|
1315
|
+
create_table "subscriptions", force: :cascade do |t|
|
1316
|
+
t.text "title", null: false
|
1317
|
+
t.text "note"
|
1318
|
+
t.integer "user_id"
|
1319
|
+
t.integer "order_list_id"
|
1320
|
+
t.datetime "deleted_at"
|
1321
|
+
t.integer "subscribes_count", default: 0, null: false
|
1322
|
+
t.datetime "created_at"
|
1323
|
+
t.datetime "updated_at"
|
1324
|
+
end
|
1325
|
+
|
1326
|
+
add_index "subscriptions", ["order_list_id"], name: "index_subscriptions_on_order_list_id"
|
1327
|
+
add_index "subscriptions", ["user_id"], name: "index_subscriptions_on_user_id"
|
1328
|
+
|
1154
1329
|
create_table "use_restrictions", force: :cascade do |t|
|
1155
1330
|
t.string "name", null: false
|
1156
1331
|
t.text "display_name"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
2
|
+
one:
|
3
|
+
id: 1
|
4
|
+
name: enju_library
|
5
|
+
display_name: "<%= I18n.locale %>: Enju Library"
|
6
|
+
short_name: enju
|
7
|
+
note:
|
8
|
+
my_networks: 0.0.0.0/0
|
9
|
+
url: "http://localhost:3000/"
|
10
|
+
|
11
|
+
|
12
|
+
# == Schema Information
|
13
|
+
#
|
14
|
+
# Table name: library_groups
|
15
|
+
#
|
16
|
+
# id :integer not null, primary key
|
17
|
+
# name :string(255) not null
|
18
|
+
# display_name :text
|
19
|
+
# short_name :string(255) not null
|
20
|
+
# my_networks :text
|
21
|
+
# login_banner :text
|
22
|
+
# note :text
|
23
|
+
# country_id :integer
|
24
|
+
# created_at :datetime not null
|
25
|
+
# updated_at :datetime not null
|
26
|
+
# admin_networks :text
|
27
|
+
# allow_bookmark_external_url :boolean default(FALSE), not null
|
28
|
+
# position :integer
|
29
|
+
# url :string(255) default("http://localhost:3000/")
|
30
|
+
#
|
31
|
+
|
data/spec/fixtures/users.yml
CHANGED
@@ -3,7 +3,7 @@ admin:
|
|
3
3
|
updated_at: 2008-05-31 13:16:30.163731 +09:00
|
4
4
|
encrypted_password: $2a$10$vHohD1WflnTIqAa8zMkF9evwAgIZRw3XuR4d3bi29M.jph/MB/AJi
|
5
5
|
id: 1
|
6
|
-
username:
|
6
|
+
username: enjuadmin
|
7
7
|
email: tanabe@kamata.lib.teu.ac.jp
|
8
8
|
created_at: 2007-11-19 16:58:32.111941 +09:00
|
9
9
|
librarian1:
|
@@ -76,12 +76,20 @@ describe NdlBook do
|
|
76
76
|
manifestation.series_statements.first.title_transcription.should eq "コウダンシャ ゲンダイ シンショ"
|
77
77
|
end
|
78
78
|
|
79
|
-
it "should import series_statement if the resource is serial", :
|
79
|
+
it "should import series_statement if the resource is serial", vcr: true, solr: true do
|
80
80
|
manifestation = NdlBook.import_from_sru_response('R100000039-I001413988-00')
|
81
81
|
manifestation.original_title.should eq "週刊新潮"
|
82
82
|
manifestation.series_statements.first.original_title.should eq "週刊新潮"
|
83
83
|
manifestation.series_statements.first.series_master.should be_truthy
|
84
84
|
manifestation.serial.should be_truthy
|
85
|
+
manifestation.series_statements.first.root_manifestation.should eq manifestation
|
86
|
+
manifestation.root_series_statement.should eq manifestation.series_statements.first
|
87
|
+
|
88
|
+
search = Manifestation.search
|
89
|
+
search.build do
|
90
|
+
with(:resource_master).equal_to true
|
91
|
+
end
|
92
|
+
search.results.first.original_title.should eq "週刊新潮"
|
85
93
|
end
|
86
94
|
|
87
95
|
it "should import pud_date is nil", :vcr => true do
|
@@ -174,5 +182,16 @@ describe NdlBook do
|
|
174
182
|
manifestation.classifications.first.classification_type.name.should eq "ndc8"
|
175
183
|
manifestation.classifications.first.category.should eq "547.48"
|
176
184
|
end
|
185
|
+
|
186
|
+
it "should import edition", :vcr => true do
|
187
|
+
manifestation = NdlBook.import_from_sru_response( "R100000002-I025107686-00" )
|
188
|
+
manifestation.edition_string.should eq "改訂第2版"
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should import volume title", :vcr => true do
|
192
|
+
manifestation = NdlBook.import_from_sru_response( "R100000002-I000011225479-00" )
|
193
|
+
manifestation.original_title.should eq "じゃらん 関東・東北"
|
194
|
+
manifestation.title_transcription.should eq "ジャラン カントウ トウホク"
|
195
|
+
end
|
177
196
|
end
|
178
197
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,6 +8,7 @@ ENV["RAILS_ENV"] ||= 'test'
|
|
8
8
|
require File.expand_path("../dummy/config/environment", __FILE__)
|
9
9
|
require 'rspec/rails'
|
10
10
|
require 'vcr'
|
11
|
+
require 'sunspot-rails-tester'
|
11
12
|
|
12
13
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
13
14
|
# in spec/support/ and its subdirectories.
|
@@ -37,8 +38,18 @@ RSpec.configure do |config|
|
|
37
38
|
config.before do
|
38
39
|
Sunspot.session = Sunspot::Rails::StubSessionProxy.new($original_sunspot_session)
|
39
40
|
end
|
41
|
+
config.before :each, :solr => true do
|
42
|
+
Sunspot::Rails::Tester.start_original_sunspot_session
|
43
|
+
Sunspot.session = $original_sunspot_session
|
44
|
+
Sunspot.remove_all!
|
45
|
+
end
|
40
46
|
|
41
47
|
config.infer_spec_type_from_file_location!
|
48
|
+
|
49
|
+
config.include Warden::Test::Helpers
|
50
|
+
config.before :suite do
|
51
|
+
Warden.test_mode!
|
52
|
+
end
|
42
53
|
end
|
43
54
|
|
44
55
|
VCR.configure do |c|
|
@@ -46,4 +57,5 @@ VCR.configure do |c|
|
|
46
57
|
c.hook_into :webmock
|
47
58
|
c.configure_rspec_metadata!
|
48
59
|
c.allow_http_connections_when_no_cassette = true
|
60
|
+
c.ignore_localhost = true
|
49
61
|
end
|
data/spec/support/devise.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
RSpec.configure do |config|
|
2
|
-
config.include Devise::
|
3
|
-
config.include Devise::
|
2
|
+
config.include Devise::Test::ControllerHelpers, type: :controller
|
3
|
+
config.include Devise::Test::ControllerHelpers, type: :view
|
4
4
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "spec_helper.rb"
|
2
|
+
|
3
|
+
describe "ndl_books/index" do
|
4
|
+
describe "ndl search menu" do
|
5
|
+
it "should reflect query params for views", vcr: true do
|
6
|
+
params[:query] = "test"
|
7
|
+
assign(:query, "test")
|
8
|
+
books = NdlBook.search(params[:query])
|
9
|
+
assign(:books, Kaminari.paginate_array(books[:items],
|
10
|
+
total_count: books[:total_entries],
|
11
|
+
).page(1).per(10))
|
12
|
+
render
|
13
|
+
expect(rendered).to include "http://iss.ndl.go.jp/books?any=test"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|