enju_circulation 0.0.64 → 0.0.65

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.
@@ -2,6 +2,7 @@ class Checkout < ActiveRecord::Base
2
2
  attr_accessible :due_date
3
3
  default_scope :order => 'checkouts.id DESC'
4
4
  scope :not_returned, where(:checkin_id => nil)
5
+ scope :returned, where('checkin_id IS NOT NULL')
5
6
  scope :overdue, lambda {|date| {:conditions => ['checkin_id IS NULL AND due_date < ?', date]}}
6
7
  scope :due_date_on, lambda {|date| where(:checkin_id => nil, :due_date => date.beginning_of_day .. date.end_of_day)}
7
8
  scope :completed, lambda {|start_date, end_date| {:conditions => ['created_at >= ? AND created_at < ?', start_date, end_date]}}
@@ -108,7 +109,7 @@ class Checkout < ActiveRecord::Base
108
109
  end
109
110
 
110
111
  def self.remove_all_history(user)
111
- user.checkouts.update_all(:user_id => nil)
112
+ user.checkouts.returned.update_all(:user_id => nil)
112
113
  end
113
114
  end
114
115
  # == Schema Information
@@ -53,7 +53,7 @@
53
53
  </ul>
54
54
  <ul>
55
55
  <% if @user == current_user %>
56
- <li><%= link_to t('checkout.remove_all_history'), remove_all_user_checkouts_path(current_user), :method => :put %></li>
56
+ <li><%= link_to t('checkout.remove_all_history'), remove_all_user_checkouts_path(current_user), :method => :put, :data => {:confirm => t('page.are_you_sure')} %></li>
57
57
  <% end %>
58
58
  </ul>
59
59
  </div>
@@ -1,3 +1,3 @@
1
1
  module EnjuCirculation
2
- VERSION = "0.0.64"
2
+ VERSION = "0.0.65"
3
3
  end
@@ -276,13 +276,13 @@ describe CheckoutsController do
276
276
 
277
277
  it "should remove its own checkout history" do
278
278
  put :remove_all, :user_id => users(:user1).username
279
- users(:user1).checkouts.count.should eq 0
279
+ users(:user1).checkouts.returned.count.should eq 0
280
280
  response.should redirect_to checkouts_url
281
281
  end
282
282
 
283
283
  it "should not remove other checkout history" do
284
284
  put :remove_all, :user_id => users(:user2).username
285
- users(:user1).checkouts.count.should_not eq 0
285
+ users(:user1).checkouts.returned.count.should_not eq 0
286
286
  response.should redirect_to checkouts_url
287
287
  end
288
288
  end
@@ -327,13 +327,13 @@ describe CheckoutsController do
327
327
 
328
328
  it "should remove its own checkout history" do
329
329
  put :remove_all, :user_id => users(:user1).username
330
- users(:user1).checkouts.count.should eq 0
330
+ users(:user1).checkouts.returned.count.should eq 0
331
331
  response.should redirect_to checkouts_url
332
332
  end
333
333
 
334
334
  it "should not remove other checkout history" do
335
335
  put :remove_all, :user_id => users(:user2).username
336
- users(:user1).checkouts.count.should_not eq 0
336
+ users(:user1).checkouts.returned.count.should_not eq 0
337
337
  response.should redirect_to checkouts_url
338
338
  end
339
339
  end
@@ -386,13 +386,13 @@ describe CheckoutsController do
386
386
 
387
387
  it "should remove its own checkout history" do
388
388
  put :remove_all, :user_id => users(:user1).username
389
- assigns(:user).checkouts.count.should eq 0
389
+ assigns(:user).checkouts.returned.count.should eq 0
390
390
  response.should redirect_to checkouts_url
391
391
  end
392
392
 
393
393
  it "should not remove other checkout history" do
394
394
  put :remove_all, :user_id => users(:admin).username
395
- assigns(:user).checkouts.count.should_not eq 0
395
+ assigns(:user).checkouts.returned.count.should eq 0
396
396
  response.should be_forbidden
397
397
  end
398
398
  end
Binary file
@@ -51,7 +51,7 @@ describe Checkout do
51
51
  user = users(:user1)
52
52
  old_count = Checkout.count
53
53
  Checkout.remove_all_history(user)
54
- user.checkouts.count.should eq 0
54
+ user.checkouts.returned.count.should eq 0
55
55
  Checkout.count.should eq old_count
56
56
  end
57
57
  end
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.64
4
+ version: 0.0.65
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-06-21 00:00:00.000000000 Z
12
+ date: 2012-06-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails