spree_promo 1.3.4 → 1.3.5

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: 40582bf42f5cd6675df3f3f3db1480808111213f
4
- data.tar.gz: 2868fc07c91b0cecf867536dddcb1af9efaccda0
3
+ metadata.gz: bb2bcb36b3161c9cc5feb74608068d31d53651d0
4
+ data.tar.gz: 7cd89e77ada75630528557cc8a61aedd8adce059
5
5
  SHA512:
6
- metadata.gz: 5c949e94bd1b46aaf8a9240ee90366068676fcce700b5081e7117699b2944823ed22df631707ee6c0670eddbafb9389bda7d8afa2459f9b8316b2f76a30ff6aa
7
- data.tar.gz: e82b0b25514add622fa7645073a5a748aaaabb79ba8880f034531c774be28a64bf7ef1854f640624480d51e4fe3f0813505ddcf517acb4c5c523b6142ce4a5e5
6
+ metadata.gz: 0892f38c4782cb2312fe23d117ac7f763984919c250449d965754cab146166475abd73a7436e58e8ee830596f9055e1c65c0018efa060b976455b401c6475ef4
7
+ data.tar.gz: 1c1acc85af0985b74a14236917920925e589ed8f6332de2fb5c4b54033a02eaac03dff5e17c053e8528ce6dda81f5246491f10e3ff4a0245a4c3d373d6cd8f0f
@@ -2,13 +2,16 @@ Spree::CheckoutController.class_eval do
2
2
 
3
3
  #TODO 90% of this method is duplicated code. DRY
4
4
  def update
5
- if @order.update_attributes(object_params)
6
-
7
- fire_event('spree.checkout.update')
8
- unless apply_coupon_code
5
+ if params[:order] && params[:order][:coupon_code]
6
+ @order.coupon_code = params[:order][:coupon_code]
7
+ unless status = apply_coupon_code
9
8
  respond_with(@order) { |format| format.html { render :edit } }
10
9
  return
11
10
  end
11
+ end
12
+
13
+ if @order.update_attributes(object_params)
14
+ fire_event('spree.checkout.update')
12
15
 
13
16
  if @order.next
14
17
  state_callback(:after)
@@ -9,8 +9,9 @@ Spree::OrdersController.class_eval do
9
9
 
10
10
  if @order.update_attributes(params[:order])
11
11
  render :edit and return unless apply_coupon_code
12
-
12
+
13
13
  @order.line_items = @order.line_items.select {|li| li.quantity > 0 }
14
+ @order.restart_checkout_flow
14
15
  fire_event('spree.order.contents_changed')
15
16
  respond_with(@order) do |format|
16
17
  format.html do
@@ -27,7 +27,7 @@ Spree::Order.class_eval do
27
27
  end
28
28
 
29
29
  def find_promo_for_coupon_code
30
- Spree::Promotion.where("LOWER(code) = '#{normalized_coupon_code}'").first
30
+ Spree::Promotion.where("LOWER(code) = ?", normalized_coupon_code).first
31
31
  end
32
32
 
33
33
  def normalized_coupon_code
@@ -57,8 +57,10 @@ module Spree
57
57
  def deals_with_adjustments
58
58
  self.adjustments.each do |adjustment|
59
59
  if adjustment.adjustable.complete?
60
- adjustment.originator = nil
61
- adjustment.save
60
+ adjustment.update_attributes_without_callbacks(
61
+ :originator_id => nil,
62
+ :originator_type => nil
63
+ )
62
64
  else
63
65
  adjustment.destroy
64
66
  end
@@ -20,9 +20,12 @@ module Spree
20
20
  config.autoload_paths += %W(#{config.root}/lib)
21
21
  config.to_prepare &method(:activate).to_proc
22
22
 
23
+ # We need to define promotions rules here so extensions and existing apps
24
+ # can add their custom classes on their initializer files
23
25
  initializer 'spree.promo.environment', :after => 'spree.environment' do |app|
24
26
  app.config.spree.add_class('promotions')
25
27
  app.config.spree.promotions = Spree::Promo::Environment.new
28
+ app.config.spree.promotions.rules = []
26
29
  end
27
30
 
28
31
  initializer 'spree.promo.register.promotion.calculators' do |app|
@@ -37,8 +40,12 @@ module Spree
37
40
  ]
38
41
  end
39
42
 
40
- initializer 'spree.promo.register.promotions.rules' do |app|
41
- app.config.spree.promotions.rules = [
43
+ # Promotion rules need to be evaluated on after initialize otherwise
44
+ # Spree.user_class would be nil and users might experience errors related
45
+ # to malformed model associations (Spree.user_class is only defined on
46
+ # the app initializer)
47
+ config.after_initialize do
48
+ Rails.application.config.spree.promotions.rules.concat [
42
49
  Spree::Promotion::Rules::ItemTotal,
43
50
  Spree::Promotion::Rules::Product,
44
51
  Spree::Promotion::Rules::User,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_promo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - David North
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-15 00:00:00.000000000 Z
11
+ date: 2014-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spree_core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.3.4
19
+ version: 1.3.5
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.3.4
26
+ version: 1.3.5
27
27
  description: Required dependency for Spree
28
28
  email: david@spreecommerce.com
29
29
  executables: []
@@ -53,6 +53,7 @@ files:
53
53
  - app/models/spree/order_updater_decorator.rb
54
54
  - app/models/spree/payment_decorator.rb
55
55
  - app/models/spree/product_decorator.rb
56
+ - app/models/spree/promotion.rb
56
57
  - app/models/spree/promotion/actions/create_adjustment.rb
57
58
  - app/models/spree/promotion/actions/create_line_items.rb
58
59
  - app/models/spree/promotion/rules/first_order.rb
@@ -60,7 +61,6 @@ files:
60
61
  - app/models/spree/promotion/rules/product.rb
61
62
  - app/models/spree/promotion/rules/user.rb
62
63
  - app/models/spree/promotion/rules/user_logged_in.rb
63
- - app/models/spree/promotion.rb
64
64
  - app/models/spree/promotion_action.rb
65
65
  - app/models/spree/promotion_action_line_item.rb
66
66
  - app/models/spree/promotion_rule.rb
@@ -94,11 +94,11 @@ files:
94
94
  - app/views/spree/products/_promotions.html.erb
95
95
  - config/locales/en.yml
96
96
  - config/routes.rb
97
+ - db/migrate/20120831092359_spree_promo_one_two.rb
98
+ - lib/spree/promo.rb
97
99
  - lib/spree/promo/engine.rb
98
100
  - lib/spree/promo/environment.rb
99
- - lib/spree/promo.rb
100
101
  - lib/spree_promo.rb
101
- - db/migrate/20120831092359_spree_promo_one_two.rb
102
102
  homepage: http://spreecommerce.com
103
103
  licenses:
104
104
  - BSD-3
@@ -109,18 +109,18 @@ require_paths:
109
109
  - lib
110
110
  required_ruby_version: !ruby/object:Gem::Requirement
111
111
  requirements:
112
- - - '>='
112
+ - - ">="
113
113
  - !ruby/object:Gem::Version
114
114
  version: 1.8.7
115
115
  required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - '>='
117
+ - - ">="
118
118
  - !ruby/object:Gem::Version
119
119
  version: '0'
120
120
  requirements:
121
121
  - none
122
122
  rubyforge_project:
123
- rubygems_version: 2.1.0
123
+ rubygems_version: 2.2.0
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: Promotion functionality for use with Spree.