enju_circulation 0.0.37 → 0.0.38
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.
- data/app/controllers/reserves_controller.rb +0 -1
- data/app/models/item_has_use_restriction.rb +4 -3
- data/lib/enju_circulation/version.rb +1 -1
- data/spec/dummy/app/models/basket.rb +5 -6
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/fixtures/languages.yml +4 -4
- data/spec/fixtures/lending_policies.yml +18 -9
- data/spec/models/basket_spec.rb +39 -0
- data/spec/models/user_group_has_checkout_type_spec.rb +2 -2
- metadata +3 -1
@@ -109,7 +109,6 @@ class ReservesController < ApplicationController
|
|
109
109
|
@reserve.sm_request!
|
110
110
|
@reserve.send_message
|
111
111
|
|
112
|
-
#format.html { redirect_to reserve_url(@reserve) }
|
113
112
|
format.html { redirect_to @reserve, :notice => t('controller.successfully_created', :model => t('activerecord.models.reserve')) }
|
114
113
|
format.json { render :json => @reserve, :status => :created, :location => reserve_url(@reserve) }
|
115
114
|
else
|
@@ -1,13 +1,14 @@
|
|
1
1
|
class ItemHasUseRestriction < ActiveRecord::Base
|
2
2
|
belongs_to :item, :validate => true
|
3
3
|
belongs_to :use_restriction, :validate => true
|
4
|
+
accepts_nested_attributes_for :use_restriction
|
5
|
+
|
6
|
+
validates_associated :item, :use_restriction
|
7
|
+
validates_presence_of :item, :use_restriction
|
4
8
|
|
5
9
|
def self.per_page
|
6
10
|
10
|
7
11
|
end
|
8
|
-
|
9
|
-
validates_associated :item, :use_restriction
|
10
|
-
validates_presence_of :item, :use_restriction
|
11
12
|
end
|
12
13
|
|
13
14
|
# == Schema Information
|
@@ -32,15 +32,14 @@ class Basket < ActiveRecord::Base
|
|
32
32
|
has_many :checkins
|
33
33
|
|
34
34
|
def basket_checkout(librarian)
|
35
|
-
return nil if
|
35
|
+
return nil if checked_items.size == 0
|
36
36
|
Item.transaction do
|
37
37
|
self.checked_items.each do |checked_item|
|
38
|
-
checkout = self.user.checkouts.new(:librarian_id => librarian.id, :item_id => checked_item.item.id, :basket_id =>
|
39
|
-
|
40
|
-
|
41
|
-
end
|
38
|
+
checkout = self.user.checkouts.new(:librarian_id => librarian.id, :item_id => checked_item.item.id, :basket_id => id, :due_date => checked_item.due_date)
|
39
|
+
checked_item.item.checkout!(user)
|
40
|
+
checkout.save!
|
42
41
|
end
|
43
|
-
CheckedItem.destroy_all(:basket_id =>
|
42
|
+
CheckedItem.destroy_all(:basket_id => id)
|
44
43
|
end
|
45
44
|
end
|
46
45
|
end
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
data/spec/fixtures/languages.yml
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
language_00001:
|
3
3
|
position: 1
|
4
4
|
name: unknown
|
5
|
-
display_name: "en:unknown\r\n\
|
6
|
-
ja
|
5
|
+
display_name: "en: unknown\r\n\
|
6
|
+
ja: 不明"
|
7
7
|
iso_639_1: unknown
|
8
8
|
iso_639_2: unknown
|
9
9
|
iso_639_3: unknown
|
@@ -1355,8 +1355,8 @@ language_00160:
|
|
1355
1355
|
language_00077:
|
1356
1356
|
position: 77
|
1357
1357
|
name: Japanese
|
1358
|
-
display_name: "en:Japanese\r\n\
|
1359
|
-
ja
|
1358
|
+
display_name: "en: Japanese\r\n\
|
1359
|
+
ja: 日本語"
|
1360
1360
|
iso_639_1: ja
|
1361
1361
|
iso_639_2: jpn
|
1362
1362
|
iso_639_3: jpn
|
@@ -6,7 +6,7 @@ lending_policy_00001:
|
|
6
6
|
loan_period: 1
|
7
7
|
fixed_due_date:
|
8
8
|
renewal: 1
|
9
|
-
fine:
|
9
|
+
fine: 10
|
10
10
|
note: MyText
|
11
11
|
position: 1
|
12
12
|
lending_policy_00002:
|
@@ -15,7 +15,7 @@ lending_policy_00002:
|
|
15
15
|
loan_period: 1
|
16
16
|
fixed_due_date:
|
17
17
|
renewal: 1
|
18
|
-
fine:
|
18
|
+
fine: 10
|
19
19
|
note: MyText
|
20
20
|
position: 2
|
21
21
|
lending_policy_00003:
|
@@ -24,7 +24,7 @@ lending_policy_00003:
|
|
24
24
|
loan_period: 1
|
25
25
|
fixed_due_date:
|
26
26
|
renewal: 1
|
27
|
-
fine:
|
27
|
+
fine: 10
|
28
28
|
note: MyText
|
29
29
|
position: 1
|
30
30
|
lending_policy_00004:
|
@@ -33,7 +33,7 @@ lending_policy_00004:
|
|
33
33
|
loan_period: 1
|
34
34
|
fixed_due_date:
|
35
35
|
renewal: 1
|
36
|
-
fine:
|
36
|
+
fine: 10
|
37
37
|
note: MyText
|
38
38
|
position: 1
|
39
39
|
lending_policy_00005:
|
@@ -42,7 +42,7 @@ lending_policy_00005:
|
|
42
42
|
loan_period: 1
|
43
43
|
fixed_due_date:
|
44
44
|
renewal: 1
|
45
|
-
fine:
|
45
|
+
fine: 10
|
46
46
|
note: MyText
|
47
47
|
position: 1
|
48
48
|
lending_policy_00006:
|
@@ -51,7 +51,9 @@ lending_policy_00006:
|
|
51
51
|
loan_period: 1
|
52
52
|
fixed_due_date:
|
53
53
|
renewal: 1
|
54
|
-
fine:
|
54
|
+
fine: 10
|
55
|
+
note: MyText
|
56
|
+
position: 1
|
55
57
|
note: MyText
|
56
58
|
position: 1
|
57
59
|
lending_policy_00007:
|
@@ -60,9 +62,16 @@ lending_policy_00007:
|
|
60
62
|
loan_period: 1
|
61
63
|
fixed_due_date:
|
62
64
|
renewal: 1
|
63
|
-
fine:
|
65
|
+
fine: 10
|
64
66
|
note: MyText
|
65
67
|
position: 1
|
68
|
+
lending_policy_00008:
|
69
|
+
item_id: 11
|
70
|
+
user_group_id: 2
|
71
|
+
loan_period: 1
|
72
|
+
fixed_due_date:
|
73
|
+
renewal: 1
|
74
|
+
fine: 10
|
66
75
|
|
67
76
|
# == Schema Information
|
68
77
|
#
|
@@ -77,7 +86,7 @@ lending_policy_00007:
|
|
77
86
|
# fine :decimal(, ) default(0.0), not null
|
78
87
|
# note :text
|
79
88
|
# position :integer
|
80
|
-
# created_at :datetime
|
81
|
-
# updated_at :datetime
|
89
|
+
# created_at :datetime not null
|
90
|
+
# updated_at :datetime not null
|
82
91
|
#
|
83
92
|
|
@@ -0,0 +1,39 @@
|
|
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
|
+
|
@@ -6,8 +6,8 @@ describe UserGroupHasCheckoutType do
|
|
6
6
|
|
7
7
|
it "should create lending_policy" do
|
8
8
|
old_count = LendingPolicy.count
|
9
|
-
user_group_has_checkout_types(:
|
10
|
-
user_group_has_checkout_types(:
|
9
|
+
user_group_has_checkout_types(:user_group_has_checkout_type_00004).create_lending_policy
|
10
|
+
user_group_has_checkout_types(:user_group_has_checkout_type_00004).checkout_type.items.count.should eq old_count
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should update lending_policy" do
|
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.38
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -713,6 +713,7 @@ 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
|
716
717
|
- spec/models/carrier_type_has_checkout_type_spec.rb
|
717
718
|
- spec/models/checked_item_spec.rb
|
718
719
|
- spec/models/checkin_spec.rb
|
@@ -943,6 +944,7 @@ test_files:
|
|
943
944
|
- spec/fixtures/user_has_roles.yml
|
944
945
|
- spec/fixtures/user_reserve_stats.yml
|
945
946
|
- spec/fixtures/users.yml
|
947
|
+
- spec/models/basket_spec.rb
|
946
948
|
- spec/models/carrier_type_has_checkout_type_spec.rb
|
947
949
|
- spec/models/checked_item_spec.rb
|
948
950
|
- spec/models/checkin_spec.rb
|