enju_circulation 0.3.11 → 0.4.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -3
  3. data/app/controllers/checkins_controller.rb +2 -2
  4. data/app/controllers/checkouts_controller.rb +2 -2
  5. data/app/controllers/demands_controller.rb +1 -1
  6. data/app/controllers/manifestation_checkout_stats_controller.rb +2 -2
  7. data/app/controllers/manifestation_reserve_stats_controller.rb +2 -2
  8. data/app/controllers/reserves_controller.rb +2 -2
  9. data/app/controllers/user_checkout_stats_controller.rb +2 -2
  10. data/app/controllers/user_group_has_checkout_types_controller.rb +1 -1
  11. data/app/controllers/user_reserve_stats_controller.rb +2 -2
  12. data/app/helpers/items_helper.rb +3 -3
  13. data/app/models/checked_item.rb +7 -17
  14. data/app/models/checkin.rb +3 -2
  15. data/app/models/checkout.rb +2 -2
  16. data/app/models/checkout_stat_has_user.rb +1 -1
  17. data/app/models/checkout_type.rb +9 -7
  18. data/app/models/circulation_status.rb +9 -8
  19. data/app/models/concerns/enju_circulation/enju_item.rb +2 -46
  20. data/app/models/concerns/enju_circulation/enju_user_group.rb +0 -1
  21. data/app/models/concerns/enju_circulation/enju_withdraw.rb +1 -7
  22. data/app/models/manifestation_checkout_stat_transition.rb +1 -1
  23. data/app/models/manifestation_reserve_stat_transition.rb +1 -1
  24. data/app/models/reserve.rb +5 -5
  25. data/app/models/reserve_state_machine.rb +3 -2
  26. data/app/models/reserve_transition.rb +1 -1
  27. data/app/models/retain.rb +15 -0
  28. data/app/models/user_checkout_stat_transition.rb +1 -1
  29. data/app/models/user_group_has_checkout_type.rb +15 -37
  30. data/app/models/user_reserve_stat_transition.rb +1 -1
  31. data/app/views/carrier_type_has_checkout_types/_form.html.erb +2 -2
  32. data/app/views/carrier_type_has_checkout_types/index.html.erb +2 -2
  33. data/app/views/carrier_type_has_checkout_types/show.html.erb +2 -2
  34. data/app/views/carrier_types/_carrier_type_has_checkout_type_fields.html.erb +1 -1
  35. data/app/views/checked_items/new.html.erb +1 -1
  36. data/app/views/checkins/_checkin.html.erb +1 -1
  37. data/app/views/checkout_types/_form.html.erb +1 -1
  38. data/app/views/checkout_types/index.html.erb +1 -1
  39. data/app/views/checkout_types/show.html.erb +2 -2
  40. data/app/views/checkouts/_index_user.html.erb +1 -1
  41. data/app/views/checkouts/_list.html.erb +2 -9
  42. data/app/views/checkouts/index.atom.builder +1 -1
  43. data/app/views/checkouts/index.ics.erb +1 -1
  44. data/app/views/checkouts/index.rss.builder +1 -1
  45. data/app/views/checkouts/{index.text.ruby → index.txt.ruby} +0 -0
  46. data/app/views/circulation_statuses/_form.html.erb +1 -1
  47. data/app/views/circulation_statuses/index.html.erb +1 -1
  48. data/app/views/circulation_statuses/show.html.erb +1 -1
  49. data/app/views/item_has_use_restrictions/index.html.erb +1 -1
  50. data/app/views/item_has_use_restrictions/show.html.erb +1 -1
  51. data/app/views/manifestation_checkout_stats/_group_by_carrier_type.html.erb +3 -3
  52. data/app/views/manifestation_checkout_stats/_group_by_checkout_type.html.erb +3 -3
  53. data/app/views/manifestation_checkout_stats/{show.text.erb → show.txt.erb} +0 -0
  54. data/app/views/manifestation_reserve_stats/{show.text.erb → show.txt.erb} +0 -0
  55. data/app/views/manifestations/_circulation_status.html.erb +3 -3
  56. data/app/views/profiles/_submenu_checkout.html.erb +1 -1
  57. data/app/views/reserves/_new.html.erb +1 -1
  58. data/app/views/reserves/_new_user.html.erb +1 -1
  59. data/app/views/reserves/edit.html.erb +1 -1
  60. data/app/views/reserves/index.atom.builder +1 -1
  61. data/app/views/reserves/index.html.erb +1 -1
  62. data/app/views/reserves/index.rss.builder +1 -1
  63. data/app/views/reserves/{index.text.ruby → index.txt.ruby} +0 -0
  64. data/app/views/reserves/show.html.erb +1 -1
  65. data/app/views/use_restrictions/_form.html.erb +1 -1
  66. data/app/views/use_restrictions/index.html.erb +1 -1
  67. data/app/views/use_restrictions/show.html.erb +1 -1
  68. data/app/views/user_checkout_stats/{show.text.erb → show.txt.erb} +0 -0
  69. data/app/views/user_group_has_checkout_types/edit.html.erb +4 -4
  70. data/app/views/user_group_has_checkout_types/index.html.erb +2 -2
  71. data/app/views/user_group_has_checkout_types/new.html.erb +4 -4
  72. data/app/views/user_group_has_checkout_types/show.html.erb +4 -4
  73. data/app/views/user_groups/_user_group_has_checkout_type_fields.html.erb +2 -2
  74. data/app/views/user_reserve_stats/{show.text.erb → show.txt.erb} +0 -0
  75. data/config/locales/translation_en.yml +1 -14
  76. data/config/locales/translation_ja.yml +1 -14
  77. data/config/routes.rb +1 -2
  78. data/db/migrate/20110627122938_add_number_of_day_to_notify_overdue_to_user_group.rb +3 -3
  79. data/db/migrate/20190508160525_create_retains.rb +10 -0
  80. data/db/migrate/20190629134017_rename_user_group_has_checkout_type_due_date_before_to_due_date_after.rb +5 -0
  81. data/db/migrate/20190706052525_add_display_name_translations_to_circulation_status.rb +5 -0
  82. data/db/migrate/20190713114724_add_checkout_id_to_checkin.rb +5 -0
  83. data/db/migrate/20190814120827_add_display_name_translations_to_checkout_type.rb +5 -0
  84. data/lib/enju_circulation/version.rb +1 -1
  85. data/lib/generators/enju_circulation/setup/templates/db/fixtures/checkout_types.yml +3 -5
  86. data/lib/generators/enju_circulation/setup/templates/db/fixtures/circulation_statuses.yml +16 -48
  87. data/lib/tasks/enju_circulation_tasks.rake +7 -1
  88. data/spec/concerns/enju_accept_spec.rb +14 -14
  89. data/spec/controllers/accepts_controller_spec.rb +294 -0
  90. data/spec/controllers/baskets_controller_spec.rb +379 -0
  91. data/spec/controllers/checkins_controller_spec.rb +8 -130
  92. data/spec/controllers/checkouts_controller_spec.rb +5 -5
  93. data/spec/controllers/items_controller_spec.rb +23 -43
  94. data/spec/controllers/reserves_controller_spec.rb +9 -9
  95. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  96. data/spec/dummy/app/models/user.rb +1 -1
  97. data/spec/dummy/bin/bundle +1 -1
  98. data/spec/dummy/bin/setup +1 -3
  99. data/spec/dummy/bin/update +4 -2
  100. data/spec/dummy/bin/yarn +3 -3
  101. data/spec/dummy/config/database.yml +70 -9
  102. data/spec/dummy/config/initializers/assets.rb +1 -0
  103. data/spec/dummy/db/development.sqlite3 +0 -0
  104. data/spec/dummy/db/migrate/113_create_events.rb +2 -4
  105. data/spec/dummy/db/migrate/20081028093607_create_event_import_files.rb +2 -4
  106. data/spec/dummy/db/migrate/20090519203307_create_participates.rb +2 -4
  107. data/spec/dummy/db/migrate/20100925074639_create_event_import_results.rb +2 -2
  108. data/spec/dummy/db/migrate/20140720192418_add_default_library_id_to_event_import_file.rb +1 -1
  109. data/spec/dummy/db/migrate/20140812152348_create_event_export_files.rb +1 -1
  110. data/spec/dummy/db/migrate/20140814070854_add_default_event_category_id_to_event_import_file.rb +1 -1
  111. data/spec/dummy/db/migrate/20151128142913_create_places.rb +14 -0
  112. data/spec/dummy/db/migrate/20151201163718_add_place_id_to_event.rb +5 -0
  113. data/spec/dummy/db/migrate/20160703184258_add_most_recent_to_event_import_file_transitions.rb +9 -0
  114. data/spec/dummy/db/migrate/20160703184311_add_most_recent_to_event_export_file_transitions.rb +9 -0
  115. data/spec/dummy/db/migrate/20180107160726_add_constraints_to_most_recent_for_user_import_file_transitions.rb +1 -1
  116. data/spec/dummy/db/migrate/20180107160740_add_constraints_to_most_recent_for_user_export_file_transitions.rb +1 -1
  117. data/spec/dummy/db/migrate/20180107164558_add_constraints_to_most_recent_for_event_import_file_transitions.rb +13 -0
  118. data/spec/dummy/db/migrate/20180107164617_add_constraints_to_most_recent_for_event_export_file_transitions.rb +13 -0
  119. data/spec/dummy/db/migrate/20181119170645_add_foreign_key_to_events_referencing_event_categories.rb +5 -0
  120. data/spec/dummy/db/migrate/20190630113817_add_display_name_translations_to_library_group.rb +12 -0
  121. data/spec/dummy/db/migrate/20190630115523_add_login_banner_translations_to_library_group.rb +6 -0
  122. data/spec/dummy/db/migrate/20190630151446_add_display_name_translations_to_role.rb +5 -0
  123. data/spec/dummy/db/migrate/20190630153136_add_display_name_translations_to_event.rb +6 -0
  124. data/spec/dummy/db/migrate/20190712163038_add_display_name_translations_to_carrier_type.rb +21 -0
  125. data/spec/dummy/db/migrate/20190713114940_add_profile_id_to_user.rb +5 -0
  126. data/spec/dummy/db/migrate/20190713115451_add_full_name_translations_to_profile.rb +5 -0
  127. data/spec/dummy/db/schema.rb +221 -184
  128. data/spec/dummy/db/test.sqlite3 +0 -0
  129. data/spec/dummy/private/system/carrier_types/attachments/000/000/001/original/book.png +0 -0
  130. data/spec/dummy/private/system/carrier_types/attachments/000/000/001/thumb/book.png +0 -0
  131. data/spec/factories/accept.rb +1 -1
  132. data/spec/factories/item.rb +4 -4
  133. data/spec/factories/reserve.rb +1 -5
  134. data/spec/fixtures/carrier_types.yml +16 -15
  135. data/spec/fixtures/checkins.yml +2 -1
  136. data/spec/fixtures/checkout_stat_has_users.yml +1 -1
  137. data/spec/fixtures/checkout_types.yml +11 -10
  138. data/spec/fixtures/checkouts.yml +2 -2
  139. data/spec/fixtures/circulation_statuses.yml +26 -34
  140. data/spec/fixtures/content_types.yml +20 -31
  141. data/spec/fixtures/event_categories.yml +23 -23
  142. data/spec/fixtures/frequencies.yml +17 -25
  143. data/spec/fixtures/items.yml +1 -1
  144. data/spec/fixtures/libraries.yml +30 -31
  145. data/spec/fixtures/library_groups.yml +43 -20
  146. data/spec/fixtures/request_status_types.yml +14 -14
  147. data/spec/fixtures/request_types.yml +13 -13
  148. data/spec/fixtures/reserve_transitions.yml +1 -1
  149. data/spec/fixtures/reserves.yml +3 -3
  150. data/spec/fixtures/roles.yml +22 -5
  151. data/spec/fixtures/shelves.yml +16 -15
  152. data/spec/fixtures/user_group_has_checkout_types.yml +24 -24
  153. data/spec/fixtures/user_groups.yml +23 -3
  154. data/spec/helpers/items_helper_spec.rb +1 -1
  155. data/spec/models/checked_item_spec.rb +0 -11
  156. data/spec/models/checkin_spec.rb +2 -1
  157. data/spec/models/checkout_spec.rb +2 -2
  158. data/spec/models/checkout_stat_has_user_spec.rb +1 -1
  159. data/spec/models/checkout_type_spec.rb +8 -7
  160. data/spec/models/circulation_status_spec.rb +8 -7
  161. data/spec/models/item_spec.rb +6 -8
  162. data/spec/models/manifestation_spec.rb +15 -18
  163. data/spec/models/reserve_spec.rb +3 -3
  164. data/spec/models/resource_export_file_spec.rb +0 -15
  165. data/spec/models/retain_spec.rb +16 -0
  166. data/spec/models/user_group_has_checkout_type_spec.rb +15 -32
  167. data/spec/models/withdraw_spec.rb +4 -6
  168. data/spec/policies/manifestation_policy_spec.rb +2 -1
  169. data/spec/rails_helper.rb +10 -3
  170. data/spec/system/reserves_spec.rb +1 -1
  171. data/spec/views/items/index.html.erb_spec.rb +1 -4
  172. metadata +402 -452
  173. data/app/controllers/lending_policies_controller.rb +0 -106
  174. data/app/models/lending_policy.rb +0 -30
  175. data/app/views/lending_policies/_form.html.erb +0 -41
  176. data/app/views/lending_policies/edit.html.erb +0 -13
  177. data/app/views/lending_policies/index.html.erb +0 -42
  178. data/app/views/lending_policies/new.html.erb +0 -12
  179. data/app/views/lending_policies/show.html.erb +0 -50
  180. data/db/migrate/20090831220301_create_lending_policies.rb +0 -21
  181. data/spec/controllers/lending_policies_controller_spec.rb +0 -444
  182. data/spec/controllers/withdraws_controller_spec.rb +0 -26
  183. data/spec/dummy/config/locales/en.yml +0 -208
  184. data/spec/dummy/config/locales/ja.yml +0 -200
  185. data/spec/dummy/db/migrate/20190818075603_add_memo_to_manifestation.rb +0 -5
  186. data/spec/dummy/db/migrate/20190818075628_add_memo_to_item.rb +0 -5
  187. data/spec/dummy/db/migrate/20200425072340_create_manifestation_custom_properties.rb +0 -12
  188. data/spec/dummy/db/migrate/20200425072349_create_item_custom_properties.rb +0 -12
  189. data/spec/dummy/db/migrate/20200425074758_create_manifestation_custom_values.rb +0 -12
  190. data/spec/dummy/db/migrate/20200425074822_create_item_custom_values.rb +0 -12
  191. data/spec/fixtures/accepts.yml +0 -9
  192. data/spec/fixtures/bookstores.yml +0 -99
  193. data/spec/fixtures/budget_types.yml +0 -30
  194. data/spec/fixtures/exemplifies.yml +0 -168
  195. data/spec/fixtures/lending_policies.yml +0 -98
  196. data/spec/models/lending_policy_spec.rb +0 -23
  197. data/spec/system/items_spec.rb +0 -21
  198. data/spec/system/user_group_has_checkout_types.rb +0 -14
@@ -9,11 +9,12 @@ end
9
9
  #
10
10
  # Table name: checkout_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: circulation_statuses
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
  #
@@ -33,15 +33,13 @@ describe Item do
33
33
  items(:item_00012).available_for_checkout?.should be_falsy
34
34
  end
35
35
 
36
- it "should not be able to checkout a removed item" do
37
- Item.for_checkout.include?(items(:item_00023)).should be_falsy
36
+ it "should not create item without manifestation_id" do
37
+ item = items(:item_00001)
38
+ item.manifestation_id = nil
39
+ item.valid?.should be_falsy
38
40
  end
39
41
 
40
- it "should delete lending policies" do
41
- item = items(:item_00001)
42
- item.checkout_type = CheckoutType.find_by(name: 'serial')
43
- item.save
44
- item.reload
45
- item.lending_policies.count.should eq 0
42
+ it "should not be able to checkout a removed item" do
43
+ Item.for_checkout.include?(items(:item_00023)).should be_falsy
46
44
  end
47
45
  end
@@ -1,7 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- describe Manifestation do
4
- # pending "add some examples to (or delete) #{__FILE__}"
3
+ describe Manifestation, solr: true do
5
4
  fixtures :all
6
5
 
7
6
  it "should be reserved" do
@@ -16,23 +15,21 @@ describe Manifestation do
16
15
  manifestations(:manifestation_00008).is_reservable_by?(users(:admin)).should be_falsy
17
16
  end
18
17
 
19
- context ".export" do
20
- it "should not export use_restriction for Guest" do
21
- manifestation = FactoryBot.create(:manifestation)
22
- use_restriction = UseRestriction.find(1)
23
- item = FactoryBot.create(:item, manifestation: manifestation, use_restriction: use_restriction)
24
- lines = Manifestation.export(role: "Guest")
25
- csv = CSV.parse(lines, headers: true, col_sep: "\t")
26
- expect(csv["use_restriction"].compact).to be_empty
18
+ it "should not export use_restriction for Guest" do
19
+ manifestation = FactoryBot.create(:manifestation)
20
+ use_restriction = UseRestriction.find(1)
21
+ item = FactoryBot.create(:item, manifestation: manifestation, use_restriction: use_restriction)
22
+ lines = Manifestation.export(format: :txt, role: "Guest")
23
+ csv = CSV.parse(lines, headers: true, col_sep: "\t")
24
+ expect(csv["use_restriction"].compact).to be_empty
27
25
 
28
- lines = Manifestation.export(role: "Administrator")
29
- csv = CSV.parse(lines, headers: true, col_sep: "\t")
30
- expect(csv["use_restriction"].compact).not_to be_empty
31
- end
26
+ lines = Manifestation.export(format: :txt, role: "Administrator")
27
+ csv = CSV.parse(lines, headers: true, col_sep: "\t")
28
+ expect(csv["use_restriction"].compact).not_to be_empty
29
+ end
32
30
 
33
- it "should respond to is_checked_out_by?" do
34
- manifestations(:manifestation_00001).is_checked_out_by?(users(:admin)).should be_truthy
35
- manifestations(:manifestation_00001).is_checked_out_by?(users(:librarian2)).should be_falsy
36
- end
31
+ it "should respond to is_checked_out_by?" do
32
+ manifestations(:manifestation_00001).is_checked_out_by?(users(:admin)).should be_truthy
33
+ manifestations(:manifestation_00001).is_checked_out_by?(users(:librarian2)).should be_falsy
37
34
  end
38
35
  end
@@ -147,10 +147,10 @@ end
147
147
  # canceled_at :datetime
148
148
  # expired_at :datetime
149
149
  # deleted_at :datetime
150
- # expiration_notice_to_patron :boolean default("0")
151
- # expiration_notice_to_library :boolean default("0")
150
+ # expiration_notice_to_patron :boolean default(FALSE)
151
+ # expiration_notice_to_library :boolean default(FALSE)
152
152
  # pickup_location_id :integer
153
153
  # retained_at :datetime
154
154
  # postponed_at :datetime
155
- # lock_version :integer default("0"), not null
155
+ # lock_version :integer default(0), not null
156
156
  #
@@ -25,18 +25,3 @@ describe ResourceExportFile do
25
25
  end
26
26
  end
27
27
  end
28
-
29
- # == Schema Information
30
- #
31
- # Table name: resource_export_files
32
- #
33
- # id :integer not null, primary key
34
- # user_id :integer
35
- # resource_export_file_name :string
36
- # resource_export_content_type :string
37
- # resource_export_file_size :integer
38
- # resource_export_updated_at :datetime
39
- # executed_at :datetime
40
- # created_at :datetime
41
- # updated_at :datetime
42
- #
@@ -0,0 +1,16 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe Retain, type: :model do
4
+ pending "add some examples to (or delete) #{__FILE__}"
5
+ end
6
+
7
+ # == Schema Information
8
+ #
9
+ # Table name: retains
10
+ #
11
+ # id :bigint not null, primary key
12
+ # reserve_id :bigint not null
13
+ # item_id :bigint not null
14
+ # created_at :datetime not null
15
+ # updated_at :datetime not null
16
+ #
@@ -3,23 +3,6 @@ require 'rails_helper'
3
3
  describe UserGroupHasCheckoutType do
4
4
  fixtures :all
5
5
 
6
- it "should create lending_policy" do
7
- old_count = LendingPolicy.count
8
- user_group_has_checkout_types(:user_group_has_checkout_type_00005).create_lending_policy
9
- (user_group_has_checkout_types(:user_group_has_checkout_type_00005).checkout_type.items.count + old_count).should eq LendingPolicy.count
10
- end
11
-
12
- it "should update lending_policy" do
13
- old_updated_at = lending_policies(:lending_policy_00004).updated_at
14
- user_group_has_checkout_types(:user_group_has_checkout_type_00002).checkout_period = 100
15
- user_group_has_checkout_types(:user_group_has_checkout_type_00002).checkout_renewal_limit = 5
16
- user_group_has_checkout_types(:user_group_has_checkout_type_00002).update_lending_policy.should be_truthy
17
- lending_policies(:lending_policy_00004).reload
18
- lending_policies(:lending_policy_00004).updated_at.should > old_updated_at
19
- lending_policies(:lending_policy_00004).loan_period.should eq 100
20
- lending_policies(:lending_policy_00004).renewal.should eq 5
21
- end
22
-
23
6
  it "should respond to update_current_checkout_count" do
24
7
  UserGroupHasCheckoutType.update_current_checkout_count.should be_truthy
25
8
  end
@@ -29,19 +12,19 @@ end
29
12
  #
30
13
  # Table name: user_group_has_checkout_types
31
14
  #
32
- # id :integer not null, primary key
33
- # user_group_id :integer not null
34
- # checkout_type_id :integer not null
35
- # checkout_limit :integer default("0"), not null
36
- # checkout_period :integer default("0"), not null
37
- # checkout_renewal_limit :integer default("0"), not null
38
- # reservation_limit :integer default("0"), not null
39
- # reservation_expired_period :integer default("7"), not null
40
- # set_due_date_before_closing_day :boolean default("0"), not null
41
- # fixed_due_date :datetime
42
- # note :text
43
- # position :integer
44
- # created_at :datetime
45
- # updated_at :datetime
46
- # current_checkout_count :integer
15
+ # id :integer not null, primary key
16
+ # user_group_id :integer not null
17
+ # checkout_type_id :integer not null
18
+ # checkout_limit :integer default(0), not null
19
+ # checkout_period :integer default(0), not null
20
+ # checkout_renewal_limit :integer default(0), not null
21
+ # reservation_limit :integer default(0), not null
22
+ # reservation_expired_period :integer default(7), not null
23
+ # set_due_date_after_closing_day :boolean default(FALSE), not null
24
+ # fixed_due_date :datetime
25
+ # note :text
26
+ # position :integer
27
+ # created_at :datetime
28
+ # updated_at :datetime
29
+ # current_checkout_count :integer
47
30
  #
@@ -5,22 +5,20 @@ RSpec.describe Withdraw, type: :model do
5
5
 
6
6
  it "should change circulation_status" do
7
7
  withdraw = FactoryBot.create(:withdraw)
8
- expect(withdraw.item.circulation_status.name).to eq 'Removed'
9
- expect(withdraw.item.use_restriction.name).to eq 'Not For Loan'
8
+ withdraw.item.circulation_status.name.should eq 'Removed'
9
+ withdraw.item.use_restriction.name.should eq 'Not For Loan'
10
10
  end
11
11
 
12
12
  it "should not withdraw rented item" do
13
13
  withdraw = Withdraw.new(librarian: users(:librarian1))
14
14
  withdraw.item = items(:item_00013)
15
- expect(withdraw.valid?).to be_falsy
16
- expect(withdraw.errors.messages[:item_id]).to include('is rented.')
15
+ withdraw.valid?.should be_falsy
17
16
  end
18
17
 
19
18
  it "should not withdraw reserved item" do
20
19
  reserve = FactoryBot.create(:reserve)
21
20
  withdraw = FactoryBot.build(:withdraw, item: reserve.manifestation.items.first)
22
- expect(withdraw.valid?).to be_falsy
23
- expect(withdraw.errors.messages[:item_id]).to include('is reserved.')
21
+ withdraw.valid?.should be_falsy
24
22
  end
25
23
  end
26
24
 
@@ -8,7 +8,8 @@ describe ManifestationPolicy do
8
8
  end
9
9
 
10
10
  it "not grants destroy if it is reserved" do
11
- record = FactoryBot.create(:reserve).manifestation
11
+ record = FactoryBot.create(:manifestation)
12
+ reserve = FactoryBot.create(:reserve, manifestation_id: record.id)
12
13
  expect(subject).not_to permit(@admin, record)
13
14
  end
14
15
  end
data/spec/rails_helper.rb CHANGED
@@ -1,16 +1,20 @@
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'
8
12
  require File.expand_path("../dummy/config/environment", __FILE__)
9
13
  require 'rspec/rails'
10
- require 'factory_bot_rails'
14
+ require 'factory_bot'
11
15
  require 'rspec/active_model/mocks'
16
+ require 'pundit/rspec'
12
17
  require "capybara/rspec"
13
- require "pundit/rspec"
14
18
 
15
19
  # Requires supporting ruby files with custom matchers and macros, etc,
16
20
  # in spec/support/ and its subdirectories.
@@ -44,3 +48,6 @@ RSpec.configure do |config|
44
48
  end
45
49
  end
46
50
  end
51
+
52
+ FactoryBot.definition_file_paths << "#{::Rails.root}/../../spec/factories"
53
+ FactoryBot.find_definitions
@@ -7,7 +7,7 @@ RSpec.describe 'Reserves', type: :system do
7
7
  describe 'When logged in as Librarian' do
8
8
  it 'should contain user information' do
9
9
  sign_in users(:librarian1)
10
- visit reserves_path(format: :text)
10
+ visit reserves_path(format: :txt)
11
11
  expect(page).to have_content reserves(:reserve_00001).user.username
12
12
  expect(page).to have_content reserves(:reserve_00001).manifestation.original_title
13
13
  end
@@ -16,11 +16,9 @@ describe "items/index" do
16
16
  allow(view).to receive(:policy) do |record|
17
17
  Pundit.policy(user, record)
18
18
  end
19
-
20
- Item.reindex
21
19
  end
22
20
 
23
- describe "circulation_status facet", solr: true do
21
+ describe "circulation_status facet" do
24
22
  it "should work with searching acquired_at fields" do
25
23
  view.stub(:filtered_params).and_return(ActionController::Parameters.new().permit)
26
24
  render
@@ -32,4 +30,3 @@ describe "items/index" do
32
30
  end
33
31
  end
34
32
  end
35
-