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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f85f11cafab5fc9f037e657dbbdcbd035445d530
|
4
|
+
data.tar.gz: cdbe305d67dd94f1123dfa266a60cf87c951e541
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 214a68adaac36287bc20b766e8fce424f3064b97942628099cffb7ede9ff3acaba7f9d01242653d79eab09d1349dd363cf4be2257a9ef759293ef162477943aa
|
7
|
+
data.tar.gz: 71106c56751b7a8d41517fff58806123a8e6669af43a745720c074f374b979ddf042ff06f42349ef72e1b2a3e61b4d731229261c867b6fa18e07ca02d166b994
|
data/README.markdown
CHANGED
@@ -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
|
-
|
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
|
|
@@ -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
|
-
|
30
|
-
subject.
|
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.
|
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-
|
11
|
+
date: 2014-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|