enju_circulation 0.1.0.pre30 → 0.1.0.pre31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/checked_items_controller.rb +5 -4
- data/app/controllers/checkins_controller.rb +5 -1
- data/app/models/checked_item.rb +3 -6
- data/app/views/checked_items/_list.html.erb +7 -2
- data/app/views/checkins/_checkin.html.erb +1 -1
- data/app/views/checkouts/show.html.erb +1 -1
- data/config/locales/translation_en.yml +1 -0
- data/config/locales/translation_ja.yml +1 -0
- data/lib/enju_circulation/item.rb +12 -0
- data/lib/enju_circulation/version.rb +1 -1
- data/spec/dummy/db/migrate/059_create_libraries.rb +0 -2
- data/spec/dummy/db/schema.rb +0 -3
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/solr/data/test/index/{_2hv.fdt → _3ed.fdt} +0 -0
- data/spec/dummy/solr/data/test/index/{_2hv.fdx → _3ed.fdx} +0 -0
- data/spec/dummy/solr/data/test/index/{_2hv.fnm → _3ed.fnm} +0 -0
- data/spec/dummy/solr/data/test/index/{_2hv.frq → _3ed.frq} +0 -0
- data/spec/dummy/solr/data/test/index/{_2hv.nrm → _3ed.nrm} +0 -0
- data/spec/dummy/solr/data/test/index/{_2hv.prx → _3ed.prx} +0 -0
- data/spec/dummy/solr/data/test/index/{_2hv.tii → _3ed.tii} +0 -0
- data/spec/dummy/solr/data/test/index/{_2hv.tis → _3ed.tis} +0 -0
- data/spec/dummy/solr/data/test/index/segments.gen +0 -0
- data/spec/dummy/solr/data/test/index/{segments_4zj → segments_6sj} +0 -0
- data/spec/fixtures/libraries.yml +0 -6
- data/spec/models/reserve_spec.rb +8 -6
- metadata +28 -39
- data/app/controllers/baskets_controller.rb +0 -109
- data/app/views/baskets/edit.html.erb +0 -30
- data/app/views/baskets/index.html.erb +0 -31
- data/app/views/baskets/new.html.erb +0 -29
- data/app/views/baskets/show.html.erb +0 -23
- data/spec/controllers/baskets_controller_spec.rb +0 -379
- data/spec/dummy/app/controllers/baskets_controller.rb +0 -103
- data/spec/routing/baskets_routing_spec.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dedd68808f1e7f2e922af5529be97237a6aeefe2
|
4
|
+
data.tar.gz: f4d2cb455f03830eb8059167a47762ecde58af11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74e721f2f556d8cd3d760bf45defb81504693e1b99cf636c6d5355969513985f0bb8e44bc7bf8402d02fa12fcd261a1b47fbdcce9429ddb1d09f3820ebb2849d
|
7
|
+
data.tar.gz: 8fd577120312b000da5151c4120e18ddce9180060be9191660a3e9e3ee87eee81ee44014ace44c29afac6995eafd64e7055b53553f82cfb566353d2c61092afc
|
@@ -6,10 +6,11 @@ class CheckedItemsController < ApplicationController
|
|
6
6
|
# GET /checked_items.json
|
7
7
|
def index
|
8
8
|
if @basket
|
9
|
-
@checked_items = @basket.checked_items.page(params[:page])
|
9
|
+
@checked_items = @basket.checked_items.order('created_at DESC').page(params[:page])
|
10
10
|
else
|
11
|
-
@checked_items = CheckedItem.page(params[:page])
|
11
|
+
@checked_items = CheckedItem.order('created_at DESC').page(params[:page])
|
12
12
|
end
|
13
|
+
@checked_item = CheckedItem.new
|
13
14
|
|
14
15
|
respond_to do |format|
|
15
16
|
format.html # index.html.erb
|
@@ -35,7 +36,7 @@ class CheckedItemsController < ApplicationController
|
|
35
36
|
return
|
36
37
|
end
|
37
38
|
@checked_item = CheckedItem.new
|
38
|
-
@checked_items =
|
39
|
+
@checked_items = @basket.checked_items
|
39
40
|
|
40
41
|
respond_to do |format|
|
41
42
|
format.html # new.html.erb
|
@@ -67,7 +68,7 @@ class CheckedItemsController < ApplicationController
|
|
67
68
|
format.json { render :json => @checked_item, :status => :created, :location => @checked_item }
|
68
69
|
format.js { redirect_to(basket_checked_items_url(@basket, :format => :js)) }
|
69
70
|
else
|
70
|
-
@checked_items = @basket.checked_items
|
71
|
+
@checked_items = @basket.checked_items.order('created_at DESC').page(1)
|
71
72
|
format.html { render :action => "index" }
|
72
73
|
format.json { render :json => @checked_item.errors, :status => :unprocessable_entity }
|
73
74
|
format.js { render :action => "index" }
|
@@ -69,8 +69,12 @@ class CheckinsController < ApplicationController
|
|
69
69
|
|
70
70
|
respond_to do |format|
|
71
71
|
if @checkin.save
|
72
|
-
flash[:message] << t('checkin.successfully_checked_in', :model => t('activerecord.models.checkin'))
|
73
72
|
message = @checkin.item_checkin(current_user)
|
73
|
+
if @checkin.checkout
|
74
|
+
flash[:message] << t('checkin.successfully_checked_in')
|
75
|
+
else
|
76
|
+
flash[:message] << t('checkin.not_checked_out')
|
77
|
+
end
|
74
78
|
flash[:message] << message if message
|
75
79
|
format.html { redirect_to basket_checkins_url(@checkin.basket) }
|
76
80
|
format.json { render :json => @checkin, :status => :created, :location => @checkin }
|
data/app/models/checked_item.rb
CHANGED
@@ -60,12 +60,9 @@ class CheckedItem < ActiveRecord::Base
|
|
60
60
|
end
|
61
61
|
|
62
62
|
checkout_count = basket.user.checked_item_count
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
errors[:base] << I18n.t('activerecord.errors.messages.checked_item.excessed_checkout_limit')
|
67
|
-
break
|
68
|
-
end
|
63
|
+
checkout_type = item_checkout_type.checkout_type
|
64
|
+
if checkout_count[:"#{checkout_type.name}"] >= item_checkout_type.checkout_limit
|
65
|
+
errors[:base] << I18n.t('activerecord.errors.messages.checked_item.excessed_checkout_limit')
|
69
66
|
end
|
70
67
|
|
71
68
|
if errors[:base].empty?
|
@@ -7,12 +7,17 @@
|
|
7
7
|
<%= f.label :item_identifier, t('activerecord.attributes.item.item_identifier') -%>: <%= f.search_field :item_identifier -%>
|
8
8
|
<%= f.submit t('page.read'), 'data-disable-with' => t('page.saving') -%><br />
|
9
9
|
<%= f.label :due_date %>
|
10
|
-
<%= f.text_field :due_date_string, :class => '
|
10
|
+
<%= f.text_field :due_date_string, :class => 'datepicker' %>
|
11
11
|
<%= t('checked_item.ignore_restriction') -%>: <%= f.check_box :ignore_restriction -%>
|
12
12
|
</p>
|
13
13
|
<%- end -%>
|
14
14
|
|
15
|
-
|
15
|
+
<script type="text/javascript">
|
16
|
+
$(document).ready(function(){
|
17
|
+
$('.datepicker').datepicker({dateFormat: 'yy-mm-dd'});
|
18
|
+
$('#checked_item_item_identifier').focus().select();
|
19
|
+
});
|
20
|
+
</script>
|
16
21
|
</div>
|
17
22
|
|
18
23
|
<%= render 'checked_item' %>
|
@@ -9,7 +9,7 @@
|
|
9
9
|
<%- @checkins.each_with_index do |checkin, i| -%>
|
10
10
|
<tr class="line<%= cycle("0", "1") -%>">
|
11
11
|
<td>
|
12
|
-
<%= render 'manifestations/show_index', :manifestation => checkin.item.manifestation -%>
|
12
|
+
<%= render 'manifestations/show_index', :manifestation => checkin.item.manifestation if checkin.item.manifestation -%>
|
13
13
|
</td>
|
14
14
|
<td>
|
15
15
|
<%= link_to checkin.item.item_identifier, checkin.item -%>
|
@@ -12,7 +12,7 @@
|
|
12
12
|
<strong><%= t('activerecord.attributes.checkout.due_date') -%></strong><br />
|
13
13
|
<%= l(@checkout.due_date, :format => :only_date) if @checkout.due_date -%>
|
14
14
|
</p>
|
15
|
-
<%- if can? :
|
15
|
+
<%- if can? :update, @checkout -%>
|
16
16
|
<p>
|
17
17
|
<strong><%= t('checkout.current_user') -%></strong><br />
|
18
18
|
<%= link_to @checkout.user_username, @checkout.user if @checkout.user -%>
|
@@ -160,6 +160,7 @@ en:
|
|
160
160
|
checkin: "Checkin!"
|
161
161
|
successfully_checked_in: "This items was successfully checked in."
|
162
162
|
missing_item_found: "A missing item is found."
|
163
|
+
not_checked_out: "This item is not checked out."
|
163
164
|
reserve:
|
164
165
|
user_reserve: "%{login_name}'s reservations"
|
165
166
|
library_group_reserve: "Reservations in %{library_group_name}"
|
@@ -158,6 +158,7 @@ ja:
|
|
158
158
|
checkin: "返却(取り消しはできません)"
|
159
159
|
successfully_checked_in: "この資料は正常に返却されました。"
|
160
160
|
missing_item_found: "行方不明だった資料が見つかりました。"
|
161
|
+
not_checked_out: "この資料は未貸出の資料です。"
|
161
162
|
reserve:
|
162
163
|
user_reserve: "%{login_name} さんの予約資料"
|
163
164
|
library_group_reserve: "%{library_group_name} での予約資料"
|
@@ -114,6 +114,14 @@ module EnjuCirculation
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
+
def retained?
|
118
|
+
if manifestation.next_reservation.try(:state) == 'retained' and manifestation.next_reservation.item == self
|
119
|
+
return true
|
120
|
+
else
|
121
|
+
false
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
117
125
|
def lending_rule(user)
|
118
126
|
lending_policies.where(:user_group_id => user.user_group.id).first
|
119
127
|
end
|
@@ -139,6 +147,10 @@ module EnjuCirculation
|
|
139
147
|
def next_reservation
|
140
148
|
Reserve.waiting.where(:item_id => id).first
|
141
149
|
end
|
150
|
+
|
151
|
+
def latest_checkout
|
152
|
+
checkouts.order('checkouts.id').first
|
153
|
+
end
|
142
154
|
end
|
143
155
|
end
|
144
156
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
class CreateLibraries < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
3
|
create_table :libraries do |t|
|
4
|
-
t.references :agent, :polymorphic => true
|
5
4
|
t.string :name, :null => false
|
6
5
|
t.text :display_name
|
7
6
|
t.string :short_display_name, :null => false
|
@@ -23,7 +22,6 @@ class CreateLibraries < ActiveRecord::Migration
|
|
23
22
|
t.timestamps
|
24
23
|
t.datetime :deleted_at
|
25
24
|
end
|
26
|
-
add_index :libraries, :agent_id, :unique => true
|
27
25
|
add_index :libraries, :library_group_id
|
28
26
|
add_index :libraries, :name, :unique => true
|
29
27
|
end
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -412,8 +412,6 @@ ActiveRecord::Schema.define(:version => 20130519065837) do
|
|
412
412
|
add_index "lending_policies", ["item_id", "user_group_id"], :name => "index_lending_policies_on_item_id_and_user_group_id", :unique => true
|
413
413
|
|
414
414
|
create_table "libraries", :force => true do |t|
|
415
|
-
t.integer "agent_id"
|
416
|
-
t.string "agent_type"
|
417
415
|
t.string "name", :null => false
|
418
416
|
t.text "display_name"
|
419
417
|
t.string "short_display_name", :null => false
|
@@ -437,7 +435,6 @@ ActiveRecord::Schema.define(:version => 20130519065837) do
|
|
437
435
|
t.string "isil"
|
438
436
|
end
|
439
437
|
|
440
|
-
add_index "libraries", ["agent_id"], :name => "index_libraries_on_agent_id", :unique => true
|
441
438
|
add_index "libraries", ["library_group_id"], :name => "index_libraries_on_library_group_id"
|
442
439
|
add_index "libraries", ["name"], :name => "index_libraries_on_name", :unique => true
|
443
440
|
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
Binary file
|
Binary file
|
data/spec/fixtures/libraries.yml
CHANGED
@@ -14,7 +14,6 @@ library_00001:
|
|
14
14
|
street:
|
15
15
|
created_at: 2007-08-13 18:10:00 +09:00
|
16
16
|
library_group_id: 1
|
17
|
-
agent_id: 1
|
18
17
|
call_number_delimiter: "|"
|
19
18
|
position: 1
|
20
19
|
library_00002:
|
@@ -32,7 +31,6 @@ library_00002:
|
|
32
31
|
street:
|
33
32
|
created_at: 2007-08-13 18:10:00 +09:00
|
34
33
|
library_group_id: 1
|
35
|
-
agent_id: 2
|
36
34
|
call_number_delimiter: "|"
|
37
35
|
position: 2
|
38
36
|
isil: "JP-0000000"
|
@@ -51,7 +49,6 @@ library_00003:
|
|
51
49
|
street:
|
52
50
|
created_at: 2007-08-14 16:37:00 +09:00
|
53
51
|
library_group_id: 1
|
54
|
-
agent_id: 3
|
55
52
|
call_number_delimiter: "|"
|
56
53
|
position: 3
|
57
54
|
library_00004:
|
@@ -69,7 +66,6 @@ library_00004:
|
|
69
66
|
street:
|
70
67
|
created_at: 2007-08-23 19:51:00 +09:00
|
71
68
|
library_group_id: 1
|
72
|
-
agent_id: 4
|
73
69
|
call_number_delimiter: "|"
|
74
70
|
position: 4
|
75
71
|
|
@@ -78,8 +74,6 @@ library_00004:
|
|
78
74
|
# Table name: libraries
|
79
75
|
#
|
80
76
|
# id :integer not null, primary key
|
81
|
-
# agent_id :integer
|
82
|
-
# agent_type :string(255)
|
83
77
|
# name :string(255) not null
|
84
78
|
# display_name :text
|
85
79
|
# short_display_name :string(255) not null
|
data/spec/models/reserve_spec.rb
CHANGED
@@ -74,14 +74,16 @@ describe Reserve do
|
|
74
74
|
old_count = MessageRequest.count
|
75
75
|
|
76
76
|
reservation.item = old_reservation.item
|
77
|
+
reservation.item.retained?.should be_false
|
77
78
|
reservation.sm_retain!
|
78
79
|
old_reservation.reload
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
80
|
+
old_reservation.item.should be_nil
|
81
|
+
reservation.retained_at.should be_true
|
82
|
+
old_reservation.retained_at.should be_nil
|
83
|
+
old_reservation.postponed_at.should be_true
|
84
|
+
old_reservation.state.should eq 'postponed'
|
85
|
+
MessageRequest.count.should eq old_count + 4
|
86
|
+
reservation.item.retained?.should be_true
|
85
87
|
end
|
86
88
|
|
87
89
|
it "should not be valid if item_identifier is invalid" do
|
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.1.0.
|
4
|
+
version: 0.1.0.pre31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kosuke Tanabe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: enju_biblio
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.1.0.
|
19
|
+
version: 0.1.0.pre47
|
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.1.0.
|
26
|
+
version: 0.1.0.pre47
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: enju_library
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.1.0.
|
33
|
+
version: 0.1.0.pre26
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.1.0.
|
40
|
+
version: 0.1.0.pre26
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: enju_message
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.1.14.
|
47
|
+
version: 0.1.14.pre11
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.1.14.
|
54
|
+
version: 0.1.14.pre11
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: enju_event
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.1.0.
|
75
|
+
version: 1.1.0.rc5
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.1.0.
|
82
|
+
version: 1.1.0.rc5
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: sqlite3
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -199,7 +199,6 @@ executables: []
|
|
199
199
|
extensions: []
|
200
200
|
extra_rdoc_files: []
|
201
201
|
files:
|
202
|
-
- app/controllers/baskets_controller.rb
|
203
202
|
- app/controllers/carrier_type_has_checkout_types_controller.rb
|
204
203
|
- app/controllers/checked_items_controller.rb
|
205
204
|
- app/controllers/checkins_controller.rb
|
@@ -241,10 +240,6 @@ files:
|
|
241
240
|
- app/models/user_checkout_stat.rb
|
242
241
|
- app/models/user_group_has_checkout_type.rb
|
243
242
|
- app/models/user_reserve_stat.rb
|
244
|
-
- app/views/baskets/edit.html.erb
|
245
|
-
- app/views/baskets/index.html.erb
|
246
|
-
- app/views/baskets/new.html.erb
|
247
|
-
- app/views/baskets/show.html.erb
|
248
243
|
- app/views/carrier_type_has_checkout_types/_form.html.erb
|
249
244
|
- app/views/carrier_type_has_checkout_types/edit.html.erb
|
250
245
|
- app/views/carrier_type_has_checkout_types/index.html.erb
|
@@ -432,7 +427,6 @@ files:
|
|
432
427
|
- MIT-LICENSE
|
433
428
|
- Rakefile
|
434
429
|
- README.rdoc
|
435
|
-
- spec/controllers/baskets_controller_spec.rb
|
436
430
|
- spec/controllers/carrier_type_has_checkout_types_controller_spec.rb
|
437
431
|
- spec/controllers/checked_items_controller_spec.rb
|
438
432
|
- spec/controllers/checkins_controller_spec.rb
|
@@ -455,7 +449,6 @@ files:
|
|
455
449
|
- spec/dummy/app/assets/javascripts/application.js
|
456
450
|
- spec/dummy/app/assets/stylesheets/application.css
|
457
451
|
- spec/dummy/app/controllers/application_controller.rb
|
458
|
-
- spec/dummy/app/controllers/baskets_controller.rb
|
459
452
|
- spec/dummy/app/helpers/application_helper.rb
|
460
453
|
- spec/dummy/app/mailers/notifier.rb
|
461
454
|
- spec/dummy/app/models/ability.rb
|
@@ -583,16 +576,16 @@ files:
|
|
583
576
|
- spec/dummy/solr/conf/spellings.txt
|
584
577
|
- spec/dummy/solr/conf/stopwords.txt
|
585
578
|
- spec/dummy/solr/conf/synonyms.txt
|
586
|
-
- spec/dummy/solr/data/test/index/
|
587
|
-
- spec/dummy/solr/data/test/index/
|
588
|
-
- spec/dummy/solr/data/test/index/
|
589
|
-
- spec/dummy/solr/data/test/index/
|
590
|
-
- spec/dummy/solr/data/test/index/
|
591
|
-
- spec/dummy/solr/data/test/index/
|
592
|
-
- spec/dummy/solr/data/test/index/
|
593
|
-
- spec/dummy/solr/data/test/index/
|
579
|
+
- spec/dummy/solr/data/test/index/_3ed.fdt
|
580
|
+
- spec/dummy/solr/data/test/index/_3ed.fdx
|
581
|
+
- spec/dummy/solr/data/test/index/_3ed.fnm
|
582
|
+
- spec/dummy/solr/data/test/index/_3ed.frq
|
583
|
+
- spec/dummy/solr/data/test/index/_3ed.nrm
|
584
|
+
- spec/dummy/solr/data/test/index/_3ed.prx
|
585
|
+
- spec/dummy/solr/data/test/index/_3ed.tii
|
586
|
+
- spec/dummy/solr/data/test/index/_3ed.tis
|
594
587
|
- spec/dummy/solr/data/test/index/segments.gen
|
595
|
-
- spec/dummy/solr/data/test/index/
|
588
|
+
- spec/dummy/solr/data/test/index/segments_6sj
|
596
589
|
- spec/dummy/solr/data/test/spellchecker/segments.gen
|
597
590
|
- spec/dummy/solr/data/test/spellchecker/segments_1
|
598
591
|
- spec/factories/basket.rb
|
@@ -678,7 +671,6 @@ files:
|
|
678
671
|
- spec/models/user_checkout_stat_spec.rb
|
679
672
|
- spec/models/user_group_has_checkout_type_spec.rb
|
680
673
|
- spec/models/user_reserve_stat_spec.rb
|
681
|
-
- spec/routing/baskets_routing_spec.rb
|
682
674
|
- spec/routing/checked_items_routing_spec.rb
|
683
675
|
- spec/spec_helper.rb
|
684
676
|
- spec/support/controller_macros.rb
|
@@ -707,7 +699,6 @@ signing_key:
|
|
707
699
|
specification_version: 4
|
708
700
|
summary: enju_circulation plugin
|
709
701
|
test_files:
|
710
|
-
- spec/controllers/baskets_controller_spec.rb
|
711
702
|
- spec/controllers/carrier_type_has_checkout_types_controller_spec.rb
|
712
703
|
- spec/controllers/checked_items_controller_spec.rb
|
713
704
|
- spec/controllers/checkins_controller_spec.rb
|
@@ -730,7 +721,6 @@ test_files:
|
|
730
721
|
- spec/dummy/app/assets/javascripts/application.js
|
731
722
|
- spec/dummy/app/assets/stylesheets/application.css
|
732
723
|
- spec/dummy/app/controllers/application_controller.rb
|
733
|
-
- spec/dummy/app/controllers/baskets_controller.rb
|
734
724
|
- spec/dummy/app/helpers/application_helper.rb
|
735
725
|
- spec/dummy/app/mailers/notifier.rb
|
736
726
|
- spec/dummy/app/models/ability.rb
|
@@ -858,16 +848,16 @@ test_files:
|
|
858
848
|
- spec/dummy/solr/conf/spellings.txt
|
859
849
|
- spec/dummy/solr/conf/stopwords.txt
|
860
850
|
- spec/dummy/solr/conf/synonyms.txt
|
861
|
-
- spec/dummy/solr/data/test/index/
|
862
|
-
- spec/dummy/solr/data/test/index/
|
863
|
-
- spec/dummy/solr/data/test/index/
|
864
|
-
- spec/dummy/solr/data/test/index/
|
865
|
-
- spec/dummy/solr/data/test/index/
|
866
|
-
- spec/dummy/solr/data/test/index/
|
867
|
-
- spec/dummy/solr/data/test/index/
|
868
|
-
- spec/dummy/solr/data/test/index/
|
851
|
+
- spec/dummy/solr/data/test/index/_3ed.fdt
|
852
|
+
- spec/dummy/solr/data/test/index/_3ed.fdx
|
853
|
+
- spec/dummy/solr/data/test/index/_3ed.fnm
|
854
|
+
- spec/dummy/solr/data/test/index/_3ed.frq
|
855
|
+
- spec/dummy/solr/data/test/index/_3ed.nrm
|
856
|
+
- spec/dummy/solr/data/test/index/_3ed.prx
|
857
|
+
- spec/dummy/solr/data/test/index/_3ed.tii
|
858
|
+
- spec/dummy/solr/data/test/index/_3ed.tis
|
869
859
|
- spec/dummy/solr/data/test/index/segments.gen
|
870
|
-
- spec/dummy/solr/data/test/index/
|
860
|
+
- spec/dummy/solr/data/test/index/segments_6sj
|
871
861
|
- spec/dummy/solr/data/test/spellchecker/segments.gen
|
872
862
|
- spec/dummy/solr/data/test/spellchecker/segments_1
|
873
863
|
- spec/factories/basket.rb
|
@@ -953,7 +943,6 @@ test_files:
|
|
953
943
|
- spec/models/user_checkout_stat_spec.rb
|
954
944
|
- spec/models/user_group_has_checkout_type_spec.rb
|
955
945
|
- spec/models/user_reserve_stat_spec.rb
|
956
|
-
- spec/routing/baskets_routing_spec.rb
|
957
946
|
- spec/routing/checked_items_routing_spec.rb
|
958
947
|
- spec/spec_helper.rb
|
959
948
|
- spec/support/controller_macros.rb
|
@@ -1,109 +0,0 @@
|
|
1
|
-
class BasketsController < ApplicationController
|
2
|
-
load_and_authorize_resource
|
3
|
-
cache_sweeper :circulation_sweeper, :only => [:create, :update, :destroy]
|
4
|
-
|
5
|
-
# GET /baskets
|
6
|
-
# GET /baskets.json
|
7
|
-
def index
|
8
|
-
if current_user.has_role?('Librarian')
|
9
|
-
@baskets = Basket.page(params[:page])
|
10
|
-
else
|
11
|
-
redirect_to new_basket_url
|
12
|
-
return
|
13
|
-
end
|
14
|
-
|
15
|
-
respond_to do |format|
|
16
|
-
format.html # index.html.erb
|
17
|
-
format.json { render :json => @baskets }
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# GET /baskets/1
|
22
|
-
# GET /baskets/1.json
|
23
|
-
def show
|
24
|
-
respond_to do |format|
|
25
|
-
format.html # show.html.erb
|
26
|
-
format.json { render :json => @basket }
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# GET /baskets/new
|
31
|
-
# GET /baskets/new.json
|
32
|
-
def new
|
33
|
-
@basket = Basket.new
|
34
|
-
@basket.user_number = params[:user_number]
|
35
|
-
|
36
|
-
respond_to do |format|
|
37
|
-
format.html # new.html.erb
|
38
|
-
format.json { render :json => @basket }
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# GET /baskets/1/edit
|
43
|
-
def edit
|
44
|
-
end
|
45
|
-
|
46
|
-
# POST /baskets
|
47
|
-
# POST /baskets.json
|
48
|
-
def create
|
49
|
-
@basket = Basket.new(params[:basket])
|
50
|
-
@user = User.where(:user_number => @basket.user_number).first if @basket.user_number
|
51
|
-
if @user
|
52
|
-
if @user.user_number?
|
53
|
-
@basket.user = @user
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
respond_to do |format|
|
58
|
-
if @basket.save
|
59
|
-
format.html { redirect_to new_basket_checked_item_url(@basket), :notice => t('controller.successfully_created', :model => t('activerecord.models.basket')) }
|
60
|
-
format.json { render :json => @basket, :status => :created, :location => @basket }
|
61
|
-
else
|
62
|
-
format.html { render :action => "new" }
|
63
|
-
format.json { render :json => @basket.errors, :status => :unprocessable_entity }
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# PUT /baskets/1
|
69
|
-
# PUT /baskets/1.json
|
70
|
-
def update
|
71
|
-
librarian = current_user
|
72
|
-
begin
|
73
|
-
unless @basket.basket_checkout(librarian)
|
74
|
-
redirect_to new_basket_checked_item_url(@basket)
|
75
|
-
return
|
76
|
-
end
|
77
|
-
rescue ActiveRecord::RecordInvalid
|
78
|
-
flash[:message] = t('checked_item.already_checked_out_try_again')
|
79
|
-
@basket.checked_items.delete_all
|
80
|
-
redirect_to new_basket_checked_item_url(@basket)
|
81
|
-
return
|
82
|
-
end
|
83
|
-
|
84
|
-
respond_to do |format|
|
85
|
-
#if @basket.update_attributes({})
|
86
|
-
if @basket.save(:validate => false)
|
87
|
-
# 貸出完了時
|
88
|
-
format.html { redirect_to user_checkouts_url(@basket.user), :notice => t('basket.checkout_completed') }
|
89
|
-
format.json { head :no_content }
|
90
|
-
else
|
91
|
-
format.html { redirect_to basket_checked_items_url(@basket) }
|
92
|
-
format.json { render :json => @basket.errors, :status => :unprocessable_entity }
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
97
|
-
|
98
|
-
# DELETE /baskets/1
|
99
|
-
# DELETE /baskets/1.json
|
100
|
-
def destroy
|
101
|
-
@basket.destroy
|
102
|
-
|
103
|
-
respond_to do |format|
|
104
|
-
#format.html { redirect_to(user_baskets_url(@user)) }
|
105
|
-
format.html { redirect_to user_checkouts_url(@basket.user) }
|
106
|
-
format.json { head :no_content }
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
<div id="content_detail" class="ui-corner-all">
|
2
|
-
<h1 class="title"><%= t('page.editing', :model => t('activerecord.models.basket')) -%></h1>
|
3
|
-
<div id="content_list">
|
4
|
-
|
5
|
-
<%= form_for(@basket) do |f| -%>
|
6
|
-
<%= f.error_messages -%>
|
7
|
-
<div class="field">
|
8
|
-
<%= f.label t('activerecord.models.user') -%><br />
|
9
|
-
<%= @basket.user.username -%>
|
10
|
-
<%= f.hidden_field :user_id -%>
|
11
|
-
</div>
|
12
|
-
|
13
|
-
<div class="field">
|
14
|
-
<%= f.label :note -%><br />
|
15
|
-
<%= f.text_area :note, :class => 'resource_textarea' -%>
|
16
|
-
</div>
|
17
|
-
|
18
|
-
<div class="actions">
|
19
|
-
<%= f.submit %>
|
20
|
-
</div>
|
21
|
-
<%- end -%>
|
22
|
-
</div>
|
23
|
-
</div>
|
24
|
-
|
25
|
-
<div id="submenu" class="ui-corner-all">
|
26
|
-
<ul>
|
27
|
-
<li><%= link_to t('page.show'), basket_path(@basket) -%></li>
|
28
|
-
<li><%= link_to t('page.back'), user_baskets_path(@basket.user) -%></li>
|
29
|
-
</ul>
|
30
|
-
</div>
|
@@ -1,31 +0,0 @@
|
|
1
|
-
<div id="content_detail" class="ui-corner-all">
|
2
|
-
<h1 class="title"><%= t('page.listing', :model => t('activerecord.models.basket')) -%></h1>
|
3
|
-
<div id="content_list">
|
4
|
-
|
5
|
-
<table class="table table-striped index">
|
6
|
-
<tr>
|
7
|
-
<th><%= t('activerecord.models.user') -%></th>
|
8
|
-
<th><%= t('activerecord.attributes.basket.note') -%></th>
|
9
|
-
<th><%= t('page.updated_at') -%></th>
|
10
|
-
</tr>
|
11
|
-
|
12
|
-
<%- @baskets.each do |basket| -%>
|
13
|
-
<tr class="line<%= cycle("0", "1") -%>">
|
14
|
-
<td><%= basket.user.username -%></td>
|
15
|
-
<td><%= basket.note -%></td>
|
16
|
-
<td><%= basket.updated_at -%></td>
|
17
|
-
<td><%= link_to t('page.show'), basket -%></td>
|
18
|
-
</tr>
|
19
|
-
<%- end -%>
|
20
|
-
</table>
|
21
|
-
|
22
|
-
<%= paginate(@baskets) -%>
|
23
|
-
|
24
|
-
</div>
|
25
|
-
</div>
|
26
|
-
|
27
|
-
<div id="submenu" class="ui-corner-all">
|
28
|
-
<ul>
|
29
|
-
<li><%= link_to t('page.new', :model => t('activerecord.models.basket')), new_basket_path -%></li>
|
30
|
-
</ul>
|
31
|
-
</div>
|
@@ -1,29 +0,0 @@
|
|
1
|
-
<div id="content_detail" class="ui-corner-all">
|
2
|
-
<h1 class="title"><%= t('page.new', :model => t('activerecord.models.basket')) -%></h1>
|
3
|
-
<div id="content_list">
|
4
|
-
|
5
|
-
<%= form_for(@basket, :html => {:name => 'basket_form'}) do |f| -%>
|
6
|
-
<%= f.error_messages -%>
|
7
|
-
<div class="field">
|
8
|
-
<%= f.label t('activerecord.attributes.user.user_number') -%>
|
9
|
-
<%= f.search_field :user_number, :class => 'resource_user_number' -%>
|
10
|
-
|
11
|
-
<!--
|
12
|
-
<div class="field">
|
13
|
-
<%= f.label :note -%><br />
|
14
|
-
<%= f.text_area :note, :class => 'resource_textarea' -%>
|
15
|
-
</div>
|
16
|
-
-->
|
17
|
-
<%= f.submit t('page.read') -%>
|
18
|
-
</div>
|
19
|
-
<%- end -%>
|
20
|
-
<%= javascript_tag("$(function(){$('#basket_user_number').focus().select()})") %>
|
21
|
-
</div>
|
22
|
-
</div>
|
23
|
-
|
24
|
-
<div id="submenu" class="ui-corner-all">
|
25
|
-
<ul>
|
26
|
-
<li><%= link_to t('activerecord.models.checkin'), new_checkin_path -%></li>
|
27
|
-
<li><%= link_to t('page.search_resource', :model => t('activerecord.models.user')), users_path -%></li>
|
28
|
-
</ul>
|
29
|
-
</div>
|
@@ -1,23 +0,0 @@
|
|
1
|
-
<div id="content_list">
|
2
|
-
<h1 class="title"><%= t('page.showing', :model => t('activerecord.models.basket')) -%></h1>
|
3
|
-
<div id="content_detail" class="ui-corner-all">
|
4
|
-
<p id="notice"><%= notice %></p>
|
5
|
-
|
6
|
-
<p>
|
7
|
-
<strong><%= t('activerecord.models.user') -%>:</strong>
|
8
|
-
<%= @basket.user.username -%>
|
9
|
-
</p>
|
10
|
-
|
11
|
-
<p>
|
12
|
-
<strong><%= t('activerecord.attributes.basket.note') -%>:</strong>
|
13
|
-
<%= @basket.note -%>
|
14
|
-
</p>
|
15
|
-
</div>
|
16
|
-
</div>
|
17
|
-
|
18
|
-
<div id="submenu" class="ui-corner-all">
|
19
|
-
<ul>
|
20
|
-
<li><%= link_to t('page.edit'), edit_basket_path(@basket) -%></li>
|
21
|
-
<li><%= link_to t('page.back'), user_baskets_path(@basket.user) -%></li>
|
22
|
-
</ul>
|
23
|
-
</div>
|
@@ -1,379 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe BasketsController do
|
4
|
-
fixtures :all
|
5
|
-
|
6
|
-
describe "GET index" do
|
7
|
-
describe "When logged in as Administrator" do
|
8
|
-
login_admin
|
9
|
-
|
10
|
-
it "assigns all baskets as @baskets" do
|
11
|
-
get :index, :user_id => users(:user1).username
|
12
|
-
assigns(:baskets).should_not be_empty
|
13
|
-
response.should be_success
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should get index without user_id" do
|
17
|
-
get :index
|
18
|
-
response.should be_success
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "When logged in as Librarian" do
|
23
|
-
login_librarian
|
24
|
-
|
25
|
-
it "assigns all baskets as @baskets" do
|
26
|
-
get :index, :user_id => users(:user1).username
|
27
|
-
assigns(:baskets).should_not be_empty
|
28
|
-
response.should be_success
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "When logged in as User" do
|
33
|
-
login_user
|
34
|
-
|
35
|
-
it "assigns all baskets as @baskets" do
|
36
|
-
get :index, :user_id => users(:user1).username
|
37
|
-
assigns(:baskets).should be_empty
|
38
|
-
response.should be_forbidden
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "When not logged in" do
|
43
|
-
it "assigns all baskets as @baskets" do
|
44
|
-
get :index, :user_id => users(:user1).username
|
45
|
-
assigns(:baskets).should be_empty
|
46
|
-
response.should redirect_to(new_user_session_url)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "GET show" do
|
52
|
-
describe "When logged in as Administrator" do
|
53
|
-
login_admin
|
54
|
-
|
55
|
-
it "assigns the requested basket as @basket" do
|
56
|
-
get :show, :id => 1, :user_id => users(:admin).username
|
57
|
-
assigns(:basket).should eq(Basket.find(1))
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe "When logged in as Librarian" do
|
62
|
-
login_librarian
|
63
|
-
|
64
|
-
it "assigns the requested basket as @basket" do
|
65
|
-
get :show, :id => 1, :user_id => users(:admin).username
|
66
|
-
assigns(:basket).should eq(Basket.find(1))
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe "When logged in as User" do
|
71
|
-
login_user
|
72
|
-
|
73
|
-
it "assigns the requested basket as @basket" do
|
74
|
-
get :show, :id => 1, :user_id => users(:admin).username
|
75
|
-
assigns(:basket).should eq(Basket.find(1))
|
76
|
-
response.should be_forbidden
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe "When not logged in" do
|
81
|
-
it "assigns the requested basket as @basket" do
|
82
|
-
get :show, :id => 1, :user_id => users(:admin).username
|
83
|
-
assigns(:basket).should eq(Basket.find(1))
|
84
|
-
response.should redirect_to(new_user_session_url)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe "GET new" do
|
90
|
-
describe "When logged in as Administrator" do
|
91
|
-
login_admin
|
92
|
-
|
93
|
-
it "assigns the requested basket as @basket" do
|
94
|
-
get :new
|
95
|
-
assigns(:basket).should_not be_valid
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
describe "When logged in as Librarian" do
|
100
|
-
login_librarian
|
101
|
-
|
102
|
-
it "assigns the requested basket as @basket" do
|
103
|
-
get :new
|
104
|
-
assigns(:basket).should_not be_valid
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
describe "When logged in as User" do
|
109
|
-
login_user
|
110
|
-
|
111
|
-
it "should not assign the requested basket as @basket" do
|
112
|
-
get :new
|
113
|
-
assigns(:basket).should_not be_valid
|
114
|
-
response.should be_forbidden
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
describe "When not logged in" do
|
119
|
-
it "should not assign the requested basket as @basket" do
|
120
|
-
get :new
|
121
|
-
assigns(:basket).should_not be_valid
|
122
|
-
response.should redirect_to(new_user_session_url)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
describe "GET edit" do
|
128
|
-
describe "When logged in as Administrator" do
|
129
|
-
login_admin
|
130
|
-
before(:each) do
|
131
|
-
@basket = baskets(:basket_00001)
|
132
|
-
end
|
133
|
-
|
134
|
-
it "assigns the requested basket as @basket" do
|
135
|
-
get :edit, :id => @basket.id
|
136
|
-
assigns(:basket).should eq(@basket)
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
describe "When logged in as Librarian" do
|
141
|
-
login_librarian
|
142
|
-
before(:each) do
|
143
|
-
@basket = baskets(:basket_00001)
|
144
|
-
end
|
145
|
-
|
146
|
-
it "assigns the requested basket as @basket" do
|
147
|
-
get :edit, :id => @basket.id
|
148
|
-
assigns(:basket).should eq(@basket)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
describe "When logged in as User" do
|
153
|
-
login_user
|
154
|
-
before(:each) do
|
155
|
-
@basket = baskets(:basket_00001)
|
156
|
-
end
|
157
|
-
|
158
|
-
it "should not assign the requested basket as @basket" do
|
159
|
-
get :edit, :id => @basket.id
|
160
|
-
assigns(:basket).should eq(@basket)
|
161
|
-
response.should be_forbidden
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
describe "When not logged in" do
|
166
|
-
before(:each) do
|
167
|
-
@basket = baskets(:basket_00001)
|
168
|
-
end
|
169
|
-
|
170
|
-
it "should not assign the requested basket as @basket" do
|
171
|
-
get :edit, :id => @basket.id
|
172
|
-
assigns(:basket).should eq(@basket)
|
173
|
-
response.should redirect_to new_user_session_url
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
describe "POST create" do
|
179
|
-
before(:each) do
|
180
|
-
@attrs = {:user_number => users(:user1).user_number }
|
181
|
-
@invalid_attrs = {:user_number => 'invalid'}
|
182
|
-
end
|
183
|
-
|
184
|
-
describe "When logged in as Administrator" do
|
185
|
-
login_admin
|
186
|
-
|
187
|
-
describe "with valid params" do
|
188
|
-
it "assigns a newly created basket as @basket" do
|
189
|
-
post :create, :basket => {:user_number => users(:user1).user_number }
|
190
|
-
assigns(:basket).should be_valid
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
describe "with blank params" do
|
195
|
-
it "assigns a newly created basket as @basket" do
|
196
|
-
post :create, :basket => { }
|
197
|
-
assigns(:basket).should_not be_valid
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
describe "with invalid params" do
|
202
|
-
it "assigns a newly created basket as @basket" do
|
203
|
-
post :create, :basket => @invalid_attrs
|
204
|
-
assigns(:basket).should_not be_valid
|
205
|
-
end
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
describe "When logged in as Librarian" do
|
210
|
-
login_librarian
|
211
|
-
|
212
|
-
describe "with valid params" do
|
213
|
-
it "assigns a newly created basket as @basket" do
|
214
|
-
post :create, :basket => {:user_number => users(:user1).user_number }
|
215
|
-
assigns(:basket).should be_valid
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
describe "with blank params" do
|
220
|
-
it "assigns a newly created basket as @basket" do
|
221
|
-
post :create, :basket => { }
|
222
|
-
assigns(:basket).should_not be_valid
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
describe "with invalid params" do
|
227
|
-
it "assigns a newly created basket as @basket" do
|
228
|
-
post :create, :basket => @invalid_attrs
|
229
|
-
assigns(:basket).should_not be_valid
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
it "should not create basket when user is suspended" do
|
234
|
-
post :create, :basket => {:user_number => users(:user4).user_number }
|
235
|
-
assigns(:basket).should_not be_valid
|
236
|
-
assigns(:basket).errors["base"].include?(I18n.t('basket.this_account_is_suspended')).should be_true
|
237
|
-
response.should be_success
|
238
|
-
end
|
239
|
-
|
240
|
-
it "should not create basket when user is not found" do
|
241
|
-
post :create, :basket => {:user_number => 'not found' }
|
242
|
-
assigns(:basket).should_not be_valid
|
243
|
-
assigns(:basket).errors["base"].include?(I18n.t('user.not_found')).should be_true
|
244
|
-
response.should be_success
|
245
|
-
end
|
246
|
-
|
247
|
-
it "should not create basket without user_number" do
|
248
|
-
post :create, :basket => { }
|
249
|
-
assigns(:basket).should_not be_valid
|
250
|
-
response.should be_success
|
251
|
-
end
|
252
|
-
|
253
|
-
it "should create basket" do
|
254
|
-
post :create, :basket => {:user_number => users(:user1).user_number }
|
255
|
-
assigns(:basket).should be_valid
|
256
|
-
response.should redirect_to new_basket_checked_item_url(assigns(:basket))
|
257
|
-
end
|
258
|
-
|
259
|
-
it "should not create basket without user_number" do
|
260
|
-
post :create, :basket => { }
|
261
|
-
assigns(:basket).should_not be_valid
|
262
|
-
response.should be_success
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
describe "When logged in as User" do
|
267
|
-
login_user
|
268
|
-
|
269
|
-
describe "with valid params" do
|
270
|
-
it "assigns a newly created basket as @basket" do
|
271
|
-
post :create, :basket => {:user_number => users(:user1).user_number }
|
272
|
-
assigns(:basket).should_not be_valid
|
273
|
-
end
|
274
|
-
|
275
|
-
it "should be forbidden" do
|
276
|
-
post :create, :basket => {:user_number => users(:user1).user_number }
|
277
|
-
response.should be_forbidden
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
it "should not create basket" do
|
282
|
-
post :create, :basket => {:user_number => users(:user1).user_number }
|
283
|
-
response.should be_forbidden
|
284
|
-
end
|
285
|
-
end
|
286
|
-
|
287
|
-
describe "When not logged in" do
|
288
|
-
describe "with blank params" do
|
289
|
-
it "assigns a newly created basket as @basket" do
|
290
|
-
post :create, :basket => { }
|
291
|
-
assigns(:basket).should_not be_valid
|
292
|
-
end
|
293
|
-
|
294
|
-
it "should be redirected to new_user_session_url" do
|
295
|
-
post :create, :basket => { }
|
296
|
-
assigns(:basket).should_not be_valid
|
297
|
-
assert_response :redirect
|
298
|
-
response.should redirect_to new_user_session_url
|
299
|
-
end
|
300
|
-
end
|
301
|
-
end
|
302
|
-
end
|
303
|
-
|
304
|
-
describe "PUT update" do
|
305
|
-
before(:each) do
|
306
|
-
@attrs = {:user_id => users(:user1).username}
|
307
|
-
end
|
308
|
-
|
309
|
-
describe "When logged in as Librarian" do
|
310
|
-
login_librarian
|
311
|
-
|
312
|
-
describe "with valid params" do
|
313
|
-
it "updates the requested basket" do
|
314
|
-
put :update, :id => 8, :basket => @attrs
|
315
|
-
end
|
316
|
-
|
317
|
-
it "assigns the requested basket as @basket" do
|
318
|
-
put :update, :id => 8, :basket => @attrs
|
319
|
-
assigns(:basket).checkouts.first.item.circulation_status.name.should eq 'On Loan'
|
320
|
-
response.should redirect_to(user_checkouts_url(assigns(:basket).user))
|
321
|
-
end
|
322
|
-
end
|
323
|
-
end
|
324
|
-
end
|
325
|
-
|
326
|
-
describe "DELETE destroy" do
|
327
|
-
before(:each) do
|
328
|
-
@basket = FactoryGirl.create(:basket)
|
329
|
-
end
|
330
|
-
|
331
|
-
describe "When logged in as Administrator" do
|
332
|
-
login_fixture_admin
|
333
|
-
|
334
|
-
it "should destroy basket without user_id" do
|
335
|
-
delete :destroy, :id => 1, :basket => {:user_id => nil}, :user_id => users(:user1).username
|
336
|
-
response.should redirect_to user_checkouts_url(assigns(:basket).user)
|
337
|
-
end
|
338
|
-
|
339
|
-
it "should destroy basket" do
|
340
|
-
delete :destroy, :id => 1, :basket => { }, :user_id => users(:user1).username
|
341
|
-
response.should redirect_to user_checkouts_url(assigns(:basket).user)
|
342
|
-
end
|
343
|
-
end
|
344
|
-
|
345
|
-
describe "When logged in as Librarian" do
|
346
|
-
login_fixture_librarian
|
347
|
-
|
348
|
-
it "should destroy basket without user_id" do
|
349
|
-
delete :destroy, :id => 1, :basket => {:user_id => nil}, :user_id => users(:user1).username
|
350
|
-
response.should redirect_to user_checkouts_url(assigns(:basket).user)
|
351
|
-
end
|
352
|
-
|
353
|
-
it "should destroy basket" do
|
354
|
-
delete :destroy, :id => 1, :basket => { }, :user_id => users(:user1).username
|
355
|
-
response.should redirect_to user_checkouts_url(assigns(:basket).user)
|
356
|
-
end
|
357
|
-
end
|
358
|
-
|
359
|
-
describe "When logged in as User" do
|
360
|
-
login_fixture_user
|
361
|
-
|
362
|
-
it "should not destroy basket" do
|
363
|
-
delete :destroy, :id => 3, :user_id => users(:user1).username
|
364
|
-
response.should be_forbidden
|
365
|
-
end
|
366
|
-
end
|
367
|
-
|
368
|
-
describe "When not logged in" do
|
369
|
-
it "destroys the requested basket" do
|
370
|
-
delete :destroy, :id => @basket.id
|
371
|
-
end
|
372
|
-
|
373
|
-
it "should be forbidden" do
|
374
|
-
delete :destroy, :id => @basket.id
|
375
|
-
response.should redirect_to new_user_session_url
|
376
|
-
end
|
377
|
-
end
|
378
|
-
end
|
379
|
-
end
|
@@ -1,103 +0,0 @@
|
|
1
|
-
class BasketsController < ApplicationController
|
2
|
-
load_and_authorize_resource
|
3
|
-
cache_sweeper :circulation_sweeper, :only => [:create, :update, :destroy]
|
4
|
-
|
5
|
-
# GET /baskets
|
6
|
-
# GET /baskets.json
|
7
|
-
def index
|
8
|
-
if current_user.has_role?('Librarian')
|
9
|
-
@baskets = Basket.page(params[:page])
|
10
|
-
else
|
11
|
-
redirect_to new_basket_url
|
12
|
-
return
|
13
|
-
end
|
14
|
-
|
15
|
-
respond_to do |format|
|
16
|
-
format.html # index.html.erb
|
17
|
-
format.json { render :json => @baskets }
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# GET /baskets/1
|
22
|
-
# GET /baskets/1.json
|
23
|
-
def show
|
24
|
-
respond_to do |format|
|
25
|
-
format.html # show.html.erb
|
26
|
-
format.json { render :json => @basket }
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# GET /baskets/new
|
31
|
-
# GET /baskets/new.json
|
32
|
-
def new
|
33
|
-
@basket = Basket.new
|
34
|
-
@basket.user_number = params[:user_number]
|
35
|
-
|
36
|
-
respond_to do |format|
|
37
|
-
format.html # new.html.erb
|
38
|
-
format.json { render :json => @basket }
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# GET /baskets/1/edit
|
43
|
-
def edit
|
44
|
-
end
|
45
|
-
|
46
|
-
# POST /baskets
|
47
|
-
# POST /baskets.json
|
48
|
-
def create
|
49
|
-
@basket = Basket.new
|
50
|
-
@user = User.where(:user_number => params[:basket][:user_number]).first rescue nil
|
51
|
-
if @user
|
52
|
-
if @user.user_number?
|
53
|
-
@basket.user = @user
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
respond_to do |format|
|
58
|
-
if @basket.save
|
59
|
-
format.html { redirect_to new_basket_checked_item_url(@basket), :notice => t('controller.successfully_created', :model => t('activerecord.models.basket')) }
|
60
|
-
format.json { render :json => @basket, :status => :created, :location => @basket }
|
61
|
-
else
|
62
|
-
format.html { render :action => "new" }
|
63
|
-
format.json { render :json => @basket.errors, :status => :unprocessable_entity }
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# PUT /baskets/1
|
69
|
-
# PUT /baskets/1.json
|
70
|
-
def update
|
71
|
-
librarian = current_user
|
72
|
-
unless @basket.basket_checkout(librarian)
|
73
|
-
redirect_to basket_checked_items_url(@basket)
|
74
|
-
return
|
75
|
-
end
|
76
|
-
|
77
|
-
#@checkout_count = @basket.user.checkouts.count
|
78
|
-
respond_to do |format|
|
79
|
-
#if @basket.update_attributes({})
|
80
|
-
if @basket.save(:validate => false)
|
81
|
-
# 貸出完了時
|
82
|
-
format.html { redirect_to user_checkouts_url(@basket.user), :notice => t('basket.checkout_completed') }
|
83
|
-
format.json { head :no_content }
|
84
|
-
else
|
85
|
-
format.html { redirect_to basket_checked_items_url(@basket) }
|
86
|
-
format.json { render :json => @basket.errors, :status => :unprocessable_entity }
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|
91
|
-
|
92
|
-
# DELETE /baskets/1
|
93
|
-
# DELETE /baskets/1.json
|
94
|
-
def destroy
|
95
|
-
@basket.destroy
|
96
|
-
|
97
|
-
respond_to do |format|
|
98
|
-
#format.html { redirect_to(user_baskets_url(@user)) }
|
99
|
-
format.html { redirect_to user_checkouts_url(@basket.user) }
|
100
|
-
format.json { head :no_content }
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe BasketsController do
|
4
|
-
describe "routing" do
|
5
|
-
|
6
|
-
it "recognizes and generates #index" do
|
7
|
-
{ :get => "/baskets" }.should route_to(:controller => "baskets", :action => "index")
|
8
|
-
end
|
9
|
-
|
10
|
-
it "recognizes and generates #new" do
|
11
|
-
{ :get => "/baskets/new" }.should route_to(:controller => "baskets", :action => "new")
|
12
|
-
end
|
13
|
-
|
14
|
-
it "recognizes and generates #show" do
|
15
|
-
{ :get => "/baskets/1" }.should route_to(:controller => "baskets", :action => "show", :id => "1")
|
16
|
-
end
|
17
|
-
|
18
|
-
it "recognizes and generates #edit" do
|
19
|
-
{ :get => "/baskets/1/edit" }.should route_to(:controller => "baskets", :action => "edit", :id => "1")
|
20
|
-
end
|
21
|
-
|
22
|
-
it "recognizes and generates #create" do
|
23
|
-
{ :post => "/baskets" }.should route_to(:controller => "baskets", :action => "create")
|
24
|
-
end
|
25
|
-
|
26
|
-
it "recognizes and generates #update" do
|
27
|
-
{ :put => "/baskets/1" }.should route_to(:controller => "baskets", :action => "update", :id => "1")
|
28
|
-
end
|
29
|
-
|
30
|
-
it "recognizes and generates #destroy" do
|
31
|
-
{ :delete => "/baskets/1" }.should route_to(:controller => "baskets", :action => "destroy", :id => "1")
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|