enju_library 0.3.9 → 0.4.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -3
  3. data/app/controllers/concerns/enju_library/controller.rb +5 -5
  4. data/app/controllers/libraries_controller.rb +4 -1
  5. data/app/controllers/library_groups_controller.rb +7 -1
  6. data/app/controllers/request_status_types_controller.rb +6 -1
  7. data/app/controllers/request_types_controller.rb +6 -1
  8. data/app/controllers/shelves_controller.rb +4 -1
  9. data/app/controllers/user_groups_controller.rb +3 -0
  10. data/app/helpers/enju_library/application_helper.rb +18 -0
  11. data/app/models/budget_type.rb +9 -7
  12. data/app/models/concerns/enju_library/enju_user.rb +10 -0
  13. data/app/models/library.rb +29 -43
  14. data/app/models/library_group.rb +10 -11
  15. data/app/models/request_status_type.rb +9 -7
  16. data/app/models/request_type.rb +9 -7
  17. data/app/models/search_engine.rb +14 -18
  18. data/app/models/shelf.rb +13 -11
  19. data/app/models/user_export_file.rb +1 -1
  20. data/app/models/user_export_file_state_machine.rb +1 -1
  21. data/app/models/user_group.rb +2 -0
  22. data/app/models/user_import_file.rb +28 -27
  23. data/app/models/user_import_file_state_machine.rb +1 -1
  24. data/app/models/withdraw.rb +6 -0
  25. data/app/policies/shelf_policy.rb +1 -1
  26. data/app/views/accepts/_list.html.erb +2 -2
  27. data/app/views/accepts/index.html.erb +2 -2
  28. data/app/views/budget_types/_form.html.erb +1 -1
  29. data/app/views/budget_types/index.html.erb +1 -1
  30. data/app/views/budget_types/show.html.erb +1 -1
  31. data/app/views/libraries/_calendar.html.erb +1 -1
  32. data/app/views/libraries/_form.html.erb +2 -12
  33. data/app/views/libraries/_map.html+phone.erb +2 -2
  34. data/app/views/libraries/_map.html.erb +23 -10
  35. data/app/views/libraries/index.html.erb +1 -1
  36. data/app/views/libraries/show.html+phone.erb +1 -1
  37. data/app/views/libraries/show.html+phone.slim +1 -1
  38. data/app/views/libraries/show.html.erb +2 -2
  39. data/app/views/library_groups/_form.html.erb +14 -13
  40. data/app/views/library_groups/index.html.erb +1 -1
  41. data/app/views/library_groups/show.html.erb +2 -2
  42. data/app/views/picture_files/_index_shelf.html.erb +1 -1
  43. data/app/views/request_status_types/_form.html.erb +1 -1
  44. data/app/views/request_status_types/index.html.erb +1 -1
  45. data/app/views/request_status_types/show.html.erb +1 -1
  46. data/app/views/request_types/_form.html.erb +1 -1
  47. data/app/views/request_types/index.html.erb +1 -1
  48. data/app/views/request_types/show.html.erb +1 -1
  49. data/app/views/shelves/_form.html.erb +1 -1
  50. data/app/views/shelves/_select_form.html.erb +1 -1
  51. data/app/views/shelves/index.html.erb +3 -3
  52. data/app/views/shelves/show.html+phone.erb +1 -1
  53. data/app/views/shelves/show.html+phone.slim +1 -1
  54. data/app/views/shelves/show.html.erb +2 -2
  55. data/app/views/user_groups/_form.html.erb +1 -1
  56. data/app/views/user_groups/index.html.erb +1 -1
  57. data/app/views/user_groups/show.html.erb +2 -2
  58. data/app/views/user_import_files/_results.html.erb +0 -5
  59. data/app/views/user_import_files/new.html.erb +2 -2
  60. data/app/views/user_import_files/show.html.erb +2 -2
  61. data/app/views/user_import_results/index.html.erb +11 -0
  62. data/app/views/withdraws/_list.html.erb +2 -2
  63. data/app/views/withdraws/index.html.erb +3 -3
  64. data/app/views/withdraws/new.html.erb +1 -1
  65. data/config/locales/translation_en.yml +2 -4
  66. data/config/locales/translation_ja.yml +2 -4
  67. data/db/migrate/20160813191647_add_max_number_of_results_to_library_group.rb +1 -1
  68. data/db/migrate/20190630113817_add_display_name_translations_to_library_group.rb +12 -0
  69. data/db/migrate/20190630115523_add_login_banner_translations_to_library_group.rb +6 -0
  70. data/lib/enju_library/version.rb +1 -1
  71. data/lib/generators/enju_library/setup/setup_generator.rb +2 -7
  72. data/lib/generators/enju_library/setup/templates/db/fixtures/budget_types.yml +4 -0
  73. data/lib/generators/enju_library/setup/templates/db/fixtures/libraries.yml +2 -2
  74. data/lib/generators/enju_library/setup/templates/db/fixtures/library_groups.yml +11 -5
  75. data/lib/generators/enju_library/setup/templates/db/fixtures/user_groups.yml +1 -2
  76. data/spec/controllers/budget_types_controller_spec.rb +1 -1
  77. data/spec/controllers/items_controller_spec.rb +35 -0
  78. data/spec/dummy/app/helpers/application_helper.rb +1 -0
  79. data/spec/dummy/app/models/user.rb +1 -2
  80. data/spec/dummy/bin/bundle +1 -1
  81. data/spec/dummy/bin/setup +1 -3
  82. data/spec/dummy/bin/update +4 -2
  83. data/spec/dummy/bin/yarn +3 -3
  84. data/spec/dummy/config/application.rb +1 -0
  85. data/spec/dummy/config/database.yml +70 -9
  86. data/spec/dummy/config/initializers/assets.rb +1 -1
  87. data/spec/dummy/config/storage.yml +34 -0
  88. data/spec/dummy/db/development.sqlite3 +0 -0
  89. data/spec/dummy/db/migrate/113_create_events.rb +2 -4
  90. data/spec/dummy/db/migrate/20081028093607_create_event_import_files.rb +2 -4
  91. data/spec/dummy/db/migrate/20090519203307_create_participates.rb +2 -4
  92. data/spec/dummy/db/migrate/20100925074639_create_event_import_results.rb +2 -2
  93. data/spec/dummy/db/migrate/20140720192418_add_default_library_id_to_event_import_file.rb +1 -1
  94. data/spec/dummy/db/migrate/20140812152348_create_event_export_files.rb +1 -1
  95. data/spec/dummy/db/migrate/20140814070854_add_default_event_category_id_to_event_import_file.rb +1 -1
  96. data/spec/dummy/db/migrate/20151128142913_create_places.rb +14 -0
  97. data/spec/dummy/db/migrate/20151201163718_add_place_id_to_event.rb +5 -0
  98. data/spec/dummy/db/migrate/20160319144230_create_issn_records.rb +11 -0
  99. data/spec/dummy/db/migrate/20160506144040_create_isbn_records.rb +11 -0
  100. data/spec/dummy/db/migrate/20160703184258_add_most_recent_to_event_import_file_transitions.rb +9 -0
  101. data/spec/dummy/db/migrate/20160703184311_add_most_recent_to_event_export_file_transitions.rb +9 -0
  102. data/spec/dummy/db/migrate/20170116134107_create_issn_record_and_manifestations.rb +11 -0
  103. data/spec/dummy/db/migrate/20170116134120_create_isbn_record_and_manifestations.rb +11 -0
  104. data/spec/dummy/db/migrate/20170116150432_create_jpno_records.rb +10 -0
  105. data/spec/dummy/db/migrate/20171126072934_create_ndla_records.rb +10 -0
  106. data/spec/dummy/db/migrate/20180107162659_add_constraints_to_most_recent_for_message_transitions.rb +13 -0
  107. data/spec/dummy/db/migrate/20180107162711_add_constraints_to_most_recent_for_message_request_transitions.rb +13 -0
  108. data/spec/dummy/db/migrate/20180107164558_add_constraints_to_most_recent_for_event_import_file_transitions.rb +13 -0
  109. data/spec/dummy/db/migrate/20180107164617_add_constraints_to_most_recent_for_event_export_file_transitions.rb +13 -0
  110. data/spec/dummy/db/migrate/20181030072731_add_not_null_to_position_on_carrier_type.rb +14 -0
  111. data/spec/dummy/db/migrate/20181119170645_add_foreign_key_to_events_referencing_event_categories.rb +5 -0
  112. data/spec/dummy/db/migrate/20190102034126_create_doi_records.rb +13 -0
  113. data/spec/dummy/db/migrate/20190208135957_create_active_storage_tables.active_storage.rb +27 -0
  114. data/spec/dummy/db/migrate/20190311154610_create_periodicals.rb +10 -0
  115. data/spec/dummy/db/migrate/20190312033839_create_periodical_and_manifestations.rb +11 -0
  116. data/spec/dummy/db/migrate/20190314151124_add_full_name_translations_to_create.rb +7 -0
  117. data/spec/dummy/db/migrate/20190501043418_create_ndl_bib_id_records.rb +10 -0
  118. data/spec/dummy/db/migrate/20190508160525_create_retains.rb +10 -0
  119. data/spec/dummy/db/migrate/20190512133459_upgrade_enju_event_to_enju_leaf20.rb +115 -0
  120. data/spec/dummy/db/migrate/20190629134017_rename_user_group_has_checkout_type_due_date_before_to_due_date_after.rb +5 -0
  121. data/spec/dummy/db/migrate/20190630151446_add_display_name_translations_to_role.rb +5 -0
  122. data/spec/dummy/db/migrate/20190630153136_add_display_name_translations_to_event.rb +6 -0
  123. data/spec/dummy/db/migrate/20190706052525_add_display_name_translations_to_circulation_status.rb +5 -0
  124. data/spec/dummy/db/migrate/20190712163038_add_display_name_translations_to_carrier_type.rb +21 -0
  125. data/spec/dummy/db/migrate/20190713114724_add_checkout_id_to_checkin.rb +6 -0
  126. data/spec/dummy/db/migrate/20190713114940_add_profile_id_to_user.rb +5 -0
  127. data/spec/dummy/db/migrate/20190713115451_add_full_name_translations_to_profile.rb +5 -0
  128. data/spec/dummy/db/migrate/20190814120827_add_display_name_translations_to_checkout_type.rb +5 -0
  129. data/spec/dummy/db/schema.rb +402 -204
  130. data/spec/dummy/db/test.sqlite3 +0 -0
  131. data/spec/factories/budget_types.rb +8 -7
  132. data/spec/factories/profile.rb +9 -2
  133. data/spec/factories/user.rb +25 -31
  134. data/spec/factories/user_export_file.rb +5 -0
  135. data/spec/factories/user_import_file.rb +7 -0
  136. data/spec/factories/user_import_result.rb +6 -0
  137. data/spec/fixtures/agent_relationship_types.yml +34 -0
  138. data/spec/fixtures/agent_types.yml +11 -11
  139. data/spec/fixtures/agents.yml +27 -27
  140. data/spec/fixtures/baskets.yml +1 -0
  141. data/spec/fixtures/bookstores.yml +1 -0
  142. data/spec/fixtures/budget_types.yml +9 -7
  143. data/spec/fixtures/carrier_type_has_checkout_types.yml +5 -5
  144. data/spec/fixtures/carrier_types.yml +28 -24
  145. data/spec/fixtures/checked_items.yml +6 -6
  146. data/spec/fixtures/checkins.yml +4 -11
  147. data/spec/fixtures/checkout_stat_has_manifestations.yml +5 -5
  148. data/spec/fixtures/checkout_stat_has_users.yml +6 -6
  149. data/spec/fixtures/checkout_types.yml +11 -11
  150. data/spec/fixtures/checkouts.yml +16 -17
  151. data/spec/fixtures/circulation_statuses.yml +29 -38
  152. data/spec/fixtures/classification_types.yml +63 -0
  153. data/spec/fixtures/content_types.yml +20 -31
  154. data/spec/fixtures/create_types.yml +43 -0
  155. data/spec/fixtures/event_categories.yml +23 -23
  156. data/spec/fixtures/frequencies.yml +17 -25
  157. data/spec/fixtures/identifier_types.yml +42 -0
  158. data/spec/fixtures/item_has_use_restrictions.yml +11 -11
  159. data/spec/fixtures/items.yml +28 -17
  160. data/spec/fixtures/languages.yml +12 -13
  161. data/spec/fixtures/lending_policies.yml +8 -15
  162. data/spec/fixtures/libraries.yml +30 -29
  163. data/spec/fixtures/library_groups.yml +12 -9
  164. data/spec/fixtures/manifestation_checkout_stats.yml +4 -3
  165. data/spec/fixtures/manifestation_relationship_types.yml +29 -0
  166. data/spec/fixtures/manifestation_reserve_stats.yml +4 -3
  167. data/spec/fixtures/manifestations.yml +60 -50
  168. data/spec/fixtures/message_requests.yml +3 -3
  169. data/spec/fixtures/produce_types.yml +29 -0
  170. data/spec/fixtures/profiles.yml +11 -6
  171. data/spec/fixtures/realize_types.yml +36 -0
  172. data/spec/fixtures/request_status_types.yml +14 -13
  173. data/spec/fixtures/request_types.yml +13 -12
  174. data/spec/fixtures/reserve_stat_has_manifestations.yml +5 -5
  175. data/spec/fixtures/reserve_stat_has_users.yml +5 -5
  176. data/spec/fixtures/reserve_transitions.yml +8 -7
  177. data/spec/fixtures/reserves.yml +44 -64
  178. data/spec/fixtures/roles.yml +22 -5
  179. data/spec/fixtures/search_engines.yml +13 -12
  180. data/spec/fixtures/shelves.yml +16 -15
  181. data/spec/fixtures/subject_heading_types.yml +39 -0
  182. data/spec/fixtures/subject_types.yml +28 -0
  183. data/spec/fixtures/use_restrictions.yml +4 -4
  184. data/spec/fixtures/user_checkout_stats.yml +4 -4
  185. data/spec/fixtures/user_export_files.yml +1 -1
  186. data/spec/fixtures/user_group_has_checkout_types.yml +19 -19
  187. data/spec/fixtures/user_groups.yml +4 -3
  188. data/spec/fixtures/user_has_roles.yml +3 -4
  189. data/spec/fixtures/user_reserve_stats.yml +5 -4
  190. data/spec/models/budget_type_spec.rb +8 -7
  191. data/spec/models/library_group_spec.rb +5 -14
  192. data/spec/models/library_spec.rb +26 -25
  193. data/spec/models/request_status_type_spec.rb +8 -7
  194. data/spec/models/request_type_spec.rb +8 -7
  195. data/spec/models/search_engine_spec.rb +13 -12
  196. data/spec/models/shelf_spec.rb +12 -11
  197. data/spec/models/user_export_file_spec.rb +2 -2
  198. data/spec/models/user_group_spec.rb +1 -6
  199. data/spec/models/user_import_file_spec.rb +23 -23
  200. data/spec/rails_helper.rb +10 -2
  201. data/spec/system/libraries_spec.rb +5 -5
  202. metadata +476 -493
  203. data/app/helpers/shelves_helper.rb +0 -16
  204. data/app/views/layouts/libraries.html.erb +0 -31
  205. data/app/views/libraries/_map_header.html.erb +0 -6
  206. data/db/migrate/20151213070943_add_translation_table_to_library_group.rb +0 -18
  207. data/db/migrate/20151213072705_add_footer_banner_to_library_group.rb +0 -22
  208. data/lib/generators/enju_library/setup/templates/db/fixtures/library_group/translations.yml +0 -12
  209. data/spec/dummy/app/assets/config/manifest.js +0 -5
  210. data/spec/dummy/db/migrate/20190818075603_add_memo_to_manifestation.rb +0 -5
  211. data/spec/dummy/db/migrate/20190818075628_add_memo_to_item.rb +0 -5
  212. data/spec/dummy/db/migrate/20200425072340_create_manifestation_custom_properties.rb +0 -12
  213. data/spec/dummy/db/migrate/20200425072349_create_item_custom_properties.rb +0 -12
  214. data/spec/dummy/db/migrate/20200425074758_create_manifestation_custom_values.rb +0 -12
  215. data/spec/dummy/db/migrate/20200425074822_create_item_custom_values.rb +0 -12
  216. data/spec/dummy/yarn.lock +0 -7535
@@ -7,20 +7,11 @@ describe LibraryGroup do
7
7
  LibraryGroup.site_config.should be_truthy
8
8
  end
9
9
 
10
- it "should set 1000 as max_number_of_results" do
11
- expect(LibraryGroup.site_config.max_number_of_results).to eq 1000
12
- end
13
-
14
10
  it "should allow access from allowed networks" do
15
11
  library_group = LibraryGroup.find(1)
16
12
  library_group.my_networks = "127.0.0.1"
17
13
  library_group.network_access_allowed?("192.168.0.1").should be_falsy
18
14
  end
19
-
20
- it "should accept 0 as max_number_of_results" do
21
- library_group = LibraryGroup.find(1)
22
- library_group.update(max_number_of_results: 0).should be_truthy
23
- end
24
15
  end
25
16
 
26
17
  # == Schema Information
@@ -44,7 +35,7 @@ end
44
35
  # settings :text
45
36
  # html_snippet :text
46
37
  # book_jacket_source :string
47
- # max_number_of_results :integer default(1000)
38
+ # max_number_of_results :integer default(500)
48
39
  # family_name_first :boolean default(TRUE)
49
40
  # screenshot_generator :string
50
41
  # pub_year_facet_range_interval :integer default(10)
@@ -52,10 +43,10 @@ end
52
43
  # csv_charset_conversion :boolean default(FALSE), not null
53
44
  # header_logo_file_name :string
54
45
  # header_logo_content_type :string
55
- # header_logo_file_size :integer
46
+ # header_logo_file_size :bigint
56
47
  # header_logo_updated_at :datetime
57
48
  # header_logo_meta :text
58
- # library_group_id :integer not null
59
- # login_banner :text
60
- # footer_banner :text
49
+ # display_name_translations :jsonb not null
50
+ # login_banner_translations :jsonb not null
51
+ # footer_banner_translations :jsonb not null
61
52
  #
@@ -17,29 +17,30 @@ end
17
17
  #
18
18
  # Table name: libraries
19
19
  #
20
- # id :integer not null, primary key
21
- # name :string not null
22
- # display_name :text
23
- # short_display_name :string not null
24
- # zip_code :string
25
- # street :text
26
- # locality :text
27
- # region :text
28
- # telephone_number_1 :string
29
- # telephone_number_2 :string
30
- # fax_number :string
31
- # note :text
32
- # call_number_rows :integer default(1), not null
33
- # call_number_delimiter :string default("|"), not null
34
- # library_group_id :integer not null
35
- # users_count :integer default(0), not null
36
- # position :integer
37
- # country_id :integer
38
- # created_at :datetime
39
- # updated_at :datetime
40
- # deleted_at :datetime
41
- # opening_hour :text
42
- # isil :string
43
- # latitude :float
44
- # longitude :float
20
+ # id :integer not null, primary key
21
+ # name :string not null
22
+ # display_name :text
23
+ # short_display_name :string not null
24
+ # zip_code :string
25
+ # street :text
26
+ # locality :text
27
+ # region :text
28
+ # telephone_number_1 :string
29
+ # telephone_number_2 :string
30
+ # fax_number :string
31
+ # note :text
32
+ # call_number_rows :integer default(1), not null
33
+ # call_number_delimiter :string default("|"), not null
34
+ # library_group_id :integer not null
35
+ # users_count :integer default(0), not null
36
+ # position :integer
37
+ # country_id :integer
38
+ # created_at :datetime
39
+ # updated_at :datetime
40
+ # deleted_at :datetime
41
+ # opening_hour :text
42
+ # isil :string
43
+ # latitude :float
44
+ # longitude :float
45
+ # display_name_translations :jsonb not null
45
46
  #
@@ -9,11 +9,12 @@ end
9
9
  #
10
10
  # Table name: request_status_types
11
11
  #
12
- # id :integer not null, primary key
13
- # name :string not null
14
- # display_name :text
15
- # note :text
16
- # position :integer
17
- # created_at :datetime
18
- # updated_at :datetime
12
+ # id :integer not null, primary key
13
+ # name :string not null
14
+ # display_name :text
15
+ # note :text
16
+ # position :integer
17
+ # created_at :datetime
18
+ # updated_at :datetime
19
+ # display_name_translations :jsonb not null
19
20
  #
@@ -9,11 +9,12 @@ end
9
9
  #
10
10
  # Table name: request_types
11
11
  #
12
- # id :integer not null, primary key
13
- # name :string not null
14
- # display_name :text
15
- # note :text
16
- # position :integer
17
- # created_at :datetime
18
- # updated_at :datetime
12
+ # id :integer not null, primary key
13
+ # name :string not null
14
+ # display_name :text
15
+ # note :text
16
+ # position :integer
17
+ # created_at :datetime
18
+ # updated_at :datetime
19
+ # display_name_translations :jsonb not null
19
20
  #
@@ -12,16 +12,17 @@ end
12
12
  #
13
13
  # Table name: search_engines
14
14
  #
15
- # id :integer not null, primary key
16
- # name :string not null
17
- # display_name :text
18
- # url :string not null
19
- # base_url :text not null
20
- # http_method :text not null
21
- # query_param :text not null
22
- # additional_param :text
23
- # note :text
24
- # position :integer
25
- # created_at :datetime
26
- # updated_at :datetime
15
+ # id :integer not null, primary key
16
+ # name :string not null
17
+ # display_name :text
18
+ # url :string not null
19
+ # base_url :text not null
20
+ # http_method :text not null
21
+ # query_param :text not null
22
+ # additional_param :text
23
+ # note :text
24
+ # position :integer
25
+ # created_at :datetime
26
+ # updated_at :datetime
27
+ # display_name_translations :jsonb not null
27
28
  #
@@ -13,15 +13,16 @@ end
13
13
  #
14
14
  # Table name: shelves
15
15
  #
16
- # id :integer not null, primary key
17
- # name :string not null
18
- # display_name :text
19
- # note :text
20
- # library_id :integer not null
21
- # items_count :integer default(0), not null
22
- # position :integer
23
- # created_at :datetime
24
- # updated_at :datetime
25
- # deleted_at :datetime
26
- # closed :boolean default(FALSE), not null
16
+ # id :integer not null, primary key
17
+ # name :string not null
18
+ # display_name :text
19
+ # note :text
20
+ # library_id :integer not null
21
+ # items_count :integer default(0), not null
22
+ # position :integer
23
+ # created_at :datetime
24
+ # updated_at :datetime
25
+ # deleted_at :datetime
26
+ # closed :boolean default(FALSE), not null
27
+ # display_name_translations :jsonb not null
27
28
  #
@@ -9,7 +9,7 @@ describe UserExportFile do
9
9
  file.export!
10
10
  #UserExportFileJob.perform_later(file).should be_truthy
11
11
  Message.count.should eq message_count + 1
12
- Message.order(:created_at).last.subject.should eq "エクスポートが完了しました: #{file.id}"
12
+ Message.order(:created_at).last.subject.should eq "Export completed: #{file.id}"
13
13
  end
14
14
  end
15
15
 
@@ -21,7 +21,7 @@ end
21
21
  # user_id :integer
22
22
  # user_export_file_name :string
23
23
  # user_export_content_type :string
24
- # user_export_file_size :integer
24
+ # user_export_file_size :bigint
25
25
  # user_export_updated_at :datetime
26
26
  # executed_at :datetime
27
27
  # created_at :datetime
@@ -8,12 +8,6 @@ describe UserGroup do
8
8
  user_group.display_name = "en:test"
9
9
  user_group.valid?.should be_truthy
10
10
  end
11
-
12
- it "should not contain invalid yaml in its display_name" do
13
- user_group = user_groups(:user_group_00001)
14
- user_group.display_name = "en:test\r\nja: テスト"
15
- user_group.valid?.should be_falsy
16
- end
17
11
  end
18
12
 
19
13
  # == Schema Information
@@ -33,4 +27,5 @@ end
33
27
  # number_of_day_to_notify_overdue :integer default(7), not null
34
28
  # number_of_day_to_notify_due_date :integer default(3), not null
35
29
  # number_of_time_to_notify_overdue :integer default(3), not null
30
+ # display_name_translations :jsonb not null
36
31
  #
@@ -21,19 +21,19 @@ describe UserImportFile do
21
21
  old_users_count = User.count
22
22
  old_import_results_count = UserImportResult.count
23
23
  file.current_state.should eq 'pending'
24
- file.import_start.should eq({user_imported: 5, user_found: 0, failed: 0, error: 3})
24
+ file.import_start.should eq({user_imported: 5, user_found: 0, error: 3})
25
25
  User.order('id DESC')[1].username.should eq 'user005'
26
26
  User.order('id DESC')[2].username.should eq 'user003'
27
27
  User.count.should eq old_users_count + 5
28
28
 
29
- user001 = User.where(username: 'user001').first
29
+ user001 = User.find_by(username: 'user001')
30
30
  user001.profile.keyword_list.should eq "日本史\n地理"
31
31
  user001.profile.full_name.should eq '田辺 浩介'
32
32
  user001.profile.full_name_transcription.should eq 'たなべ こうすけ'
33
33
  user001.profile.required_role.name.should eq 'User'
34
34
  user001.locked_at.should be_truthy
35
35
 
36
- user002 = User.where(username: 'user002').first
36
+ user002 = User.find_by(username: 'user002')
37
37
  user002.profile.user_group.name.should eq 'faculty'
38
38
  user002.profile.expired_at.to_i.should eq Time.zone.parse('2013-12-01').end_of_day.to_i
39
39
  user002.valid_password?('4NsxXPLy')
@@ -43,7 +43,7 @@ describe UserImportFile do
43
43
  user002.profile.required_role.name.should eq 'Librarian'
44
44
  user002.locked_at.should be_nil
45
45
 
46
- user003 = User.where(username: 'user003').first
46
+ user003 = User.find_by(username: 'user003')
47
47
  user003.profile.note.should eq 'テストユーザ'
48
48
  user003.role.name.should eq 'Librarian'
49
49
  user003.profile.user_number.should eq '001003'
@@ -53,20 +53,20 @@ describe UserImportFile do
53
53
  user003.profile.save_checkout_history.should be_truthy
54
54
  user003.profile.save_search_history.should be_falsy
55
55
  user003.profile.share_bookmarks.should be_falsy
56
- User.where(username: 'user000').first.should be_nil
56
+ User.find_by(username: 'user000').should be_nil
57
57
  UserImportResult.count.should eq old_import_results_count + 10
58
- UserImportResult.order('id DESC')[0].error_message.should eq 'line 10: 利用者番号はすでに存在します'
59
- UserImportResult.order('id DESC')[1].error_message.should eq 'line 9: 利用者番号は不正な値です'
60
- UserImportResult.order('id DESC')[2].error_message.should eq 'line 8: パスワードは6文字以上で入力してください'
58
+ UserImportResult.order('id DESC')[0].error_message.should eq 'line 10: User number has already been taken'
59
+ UserImportResult.order('id DESC')[1].error_message.should eq 'line 9: User number is invalid'
60
+ UserImportResult.order('id DESC')[2].error_message.should eq 'line 8: Password is too short (minimum is 6 characters)'
61
61
 
62
- user005 = User.where(username: 'user005').first
62
+ user005 = User.find_by(username: 'user005')
63
63
  user005.role.name.should eq 'User'
64
64
  user005.profile.library.name.should eq 'hachioji'
65
65
  user005.profile.locale.should eq 'en'
66
66
  user005.profile.user_number.should eq '001005'
67
67
  user005.profile.user_group.name.should eq 'faculty'
68
68
 
69
- user006 = User.where(username: 'user006').first
69
+ user006 = User.find_by(username: 'user006')
70
70
  user006.role.name.should eq 'User'
71
71
  user006.profile.library.name.should eq 'hachioji'
72
72
  user006.profile.locale.should eq 'en'
@@ -77,25 +77,25 @@ describe UserImportFile do
77
77
  file.executed_at.should be_truthy
78
78
 
79
79
  file.reload
80
- file.error_message.should eq "次の列は無視されました。 save_search_history, share_bookmarks, invalid\nline 8: パスワードは6文字以上で入力してください\nline 9: 利用者番号は不正な値です\nline 10: 利用者番号はすでに存在します"
80
+ file.error_message.should eq "The following column(s) were ignored: save_search_history, share_bookmarks, invalid\nline 8: Password is too short (minimum is 6 characters)\nline 9: User number is invalid\nline 10: User number has already been taken"
81
81
  file.current_state.should eq 'failed'
82
82
  end
83
83
 
84
84
  it "should send message when import is completed" do
85
85
  old_message_count = Message.count
86
- @file.user = User.where(username: 'librarian1').first
86
+ @file.user = User.find_by(username: 'librarian1')
87
87
  @file.import_start
88
88
  Message.count.should eq old_message_count + 1
89
- Message.order(:created_at).last.subject.should eq "インポートが完了しました: #{@file.id}"
89
+ Message.order(:created_at).last.subject.should eq "Import completed: #{@file.id}"
90
90
  end
91
91
 
92
92
  it "should not import users that have higher roles than current user's role" do
93
93
  old_users_count = User.count
94
94
  old_import_results_count = UserImportResult.count
95
- @file.user = User.where(username: 'librarian1').first
96
- @file.import_start.should eq({user_imported: 4, user_found: 0, failed: 1, error: 3})
95
+ @file.user = User.find_by(username: 'librarian1')
96
+ @file.import_start.should eq({user_imported: 5, user_found: 0, error: 3})
97
97
  User.order('id DESC')[1].username.should eq 'user005'
98
- User.count.should eq old_users_count + 4
98
+ User.count.should eq old_users_count + 5
99
99
  UserImportResult.count.should eq old_import_results_count + 10
100
100
  end
101
101
  end
@@ -103,8 +103,7 @@ describe UserImportFile do
103
103
  describe "when its mode is 'update'" do
104
104
  before(:each) do
105
105
  FactoryBot.create(:user,
106
- username: 'user001',
107
- profile: FactoryBot.create(:profile)
106
+ username: 'user001'
108
107
  )
109
108
  end
110
109
  it "should update users" do
@@ -117,7 +116,7 @@ describe UserImportFile do
117
116
  old_message_count = Message.count
118
117
  result = @file.modify
119
118
  result.should have_key(:user_updated)
120
- user001 = User.where(username: 'user001').first
119
+ user001 = User.find_by(username: 'user001')
121
120
  user001.email.should eq 'user001@example.jp'
122
121
  user001.profile.full_name.should eq '田辺 浩介'
123
122
  user001.profile.full_name_transcription.should eq 'たなべこうすけ'
@@ -128,7 +127,7 @@ describe UserImportFile do
128
127
  end
129
128
 
130
129
  it "should not overwrite with null value" do
131
- user = User.where(username: 'user001').first
130
+ user = User.find_by(username: 'user001')
132
131
  user.profile = FactoryBot.create(:profile,
133
132
  user_number: '001',
134
133
  full_name: 'User 001',
@@ -137,6 +136,7 @@ describe UserImportFile do
137
136
  note: 'Note',
138
137
  keyword_list: 'keyword1 keyword2',
139
138
  date_of_birth: 10.years.ago)
139
+ user.save!
140
140
  file = UserImportFile.create!(
141
141
  user_import: File.new("#{Rails.root}/../../examples/user_update_file2.tsv"),
142
142
  user: users(:admin),
@@ -161,7 +161,7 @@ describe UserImportFile do
161
161
  )
162
162
  result = file.modify
163
163
  result.should have_key(:user_updated)
164
- user001 = User.where(username: 'user001').first
164
+ user001 = User.find_by(username: 'user001')
165
165
  user001.profile.user_number.should eq '0001'
166
166
  end
167
167
  it "should update user's lock status" do
@@ -173,7 +173,7 @@ describe UserImportFile do
173
173
  )
174
174
  result = file.modify
175
175
  result.should have_key(:user_updated)
176
- user001 = User.where(username: 'user001').first
176
+ user001 = User.find_by(username: 'user001')
177
177
  user001.access_locked?.should be_truthy
178
178
  end
179
179
  end
@@ -204,7 +204,7 @@ describe UserImportFile do
204
204
  end
205
205
 
206
206
  it "should not remove users if there are checkouts" do
207
- user001 = User.where(username: 'user001').first
207
+ user001 = User.find_by(username: 'user001')
208
208
  FactoryBot.create(:checkout, user: user001, item: FactoryBot.create(:item))
209
209
  old_count = User.count
210
210
  file = UserImportFile.create!(
data/spec/rails_helper.rb CHANGED
@@ -1,7 +1,11 @@
1
1
  require 'simplecov'
2
2
  require 'coveralls'
3
+
4
+ SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([
5
+ SimpleCov::Formatter::HTMLFormatter,
6
+ Coveralls::SimpleCov::Formatter
7
+ ])
3
8
  SimpleCov.start 'rails'
4
- Coveralls.wear!
5
9
 
6
10
  # This file is copied to spec/ when you run 'rails generate rspec:install'
7
11
  ENV['RAILS_ENV'] ||= 'test'
@@ -11,7 +15,7 @@ abort("The Rails environment is running in production mode!") if Rails.env.produ
11
15
  require 'spec_helper'
12
16
  require 'rspec/rails'
13
17
  # Add additional requires below this line. Rails is not loaded until this point!
14
- require 'factory_bot_rails'
18
+ require 'factory_bot'
15
19
  require 'rspec/active_model/mocks'
16
20
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
17
21
 
@@ -66,3 +70,7 @@ RSpec.configure do |config|
66
70
  end
67
71
  end
68
72
  end
73
+
74
+ FactoryBot.definition_file_paths << "#{::Rails.root}/../../spec/factories"
75
+ FactoryBot.find_definitions
76
+
@@ -9,7 +9,7 @@ RSpec.describe 'Libraries', type: :system do
9
9
  sign_in users(:admin)
10
10
  end
11
11
 
12
- xit 'should show library config' do
12
+ it 'should show library config' do
13
13
  visit library_path(libraries(:library_00002).id, locale: :ja)
14
14
  expect(page).to have_content '設定'
15
15
  end
@@ -20,9 +20,9 @@ RSpec.describe 'Libraries', type: :system do
20
20
  sign_in users(:librarian1)
21
21
  end
22
22
 
23
- xit 'should not show library config' do
23
+ it 'should not show library config' do
24
24
  visit library_path(libraries(:library_00002).id, locale: :ja)
25
- expect(page).not_to have_link '設定'
25
+ expect(page).not_to have_content '設定'
26
26
  end
27
27
  end
28
28
 
@@ -33,14 +33,14 @@ RSpec.describe 'Libraries', type: :system do
33
33
 
34
34
  it 'should not show library config' do
35
35
  visit library_path(libraries(:library_00002).id, locale: :ja)
36
- expect(page).not_to have_link '設定'
36
+ expect(page).not_to have_content '設定'
37
37
  end
38
38
  end
39
39
 
40
40
  describe 'When not logged in' do
41
41
  it 'should not show library config' do
42
42
  visit library_path(libraries(:library_00002).id, locale: :ja)
43
- expect(page).not_to have_link '設定'
43
+ expect(page).not_to have_content '設定'
44
44
  end
45
45
  end
46
46
  end