Skip to content

Commit

Permalink
Merge pull request #331 from spark-solutions/fix/zeiwerk-fixes
Browse files Browse the repository at this point in the history
Fix decorators to work with Rails 6.0 and Zeitwerk autoloader
  • Loading branch information
damianlegawiec authored Aug 29, 2019
2 parents ac009bd + 292b406 commit 76f67fa
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 24 deletions.
17 changes: 11 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ language: ruby

addons:
chrome: stable
postgresql: 9.4

env:
- DB=postgres
- DB=mysql

gemfile:
- gemfiles/spree_3_2.gemfile
# - gemfiles/spree_3_2.gemfile
- gemfiles/spree_3_5.gemfile
- gemfiles/spree_3_7.gemfile
- gemfiles/spree_master.gemfile
Expand All @@ -27,12 +28,16 @@ rvm:

matrix:
allow_failures:
- gemfile: gemfiles/spree_master.gemfile
- gemfile: gemfiles/spree_master.gemfile
exclude:
- rvm: 2.3.7
gemfile: gemfiles/spree_master.gemfile
- rvm: 2.4.4
gemfile: gemfiles/spree_master.gemfile
- rvm: 2.3.7
gemfile: gemfiles/spree_master.gemfile
- rvm: 2.4.4
gemfile: gemfiles/spree_master.gemfile
- rvm: 2.5.1
gemfile: gemfiles/spree_3_2.gemfile
- rvm: 2.4.4
gemfile: gemfiles/spree_3_2.gemfile

before_install:
- mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';"
Expand Down
1 change: 1 addition & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ end

appraise 'spree-3-7' do
gem 'spree', '~> 3.7.0'
gem 'sass-rails'
gem 'rails-controller-testing'
end

Expand Down
20 changes: 20 additions & 0 deletions app/models/spree/apple_pay_order_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module Spree
module ApplePayOrderDecorator
def confirmation_required?
return false if paid_with_apple_pay?

# Little hacky fix for #4117
# If this wasn't here, order would transition to address state on confirm failure
# because there would be no valid payments any more.
Spree::Config[:always_include_confirm_step] ||
payments.valid.map(&:payment_method).compact.any?(&:payment_profiles_supported?) ||
confirm?
end

def paid_with_apple_pay?
payments.valid.any?(&:apple_pay?)
end
end
end

Spree::Order.prepend Spree::ApplePayOrderDecorator
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module SpreeGateway
module Spree
module ApplePayPaymentDecorator
def apple_pay?
payment_method.is_a? Spree::Gateway::StripeApplePayGateway
end
end
end

Spree::Payment.prepend SpreeGateway::ApplePayPaymentDecorator
Spree::Payment.prepend Spree::ApplePayPaymentDecorator
16 changes: 0 additions & 16 deletions app/models/spree/order_decorator.rb

This file was deleted.

1 change: 1 addition & 0 deletions gemfiles/spree_3_7.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ source "https://rubygems.org"

gem "rails-controller-testing"
gem "spree", "~> 3.7.0"
gem "sass-rails"

gemspec path: "../"

0 comments on commit 76f67fa

Please sign in to comment.