From 05cefe449c4935fb09232f50c3515d6ac020c97a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Busqu=C3=A9?= Date: Mon, 24 Apr 2023 15:57:28 +0200 Subject: [PATCH 1/5] Adopt new Solidus default branch Ref. https://github.com/solidusio/solidus/pull/5042 --- .circleci/config.yml | 6 +++--- bin/dummy-app | 2 +- bin/sandbox | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b58334d..d95c78b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,7 +20,7 @@ commands: sudo apt-get update sudo apt-get install -yq libvips-dev - solidusio_extensions/test-branch: - branch: master + branch: main command: | export FRONTEND=starter sudo gem update --system @@ -64,14 +64,14 @@ workflows: - run-specs-with-sqlite - lint-code - "Weekly run specs against master": + "Weekly run specs against main": triggers: - schedule: cron: "0 0 * * 4" # every Thursday filters: branches: only: - - master + - main jobs: - run-specs-with-postgres - run-specs-with-mysql diff --git a/bin/dummy-app b/bin/dummy-app index e6c085c..5acbc30 100755 --- a/bin/dummy-app +++ b/bin/dummy-app @@ -28,7 +28,7 @@ if [ ! -d "dummy-app" ]; then fi cd ./dummy-app -unbundled bundle add solidus --github solidusio/solidus --branch "${BRANCH:-master}" --version '> 0.a' +unbundled bundle add solidus --github solidusio/solidus --branch "${BRANCH:-main}" --version '> 0.a' unbundled bundle exec rake db:drop db:create unbundled bundle exec rails generate solidus:install --auto-accept --payment-method=none --no-seed --no-sample "$@" unbundled bundle add $extension_name --path .. diff --git a/bin/sandbox b/bin/sandbox index bd96ffe..3d95d5a 100755 --- a/bin/sandbox +++ b/bin/sandbox @@ -22,7 +22,7 @@ if [ ! -z $SOLIDUS_BRANCH ] then BRANCH=$SOLIDUS_BRANCH else - BRANCH="master" + BRANCH="main" fi extension_name="solidus_paypal_commerce_platform" @@ -47,7 +47,7 @@ if [ ! -d "sandbox" ]; then fi cd ./sandbox -unbundled bundle add solidus --github solidusio/solidus --branch "${BRANCH:-master}" --version '> 0.a' +unbundled bundle add solidus --github solidusio/solidus --branch "${BRANCH:-main}" --version '> 0.a' unbundled bundle exec rake db:drop db:create unbundled bundle exec rails generate solidus:install --payment-method=none --auto-accept "$@" unbundled bundle add ${extension_name} --path '../' From 867ddedfe64968d2b0784ba06a180f1975e5b297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Busqu=C3=A9?= Date: Tue, 2 May 2023 12:33:42 +0200 Subject: [PATCH 2/5] Bump minimal Ruby version requirement to v3.0 Ruby v2.7 reached EOL on 2023-03-31 [1]. This also fixes testing against Solidus master, which also dropped Ruby 2.7 support [2]. [1] - https://www.ruby-lang.org/en/downloads/branches/ [2] - https://github.com/solidusio/solidus/pull/5012 --- .circleci/config.yml | 10 ++++++---- .rubocop.yml | 2 +- solidus_paypal_commerce_platform.gemspec | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d95c78b..095e7cc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,26 +33,28 @@ jobs: run-specs-with-postgres: executor: name: solidusio_extensions/postgres - ruby_version: '3.1' + ruby_version: '3.2' steps: - test-with-starter-frontend run-specs-with-mysql: executor: name: solidusio_extensions/mysql - ruby_version: '3.0' + ruby_version: '3.1' steps: - test-with-starter-frontend run-specs-with-sqlite: executor: name: solidusio_extensions/sqlite - ruby_version: '2.7' + ruby_version: '3.0' steps: - test-with-starter-frontend lint-code: - executor: solidusio_extensions/sqlite-memory + executor: + name: solidusio_extensions/sqlite-memory + ruby_version: '3.0' steps: - solidusio_extensions/lint-code diff --git a/.rubocop.yml b/.rubocop.yml index 1910451..aed1e4d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,7 +3,7 @@ require: AllCops: NewCops: disable - TargetRubyVersion: '2.7' + TargetRubyVersion: '3.0' Exclude: - sandbox/**/* - dummy-app/**/* diff --git a/solidus_paypal_commerce_platform.gemspec b/solidus_paypal_commerce_platform.gemspec index 05acb24..36cc75f 100644 --- a/solidus_paypal_commerce_platform.gemspec +++ b/solidus_paypal_commerce_platform.gemspec @@ -17,7 +17,7 @@ Gem::Specification.new do |spec| spec.metadata['changelog_uri'] = 'https://github.com/solidusio/solidus_paypal_commerce_platform/releases' spec.metadata['rubygems_mfa_required'] = 'true' - spec.required_ruby_version = Gem::Requirement.new('>= 2.7') + spec.required_ruby_version = Gem::Requirement.new('>= 3.0') # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. From 8f3ff8f06e745515ee6f6ba6e4d7a8f5e7188815 Mon Sep 17 00:00:00 2001 From: Jacob Penn Date: Mon, 13 Mar 2023 21:49:26 -0700 Subject: [PATCH 3/5] patch order breakdown discount --- app/models/solidus_paypal_commerce_platform/paypal_order.rb | 2 +- .../solidus_paypal_commerce_platform/paypal_order_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/solidus_paypal_commerce_platform/paypal_order.rb b/app/models/solidus_paypal_commerce_platform/paypal_order.rb index 463b52a..58c51d1 100644 --- a/app/models/solidus_paypal_commerce_platform/paypal_order.rb +++ b/app/models/solidus_paypal_commerce_platform/paypal_order.rb @@ -92,7 +92,7 @@ def breakdown item_total: price(@order.item_total), shipping: price(@order.shipment_total), tax_total: price(@order.additional_tax_total), - discount: price(@order.all_adjustments.promotion.sum(&:amount).abs) + discount: price(@order.promo_total.abs) } end diff --git a/spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb b/spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb index d4bdb3a..9088aef 100644 --- a/spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb +++ b/spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb @@ -70,6 +70,12 @@ ) end end + + context 'when an order has an inapplicable promo adjustment' do + it 'does not include it in the paypal order break' do + # TODO + end + end end private From ef5e5dc83ac663f5130ac2e93c82cb87562a52ac Mon Sep 17 00:00:00 2001 From: Jacob Penn Date: Wed, 10 May 2023 15:27:23 -0700 Subject: [PATCH 4/5] patch typo --- .../solidus_paypal_commerce_platform/paypal_order_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb b/spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb index 9088aef..ca01662 100644 --- a/spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb +++ b/spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb @@ -72,7 +72,7 @@ end context 'when an order has an inapplicable promo adjustment' do - it 'does not include it in the paypal order break' do + it 'does not include it in the paypal order breakdown' do # TODO end end From 3cf8e3ef13d19737500b4cffa75a9b842f42e30c Mon Sep 17 00:00:00 2001 From: Alberto Vena Date: Thu, 11 May 2023 12:44:47 +0200 Subject: [PATCH 5/5] Implement a discount test This spec fails with the previous version of the code. --- .../paypal_order_spec.rb | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb b/spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb index ca01662..3e2a7e1 100644 --- a/spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb +++ b/spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb @@ -72,8 +72,40 @@ end context 'when an order has an inapplicable promo adjustment' do + let(:best_promotion) { + create(:promotion, + :with_line_item_adjustment, + :with_item_total_rule, adjustment_rate: 2.5, item_total_threshold_amount: 10, + apply_automatically: true, + promotion_actions: [ + Spree::Promotion::Actions::CreateItemAdjustments.new( + calculator: Spree::Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10) + ) + ]) + } + + let(:worst_promotion) { + create(:promotion, + :with_line_item_adjustment, + :with_item_total_rule, adjustment_rate: 2.5, item_total_threshold_amount: 10, + apply_automatically: true, + promotion_actions: [ + Spree::Promotion::Actions::CreateItemAdjustments.new( + calculator: Spree::Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 5) + ) + ]) + } + + before do + best_promotion.activate(order: order) + worst_promotion.activate(order: order) + order.recalculate + end + it 'does not include it in the paypal order breakdown' do - # TODO + expect(to_json.dig(:purchase_units, 0).dig(:amount, :breakdown)).to match hash_including( + discount: { currency_code: "USD", value: "2.50" } + ) end end end