Skip to content

Commit

Permalink
Merge pull request #117 from bookmebus/108-support-spree-450-removed-…
Browse files Browse the repository at this point in the history
…spree-frontend

close #108 support spree v4.5.0
channainfo authored Jul 17, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents eb6b70d + 3ea6cdb commit b12e927
Showing 13 changed files with 331 additions and 369 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ jobs:
POSTGRES_PASSWORD: mypassword
POSTGRES_DB: test_db

ports: ["5432:5432"]
ports: ['5432:5432']
options: >-
--health-cmd pg_isready
--health-interval 10s
@@ -38,7 +38,7 @@ jobs:

- uses: ruby/setup-ruby@v1
with:
ruby-version: "2.7.6"
ruby-version: '3.2.0'

# bundle-cache might cause problem when upgrading ruby. Disable it when upgrading to solve the problem.
# bundler-cache: true
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.6
3.2.0
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -5,8 +5,6 @@ git_source(:github) do |repo_name|
"https://github.com/#{repo_name}.git"
end

gem 'spree', github: 'spree/spree', branch: '4-2-stable'

group :development, :test do
gem 'brakeman'
gem 'rails-controller-testing'
561 changes: 279 additions & 282 deletions Gemfile.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/assets/config/spree_vpago_manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//= link_tree ../images
61 changes: 0 additions & 61 deletions app/controllers/spree/checkout_controller_decorator.rb

This file was deleted.

1 change: 1 addition & 0 deletions config/initializers/assets.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rails.application.config.assets.precompile << 'spree_vpago_manifest.js'
5 changes: 5 additions & 0 deletions config/initializers/spree_permitted_attributes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Spree
module PermittedAttributes
@@source_attributes += %i[payment_option payment_id payment_method_id]
end
end
33 changes: 14 additions & 19 deletions lib/spree_vpago/engine.rb
Original file line number Diff line number Diff line change
@@ -5,35 +5,30 @@ class Engine < Rails::Engine
engine_name 'spree_vpago'

config.autoload_paths += %W[#{config.root}/lib]

# use rspec for tests
config.generators do |g|
g.test_framework :rspec
end

config.assets.precompile += [
'vpago/payway/*',
]
initializer 'spree_vpago.environment', before: :load_config_initializers do |_app|
Config = Configuration.new
end

def self.activate
::Rails.application.config.spree.payment_methods << Spree::Gateway::Payway
::Rails.application.config.spree.payment_methods << Spree::Gateway::PaywayV2
::Rails.application.config.spree.payment_methods << Spree::Gateway::WingSdk
::Rails.application.config.spree.payment_methods << Spree::Gateway::Acleda
::Rails.application.config.spree.payment_methods << Spree::Gateway::AcledaMobile
config.after_initialize do
Rails.application.config.spree.payment_methods.concat [
Spree::Gateway::Payway,
Spree::Gateway::PaywayV2,
Spree::Gateway::WingSdk,
Spree::Gateway::Acleda,
Spree::Gateway::AcledaMobile
]
end

def self.activate
Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end


Spree::PermittedAttributes.source_attributes << :payment_option
Spree::PermittedAttributes.source_attributes << :payment_id
Spree::PermittedAttributes.source_attributes << :payment_method_id

Spree::Api::ApiHelpers.payment_source_attributes << :payment_option
Spree::Api::ApiHelpers.payment_source_attributes << :payment_id
Spree::Api::ApiHelpers.payment_source_attributes << :payment_method_id
end

config.to_prepare(&method(:activate).to_proc)
9 changes: 9 additions & 0 deletions spec/factories/acleda_mobille_gateways.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
FactoryBot.define do
factory :acleda_mobile_gateway, class: Spree::Gateway::Payway do
name { 'Acleda Mobile Gateway' }

before(:create) do |payway_gateway|
if payway_gateway.stores.empty?
default_store = Spree::Store.default.persisted? ? Spree::Store.default : nil
store = default_store || create(:store)

payway_gateway.stores << store
end
end
end
end
9 changes: 9 additions & 0 deletions spec/factories/payway_gateways.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
FactoryBot.define do
factory :payway_gateway, class: Spree::Gateway::Payway do
name { 'Payway Payment Gateway' }

before(:create) do |payway_gateway|
if payway_gateway.stores.empty?
default_store = Spree::Store.default.persisted? ? Spree::Store.default : nil
store = default_store || create(:store)

payway_gateway.stores << store
end
end
end
end
9 changes: 9 additions & 0 deletions spec/factories/wing_sdk_gateway.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
FactoryBot.define do
factory :wing_sdk_gateway, class: Spree::Gateway::WingSdk do
name { 'WingPay Payment Gateway' }

before(:create) do |payway_gateway|
if payway_gateway.stores.empty?
default_store = Spree::Store.default.persisted? ? Spree::Store.default : nil
store = default_store || create(:store)

payway_gateway.stores << store
end
end
end
end
3 changes: 1 addition & 2 deletions spree_vpago.gemspec
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.requirements << 'none'

spree_version = '>= 3.2.0', '< 4.3.0'
spree_version = '>= 4.5'
s.add_dependency 'spree_core', spree_version
s.add_dependency 'spree_api', spree_version
s.add_dependency 'spree_backend', spree_version
@@ -30,7 +30,6 @@ Gem::Specification.new do |s|

s.add_development_dependency 'spree_dev_tools'
s.add_development_dependency 'byebug'
s.add_development_dependency 'sqlite3'
s.add_development_dependency 'pg'

end

0 comments on commit b12e927

Please sign in to comment.