acts_as_shopping_cart 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d1c0cb2370eaa3b579d60ae4266f669c5097e26
4
- data.tar.gz: 61bd638bf43e19ff378853c5cdcb00d620c6fc4b
3
+ metadata.gz: f85f11cafab5fc9f037e657dbbdcbd035445d530
4
+ data.tar.gz: cdbe305d67dd94f1123dfa266a60cf87c951e541
5
5
  SHA512:
6
- metadata.gz: a7ce22ce2f4555495b831de51985d7ea1c7e25a3c9366197ec46d4a9e366b02fce138fbe683d57f53d5b57286be1342e670e88f686f629de077d9b96067f5d0a
7
- data.tar.gz: 620c1e16107dabbf77774abf203ab309dd72c65b0a4cf5e867004e94a03184364735714c8566d5e97f714c33af11924c915fc8f8812a7b5bd8cfbf99cad21266
6
+ metadata.gz: 214a68adaac36287bc20b766e8fce424f3064b97942628099cffb7ede9ff3acaba7f9d01242653d79eab09d1349dd363cf4be2257a9ef759293ef162477943aa
7
+ data.tar.gz: 71106c56751b7a8d41517fff58806123a8e6669af43a745720c074f374b979ddf042ff06f42349ef72e1b2a3e61b4d731229261c867b6fa18e07ca02d166b994
data/README.markdown CHANGED
@@ -25,7 +25,7 @@ And run bundler
25
25
 
26
26
  Just include it in your Gemfile as:
27
27
 
28
- gem 'acts_as_shopping_cart', '~> 0.2.0'
28
+ gem 'acts_as_shopping_cart', '~> 0.2.1'
29
29
 
30
30
  And run bundle install
31
31
 
@@ -8,12 +8,13 @@ module ActiveRecord
8
8
  def add(object, price, quantity = 1, cumulative = true)
9
9
  cart_item = item_for(object)
10
10
 
11
- unless cart_item
12
- shopping_cart_items.create(:item => object, :price => price, :quantity => quantity)
13
- else
11
+ if cart_item
14
12
  cumulative = cumulative == true ? cart_item.quantity : 0
15
13
  cart_item.quantity = (cumulative + quantity)
16
14
  cart_item.save
15
+ cart_item
16
+ else
17
+ shopping_cart_items.create(item: object, price: price, quantity: quantity)
17
18
  end
18
19
  end
19
20
 
@@ -1,3 +1,3 @@
1
1
  module ActsAsShoppingCart
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -26,8 +26,12 @@ describe ActiveRecord::Acts::ShoppingCart::Collection do
26
26
  end
27
27
 
28
28
  it "creates a new shopping cart item" do
29
- subject.shopping_cart_items.should_receive(:create).with(:item => object, :price => 19.99, :quantity => 3)
30
- subject.add(object, 19.99, 3)
29
+ created_object = mock
30
+ subject.shopping_cart_items.should_receive(:create).
31
+ with(:item => object, :price => 19.99, :quantity => 3).
32
+ and_return(created_object)
33
+ item = subject.add(object, 19.99, 3)
34
+ item.should be created_object
31
35
  end
32
36
  end
33
37
 
@@ -49,7 +53,8 @@ describe ActiveRecord::Acts::ShoppingCart::Collection do
49
53
 
50
54
  it "updates the quantity for the item" do
51
55
  shopping_cart_item.should_receive(:quantity=).with(5)
52
- subject.add(object, 19.99, 3)
56
+ item = subject.add(object, 19.99, 3)
57
+ item.should be shopping_cart_item
53
58
  end
54
59
  end
55
60
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_shopping_cart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Padilla
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-11 00:00:00.000000000 Z
11
+ date: 2014-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord