active_cart 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.12
1
+ 0.0.13
@@ -178,11 +178,11 @@ module ActiveCart
178
178
  private
179
179
  def with_callbacks(type, item, quantity, options, &blk)
180
180
  return false unless item.send("before_#{type}".to_sym, quantity, options) if item.respond_to?("before_#{type}".to_sym)
181
- return false unless @storage_engine.send("before_#{type}".to_sym, quantity, options) if @storage_engine.respond_to?("before_#{type}".to_sym)
181
+ return false unless @storage_engine.send("before_#{type}".to_sym, item, quantity, options) if @storage_engine.respond_to?("before_#{type}".to_sym)
182
182
 
183
183
  yield
184
184
 
185
- @storage_engine.send("after_#{type}".to_sym, quantity, options) if @storage_engine.respond_to?("after_#{type}".to_sym)
185
+ @storage_engine.send("after_#{type}".to_sym, item, quantity, options) if @storage_engine.respond_to?("after_#{type}".to_sym)
186
186
  item.send("after_#{type}".to_sym, quantity, options) if item.respond_to?("after_#{type}".to_sym)
187
187
  end
188
188
  end
@@ -138,27 +138,27 @@ class CartTest < ActiveSupport::TestCase
138
138
  context 'storage engines' do
139
139
  should 'fire the storage engines before_add_to_cart callback on add to cart' do
140
140
  item = TestItem.new
141
- @cart_storage_engine.expects(:before_add_to_cart).with(1, { :option => 'value' }).returns(true)
141
+ @cart_storage_engine.expects(:before_add_to_cart).with(item, 1, { :option => 'value' }).returns(true)
142
142
  @cart.add_to_cart(item, 1, { :option => 'value' })
143
143
  assert_equal 1, @cart.quantity
144
144
  end
145
145
 
146
146
  should 'halt and return false if before_add_to_cart returns false' do
147
147
  item = TestItem.new
148
- @cart_storage_engine.expects(:before_add_to_cart).with(1, { :option => 'value' }).returns(false)
148
+ @cart_storage_engine.expects(:before_add_to_cart).with(item, 1, { :option => 'value' }).returns(false)
149
149
  assert !@cart.add_to_cart(item, 1, { :option => 'value' })
150
150
  assert_equal 0, @cart.quantity
151
151
  end
152
152
 
153
153
  should 'fire the storage engines after_add_to_cart callback' do
154
154
  item = TestItem.new
155
- @cart_storage_engine.expects(:after_add_to_cart).with(1, {})
155
+ @cart_storage_engine.expects(:after_add_to_cart).with(item, 1, {})
156
156
  @cart.add_to_cart(item, 1)
157
157
  end
158
158
 
159
159
  should 'fire the storage engines before_remove_from_cart callback on add to cart' do
160
160
  item = TestItem.new
161
- @cart_storage_engine.expects(:before_remove_from_cart).with(1, {}).returns(true)
161
+ @cart_storage_engine.expects(:before_remove_from_cart).with(item, 1, {}).returns(true)
162
162
  @cart.remove_from_cart(item, 1)
163
163
  assert_equal 0, @cart.quantity
164
164
  end
@@ -167,14 +167,14 @@ class CartTest < ActiveSupport::TestCase
167
167
  item = TestItem.new
168
168
  @cart.add_to_cart(item, 1)
169
169
  assert_equal 1, @cart.quantity
170
- @cart_storage_engine.expects(:before_remove_from_cart).with(1, { :option => 'value' }).returns(false)
170
+ @cart_storage_engine.expects(:before_remove_from_cart).with(item, 1, { :option => 'value' }).returns(false)
171
171
  assert !@cart.remove_from_cart(item, 1, { :option => 'value' })
172
172
  assert_equal 1, @cart.quantity
173
173
  end
174
174
 
175
175
  should 'fire the storage engines after_remove_from_cart callback' do
176
176
  item = TestItem.new
177
- @cart_storage_engine.expects(:after_remove_from_cart).with(1, { :option => 'value' })
177
+ @cart_storage_engine.expects(:after_remove_from_cart).with(item, 1, { :option => 'value' })
178
178
  @cart.remove_from_cart(item, 1, { :option => 'value' })
179
179
  end
180
180
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_cart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Myles Eftos