shop_bunny 0.7.4.5 → 0.7.4.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,6 +8,10 @@ class CartItem < ActiveRecord::Base
8
8
 
9
9
  before_validation :set_default_quantity
10
10
  after_update :destroy_if_empty
11
+
12
+ after_save :touch_cart
13
+ after_destroy :touch_cart
14
+
11
15
  # TODO attr_accessible :quantity
12
16
 
13
17
  def total_price
@@ -23,4 +27,9 @@ class CartItem < ActiveRecord::Base
23
27
  def destroy_if_empty
24
28
  self.destroy if quantity.to_i <= 0
25
29
  end
30
+
31
+ protected
32
+ def touch_cart
33
+ cart.touch if cart
34
+ end
26
35
  end
data/app/models/coupon.rb CHANGED
@@ -6,6 +6,9 @@ class Coupon < ActiveRecord::Base
6
6
  validates_uniqueness_of :code
7
7
  validates_presence_of :title
8
8
 
9
+ after_save :touch_cart
10
+ after_destroy :touch_cart
11
+
9
12
  # TODO Add self destruction when coupon has expired?
10
13
 
11
14
  def expired?
@@ -20,4 +23,9 @@ class Coupon < ActiveRecord::Base
20
23
  def has_expired?
21
24
  Time.now > self.valid_until if self.valid_until
22
25
  end
26
+
27
+ protected
28
+ def touch_cart
29
+ carts.each {|cart| cart.touch}
30
+ end
23
31
  end
@@ -4,4 +4,12 @@ class CouponUse < ActiveRecord::Base
4
4
 
5
5
  validates_presence_of :cart_id
6
6
  validates_presence_of :coupon_id
7
+
8
+ after_save :touch_cart
9
+ after_destroy :touch_cart
10
+
11
+ protected
12
+ def touch_cart
13
+ cart.touch if cart
14
+ end
7
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shop_bunny
3
3
  version: !ruby/object:Gem::Version
4
- hash: 109
4
+ hash: 107
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
9
  - 4
10
- - 5
11
- version: 0.7.4.5
10
+ - 6
11
+ version: 0.7.4.6
12
12
  platform: ruby
13
13
  authors:
14
14
  - kopfmaschine.com
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-10-27 00:00:00 +02:00
19
+ date: 2010-11-04 00:00:00 +01:00
20
20
  default_executable:
21
21
  dependencies: []
22
22
 
@@ -30,32 +30,32 @@ extensions: []
30
30
  extra_rdoc_files: []
31
31
 
32
32
  files:
33
- - lib/generators/shop_bunny/templates/shopbunny_model_template.rb
34
- - lib/generators/shop_bunny/templates/shopbunny_controller_template.rb
35
33
  - lib/generators/shop_bunny/install_generator.rb
36
- - lib/shop_bunny.rb
34
+ - lib/generators/shop_bunny/templates/shopbunny_controller_template.rb
35
+ - lib/generators/shop_bunny/templates/shopbunny_model_template.rb
37
36
  - lib/shop_bunny/cart_controller_module.rb
38
37
  - lib/shop_bunny/cart_module.rb
39
- - lib/shop_bunny/shipping_cost_calculator.rb
40
38
  - lib/shop_bunny/engine.rb
41
- - app/views/carts/show.html.erb
39
+ - lib/shop_bunny/shipping_cost_calculator.rb
40
+ - lib/shop_bunny.rb
41
+ - app/controllers/application_controller.rb
42
+ - app/controllers/carts_controller.rb
42
43
  - app/models/cart.rb
43
- - app/models/coupon_use.rb
44
44
  - app/models/cart_item.rb
45
45
  - app/models/coupon.rb
46
+ - app/models/coupon_use.rb
46
47
  - app/models/item.rb
47
- - app/controllers/application_controller.rb
48
- - app/controllers/carts_controller.rb
49
- - db/migrate/20100915162029_remove_owner_id_from_carts.rb
50
- - db/migrate/20100915091059_create_coupons.rb
51
- - db/migrate/20100915073016_create_items.rb
48
+ - app/views/carts/show.html.erb
52
49
  - db/migrate/20100902115627_create_carts.rb
50
+ - db/migrate/20100902115757_create_cart_items.rb
51
+ - db/migrate/20100915073016_create_items.rb
52
+ - db/migrate/20100915091059_create_coupons.rb
53
53
  - db/migrate/20100915093821_create_coupon_uses.rb
54
+ - db/migrate/20100915162029_remove_owner_id_from_carts.rb
54
55
  - db/migrate/20100916194407_set_default_column_value_for_cart_items_quantity.rb
55
- - db/migrate/20100902115757_create_cart_items.rb
56
56
  - config/initializers/add_cart_finder_to_controllers.rb
57
- - config/initializers/shop_bunny.rb
58
57
  - config/initializers/machinist.rb
58
+ - config/initializers/shop_bunny.rb
59
59
  - config/routes.rb
60
60
  has_rdoc: true
61
61
  homepage: http://kopfmaschine.com