enju_circulation 0.0.48 → 0.0.49
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/accepts_controller.rb +83 -0
- data/app/models/accept.rb +36 -0
- data/app/models/basket.rb +63 -0
- data/config/routes.rb +5 -0
- data/{spec/dummy/db → db}/migrate/120_create_baskets.rb +1 -7
- data/db/migrate/20120319173203_create_accepts.rb +14 -0
- data/lib/enju_circulation/version.rb +1 -1
- data/spec/controllers/accepts_controller_spec.rb +466 -0
- data/spec/controllers/baskets_controller_spec.rb +379 -0
- data/spec/dummy/app/models/ability.rb +2 -0
- data/spec/dummy/app/models/basket.rb +63 -0
- data/spec/dummy/db/schema.rb +11 -2
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/factories/accepts.rb +9 -0
- data/spec/models/accept_spec.rb +22 -0
- data/spec/models/use_resetriction_spec.rb +7 -0
- metadata +19 -4
@@ -0,0 +1,83 @@
|
|
1
|
+
class AcceptsController < InheritedResources::Base
|
2
|
+
load_and_authorize_resource :except => :index
|
3
|
+
authorize_resource :only => :index
|
4
|
+
respond_to :html, :json
|
5
|
+
before_filter :get_basket, :only => [:index, :create]
|
6
|
+
|
7
|
+
# GET /accepts
|
8
|
+
# GET /accepts.json
|
9
|
+
def index
|
10
|
+
if params[:format] == 'csv'
|
11
|
+
@accepts = Accept.order('accepts.created_at DESC').paginate(:page => params[:page], :per_page => 65534)
|
12
|
+
else
|
13
|
+
if params[:accept]
|
14
|
+
@query = params[:accept][:item_identifier].to_s.strip
|
15
|
+
item = Item.where(:item_identifier => @query).first if @query.present?
|
16
|
+
end
|
17
|
+
|
18
|
+
if item
|
19
|
+
@accepts = Accept.order('accepts.created_at DESC').where(:item_id => item.id).paginate(:page => params[:page])
|
20
|
+
else
|
21
|
+
if @basket
|
22
|
+
@accepts = @basket.accepts.paginate(:page => params[:page])
|
23
|
+
else
|
24
|
+
@accepts = Accept.paginate(:page => params[:page])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
respond_to do |format|
|
30
|
+
format.html # index.html.erb
|
31
|
+
format.json { render :json => @accepts }
|
32
|
+
format.js { @accept = Accept.new }
|
33
|
+
format.csv
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# GET /new
|
38
|
+
# GET /new.json
|
39
|
+
def new
|
40
|
+
@basket = Basket.new
|
41
|
+
@basket.user = current_user
|
42
|
+
@basket.save!
|
43
|
+
@accept = Accept.new
|
44
|
+
@accepts = []
|
45
|
+
|
46
|
+
respond_to do |format|
|
47
|
+
format.html # new.html.erb
|
48
|
+
format.json { render :json => @patron }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# POST /accepts
|
53
|
+
# POST /accepts.json
|
54
|
+
def create
|
55
|
+
unless @basket
|
56
|
+
access_denied; return
|
57
|
+
end
|
58
|
+
@accept.basket = @basket
|
59
|
+
@accept.librarian = current_user
|
60
|
+
|
61
|
+
flash[:message] = ''
|
62
|
+
if @accept.item_identifier.blank?
|
63
|
+
flash[:message] << t('accept.enter_item_identifier') if @accept.item_identifier.blank?
|
64
|
+
else
|
65
|
+
item = Item.where(:item_identifier => @accept.item_identifier.to_s.strip).first
|
66
|
+
end
|
67
|
+
@accept.item = item
|
68
|
+
|
69
|
+
respond_to do |format|
|
70
|
+
if @accept.save
|
71
|
+
flash[:message] << t('accept.successfully_accepted', :model => t('activerecord.models.accept'))
|
72
|
+
format.html { redirect_to basket_accepts_url(@basket) }
|
73
|
+
format.json { render :json => @accept, :status => :created, :location => @accept }
|
74
|
+
format.js { redirect_to basket_accepts_url(@basket, :format => :js) }
|
75
|
+
else
|
76
|
+
@accepts = @basket.accepts.paginate(:page => params[:page])
|
77
|
+
format.html { render :action => "index" }
|
78
|
+
format.json { render :json => @accept.errors, :status => :unprocessable_entity }
|
79
|
+
format.js { render :action => "index" }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class Accept < ActiveRecord::Base
|
2
|
+
attr_accessible :item_identifier, :librarian_id, :item_id
|
3
|
+
default_scope :order => 'accepts.id DESC'
|
4
|
+
belongs_to :basket
|
5
|
+
belongs_to :item
|
6
|
+
belongs_to :librarian, :class_name => 'User'
|
7
|
+
|
8
|
+
validates_uniqueness_of :item_id, :message => I18n.t('accept.already_accepted')
|
9
|
+
validates_presence_of :item_id, :message => I18n.t('accept.item_not_found')
|
10
|
+
validates_presence_of :basket_id
|
11
|
+
|
12
|
+
before_save :accept!, :on => :create
|
13
|
+
|
14
|
+
attr_accessor :item_identifier
|
15
|
+
|
16
|
+
def self.per_page
|
17
|
+
10
|
18
|
+
end
|
19
|
+
|
20
|
+
def accept!
|
21
|
+
item.circulation_status = CirculationStatus.where(:name => 'Available On Shelf').first
|
22
|
+
item.save(:validate => false)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
# == Schema Information
|
26
|
+
#
|
27
|
+
# Table name: accepts
|
28
|
+
#
|
29
|
+
# id :integer not null, primary key
|
30
|
+
# basket_id :integer
|
31
|
+
# item_id :integer
|
32
|
+
# librarian_id :integer
|
33
|
+
# created_at :datetime not null
|
34
|
+
# updated_at :datetime not null
|
35
|
+
#
|
36
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
class Basket < ActiveRecord::Base
|
2
|
+
attr_accessible :note, :user_number
|
3
|
+
default_scope :order => 'baskets.id DESC'
|
4
|
+
scope :will_expire, lambda {|date| {:conditions => ['created_at < ?', date]}}
|
5
|
+
belongs_to :user, :validate => true
|
6
|
+
has_many :accepts
|
7
|
+
|
8
|
+
validates_associated :user, :on => :create
|
9
|
+
# 貸出完了後にかごのユーザidは破棄する
|
10
|
+
validates_presence_of :user, :on => :create
|
11
|
+
validate :check_suspended
|
12
|
+
|
13
|
+
attr_accessor :user_number
|
14
|
+
|
15
|
+
def check_suspended
|
16
|
+
if self.user
|
17
|
+
errors[:base] << I18n.t('basket.this_account_is_suspended') if self.user.locked_at?
|
18
|
+
else
|
19
|
+
errors[:base] << I18n.t('user.not_found')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.expire
|
24
|
+
Basket.will_expire(Time.zone.now.beginning_of_day).destroy_all
|
25
|
+
logger.info "#{Time.zone.now} baskets expired!"
|
26
|
+
end
|
27
|
+
|
28
|
+
if defined?(EnjuCirculation)
|
29
|
+
has_many :checked_items, :dependent => :destroy
|
30
|
+
has_many :items, :through => :checked_items
|
31
|
+
has_many :checkouts
|
32
|
+
has_many :checkins
|
33
|
+
|
34
|
+
def basket_checkout(librarian)
|
35
|
+
return nil if checked_items.size == 0
|
36
|
+
Item.transaction do
|
37
|
+
self.checked_items.each do |checked_item|
|
38
|
+
checkout = self.user.checkouts.new
|
39
|
+
checkout.librarian = librarian
|
40
|
+
checkout.item = checked_item.item
|
41
|
+
checkout.basket = self
|
42
|
+
checkout.due_date = checked_item.due_date
|
43
|
+
checked_item.item.checkout!(user)
|
44
|
+
checkout.save!
|
45
|
+
end
|
46
|
+
CheckedItem.destroy_all(:basket_id => id)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# == Schema Information
|
53
|
+
#
|
54
|
+
# Table name: baskets
|
55
|
+
#
|
56
|
+
# id :integer not null, primary key
|
57
|
+
# user_id :integer
|
58
|
+
# note :text
|
59
|
+
# lock_version :integer default(0), not null
|
60
|
+
# created_at :datetime not null
|
61
|
+
# updated_at :datetime not null
|
62
|
+
#
|
63
|
+
|
data/config/routes.rb
CHANGED
@@ -39,4 +39,9 @@ Rails.application.routes.draw do
|
|
39
39
|
resources :checkout_stat_has_users
|
40
40
|
resources :reserve_stat_has_manifestations
|
41
41
|
resources :reserve_stat_has_users
|
42
|
+
|
43
|
+
resources :baskets do
|
44
|
+
resources :accepts, :except => [:edit, :update]
|
45
|
+
end
|
46
|
+
resources :accepts, :except => [:edit, :update]
|
42
47
|
end
|
@@ -1,18 +1,12 @@
|
|
1
1
|
class CreateBaskets < ActiveRecord::Migration
|
2
|
-
def
|
2
|
+
def change
|
3
3
|
create_table :baskets do |t|
|
4
4
|
t.integer :user_id
|
5
5
|
t.text :note
|
6
|
-
t.string :type
|
7
6
|
t.integer :lock_version, :default => 0, :null => false
|
8
7
|
|
9
8
|
t.timestamps
|
10
9
|
end
|
11
10
|
add_index :baskets, :user_id
|
12
|
-
add_index :baskets, :type
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.down
|
16
|
-
drop_table :baskets
|
17
11
|
end
|
18
12
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateAccepts < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :accepts do |t|
|
4
|
+
t.integer :basket_id
|
5
|
+
t.integer :item_id
|
6
|
+
t.integer :librarian_id
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
|
11
|
+
add_index :accepts, :basket_id
|
12
|
+
add_index :accepts, :item_id
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,466 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AcceptsController do
|
4
|
+
fixtures :all
|
5
|
+
|
6
|
+
def mock_user(stubs={})
|
7
|
+
(@mock_user ||= mock_model(Accept).as_null_object).tap do |user|
|
8
|
+
user.stub(stubs) unless stubs.empty?
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "GET index" do
|
13
|
+
describe "When logged in as Administrator" do
|
14
|
+
login_fixture_admin
|
15
|
+
|
16
|
+
it "assigns all accepts as @accepts" do
|
17
|
+
get :index
|
18
|
+
assigns(:accepts).should_not be_nil
|
19
|
+
response.should be_success
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "When basket_id is specified" do
|
23
|
+
it "assigns all accepts as @accepts" do
|
24
|
+
get :index, :basket_id => 10
|
25
|
+
assigns(:accepts).should eq Basket.find(10).accepts.page(1)
|
26
|
+
response.should be_success
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "When logged in as Librarian" do
|
32
|
+
login_fixture_librarian
|
33
|
+
|
34
|
+
it "assigns all accepts as @accepts" do
|
35
|
+
get :index
|
36
|
+
assigns(:accepts).should_not be_nil
|
37
|
+
response.should be_success
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "When basket_id is specified" do
|
41
|
+
it "assigns all accepts as @accepts" do
|
42
|
+
get :index, :basket_id => 9
|
43
|
+
assigns(:accepts).should eq Basket.find(9).accepts.page(1)
|
44
|
+
response.should be_success
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "When logged in as User" do
|
50
|
+
login_fixture_user
|
51
|
+
|
52
|
+
it "should not assign all accepts as @accepts" do
|
53
|
+
get :index
|
54
|
+
assigns(:accepts).should be_nil
|
55
|
+
response.should be_forbidden
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "GET show" do
|
61
|
+
describe "When logged in as Administrator" do
|
62
|
+
login_fixture_admin
|
63
|
+
|
64
|
+
it "assigns the requested accept as @accept" do
|
65
|
+
accept = FactoryGirl.create(:accept)
|
66
|
+
get :show, :id => accept.id
|
67
|
+
assigns(:accept).should eq(accept)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should not show missing accept" do
|
71
|
+
get :show, :id => 'missing'
|
72
|
+
response.should be_missing
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "When logged in as Librarian" do
|
77
|
+
login_fixture_librarian
|
78
|
+
|
79
|
+
it "assigns the requested accept as @accept" do
|
80
|
+
accept = FactoryGirl.create(:accept)
|
81
|
+
get :show, :id => accept.id
|
82
|
+
assigns(:accept).should eq(accept)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "When logged in as User" do
|
87
|
+
login_fixture_user
|
88
|
+
|
89
|
+
it "assigns the requested accept as @accept" do
|
90
|
+
accept = FactoryGirl.create(:accept)
|
91
|
+
get :show, :id => accept.id
|
92
|
+
assigns(:accept).should eq(accept)
|
93
|
+
response.should be_forbidden
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe "When not logged in" do
|
98
|
+
it "assigns the requested accept as @accept" do
|
99
|
+
accept = FactoryGirl.create(:accept)
|
100
|
+
get :show, :id => accept.id
|
101
|
+
assigns(:accept).should eq(accept)
|
102
|
+
response.should redirect_to new_user_session_url
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "GET new" do
|
108
|
+
describe "When logged in as Administrator" do
|
109
|
+
login_fixture_admin
|
110
|
+
|
111
|
+
it "assigns the requested accept as @accept" do
|
112
|
+
get :new
|
113
|
+
assigns(:accept).should_not be_valid
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "When logged in as Librarian" do
|
118
|
+
login_fixture_librarian
|
119
|
+
|
120
|
+
it "assigns the requested accept as @accept" do
|
121
|
+
get :new
|
122
|
+
assigns(:accept).should_not be_valid
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe "When logged in as User" do
|
127
|
+
login_fixture_user
|
128
|
+
|
129
|
+
it "should not assign the requested accept as @accept" do
|
130
|
+
get :new
|
131
|
+
assigns(:accept).should_not be_valid
|
132
|
+
response.should be_forbidden
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
describe "When not logged in" do
|
137
|
+
it "should not assign the requested accept as @accept" do
|
138
|
+
get :new
|
139
|
+
assigns(:accept).should_not be_valid
|
140
|
+
response.should redirect_to(new_user_session_url)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe "GET edit" do
|
146
|
+
describe "When logged in as Administrator" do
|
147
|
+
login_fixture_admin
|
148
|
+
|
149
|
+
it "assigns the requested accept as @accept" do
|
150
|
+
accept = FactoryGirl.create(:accept)
|
151
|
+
get :edit, :id => accept.id
|
152
|
+
assigns(:accept).should eq(accept)
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should not edit missing accept" do
|
156
|
+
get :edit, :id => 'missing'
|
157
|
+
response.should be_missing
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
describe "When logged in as Librarian" do
|
162
|
+
login_fixture_librarian
|
163
|
+
|
164
|
+
it "assigns the requested accept as @accept" do
|
165
|
+
accept = FactoryGirl.create(:accept)
|
166
|
+
get :edit, :id => accept.id
|
167
|
+
assigns(:accept).should eq(accept)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
describe "When logged in as User" do
|
172
|
+
login_fixture_user
|
173
|
+
|
174
|
+
it "assigns the requested accept as @accept" do
|
175
|
+
accept = FactoryGirl.create(:accept)
|
176
|
+
get :edit, :id => accept.id
|
177
|
+
response.should be_forbidden
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
describe "When not logged in" do
|
182
|
+
it "should not assign the requested accept as @accept" do
|
183
|
+
accept = FactoryGirl.create(:accept)
|
184
|
+
get :edit, :id => accept.id
|
185
|
+
response.should redirect_to(new_user_session_url)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
describe "POST create" do
|
191
|
+
before(:each) do
|
192
|
+
@attrs = {:item_identifier => '00003'}
|
193
|
+
@invalid_attrs = {:item_identifier => 'invalid'}
|
194
|
+
end
|
195
|
+
|
196
|
+
describe "When logged in as Administrator" do
|
197
|
+
login_fixture_admin
|
198
|
+
|
199
|
+
describe "with valid params" do
|
200
|
+
it "assigns a newly created accept as @accept" do
|
201
|
+
post :create, :accept => @attrs
|
202
|
+
assigns(:accept).should_not be_valid
|
203
|
+
end
|
204
|
+
|
205
|
+
it "should not create a new accept without basket_id" do
|
206
|
+
post :create, :accept => @attrs
|
207
|
+
response.should be_forbidden
|
208
|
+
end
|
209
|
+
|
210
|
+
describe "When basket_id is specified" do
|
211
|
+
it "redirects to the created accept" do
|
212
|
+
post :create, :accept => @attrs, :basket_id => 9
|
213
|
+
response.should redirect_to(basket_accepts_url(assigns(:accept).basket))
|
214
|
+
assigns(:accept).item.circulation_status.name.should eq 'Available On Shelf'
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
describe "with invalid params" do
|
220
|
+
it "assigns a newly created but unsaved accept as @accept" do
|
221
|
+
post :create, :accept => @invalid_attrs
|
222
|
+
assigns(:accept).should_not be_valid
|
223
|
+
end
|
224
|
+
|
225
|
+
it "should be forbidden" do
|
226
|
+
post :create, :accept => @invalid_attrs
|
227
|
+
response.should be_forbidden
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
it "should not create accept without item_id" do
|
232
|
+
post :create, :accept => {:item_identifier => nil}, :basket_id => 9
|
233
|
+
assigns(:accept).should_not be_valid
|
234
|
+
response.should be_success
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
describe "When logged in as Librarian" do
|
239
|
+
login_fixture_librarian
|
240
|
+
|
241
|
+
describe "with valid params" do
|
242
|
+
it "assigns a newly created accept as @accept" do
|
243
|
+
post :create, :accept => @attrs
|
244
|
+
assigns(:accept).should_not be_valid
|
245
|
+
end
|
246
|
+
|
247
|
+
it "should not create a new accept without basket_id" do
|
248
|
+
post :create, :accept => @attrs
|
249
|
+
response.should be_forbidden
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
describe "When logged in as User" do
|
255
|
+
login_fixture_user
|
256
|
+
|
257
|
+
describe "with valid params" do
|
258
|
+
it "assigns a newly created accept as @accept" do
|
259
|
+
post :create, :accept => @attrs
|
260
|
+
assigns(:accept).should_not be_valid
|
261
|
+
end
|
262
|
+
|
263
|
+
it "should be forbidden" do
|
264
|
+
post :create, :accept => @attrs
|
265
|
+
response.should be_forbidden
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
describe "When not logged in" do
|
271
|
+
before(:each) do
|
272
|
+
@attrs = {:item_identifier => '00003'}
|
273
|
+
@invalid_attrs = {:item_identifier => 'invalid'}
|
274
|
+
end
|
275
|
+
|
276
|
+
describe "with valid params" do
|
277
|
+
it "assigns a newly created accept as @accept" do
|
278
|
+
post :create, :accept => @attrs
|
279
|
+
end
|
280
|
+
|
281
|
+
it "should redirect to new session url" do
|
282
|
+
post :create, :accept => @attrs
|
283
|
+
response.should redirect_to new_user_session_url
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
describe "PUT update" do
|
290
|
+
before(:each) do
|
291
|
+
@accept = FactoryGirl.create(:accept)
|
292
|
+
@attrs = {:item_identifier => @accept.item.item_identifier, :librarian_id => FactoryGirl.create(:librarian).id}
|
293
|
+
@invalid_attrs = {:item_id => ''}
|
294
|
+
end
|
295
|
+
|
296
|
+
describe "When logged in as Administrator" do
|
297
|
+
login_fixture_admin
|
298
|
+
|
299
|
+
describe "with valid params" do
|
300
|
+
it "updates the requested accept" do
|
301
|
+
put :update, :id => @accept.id, :accept => @attrs
|
302
|
+
end
|
303
|
+
|
304
|
+
it "assigns the requested accept as @accept" do
|
305
|
+
put :update, :id => @accept.id, :accept => @attrs
|
306
|
+
assigns(:accept).should eq(@accept)
|
307
|
+
response.should redirect_to(@accept)
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
describe "with invalid params" do
|
312
|
+
it "assigns the requested accept as @accept" do
|
313
|
+
put :update, :id => @accept.id, :accept => @invalid_attrs
|
314
|
+
end
|
315
|
+
|
316
|
+
it "re-renders the 'edit' template" do
|
317
|
+
put :update, :id => @accept.id, :accept => @invalid_attrs
|
318
|
+
response.should render_template("edit")
|
319
|
+
end
|
320
|
+
|
321
|
+
it "should not update accept without item_id" do
|
322
|
+
put :update, :id => @accept.id, :accept => @attrs.merge(:item_id => nil)
|
323
|
+
assigns(:accept).should_not be_valid
|
324
|
+
response.should be_success
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
it "should not update missing accept" do
|
329
|
+
put :update, :id => 'missing', :accept => { }
|
330
|
+
response.should be_missing
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
describe "When logged in as Librarian" do
|
335
|
+
login_fixture_librarian
|
336
|
+
|
337
|
+
describe "with valid params" do
|
338
|
+
it "updates the requested accept" do
|
339
|
+
put :update, :id => @accept.id, :accept => @attrs
|
340
|
+
end
|
341
|
+
|
342
|
+
it "assigns the requested accept as @accept" do
|
343
|
+
put :update, :id => @accept.id, :accept => @attrs
|
344
|
+
assigns(:accept).should eq(@accept)
|
345
|
+
response.should redirect_to(@accept)
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
describe "with invalid params" do
|
350
|
+
it "assigns the accept as @accept" do
|
351
|
+
put :update, :id => @accept.id, :accept => @invalid_attrs
|
352
|
+
assigns(:accept).should_not be_valid
|
353
|
+
end
|
354
|
+
|
355
|
+
it "re-renders the 'edit' template" do
|
356
|
+
put :update, :id => @accept.id, :accept => @invalid_attrs
|
357
|
+
response.should render_template("edit")
|
358
|
+
end
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
describe "When logged in as User" do
|
363
|
+
login_fixture_user
|
364
|
+
|
365
|
+
describe "with valid params" do
|
366
|
+
it "updates the requested accept" do
|
367
|
+
put :update, :id => @accept.id, :accept => @attrs
|
368
|
+
end
|
369
|
+
|
370
|
+
it "assigns the requested accept as @accept" do
|
371
|
+
put :update, :id => @accept.id, :accept => @attrs
|
372
|
+
assigns(:accept).should eq(@accept)
|
373
|
+
response.should be_forbidden
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
describe "with invalid params" do
|
378
|
+
it "assigns the requested accept as @accept" do
|
379
|
+
put :update, :id => @accept.id, :accept => @invalid_attrs
|
380
|
+
response.should be_forbidden
|
381
|
+
end
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
describe "When not logged in" do
|
386
|
+
describe "with valid params" do
|
387
|
+
it "updates the requested accept" do
|
388
|
+
put :update, :id => @accept.id, :accept => @attrs
|
389
|
+
end
|
390
|
+
|
391
|
+
it "should be forbidden" do
|
392
|
+
put :update, :id => @accept.id, :accept => @attrs
|
393
|
+
response.should redirect_to(new_user_session_url)
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
397
|
+
describe "with invalid params" do
|
398
|
+
it "assigns the requested accept as @accept" do
|
399
|
+
put :update, :id => @accept.id, :accept => @invalid_attrs
|
400
|
+
response.should redirect_to(new_user_session_url)
|
401
|
+
end
|
402
|
+
end
|
403
|
+
end
|
404
|
+
end
|
405
|
+
|
406
|
+
describe "DELETE destroy" do
|
407
|
+
before(:each) do
|
408
|
+
@accept = FactoryGirl.create(:accept)
|
409
|
+
end
|
410
|
+
|
411
|
+
describe "When logged in as Administrator" do
|
412
|
+
login_fixture_admin
|
413
|
+
|
414
|
+
it "destroys the requested accept" do
|
415
|
+
delete :destroy, :id => @accept.id
|
416
|
+
end
|
417
|
+
|
418
|
+
it "redirects to the accepts list" do
|
419
|
+
delete :destroy, :id => @accept.id
|
420
|
+
response.should redirect_to(accepts_url)
|
421
|
+
end
|
422
|
+
|
423
|
+
it "should not destroy missing accept" do
|
424
|
+
delete :destroy, :id => 'missing'
|
425
|
+
response.should be_missing
|
426
|
+
end
|
427
|
+
end
|
428
|
+
|
429
|
+
describe "When logged in as Librarian" do
|
430
|
+
login_fixture_librarian
|
431
|
+
|
432
|
+
it "destroys the requested accept" do
|
433
|
+
delete :destroy, :id => @accept.id
|
434
|
+
end
|
435
|
+
|
436
|
+
it "redirects to the accepts list" do
|
437
|
+
delete :destroy, :id => @accept.id
|
438
|
+
response.should redirect_to(accepts_url)
|
439
|
+
end
|
440
|
+
end
|
441
|
+
|
442
|
+
describe "When logged in as User" do
|
443
|
+
login_fixture_user
|
444
|
+
|
445
|
+
it "destroys the requested accept" do
|
446
|
+
delete :destroy, :id => @accept.id
|
447
|
+
end
|
448
|
+
|
449
|
+
it "should be forbidden" do
|
450
|
+
delete :destroy, :id => @accept.id
|
451
|
+
response.should be_forbidden
|
452
|
+
end
|
453
|
+
end
|
454
|
+
|
455
|
+
describe "When not logged in" do
|
456
|
+
it "destroys the requested accept" do
|
457
|
+
delete :destroy, :id => @accept.id
|
458
|
+
end
|
459
|
+
|
460
|
+
it "should be forbidden" do
|
461
|
+
delete :destroy, :id => @accept.id
|
462
|
+
response.should redirect_to(new_user_session_url)
|
463
|
+
end
|
464
|
+
end
|
465
|
+
end
|
466
|
+
end
|
@@ -0,0 +1,379 @@
|
|
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
|
@@ -5,6 +5,7 @@ class Ability
|
|
5
5
|
case user.try(:role).try(:name)
|
6
6
|
when 'Administrator'
|
7
7
|
can :manage, [
|
8
|
+
Accept,
|
8
9
|
Basket,
|
9
10
|
CarrierTypeHasCheckoutType,
|
10
11
|
CheckedItem,
|
@@ -42,6 +43,7 @@ class Ability
|
|
42
43
|
end
|
43
44
|
when 'Librarian'
|
44
45
|
can :manage, [
|
46
|
+
Accept,
|
45
47
|
Basket,
|
46
48
|
CheckedItem,
|
47
49
|
Checkin,
|
@@ -0,0 +1,63 @@
|
|
1
|
+
class Basket < ActiveRecord::Base
|
2
|
+
attr_accessible :note, :user_number
|
3
|
+
default_scope :order => 'baskets.id DESC'
|
4
|
+
scope :will_expire, lambda {|date| {:conditions => ['created_at < ?', date]}}
|
5
|
+
belongs_to :user, :validate => true
|
6
|
+
has_many :accepts
|
7
|
+
|
8
|
+
validates_associated :user, :on => :create
|
9
|
+
# 貸出完了後にかごのユーザidは破棄する
|
10
|
+
validates_presence_of :user, :on => :create
|
11
|
+
validate :check_suspended
|
12
|
+
|
13
|
+
attr_accessor :user_number
|
14
|
+
|
15
|
+
def check_suspended
|
16
|
+
if self.user
|
17
|
+
errors[:base] << I18n.t('basket.this_account_is_suspended') if self.user.locked_at?
|
18
|
+
else
|
19
|
+
errors[:base] << I18n.t('user.not_found')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.expire
|
24
|
+
Basket.will_expire(Time.zone.now.beginning_of_day).destroy_all
|
25
|
+
logger.info "#{Time.zone.now} baskets expired!"
|
26
|
+
end
|
27
|
+
|
28
|
+
if defined?(EnjuCirculation)
|
29
|
+
has_many :checked_items, :dependent => :destroy
|
30
|
+
has_many :items, :through => :checked_items
|
31
|
+
has_many :checkouts
|
32
|
+
has_many :checkins
|
33
|
+
|
34
|
+
def basket_checkout(librarian)
|
35
|
+
return nil if checked_items.size == 0
|
36
|
+
Item.transaction do
|
37
|
+
self.checked_items.each do |checked_item|
|
38
|
+
checkout = self.user.checkouts.new
|
39
|
+
checkout.librarian = librarian
|
40
|
+
checkout.item = checked_item.item
|
41
|
+
checkout.basket = self
|
42
|
+
checkout.due_date = checked_item.due_date
|
43
|
+
checked_item.item.checkout!(user)
|
44
|
+
checkout.save!
|
45
|
+
end
|
46
|
+
CheckedItem.destroy_all(:basket_id => id)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# == Schema Information
|
53
|
+
#
|
54
|
+
# Table name: baskets
|
55
|
+
#
|
56
|
+
# id :integer not null, primary key
|
57
|
+
# user_id :integer
|
58
|
+
# note :text
|
59
|
+
# lock_version :integer default(0), not null
|
60
|
+
# created_at :datetime not null
|
61
|
+
# updated_at :datetime not null
|
62
|
+
#
|
63
|
+
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -13,16 +13,25 @@
|
|
13
13
|
|
14
14
|
ActiveRecord::Schema.define(:version => 20120424103932) do
|
15
15
|
|
16
|
+
create_table "accepts", :force => true do |t|
|
17
|
+
t.integer "basket_id"
|
18
|
+
t.integer "item_id"
|
19
|
+
t.integer "librarian_id"
|
20
|
+
t.datetime "created_at", :null => false
|
21
|
+
t.datetime "updated_at", :null => false
|
22
|
+
end
|
23
|
+
|
24
|
+
add_index "accepts", ["basket_id"], :name => "index_accepts_on_basket_id"
|
25
|
+
add_index "accepts", ["item_id"], :name => "index_accepts_on_item_id"
|
26
|
+
|
16
27
|
create_table "baskets", :force => true do |t|
|
17
28
|
t.integer "user_id"
|
18
29
|
t.text "note"
|
19
|
-
t.string "type"
|
20
30
|
t.integer "lock_version", :default => 0, :null => false
|
21
31
|
t.datetime "created_at", :null => false
|
22
32
|
t.datetime "updated_at", :null => false
|
23
33
|
end
|
24
34
|
|
25
|
-
add_index "baskets", ["type"], :name => "index_baskets_on_type"
|
26
35
|
add_index "baskets", ["user_id"], :name => "index_baskets_on_user_id"
|
27
36
|
|
28
37
|
create_table "carrier_type_has_checkout_types", :force => true do |t|
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Accept do
|
4
|
+
fixtures :all
|
5
|
+
|
6
|
+
it "should change circulation_status" do
|
7
|
+
accept = FactoryGirl.create(:accept)
|
8
|
+
accept.item.circulation_status.name.should eq 'Available On Shelf'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
# == Schema Information
|
12
|
+
#
|
13
|
+
# Table name: accepts
|
14
|
+
#
|
15
|
+
# id :integer not null, primary key
|
16
|
+
# basket_id :integer
|
17
|
+
# item_id :integer
|
18
|
+
# librarian_id :integer
|
19
|
+
# created_at :datetime not null
|
20
|
+
# updated_at :datetime not null
|
21
|
+
#
|
22
|
+
|
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.49
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -322,6 +322,7 @@ executables: []
|
|
322
322
|
extensions: []
|
323
323
|
extra_rdoc_files: []
|
324
324
|
files:
|
325
|
+
- app/controllers/accepts_controller.rb
|
325
326
|
- app/controllers/baskets_controller.rb
|
326
327
|
- app/controllers/carrier_type_has_checkout_types_controller.rb
|
327
328
|
- app/controllers/checked_items_controller.rb
|
@@ -343,6 +344,8 @@ files:
|
|
343
344
|
- app/controllers/user_group_has_checkout_types_controller.rb
|
344
345
|
- app/controllers/user_reserve_stats_controller.rb
|
345
346
|
- app/helpers/reserves_helper.rb
|
347
|
+
- app/models/accept.rb
|
348
|
+
- app/models/basket.rb
|
346
349
|
- app/models/carrier_type_has_checkout_type.rb
|
347
350
|
- app/models/checked_item.rb
|
348
351
|
- app/models/checkin.rb
|
@@ -496,6 +499,7 @@ files:
|
|
496
499
|
- db/migrate/032_create_checkins.rb
|
497
500
|
- db/migrate/033_create_checkouts.rb
|
498
501
|
- db/migrate/035_create_reserves.rb
|
502
|
+
- db/migrate/120_create_baskets.rb
|
499
503
|
- db/migrate/121_create_checked_items.rb
|
500
504
|
- db/migrate/127_create_use_restrictions.rb
|
501
505
|
- db/migrate/129_create_item_has_use_restrictions.rb
|
@@ -520,6 +524,7 @@ files:
|
|
520
524
|
- db/migrate/20110627122938_add_number_of_day_to_notify_overdue_to_user_group.rb
|
521
525
|
- db/migrate/20111217234412_add_save_checkout_history_to_user.rb
|
522
526
|
- db/migrate/20111218002349_add_checkout_icalendar_token_to_user.rb
|
527
|
+
- db/migrate/20120319173203_create_accepts.rb
|
523
528
|
- db/migrate/20120424103932_add_librarian_id_to_checked_item.rb
|
524
529
|
- lib/enju_circulation/controller.rb
|
525
530
|
- lib/enju_circulation/engine.rb
|
@@ -530,6 +535,8 @@ files:
|
|
530
535
|
- MIT-LICENSE
|
531
536
|
- Rakefile
|
532
537
|
- README.rdoc
|
538
|
+
- spec/controllers/accepts_controller_spec.rb
|
539
|
+
- spec/controllers/baskets_controller_spec.rb
|
533
540
|
- spec/controllers/carrier_type_has_checkout_types_controller_spec.rb
|
534
541
|
- spec/controllers/checked_items_controller_spec.rb
|
535
542
|
- spec/controllers/checkins_controller_spec.rb
|
@@ -556,6 +563,7 @@ files:
|
|
556
563
|
- spec/dummy/app/helpers/application_helper.rb
|
557
564
|
- spec/dummy/app/mailers/notifier.rb
|
558
565
|
- spec/dummy/app/models/ability.rb
|
566
|
+
- spec/dummy/app/models/basket.rb
|
559
567
|
- spec/dummy/app/models/role.rb
|
560
568
|
- spec/dummy/app/models/user.rb
|
561
569
|
- spec/dummy/app/models/user_group.rb
|
@@ -601,7 +609,6 @@ files:
|
|
601
609
|
- spec/dummy/db/migrate/080_create_library_groups.rb
|
602
610
|
- spec/dummy/db/migrate/113_create_events.rb
|
603
611
|
- spec/dummy/db/migrate/114_create_event_categories.rb
|
604
|
-
- spec/dummy/db/migrate/120_create_baskets.rb
|
605
612
|
- spec/dummy/db/migrate/125_create_donates.rb
|
606
613
|
- spec/dummy/db/migrate/130_create_request_status_types.rb
|
607
614
|
- spec/dummy/db/migrate/131_create_request_types.rb
|
@@ -686,6 +693,7 @@ files:
|
|
686
693
|
- spec/dummy/solr/data/test/index/segments_1
|
687
694
|
- spec/dummy/solr/data/test/spellchecker/segments.gen
|
688
695
|
- spec/dummy/solr/data/test/spellchecker/segments_1
|
696
|
+
- spec/factories/accepts.rb
|
689
697
|
- spec/factories/basket.rb
|
690
698
|
- spec/factories/carrier_type.rb
|
691
699
|
- spec/factories/carrier_type_has_checkout_type.rb
|
@@ -749,6 +757,7 @@ files:
|
|
749
757
|
- spec/fixtures/user_has_roles.yml
|
750
758
|
- spec/fixtures/user_reserve_stats.yml
|
751
759
|
- spec/fixtures/users.yml
|
760
|
+
- spec/models/accept_spec.rb
|
752
761
|
- spec/models/basket_spec.rb
|
753
762
|
- spec/models/carrier_type_has_checkout_type_spec.rb
|
754
763
|
- spec/models/checked_item_spec.rb
|
@@ -765,6 +774,7 @@ files:
|
|
765
774
|
- spec/models/reserve_spec.rb
|
766
775
|
- spec/models/reserve_stat_has_manifestation_spec.rb
|
767
776
|
- spec/models/reserve_stat_has_user_spec.rb
|
777
|
+
- spec/models/use_resetriction_spec.rb
|
768
778
|
- spec/models/user_checkout_stat_spec.rb
|
769
779
|
- spec/models/user_group_has_checkout_type_spec.rb
|
770
780
|
- spec/models/user_reserve_stat_spec.rb
|
@@ -797,6 +807,8 @@ signing_key:
|
|
797
807
|
specification_version: 3
|
798
808
|
summary: enju_circulation plugin
|
799
809
|
test_files:
|
810
|
+
- spec/controllers/accepts_controller_spec.rb
|
811
|
+
- spec/controllers/baskets_controller_spec.rb
|
800
812
|
- spec/controllers/carrier_type_has_checkout_types_controller_spec.rb
|
801
813
|
- spec/controllers/checked_items_controller_spec.rb
|
802
814
|
- spec/controllers/checkins_controller_spec.rb
|
@@ -823,6 +835,7 @@ test_files:
|
|
823
835
|
- spec/dummy/app/helpers/application_helper.rb
|
824
836
|
- spec/dummy/app/mailers/notifier.rb
|
825
837
|
- spec/dummy/app/models/ability.rb
|
838
|
+
- spec/dummy/app/models/basket.rb
|
826
839
|
- spec/dummy/app/models/role.rb
|
827
840
|
- spec/dummy/app/models/user.rb
|
828
841
|
- spec/dummy/app/models/user_group.rb
|
@@ -868,7 +881,6 @@ test_files:
|
|
868
881
|
- spec/dummy/db/migrate/080_create_library_groups.rb
|
869
882
|
- spec/dummy/db/migrate/113_create_events.rb
|
870
883
|
- spec/dummy/db/migrate/114_create_event_categories.rb
|
871
|
-
- spec/dummy/db/migrate/120_create_baskets.rb
|
872
884
|
- spec/dummy/db/migrate/125_create_donates.rb
|
873
885
|
- spec/dummy/db/migrate/130_create_request_status_types.rb
|
874
886
|
- spec/dummy/db/migrate/131_create_request_types.rb
|
@@ -953,6 +965,7 @@ test_files:
|
|
953
965
|
- spec/dummy/solr/data/test/index/segments_1
|
954
966
|
- spec/dummy/solr/data/test/spellchecker/segments.gen
|
955
967
|
- spec/dummy/solr/data/test/spellchecker/segments_1
|
968
|
+
- spec/factories/accepts.rb
|
956
969
|
- spec/factories/basket.rb
|
957
970
|
- spec/factories/carrier_type.rb
|
958
971
|
- spec/factories/carrier_type_has_checkout_type.rb
|
@@ -1016,6 +1029,7 @@ test_files:
|
|
1016
1029
|
- spec/fixtures/user_has_roles.yml
|
1017
1030
|
- spec/fixtures/user_reserve_stats.yml
|
1018
1031
|
- spec/fixtures/users.yml
|
1032
|
+
- spec/models/accept_spec.rb
|
1019
1033
|
- spec/models/basket_spec.rb
|
1020
1034
|
- spec/models/carrier_type_has_checkout_type_spec.rb
|
1021
1035
|
- spec/models/checked_item_spec.rb
|
@@ -1032,6 +1046,7 @@ test_files:
|
|
1032
1046
|
- spec/models/reserve_spec.rb
|
1033
1047
|
- spec/models/reserve_stat_has_manifestation_spec.rb
|
1034
1048
|
- spec/models/reserve_stat_has_user_spec.rb
|
1049
|
+
- spec/models/use_resetriction_spec.rb
|
1035
1050
|
- spec/models/user_checkout_stat_spec.rb
|
1036
1051
|
- spec/models/user_group_has_checkout_type_spec.rb
|
1037
1052
|
- spec/models/user_reserve_stat_spec.rb
|