effective_orders 5.2.1 → 5.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
  SHA256:
3
- metadata.gz: 7b2e8598ea6f759b602e70d61c5942080c2e528fc8c123b93e3396cbc2a8a26a
4
- data.tar.gz: 004e0db3016e081294d9c6fe49a02eb800a13f49f7917f0d83c445e5a615ebdc
3
+ metadata.gz: a7da6644ca7ccf8e9bcc7b2326e0b68e7290bb75ab21324a81ae7e94cc912473
4
+ data.tar.gz: 41de16ee30c34ec82299e9e372d7df60a9ae862a0fb44ae4accfb964910ae5c4
5
5
  SHA512:
6
- metadata.gz: 071a7b38a0c5817e3165ac17b2193288e435b0e92c3a54163bfa7997c7132f9f5c02329421198ad51e9078dc351e77a5984aafa96a2f51bef518913886bf0870
7
- data.tar.gz: d2825cd0a8f2c66c6975bcdaf926ab9ac35081383547ad41965813d26a4d2ea059426340a1bba723f22f1ada37c19d2e16a0d34c23423189981fb8611ffdbbbd
6
+ metadata.gz: 06cc3930613fa6359f603df842a44ec24d85e4d104aad2f41c964eaf800f1b98d16e2e04a3a91cfe9f7ec6a56b3516e69b579a1b709cbbe413306f60fcf20070
7
+ data.tar.gz: b5d5f0e94ef38065f924d66fca1f6124baf15b956639c216e72a1da13e205fcf22304c9be410c07e2ee79f147f8abda0c17d1cb4cedc2a7eaa49fbbf6893ee0b
@@ -459,13 +459,16 @@ module Effective
459
459
  self.payment = payment_to_h(payment) if self.payment.blank?
460
460
 
461
461
  begin
462
- Effective::Order.transaction do
462
+ EffectiveResources.transaction do
463
463
  run_purchasable_callbacks(:before_purchase)
464
+
464
465
  save!
465
466
  update_purchasables_purchased_order!
467
+
468
+ run_purchasable_callbacks(:after_purchase)
466
469
  end
467
470
  rescue => e
468
- Effective::Order.transaction do
471
+ EffectiveResources.transaction do
469
472
  save!(validate: false)
470
473
  update_purchasables_purchased_order!
471
474
  end
@@ -473,7 +476,6 @@ module Effective
473
476
  raise(e)
474
477
  end
475
478
 
476
- run_purchasable_callbacks(:after_purchase)
477
479
  send_order_receipts! if email
478
480
 
479
481
  true
@@ -506,9 +508,11 @@ module Effective
506
508
  skip_buyer_validations: true
507
509
  )
508
510
 
509
- Effective::Order.transaction do
511
+ EffectiveResources.transaction do
510
512
  begin
513
+ run_purchasable_callbacks(:before_decline)
511
514
  save!(validate: validate)
515
+ run_purchasable_callbacks(:after_decline)
512
516
  rescue => e
513
517
  self.state = state_was
514
518
 
@@ -519,8 +523,6 @@ module Effective
519
523
 
520
524
  raise "Failed to decline order: #{error || errors.full_messages.to_sentence}" unless error.nil?
521
525
 
522
- run_purchasable_callbacks(:after_decline)
523
-
524
526
  true
525
527
  end
526
528
 
@@ -637,8 +639,15 @@ module Effective
637
639
  end
638
640
 
639
641
  def run_purchasable_callbacks(name)
640
- order_items.each { |oi| oi.purchasable.public_send(name, self, oi) if oi.purchasable.respond_to?(name) }
641
- parent.public_send(name, self) if parent.respond_to?(name)
642
+ order_items.select { |item| item.purchasable.respond_to?(name) }.each do |item|
643
+ EffectiveResources.transaction(item) { item.purchasable.public_send(name, self, item) }
644
+ end
645
+
646
+ if parent.respond_to?(name)
647
+ EffectiveResources.transaction(parent) { parent.public_send(name, self) }
648
+ end
649
+
650
+ true
642
651
  end
643
652
 
644
653
  def send_email(email, *args)
@@ -1,6 +1,7 @@
1
1
  = render partial: 'effective/orders/order', locals: { order: order }
2
2
 
3
- - if order.persisted? && order.user == current_user
3
+ - # Show this if I'm on the effective orders checkout screen. But not on a rendered order.
4
+ - if order.persisted? && order.user == current_user && request.path.to_s.start_with?(effective_orders.order_path(order))
4
5
  .effective-order-change-items
5
6
  = link_to 'Change Addresses', effective_orders.edit_order_path(order), rel: :nofollow, class: 'btn btn-secondary'
6
7
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '5.2.1'.freeze
2
+ VERSION = '5.2.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_orders
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.1
4
+ version: 5.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-15 00:00:00.000000000 Z
11
+ date: 2021-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails