shop_bunny 0.8.6 → 0.8.8
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/shop_bunny/coupon_use.rb +1 -0
- data/db/migrate/20120315145137_index_to_coupon_use_coupon_id_and_cart_id.rb +10 -0
- data/lib/shop_bunny/cart_controller_module.rb +14 -10
- data/lib/shop_bunny/cart_module.rb +12 -2
- data/lib/shop_bunny/version.rb +1 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +3 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +99 -0
- data/spec/dummy/log/test.log +32885 -0
- data/spec/models/cart_spec.rb +10 -19
- data/spec/models/shop_bunny/coupon_use_spec.rb +10 -1
- metadata +26 -17
data/spec/models/cart_spec.rb
CHANGED
@@ -51,21 +51,18 @@ describe Cart do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
describe "adding coupons using #coupons<<" do
|
54
|
-
it "adds a coupon
|
54
|
+
it "adds a coupon" do
|
55
55
|
coupon = Coupon.make
|
56
|
-
|
56
|
+
expect {
|
57
57
|
@cart.coupons << coupon
|
58
|
-
}
|
59
|
-
add_a_coupon.should change { @cart.coupons.count }.by(1)
|
60
|
-
add_a_coupon.should change { CouponUse.count }.by(1)
|
58
|
+
}.to change { @cart.coupons.count }.by(1)
|
61
59
|
end
|
62
60
|
|
63
|
-
it "
|
61
|
+
it "creates a CouponUse" do
|
64
62
|
coupon = Coupon.make
|
65
|
-
|
66
|
-
@cart.coupons << coupon
|
63
|
+
expect {
|
67
64
|
@cart.coupons << coupon
|
68
|
-
}.
|
65
|
+
}.to change { CouponUse.count }.by(1)
|
69
66
|
end
|
70
67
|
end
|
71
68
|
|
@@ -134,9 +131,9 @@ describe Cart do
|
|
134
131
|
end
|
135
132
|
|
136
133
|
it "with max_uses=1 via coupon_code= should not invalidate the cart" do
|
137
|
-
coupon = Coupon.make(:max_uses => 1)
|
134
|
+
coupon = Coupon.make(:max_uses => 1, :state => "active")
|
138
135
|
@cart.coupon_code = coupon.code
|
139
|
-
@cart.save
|
136
|
+
@cart.save
|
140
137
|
@cart.should be_valid
|
141
138
|
end
|
142
139
|
|
@@ -155,19 +152,12 @@ describe Cart do
|
|
155
152
|
@cart.coupons.should be_empty
|
156
153
|
@cart.save
|
157
154
|
@cart.reload
|
158
|
-
|
159
155
|
@cart.coupons.should include coupon
|
160
156
|
@cart.coupons.size.should == 1
|
161
|
-
|
162
|
-
@cart.coupon_code = ""
|
163
|
-
@cart.save
|
164
|
-
@cart.reload
|
165
|
-
|
166
|
-
@cart.coupons.size.should == 1
|
157
|
+
|
167
158
|
@cart.coupon_code = coupon.code
|
168
159
|
@cart.save
|
169
160
|
@cart.reload
|
170
|
-
|
171
161
|
@cart.coupons.size.should == 1
|
172
162
|
end
|
173
163
|
|
@@ -182,6 +172,7 @@ describe Cart do
|
|
182
172
|
@cart.coupons.size.should == 0
|
183
173
|
end
|
184
174
|
end
|
175
|
+
|
185
176
|
context "with bonusarticle" do
|
186
177
|
before do
|
187
178
|
@item = Item.make
|
@@ -2,5 +2,14 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ShopBunny::CouponUse do
|
4
4
|
it { should validate_presence_of :cart_id }
|
5
|
-
it { should validate_presence_of :coupon_id }
|
5
|
+
it { should validate_presence_of :coupon_id }
|
6
|
+
|
7
|
+
it "validates uniqueness of the cart and coupon tuple" do
|
8
|
+
cart = Cart.make
|
9
|
+
coupon = ShopBunny::Coupon.make
|
10
|
+
ShopBunny::CouponUse.create!(:coupon => coupon, :cart => cart)
|
11
|
+
expect {
|
12
|
+
ShopBunny::CouponUse.create!(:coupon => coupon, :cart => cart)
|
13
|
+
}.to raise_error(ActiveRecord::RecordInvalid)
|
14
|
+
end
|
6
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shop_bunny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-03-15 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &21969160 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: 3.1.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *21969160
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: sqlite3
|
27
|
-
requirement: &
|
27
|
+
requirement: &21963860 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *21963860
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec-rails
|
38
|
-
requirement: &
|
38
|
+
requirement: &21959860 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *21959860
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: machinist
|
49
|
-
requirement: &
|
49
|
+
requirement: &21959440 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *21959440
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: mocha
|
60
|
-
requirement: &
|
60
|
+
requirement: &21958980 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *21958980
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: shoulda-matchers
|
71
|
-
requirement: &
|
71
|
+
requirement: &21958340 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *21958340
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: capybara
|
82
|
-
requirement: &
|
82
|
+
requirement: &21957600 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *21957600
|
91
91
|
description: A simple shop gem that integrates a cart and coupons functionality
|
92
92
|
email:
|
93
93
|
- jan@kopfmaschine.com
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- config/locales/shop_bunny.en.yml
|
106
106
|
- db/test.sqlite3
|
107
107
|
- db/development.sqlite3
|
108
|
+
- db/migrate/20120315145137_index_to_coupon_use_coupon_id_and_cart_id.rb
|
108
109
|
- db/migrate/20100915162029_remove_owner_id_from_carts.rb
|
109
110
|
- db/migrate/20110821124655_add_max_uses_to_coupon.rb
|
110
111
|
- db/migrate/20101125140137_add_value_of_automatic_add_to_coupons.rb
|
@@ -135,8 +136,12 @@ files:
|
|
135
136
|
- spec/controllers/shop_bunny/carts_controller_spec.rb
|
136
137
|
- spec/requests/shop_bunny/shopping_spec.rb
|
137
138
|
- spec/spec_helper.rb
|
139
|
+
- spec/dummy/db/test.sqlite3
|
140
|
+
- spec/dummy/db/development.sqlite3
|
138
141
|
- spec/dummy/db/migrate/20100915073016_create_items.rb
|
139
142
|
- spec/dummy/db/schema.rb
|
143
|
+
- spec/dummy/log/development.log
|
144
|
+
- spec/dummy/log/test.log
|
140
145
|
- spec/dummy/script/rails
|
141
146
|
- spec/dummy/config.ru
|
142
147
|
- spec/dummy/Rakefile
|
@@ -203,8 +208,12 @@ test_files:
|
|
203
208
|
- spec/controllers/shop_bunny/carts_controller_spec.rb
|
204
209
|
- spec/requests/shop_bunny/shopping_spec.rb
|
205
210
|
- spec/spec_helper.rb
|
211
|
+
- spec/dummy/db/test.sqlite3
|
212
|
+
- spec/dummy/db/development.sqlite3
|
206
213
|
- spec/dummy/db/migrate/20100915073016_create_items.rb
|
207
214
|
- spec/dummy/db/schema.rb
|
215
|
+
- spec/dummy/log/development.log
|
216
|
+
- spec/dummy/log/test.log
|
208
217
|
- spec/dummy/script/rails
|
209
218
|
- spec/dummy/config.ru
|
210
219
|
- spec/dummy/Rakefile
|