enju_circulation 0.3.6 → 0.3.7
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/app/models/concerns/enju_circulation/enju_item.rb +15 -2
- data/app/models/concerns/enju_circulation/enju_withdraw.rb +7 -1
- data/app/models/reserve.rb +1 -1
- data/app/views/checkouts/_list.html.erb +7 -0
- data/config/locales/translation_en.yml +12 -0
- data/config/locales/translation_ja.yml +12 -0
- data/db/migrate/20110627122938_add_number_of_day_to_notify_overdue_to_user_group.rb +3 -3
- data/lib/enju_circulation/version.rb +1 -1
- data/lib/generators/enju_circulation/setup/setup_generator.rb +5 -0
- data/spec/controllers/items_controller_spec.rb +20 -0
- data/spec/dummy/db/migrate/20190818075603_add_memo_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20190818075628_add_memo_to_item.rb +5 -0
- data/spec/dummy/db/migrate/20191219122214_create_custom_properties.rb +12 -0
- data/spec/dummy/db/schema.rb +15 -4
- data/spec/factories/item.rb +3 -3
- data/spec/factories/reserve.rb +5 -1
- data/spec/fixtures/bookstores.yml +99 -0
- data/spec/fixtures/budget_types.yml +30 -0
- data/spec/models/manifestation_spec.rb +2 -2
- data/spec/models/withdraw_spec.rb +6 -4
- data/spec/policies/manifestation_policy_spec.rb +1 -2
- data/spec/rails_helper.rb +1 -4
- data/spec/system/items_spec.rb +21 -0
- metadata +32 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec0186b540696a095318784c23672ed230f8185e2c0d52f365e4695ef4a657da
|
4
|
+
data.tar.gz: a2f541396204e0fedfb66286073ae7692d115139cc2158b60d675e690ec0b64b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6b679339032cac9d2e882dda4a3f07e0a13b4ed14d5dcbca2ce33c4fbeb11ab6f55ceb35cfb5e96f6d937659ad5ddb9df01b733cbad4c22561d1d13d8dbc45c
|
7
|
+
data.tar.gz: 252a3d9f72f818c3923f03b8a7df79c7892afea7453ad173139549a4b83da9991a5fb2063476817a244de68084f93cfe084c5d902b3aa1f3f0e06e667d28fd7f
|
@@ -35,13 +35,14 @@ module EnjuCirculation
|
|
35
35
|
has_many :reserves
|
36
36
|
has_many :checked_items
|
37
37
|
has_many :baskets, through: :checked_items
|
38
|
-
belongs_to :circulation_status
|
38
|
+
belongs_to :circulation_status
|
39
39
|
belongs_to :checkout_type
|
40
40
|
has_many :lending_policies, dependent: :destroy
|
41
41
|
has_one :item_has_use_restriction, dependent: :destroy
|
42
42
|
has_one :use_restriction, through: :item_has_use_restriction
|
43
|
-
validates_associated :circulation_status, :checkout_type
|
44
43
|
validates :circulation_status, :checkout_type, presence: true
|
44
|
+
validate :check_circulation_status
|
45
|
+
|
45
46
|
searchable do
|
46
47
|
string :circulation_status do
|
47
48
|
circulation_status.name
|
@@ -56,6 +57,14 @@ module EnjuCirculation
|
|
56
57
|
self.circulation_status = CirculationStatus.find_by(name: 'In Process') if circulation_status.nil?
|
57
58
|
end
|
58
59
|
|
60
|
+
def check_circulation_status
|
61
|
+
#circulation_status.name_will_change!
|
62
|
+
#return unless circulation_status.name_change.first == 'Removed'
|
63
|
+
return unless circulation_status.name == 'Removed'
|
64
|
+
errors[:base] << I18n.t('activerecord.errors.models.item.attributes.circulation_status_id.is_rented') if rented?
|
65
|
+
errors[:base] << I18n.t('activerecord.errors.models.item.attributes.circulation_status_id.is_reserved') if reserved?
|
66
|
+
end
|
67
|
+
|
59
68
|
def checkout_status(user)
|
60
69
|
return nil unless user
|
61
70
|
user.profile.user_group.user_group_has_checkout_types.find_by(checkout_type_id: checkout_type.id)
|
@@ -71,6 +80,10 @@ module EnjuCirculation
|
|
71
80
|
false
|
72
81
|
end
|
73
82
|
|
83
|
+
def rented?
|
84
|
+
rent?
|
85
|
+
end
|
86
|
+
|
74
87
|
def reserved_by_user?(user)
|
75
88
|
if manifestation.next_reservation
|
76
89
|
return true if manifestation.next_reservation.user == user
|
@@ -3,7 +3,8 @@ module EnjuCirculation
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
|
6
|
+
before_create :withdraw!
|
7
|
+
validate :check_item
|
7
8
|
end
|
8
9
|
|
9
10
|
def withdraw!
|
@@ -12,5 +13,10 @@ module EnjuCirculation
|
|
12
13
|
item.use_restriction = UseRestriction.where(name: 'Not For Loan').first
|
13
14
|
item.index!
|
14
15
|
end
|
16
|
+
|
17
|
+
def check_item
|
18
|
+
errors.add(:item_id, :is_rented) if item.try(:rent?)
|
19
|
+
errors.add(:item_id, :is_reserved) if item.try(:reserved?)
|
20
|
+
end
|
15
21
|
end
|
16
22
|
end
|
data/app/models/reserve.rb
CHANGED
@@ -371,7 +371,7 @@ class Reserve < ApplicationRecord
|
|
371
371
|
end
|
372
372
|
|
373
373
|
def manifestation_must_include_item
|
374
|
-
if
|
374
|
+
if manifestation && item && !completed?
|
375
375
|
errors[:base] << I18n.t('reserve.invalid_item') unless manifestation.items.include?(item)
|
376
376
|
end
|
377
377
|
end
|
@@ -24,6 +24,13 @@
|
|
24
24
|
<%= link_to checkout.shelf.display_name.localize, checkout.shelf %>
|
25
25
|
(<%= link_to checkout.shelf.library.display_name.localize, checkout.shelf.library %>)
|
26
26
|
<% end %>
|
27
|
+
<% if checkout.item.manifestation.next_reservation %>
|
28
|
+
<br />
|
29
|
+
(<%= link_to_if(current_user.has_role?('Librarian'),
|
30
|
+
t('page.number_of_reservations',
|
31
|
+
count: Reserve.waiting.where(manifestation_id: checkout.item.manifestation.id, checked_out_at: nil).count),
|
32
|
+
reserves_path(query: "manifestation_id_i:#{checkout.item.manifestation.id}")) -%>)
|
33
|
+
<% end %>
|
27
34
|
</td>
|
28
35
|
<td>
|
29
36
|
<%= l(checkout.due_date, format: :only_date) -%>
|
@@ -125,6 +125,18 @@ en:
|
|
125
125
|
profile:
|
126
126
|
checkout_icalendar_token: Checkout iCalendar token
|
127
127
|
save_checkout_history: Save checkout history
|
128
|
+
errors:
|
129
|
+
models:
|
130
|
+
item:
|
131
|
+
attributes:
|
132
|
+
circulation_status_id:
|
133
|
+
is_rented: Circulation status is invalid. This item is rented.
|
134
|
+
is_reserved: Circulation status is invalid. This item is reserved.
|
135
|
+
withdraw:
|
136
|
+
attributes:
|
137
|
+
item_id:
|
138
|
+
is_rented: is rented.
|
139
|
+
is_reserved: is reserved.
|
128
140
|
|
129
141
|
basket:
|
130
142
|
this_account_is_suspended: "This account is suspended."
|
@@ -123,6 +123,18 @@ ja:
|
|
123
123
|
profile:
|
124
124
|
checkout_icalendar_token: 貸出iCalendarのトークン
|
125
125
|
save_checkout_history: 貸出の履歴を保存する
|
126
|
+
errors:
|
127
|
+
models:
|
128
|
+
item:
|
129
|
+
attributes:
|
130
|
+
circulation_status_id:
|
131
|
+
is_rented: この貸出状態には変更できません。資料が貸し出されています。
|
132
|
+
is_reserved: この貸出状態には変更できません。資料が予約されています。
|
133
|
+
withdraw:
|
134
|
+
attributes:
|
135
|
+
item_id:
|
136
|
+
is_rented: は貸し出されています。
|
137
|
+
is_reserved: は予約されています。
|
126
138
|
|
127
139
|
basket:
|
128
140
|
this_account_is_suspended: "このアカウントは停止されています。"
|
@@ -1,8 +1,8 @@
|
|
1
1
|
class AddNumberOfDayToNotifyOverdueToUserGroup < ActiveRecord::Migration[4.2]
|
2
2
|
def self.up
|
3
|
-
add_column :user_groups, :number_of_day_to_notify_overdue, :integer, default:
|
4
|
-
add_column :user_groups, :number_of_day_to_notify_due_date, :integer, default:
|
5
|
-
add_column :user_groups, :number_of_time_to_notify_overdue, :integer, default:
|
3
|
+
add_column :user_groups, :number_of_day_to_notify_overdue, :integer, default: 0, null: false
|
4
|
+
add_column :user_groups, :number_of_day_to_notify_due_date, :integer, default: 0, null: false
|
5
|
+
add_column :user_groups, :number_of_time_to_notify_overdue, :integer, default: 0, null: false
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.down
|
@@ -32,5 +32,10 @@ ActiveSupport::Inflector.inflections do |inflect|
|
|
32
32
|
inflect.irregular 'reserve', 'reserves'
|
33
33
|
end
|
34
34
|
EOS
|
35
|
+
|
36
|
+
UserGroup.order(created_at: :desc).first.update!(
|
37
|
+
number_of_day_to_notify_overdue: 7,
|
38
|
+
number_of_day_to_notify_due_date: 3
|
39
|
+
)
|
35
40
|
end
|
36
41
|
end
|
@@ -44,6 +44,26 @@ describe ItemsController do
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
describe 'PUT update' do
|
48
|
+
describe 'When logged in as Administrator' do
|
49
|
+
login_fixture_admin
|
50
|
+
|
51
|
+
it 'should remove an item' do
|
52
|
+
item = FactoryBot.create(:item)
|
53
|
+
put :update, params: { id: item.id, item: {circulation_status_id: CirculationStatus.find_by(name: 'Removed').id } }
|
54
|
+
expect(assigns(:item).valid?).to be_truthy
|
55
|
+
expect(response).to redirect_to item_url(assigns(:item))
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should not remove a reserved item' do
|
59
|
+
item = FactoryBot.create(:reserve).item
|
60
|
+
put :update, params: { id: item.id, item: {circulation_status_id: CirculationStatus.find_by(name: 'Removed').id } }
|
61
|
+
expect(assigns(:item).valid?).to be_falsy
|
62
|
+
expect(response).to be_successful
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
47
67
|
describe 'DELETE destroy' do
|
48
68
|
describe 'When logged in as Administrator' do
|
49
69
|
login_fixture_admin
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateCustomProperties < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
create_table :custom_properties do |t|
|
4
|
+
t.integer :resource_id, null: false
|
5
|
+
t.string :resource_type, null: false
|
6
|
+
t.text :label, null: false
|
7
|
+
t.text :value
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
#
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
12
12
|
|
13
|
-
ActiveRecord::Schema.define(version:
|
13
|
+
ActiveRecord::Schema.define(version: 2019_12_19_122214) do
|
14
14
|
|
15
15
|
create_table "accepts", force: :cascade do |t|
|
16
16
|
t.integer "basket_id"
|
@@ -361,6 +361,15 @@ ActiveRecord::Schema.define(version: 2018_01_07_162048) do
|
|
361
361
|
t.index ["work_id"], name: "index_creates_on_work_id"
|
362
362
|
end
|
363
363
|
|
364
|
+
create_table "custom_properties", force: :cascade do |t|
|
365
|
+
t.integer "resource_id", null: false
|
366
|
+
t.string "resource_type", null: false
|
367
|
+
t.text "label", null: false
|
368
|
+
t.text "value"
|
369
|
+
t.datetime "created_at", null: false
|
370
|
+
t.datetime "updated_at", null: false
|
371
|
+
end
|
372
|
+
|
364
373
|
create_table "demands", force: :cascade do |t|
|
365
374
|
t.integer "user_id"
|
366
375
|
t.integer "item_id"
|
@@ -575,6 +584,7 @@ ActiveRecord::Schema.define(version: 2018_01_07_162048) do
|
|
575
584
|
t.string "binding_call_number"
|
576
585
|
t.datetime "binded_at"
|
577
586
|
t.integer "manifestation_id", null: false
|
587
|
+
t.text "memo"
|
578
588
|
t.index ["binding_item_identifier"], name: "index_items_on_binding_item_identifier"
|
579
589
|
t.index ["bookstore_id"], name: "index_items_on_bookstore_id"
|
580
590
|
t.index ["checkout_type_id"], name: "index_items_on_checkout_type_id"
|
@@ -823,6 +833,7 @@ ActiveRecord::Schema.define(version: 2018_01_07_162048) do
|
|
823
833
|
t.text "publication_place"
|
824
834
|
t.text "extent"
|
825
835
|
t.text "dimensions"
|
836
|
+
t.text "memo"
|
826
837
|
t.index ["access_address"], name: "index_manifestations_on_access_address"
|
827
838
|
t.index ["date_of_publication"], name: "index_manifestations_on_date_of_publication"
|
828
839
|
t.index ["manifestation_identifier"], name: "index_manifestations_on_manifestation_identifier"
|
@@ -1343,9 +1354,9 @@ ActiveRecord::Schema.define(version: 2018_01_07_162048) do
|
|
1343
1354
|
t.datetime "deleted_at"
|
1344
1355
|
t.integer "valid_period_for_new_user", default: 0, null: false
|
1345
1356
|
t.datetime "expired_at"
|
1346
|
-
t.integer "number_of_day_to_notify_overdue", default:
|
1347
|
-
t.integer "number_of_day_to_notify_due_date", default:
|
1348
|
-
t.integer "number_of_time_to_notify_overdue", default:
|
1357
|
+
t.integer "number_of_day_to_notify_overdue", default: 0, null: false
|
1358
|
+
t.integer "number_of_day_to_notify_due_date", default: 0, null: false
|
1359
|
+
t.integer "number_of_time_to_notify_overdue", default: 0, null: false
|
1349
1360
|
end
|
1350
1361
|
|
1351
1362
|
create_table "user_has_roles", force: :cascade do |t|
|
data/spec/factories/item.rb
CHANGED
@@ -3,9 +3,9 @@ FactoryBot.define do
|
|
3
3
|
sequence(:item_identifier){|n| "item_#{n}"}
|
4
4
|
circulation_status_id{CirculationStatus.find(1).id}
|
5
5
|
manifestation_id{FactoryBot.create(:manifestation).id}
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
after(:build) do |item|
|
7
|
+
bookstore = Bookstore.find(1)
|
8
|
+
budget_type = BudgetType.find(1)
|
9
9
|
item.use_restriction = UseRestriction.find_by(name: 'Limited Circulation, Normal Loan Period')
|
10
10
|
end
|
11
11
|
end
|
data/spec/factories/reserve.rb
CHANGED
@@ -6,6 +6,10 @@ FactoryBot.define do
|
|
6
6
|
user.profile = profile
|
7
7
|
reserve.user = user
|
8
8
|
end
|
9
|
-
|
9
|
+
after(:build) do |reserve|
|
10
|
+
item = FactoryBot.create(:item, use_restriction: UseRestriction.find_by(name: 'Available On Shelf'))
|
11
|
+
reserve.manifestation = item.manifestation
|
12
|
+
reserve.item = item
|
13
|
+
end
|
10
14
|
end
|
11
15
|
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
---
|
2
|
+
bookstore_00001:
|
3
|
+
name: unknown
|
4
|
+
fax_number:
|
5
|
+
updated_at: 2008-02-10 11:14:57.605329 +09:00
|
6
|
+
telephone_number:
|
7
|
+
id: 1
|
8
|
+
note: ""
|
9
|
+
address: ""
|
10
|
+
created_at: 2008-02-10 11:14:57.605329 +09:00
|
11
|
+
position: 1
|
12
|
+
bookstore_00002:
|
13
|
+
name: !binary |
|
14
|
+
5a+E6LSI
|
15
|
+
|
16
|
+
fax_number: ""
|
17
|
+
updated_at: 2008-02-10 12:15:14.840711 +09:00
|
18
|
+
telephone_number: ""
|
19
|
+
id: 2
|
20
|
+
note: ""
|
21
|
+
address: ""
|
22
|
+
created_at: 2008-02-10 11:16:02.598844 +09:00
|
23
|
+
position: 2
|
24
|
+
bookstore_00003:
|
25
|
+
name: !binary |
|
26
|
+
5pyJ6Zqj5aCC
|
27
|
+
|
28
|
+
fax_number: ""
|
29
|
+
updated_at: 2008-02-10 12:15:33.555463 +09:00
|
30
|
+
telephone_number: ""
|
31
|
+
id: 3
|
32
|
+
note: ""
|
33
|
+
address: ""
|
34
|
+
created_at: 2008-02-10 11:16:11.585284 +09:00
|
35
|
+
position: 3
|
36
|
+
bookstore_00004:
|
37
|
+
name: !binary |
|
38
|
+
57SA5LyK5ZyL5bGL5pu45bqX
|
39
|
+
|
40
|
+
fax_number: ""
|
41
|
+
updated_at: 2008-02-10 12:16:07.726445 +09:00
|
42
|
+
telephone_number: ""
|
43
|
+
id: 4
|
44
|
+
note: ""
|
45
|
+
address: ""
|
46
|
+
created_at: 2008-02-10 11:16:22.565660 +09:00
|
47
|
+
position: 4
|
48
|
+
bookstore_00005:
|
49
|
+
name: !binary |
|
50
|
+
5Li45ZaE
|
51
|
+
|
52
|
+
fax_number: ""
|
53
|
+
updated_at: 2008-02-10 12:16:17.990285 +09:00
|
54
|
+
telephone_number: ""
|
55
|
+
id: 5
|
56
|
+
note: ""
|
57
|
+
address: ""
|
58
|
+
created_at: 2008-02-10 12:15:44.923758 +09:00
|
59
|
+
position: 5
|
60
|
+
bookstore_00006:
|
61
|
+
name: !binary |
|
62
|
+
5Zuz5pu46aSo5rWB6YCa44K744Oz44K/44O8
|
63
|
+
|
64
|
+
fax_number: ""
|
65
|
+
updated_at: 2008-02-10 12:16:25.906073 +09:00
|
66
|
+
telephone_number: ""
|
67
|
+
id: 6
|
68
|
+
note: ""
|
69
|
+
address: ""
|
70
|
+
created_at: 2008-02-10 12:15:54.558517 +09:00
|
71
|
+
position: 6
|
72
|
+
bookstore_00007:
|
73
|
+
name: Example store
|
74
|
+
fax_number: ""
|
75
|
+
updated_at: 2008-02-10 12:16:25.906073 +09:00
|
76
|
+
telephone_number: ""
|
77
|
+
id: 7
|
78
|
+
note: ""
|
79
|
+
address: ""
|
80
|
+
created_at: 2008-02-10 12:15:54.558517 +09:00
|
81
|
+
position: 7
|
82
|
+
|
83
|
+
# == Schema Information
|
84
|
+
#
|
85
|
+
# Table name: bookstores
|
86
|
+
#
|
87
|
+
# id :bigint not null, primary key
|
88
|
+
# name :text not null
|
89
|
+
# zip_code :string
|
90
|
+
# address :text
|
91
|
+
# note :text
|
92
|
+
# telephone_number :string
|
93
|
+
# fax_number :string
|
94
|
+
# url :string
|
95
|
+
# position :integer
|
96
|
+
# created_at :datetime not null
|
97
|
+
# updated_at :datetime not null
|
98
|
+
#
|
99
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
2
|
+
|
3
|
+
public_fund:
|
4
|
+
name: Public fund
|
5
|
+
display_name: {"en": "Public fund"}
|
6
|
+
note:
|
7
|
+
position: 1
|
8
|
+
id: 1
|
9
|
+
|
10
|
+
donation:
|
11
|
+
name: Donation
|
12
|
+
display_name: {"en": "Donation"}
|
13
|
+
note:
|
14
|
+
position: 2
|
15
|
+
id: 2
|
16
|
+
|
17
|
+
# == Schema Information
|
18
|
+
#
|
19
|
+
# Table name: budget_types
|
20
|
+
#
|
21
|
+
# id :bigint not null, primary key
|
22
|
+
# name :string
|
23
|
+
# display_name :text
|
24
|
+
# note :text
|
25
|
+
# position :integer
|
26
|
+
# created_at :datetime not null
|
27
|
+
# updated_at :datetime not null
|
28
|
+
# display_name_translations :jsonb not null
|
29
|
+
#
|
30
|
+
|
@@ -21,11 +21,11 @@ describe Manifestation do
|
|
21
21
|
manifestation = FactoryBot.create(:manifestation)
|
22
22
|
use_restriction = UseRestriction.find(1)
|
23
23
|
item = FactoryBot.create(:item, manifestation: manifestation, use_restriction: use_restriction)
|
24
|
-
lines = Manifestation.export(
|
24
|
+
lines = Manifestation.export(role: "Guest")
|
25
25
|
csv = CSV.parse(lines, headers: true, col_sep: "\t")
|
26
26
|
expect(csv["use_restriction"].compact).to be_empty
|
27
27
|
|
28
|
-
lines = Manifestation.export(
|
28
|
+
lines = Manifestation.export(role: "Administrator")
|
29
29
|
csv = CSV.parse(lines, headers: true, col_sep: "\t")
|
30
30
|
expect(csv["use_restriction"].compact).not_to be_empty
|
31
31
|
end
|
@@ -5,20 +5,22 @@ RSpec.describe Withdraw, type: :model do
|
|
5
5
|
|
6
6
|
it "should change circulation_status" do
|
7
7
|
withdraw = FactoryBot.create(:withdraw)
|
8
|
-
withdraw.item.circulation_status.name.
|
9
|
-
withdraw.item.use_restriction.name.
|
8
|
+
expect(withdraw.item.circulation_status.name).to eq 'Removed'
|
9
|
+
expect(withdraw.item.use_restriction.name).to 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
|
-
withdraw.valid
|
15
|
+
expect(withdraw.valid?).to be_falsy
|
16
|
+
expect(withdraw.errors.messages[:item_id]).to include('is rented.')
|
16
17
|
end
|
17
18
|
|
18
19
|
it "should not withdraw reserved item" do
|
19
20
|
reserve = FactoryBot.create(:reserve)
|
20
21
|
withdraw = FactoryBot.build(:withdraw, item: reserve.manifestation.items.first)
|
21
|
-
withdraw.valid
|
22
|
+
expect(withdraw.valid?).to be_falsy
|
23
|
+
expect(withdraw.errors.messages[:item_id]).to include('is reserved.')
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
@@ -8,8 +8,7 @@ describe ManifestationPolicy do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it "not grants destroy if it is reserved" do
|
11
|
-
record = FactoryBot.create(:manifestation
|
12
|
-
reserve = FactoryBot.create(:reserve, manifestation_id: record.id)
|
11
|
+
record = FactoryBot.create(:reserve).manifestation
|
13
12
|
expect(subject).not_to permit(@admin, record)
|
14
13
|
end
|
15
14
|
end
|
data/spec/rails_helper.rb
CHANGED
@@ -7,7 +7,7 @@ Coveralls.wear!
|
|
7
7
|
ENV["RAILS_ENV"] ||= 'test'
|
8
8
|
require File.expand_path("../dummy/config/environment", __FILE__)
|
9
9
|
require 'rspec/rails'
|
10
|
-
require '
|
10
|
+
require 'factory_bot_rails'
|
11
11
|
require 'rspec/active_model/mocks'
|
12
12
|
require "capybara/rspec"
|
13
13
|
require "pundit/rspec"
|
@@ -44,6 +44,3 @@ RSpec.configure do |config|
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
47
|
-
|
48
|
-
FactoryBot.definition_file_paths << "#{::Rails.root}/../../spec/factories"
|
49
|
-
FactoryBot.find_definitions
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'Checkouts', type: :system do
|
4
|
+
include Devise::Test::IntegrationHelpers
|
5
|
+
fixtures :all
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
CarrierType.find_by(name: 'volume').update(attachment: File.open("#{Rails.root.to_s}/app/assets/images/icons/book.png"))
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'When logged in as Librarian' do
|
12
|
+
it 'should not set "Removed" as circulation status if the item is reserved' do
|
13
|
+
item = FactoryBot.create(:reserve).item
|
14
|
+
sign_in users(:librarian1)
|
15
|
+
visit edit_item_path(item)
|
16
|
+
select('除籍済み', from: 'item_circulation_status_id')
|
17
|
+
click_button('更新する')
|
18
|
+
expect(page).to have_content 'この貸出状態には変更できません。資料が予約されています。'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enju_circulation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kosuke Tanabe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: enju_biblio
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.3.
|
19
|
+
version: 0.3.7
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.3.
|
26
|
+
version: 0.3.7
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: enju_manifestation_viewer
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -61,7 +61,7 @@ dependencies:
|
|
61
61
|
version: '3.11'
|
62
62
|
- - "<"
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: '3.
|
64
|
+
version: '3.27'
|
65
65
|
type: :development
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -71,7 +71,7 @@ dependencies:
|
|
71
71
|
version: '3.11'
|
72
72
|
- - "<"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '3.
|
74
|
+
version: '3.27'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: coveralls
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -282,6 +282,20 @@ dependencies:
|
|
282
282
|
- - "~>"
|
283
283
|
- !ruby/object:Gem::Version
|
284
284
|
version: '5.2'
|
285
|
+
- !ruby/object:Gem::Dependency
|
286
|
+
name: sprockets
|
287
|
+
requirement: !ruby/object:Gem::Requirement
|
288
|
+
requirements:
|
289
|
+
- - "~>"
|
290
|
+
- !ruby/object:Gem::Version
|
291
|
+
version: '3.7'
|
292
|
+
type: :development
|
293
|
+
prerelease: false
|
294
|
+
version_requirements: !ruby/object:Gem::Requirement
|
295
|
+
requirements:
|
296
|
+
- - "~>"
|
297
|
+
- !ruby/object:Gem::Version
|
298
|
+
version: '3.7'
|
285
299
|
description: Circulation management for Next-L Enju
|
286
300
|
email:
|
287
301
|
- nabeta@fastmail.fm
|
@@ -820,6 +834,9 @@ files:
|
|
820
834
|
- spec/dummy/db/migrate/20180107161331_add_constraints_to_most_recent_for_resource_import_file_transitions.rb
|
821
835
|
- spec/dummy/db/migrate/20180107161347_add_constraints_to_most_recent_for_resource_export_file_transitions.rb
|
822
836
|
- spec/dummy/db/migrate/20180107161410_add_constraints_to_most_recent_for_import_request_transitions.rb
|
837
|
+
- spec/dummy/db/migrate/20190818075603_add_memo_to_manifestation.rb
|
838
|
+
- spec/dummy/db/migrate/20190818075628_add_memo_to_item.rb
|
839
|
+
- spec/dummy/db/migrate/20191219122214_create_custom_properties.rb
|
823
840
|
- spec/dummy/db/schema.rb
|
824
841
|
- spec/dummy/public/404.html
|
825
842
|
- spec/dummy/public/422.html
|
@@ -858,6 +875,8 @@ files:
|
|
858
875
|
- spec/fixtures/agent_types.yml
|
859
876
|
- spec/fixtures/agents.yml
|
860
877
|
- spec/fixtures/baskets.yml
|
878
|
+
- spec/fixtures/bookstores.yml
|
879
|
+
- spec/fixtures/budget_types.yml
|
861
880
|
- spec/fixtures/carrier_type_has_checkout_types.yml
|
862
881
|
- spec/fixtures/carrier_types.yml
|
863
882
|
- spec/fixtures/checked_items.yml
|
@@ -934,6 +953,7 @@ files:
|
|
934
953
|
- spec/support/devise.rb
|
935
954
|
- spec/support/tasks.rb
|
936
955
|
- spec/system/checkouts_spec.rb
|
956
|
+
- spec/system/items_spec.rb
|
937
957
|
- spec/system/manifestations_spec.rb
|
938
958
|
- spec/system/reserves_spec.rb
|
939
959
|
- spec/system/user_group_has_checkout_types.rb
|
@@ -1127,6 +1147,7 @@ test_files:
|
|
1127
1147
|
- spec/dummy/db/migrate/20160627232219_add_most_recent_to_user_import_file_transitions.rb
|
1128
1148
|
- spec/dummy/db/migrate/20100129142347_create_import_requests.rb
|
1129
1149
|
- spec/dummy/db/migrate/125_create_donates.rb
|
1150
|
+
- spec/dummy/db/migrate/20190818075628_add_memo_to_item.rb
|
1130
1151
|
- spec/dummy/db/migrate/20120129020544_add_budget_type_id_to_item.rb
|
1131
1152
|
- spec/dummy/db/migrate/20180107161331_add_constraints_to_most_recent_for_resource_import_file_transitions.rb
|
1132
1153
|
- spec/dummy/db/migrate/20081028083142_create_agent_import_files.rb
|
@@ -1174,6 +1195,7 @@ test_files:
|
|
1174
1195
|
- spec/dummy/db/migrate/20160801080643_add_most_recent_to_agent_import_file_transitions.rb
|
1175
1196
|
- spec/dummy/db/migrate/20130421155019_add_creator_string_to_series_statement.rb
|
1176
1197
|
- spec/dummy/db/migrate/20100814091104_add_position_to_agent_relationship.rb
|
1198
|
+
- spec/dummy/db/migrate/20191219122214_create_custom_properties.rb
|
1177
1199
|
- spec/dummy/db/migrate/117_create_form_of_works.rb
|
1178
1200
|
- spec/dummy/db/migrate/20080819181903_create_message_requests.rb
|
1179
1201
|
- spec/dummy/db/migrate/20130506175834_create_identifiers.rb
|
@@ -1203,6 +1225,7 @@ test_files:
|
|
1203
1225
|
- spec/dummy/db/migrate/20160811102604_add_picture_width_to_picture_file.rb
|
1204
1226
|
- spec/dummy/db/migrate/20130429020822_add_root_manifestation_id_to_series_statement.rb
|
1205
1227
|
- spec/dummy/db/migrate/20090705133942_add_attachments_picture_to_picture_file.rb
|
1228
|
+
- spec/dummy/db/migrate/20190818075603_add_memo_to_manifestation.rb
|
1206
1229
|
- spec/dummy/db/migrate/20110222073537_add_url_to_library_group.rb
|
1207
1230
|
- spec/dummy/db/migrate/20120511072422_add_agent_identifier_to_agent.rb
|
1208
1231
|
- spec/dummy/db/migrate/20110301121550_add_birth_date_and_death_date_to_agent.rb
|
@@ -1249,6 +1272,7 @@ test_files:
|
|
1249
1272
|
- spec/system/manifestations_spec.rb
|
1250
1273
|
- spec/system/checkouts_spec.rb
|
1251
1274
|
- spec/system/reserves_spec.rb
|
1275
|
+
- spec/system/items_spec.rb
|
1252
1276
|
- spec/support/controller_macros.rb
|
1253
1277
|
- spec/support/devise.rb
|
1254
1278
|
- spec/support/tasks.rb
|
@@ -1295,9 +1319,11 @@ test_files:
|
|
1295
1319
|
- spec/fixtures/users.yml
|
1296
1320
|
- spec/fixtures/accepts.yml
|
1297
1321
|
- spec/fixtures/circulation_statuses.yml
|
1322
|
+
- spec/fixtures/budget_types.yml
|
1298
1323
|
- spec/fixtures/user_reserve_stats.yml
|
1299
1324
|
- spec/fixtures/manifestations.yml
|
1300
1325
|
- spec/fixtures/request_types.yml
|
1326
|
+
- spec/fixtures/bookstores.yml
|
1301
1327
|
- spec/fixtures/checkins.yml
|
1302
1328
|
- spec/fixtures/user_checkout_stats.yml
|
1303
1329
|
- spec/fixtures/item_has_use_restrictions.yml
|