enju_circulation 0.0.40 → 0.0.41
Sign up to get free protection for your applications and to get access to all the features.
- data/config/locales/translation_en.yml +1 -1
- data/config/locales/translation_ja.yml +1 -1
- data/lib/enju_circulation/version.rb +1 -1
- data/spec/controllers/checkouts_controller_spec.rb +13 -13
- data/spec/dummy/app/models/ability.rb +12 -3
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/fixtures/checkouts.yml +24 -0
- metadata +1 -3
- data/spec/models/basket_spec.rb +0 -39
@@ -142,7 +142,7 @@ en:
|
|
142
142
|
extend: "Extend"
|
143
143
|
returned: "Returned"
|
144
144
|
my_checkout: "My checkout"
|
145
|
-
|
145
|
+
remove_all_history: "Remove all checkout history"
|
146
146
|
checkin:
|
147
147
|
item_not_found: "Item not found."
|
148
148
|
enter_item_identifier: "Enter item identifier."
|
@@ -411,6 +411,7 @@ describe CheckoutsController do
|
|
411
411
|
describe "DELETE destroy" do
|
412
412
|
before(:each) do
|
413
413
|
@checkout = checkouts(:checkout_00003)
|
414
|
+
@returned_checkout = checkouts(:checkout_00012)
|
414
415
|
end
|
415
416
|
|
416
417
|
describe "When logged in as Administrator" do
|
@@ -420,16 +421,16 @@ describe CheckoutsController do
|
|
420
421
|
delete :destroy, :id => @checkout.id
|
421
422
|
end
|
422
423
|
|
423
|
-
it "
|
424
|
+
it "should not destroy the checkout that is not checked in" do
|
424
425
|
delete :destroy, :id => @checkout.id
|
425
|
-
response.should
|
426
|
+
response.should be_forbidden
|
426
427
|
end
|
427
428
|
|
428
|
-
it "
|
429
|
-
delete :destroy, :id =>
|
430
|
-
response.should redirect_to
|
429
|
+
it "redirects to the checkouts list" do
|
430
|
+
delete :destroy, :id => @returned_checkout.id
|
431
|
+
response.should redirect_to(user_checkouts_url(@returned_checkout.user))
|
431
432
|
end
|
432
|
-
|
433
|
+
|
433
434
|
it "should not destroy missing checkout" do
|
434
435
|
delete :destroy, :id => 'missing'
|
435
436
|
response.should be_missing
|
@@ -443,15 +444,14 @@ describe CheckoutsController do
|
|
443
444
|
delete :destroy, :id => @checkout.id
|
444
445
|
end
|
445
446
|
|
446
|
-
it "
|
447
|
+
it "should not destroy the checkout that is not checked in" do
|
447
448
|
delete :destroy, :id => @checkout.id
|
448
|
-
response.should
|
449
|
+
response.should be_forbidden
|
449
450
|
end
|
450
451
|
|
451
|
-
it "
|
452
|
-
|
453
|
-
|
454
|
-
response.should redirect_to user_checkouts_url(user)
|
452
|
+
it "redirects to the checkouts list" do
|
453
|
+
delete :destroy, :id => @returned_checkout.id
|
454
|
+
response.should redirect_to(user_checkouts_url(@returned_checkout.user))
|
455
455
|
end
|
456
456
|
end
|
457
457
|
|
@@ -468,7 +468,7 @@ describe CheckoutsController do
|
|
468
468
|
end
|
469
469
|
|
470
470
|
it "should destroy my checkout" do
|
471
|
-
delete :destroy, :id =>
|
471
|
+
delete :destroy, :id => 13
|
472
472
|
response.should redirect_to user_checkouts_url(users(:user1))
|
473
473
|
end
|
474
474
|
end
|
@@ -9,7 +9,6 @@ class Ability
|
|
9
9
|
CarrierTypeHasCheckoutType,
|
10
10
|
CheckedItem,
|
11
11
|
Checkin,
|
12
|
-
Checkout,
|
13
12
|
CheckoutStatHasManifestation,
|
14
13
|
CheckoutStatHasUser,
|
15
14
|
CheckoutType,
|
@@ -23,6 +22,10 @@ class Ability
|
|
23
22
|
UserGroupHasCheckoutType,
|
24
23
|
UserReserveStat
|
25
24
|
]
|
25
|
+
can [:read, :create, :update, :remove_all], Checkout
|
26
|
+
can :destroy, Checkout do |checkout|
|
27
|
+
checkout.checkin
|
28
|
+
end
|
26
29
|
can [:read, :update], [
|
27
30
|
CirculationStatus,
|
28
31
|
LendingPolicy,
|
@@ -42,11 +45,14 @@ class Ability
|
|
42
45
|
Basket,
|
43
46
|
CheckedItem,
|
44
47
|
Checkin,
|
45
|
-
Checkout,
|
46
48
|
ManifestationCheckoutStat,
|
47
49
|
ManifestationReserveStat,
|
48
50
|
Reserve
|
49
51
|
]
|
52
|
+
can [:read, :create, :update, :remove_all], Checkout
|
53
|
+
can :destroy, Checkout do |checkout|
|
54
|
+
checkout.checkin
|
55
|
+
end
|
50
56
|
can [:read, :create, :update], UserCheckoutStat
|
51
57
|
can [:read, :create, :update], UserReserveStat
|
52
58
|
can :read, [
|
@@ -72,9 +78,12 @@ class Ability
|
|
72
78
|
end
|
73
79
|
when 'User'
|
74
80
|
can [:index, :create, :remove_all], Checkout
|
75
|
-
can [:show, :update
|
81
|
+
can [:show, :update], Checkout do |checkout|
|
76
82
|
checkout.user == user
|
77
83
|
end
|
84
|
+
can :destroy, Checkout do |checkout|
|
85
|
+
checkout.user == user && checkout.checkin
|
86
|
+
end
|
78
87
|
can :index, Reserve
|
79
88
|
can :create, Reserve do |reserve|
|
80
89
|
user.user_number.present?
|
Binary file
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
data/spec/fixtures/checkouts.yml
CHANGED
@@ -119,6 +119,30 @@ checkout_00011:
|
|
119
119
|
due_date: <%= 180.days.ago.beginning_of_day %>
|
120
120
|
created_at: 2007-09-08 01:39:03.210081 +09:00
|
121
121
|
basket_id: 7
|
122
|
+
checkout_00012:
|
123
|
+
item_id: 6
|
124
|
+
updated_at: 2007-09-09 21:15:11.648996 +09:00
|
125
|
+
lock_version: 0
|
126
|
+
user_id: 3
|
127
|
+
id: 12
|
128
|
+
librarian_id: 1
|
129
|
+
checkout_renewal_count: 1
|
130
|
+
due_date: <%= 180.days.ago.beginning_of_day %>
|
131
|
+
created_at: 2007-09-08 01:39:03.210081 +09:00
|
132
|
+
basket_id: 8
|
133
|
+
checkin_id: 5
|
134
|
+
checkout_00013:
|
135
|
+
item_id: 7
|
136
|
+
updated_at: 2007-09-09 21:15:11.648996 +09:00
|
137
|
+
lock_version: 0
|
138
|
+
user_id: 3
|
139
|
+
id: 13
|
140
|
+
librarian_id: 1
|
141
|
+
checkout_renewal_count: 1
|
142
|
+
due_date: <%= 180.days.ago.beginning_of_day %>
|
143
|
+
created_at: 2007-09-08 01:39:03.210081 +09:00
|
144
|
+
basket_id: 8
|
145
|
+
checkin_id: 4
|
122
146
|
|
123
147
|
# == Schema Information
|
124
148
|
#
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enju_circulation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.41
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -713,7 +713,6 @@ files:
|
|
713
713
|
- spec/fixtures/user_has_roles.yml
|
714
714
|
- spec/fixtures/user_reserve_stats.yml
|
715
715
|
- spec/fixtures/users.yml
|
716
|
-
- spec/models/basket_spec.rb
|
717
716
|
- spec/models/carrier_type_has_checkout_type_spec.rb
|
718
717
|
- spec/models/checked_item_spec.rb
|
719
718
|
- spec/models/checkin_spec.rb
|
@@ -944,7 +943,6 @@ test_files:
|
|
944
943
|
- spec/fixtures/user_has_roles.yml
|
945
944
|
- spec/fixtures/user_reserve_stats.yml
|
946
945
|
- spec/fixtures/users.yml
|
947
|
-
- spec/models/basket_spec.rb
|
948
946
|
- spec/models/carrier_type_has_checkout_type_spec.rb
|
949
947
|
- spec/models/checked_item_spec.rb
|
950
948
|
- spec/models/checkin_spec.rb
|
data/spec/models/basket_spec.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Basket do
|
5
|
-
fixtures :all
|
6
|
-
|
7
|
-
it "should not create basket when user is not active" do
|
8
|
-
Basket.create(:user => users(:user4)).id.should be_nil
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should not check out items that are already checked out" do
|
12
|
-
items(:item_00021).checkouts.count.should eq 0
|
13
|
-
basket_1 = Basket.create(:user => users(:admin))
|
14
|
-
checked_item_1 = basket_1.checked_items.new
|
15
|
-
checked_item_1.item = items(:item_00011)
|
16
|
-
checked_item_1.save
|
17
|
-
basket_2 = Basket.create(:user => users(:user1))
|
18
|
-
checked_item_2 = basket_2.checked_items.new
|
19
|
-
checked_item_2.item = items(:item_00011)
|
20
|
-
checked_item_2.save
|
21
|
-
basket_1.basket_checkout(users(:librarian1))
|
22
|
-
lambda{basket_2.basket_checkout(users(:librarian1))}.should raise_exception ActiveRecord::RecordInvalid
|
23
|
-
items(:item_00011).checkouts.first.user.should eq users(:admin)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# == Schema Information
|
28
|
-
#
|
29
|
-
# Table name: baskets
|
30
|
-
#
|
31
|
-
# id :integer not null, primary key
|
32
|
-
# user_id :integer
|
33
|
-
# note :text
|
34
|
-
# type :string(255)
|
35
|
-
# lock_version :integer default(0), not null
|
36
|
-
# created_at :datetime
|
37
|
-
# updated_at :datetime
|
38
|
-
#
|
39
|
-
|