Compare commits

...

38 Commits

Author SHA1 Message Date
Ahmed Ejaz
7415503b63 Update all locales with the latest Transifex translations 2025-10-27 05:55:44 +05:00
Filipe
cc35d118eb Merge pull request #13627 from guidoDutra/10261/bad-table-format-in-edit-order-page
fix table format in edit order page
2025-10-24 13:16:49 +01:00
Maikel
025f8b25b1 Merge pull request #13637 from deivid-rodriguez/fix-missing-stripe-js-error-in-edge-case
Fix JS error when Stripe connect is disabled but Stripe API keys are setup
2025-10-22 13:09:58 +11:00
Maikel
3017f61047 Merge pull request #13638 from deivid-rodriguez/refactor-specs
Remove only usage of `STRIPE_PUBLIC_TEST_API_KEY` env and refactor specs that were using it
2025-10-22 13:08:31 +11:00
Maikel
8cb3d06f7c Merge pull request #13635 from deivid-rodriguez/testing-stripe-wiki
Link to Stripe testing wiki page from the cassette regeneration script
2025-10-22 13:02:21 +11:00
Maikel
8f442e82ed Merge pull request #13634 from openfoodfoundation/dependabot/bundler/activerecord-import-2.2.0
Bump activerecord-import from 1.6.0 to 2.2.0
2025-10-22 13:00:43 +11:00
David Rodríguez
b28886dd38 Normalize casing 2025-10-21 17:34:40 +02:00
David Rodríguez
bd4f115185 Create account directly with the proper stripe_user_id 2025-10-21 17:34:40 +02:00
David Rodríguez
c43650034f Remove unnecessary test specific environment variable 2025-10-21 17:34:40 +02:00
David Rodríguez
94bc787283 Remove unused let 2025-10-21 17:34:40 +02:00
David Rodríguez
58851a8e67 Move client_id let to the only spec using it 2025-10-21 17:34:39 +02:00
David Rodríguez
c3e2382600 Move let! to the only spec using it 2025-10-21 17:34:39 +02:00
David Rodríguez
802878b4eb Fix JS error when Stripe connect is disabled but Stripe API keys are setup 2025-10-21 17:24:34 +02:00
Filipe
69d8fc3cad Merge pull request #13624 from chahmedejaz/bugfix/13556-fix-500-error-on-stripe-checkout
Error 500 checking out with Stripe, after navigating back to the Summary page
2025-10-21 14:34:53 +01:00
David Rodríguez
6a226e476d Link to Stripe testing wiki page from the cassette regeneration script
I think this is the more relevant wiki page for someone looking into
regenerating cassettes.

Also, no need to mention bitwarden explicitly, the wiki page already
explains everything.
2025-10-21 14:38:10 +02:00
dependabot[bot]
479d52a2bb Bump activerecord-import from 1.6.0 to 2.2.0
Bumps [activerecord-import](https://github.com/zdennis/activerecord-import) from 1.6.0 to 2.2.0.
- [Changelog](https://github.com/zdennis/activerecord-import/blob/master/CHANGELOG.md)
- [Commits](https://github.com/zdennis/activerecord-import/compare/v1.6.0...v2.2.0)

---
updated-dependencies:
- dependency-name: activerecord-import
  dependency-version: 2.2.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-21 09:02:00 +00:00
Gaetan Craig-Riou
73688b9544 Merge pull request #13630 from openfoodfoundation/dependabot/bundler/webmock-3.25.1
Bump webmock from 3.23.1 to 3.25.1
2025-10-21 10:02:14 +11:00
dependabot[bot]
02ea3cb61c Bump webmock from 3.23.1 to 3.25.1
Bumps [webmock](https://github.com/bblimke/webmock) from 3.23.1 to 3.25.1.
- [Changelog](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bblimke/webmock/compare/v3.23.1...v3.25.1)

---
updated-dependencies:
- dependency-name: webmock
  dependency-version: 3.25.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-20 09:26:20 +00:00
Maikel
c7d0594257 Merge pull request #13622 from deivid-rodriguez/no-reviewdog-master
Don't run reviewdog on pushes
2025-10-20 16:34:06 +11:00
Maikel
4eee7ad603 Merge pull request #13604 from deivid-rodriguez/silent-puma
Silence capybara starting puma during system specs
2025-10-20 16:26:18 +11:00
David Cook
23f7f2974a Merge pull request #13618 from deivid-rodriguez/remove-unnecessary-sleeps
Remove unnecessary explicit sleeps
2025-10-20 16:06:44 +11:00
Maikel
8105b919e0 Merge pull request #13600 from deivid-rodriguez/profile-enables-dev-caching
The PROFILE env variable should actually enable, not disable, caching
2025-10-20 16:03:20 +11:00
David Cook
53ef5148e9 Merge pull request #13617 from deivid-rodriguez/upgrade-cache-format-version
Upgrade cache format version
2025-10-20 15:41:52 +11:00
David Cook
93e6f9034c Merge pull request #13602 from deivid-rodriguez/bump-mini_magick
Update mini_magick to a version that plays nice with imagemagick v7
2025-10-20 15:26:20 +11:00
David Cook
125a92346c Merge pull request #13599 from deivid-rodriguez/fix-duplicate-key-warning
Fix duplicate keys warnings in some views
2025-10-20 15:21:40 +11:00
Gaetan Craig-Riou
31b8fe16cb Merge pull request #13623 from deivid-rodriguez/follow-up-to-old-rename
Follow up to old ofnEmptiesCart to ofnChangeHub rename
2025-10-20 10:53:47 +11:00
Gaetan Craig-Riou
cbffea8d30 Merge pull request #13616 from openfoodfoundation/dependabot/bundler/state_machines-activerecord-0.31.0
Bump state_machines-activerecord from 0.9.0 to 0.31.0
2025-10-20 09:50:30 +11:00
Guido Oliveira
be9da62d98 fix table format in edit order page 2025-10-19 07:58:40 -03:00
Ahmed Ejaz
9f6c149735 Add check for payment authorization state in StripeScaPaymentAuthorize and corresponding spec 2025-10-17 05:25:45 +05:00
David Rodríguez
50578647ee Follow up to old ofnEmptiesCart to ofnChangeHub rename
This happened back in 2015 through
9c9051498b, but two places were missed.

One was a code comment so did not affect anything (other than confused
code readers I guess?). The other one did create a regression but was
later fixed by 18d966f0de in 2021.
2025-10-16 12:56:17 +02:00
David Rodríguez
a28f05fddc Don't run reviewdog on pushes
As configured, it's meant to annotate PRs with linter errors (so you
don't have to skim through logs). So it does not make sense for pushes.

In fact, on pushes rubocop action is doing nothing, and prettier action
is failing with:

> reviewdog: this is not PullRequest build.
> sed: couldn't write 80 items to stdout: Broken pipe
2025-10-16 12:34:37 +02:00
David Rodríguez
d6c044fd5b Remove unnecessary explicit sleeps
Capybara helpers already wait for the content to show up (and we already
have a default of 10 seconds configured), so I don't think waiting more is
actually the problem in these specs.

But if we wanted to wait more, I think it's better to pass the `:wait`
option to capybara matchers, because that's a "maximum waiting value"
but we'll still proceed earlier if the content shows up.

Using the same idea, I changed the positive assertions to happen first,
because negative assertions do spend "max wait time" waiting, while
positive assertions only wait until the content shows up.
2025-10-15 13:09:52 +02:00
David Rodríguez
a75ea5b506 Upgrade cache format version
It's supposed to be faster and more compact, and the previous format
will become unsupported in Rails 7.2 as per Rails boot warnings:

> DEPRECATION WARNING: Support for `config.active_support.cache_format_version = 6.1` has been deprecated and will be removed in Rails 7.2.
>
> Check the Rails upgrade guide at https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#new-activesupport-cache-serialization-format
> for more information on how to upgrade.
>    (called from <main> at /path/to/config/environment.rb:5)
2025-10-15 12:17:03 +02:00
dependabot[bot]
7f937fd4b1 Bump state_machines-activerecord from 0.9.0 to 0.31.0
Bumps [state_machines-activerecord](https://github.com/state-machines/state_machines-activerecord) from 0.9.0 to 0.31.0.
- [Release notes](https://github.com/state-machines/state_machines-activerecord/releases)
- [Changelog](https://github.com/state-machines/state_machines-activerecord/blob/master/CHANGELOG.md)
- [Commits](https://github.com/state-machines/state_machines-activerecord/compare/v0.9.0...state_machines-activerecord/v0.31.0)

---
updated-dependencies:
- dependency-name: state_machines-activerecord
  dependency-version: 0.31.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-15 09:02:41 +00:00
David Rodríguez
667ce5eda2 Silence capybara starting puma during system specs
##### Before

```
$ bin/rspec spec/system/admin/order_cycles/simple_spec.rb:460
Running via Spring preloader in process 79308
Run options: include {:locations=>{"./spec/system/admin/order_cycles/simple_spec.rb"=>[460]}}

As an administrator
    I want to manage simple order cycles
  as an enterprise user
    that is a manager of the coordinator
      when variants are hidden via inventory settings
Capybara starting Puma...
* Version 6.5.0, codename: Sky's Version
* Min threads: 0, max threads: 4
* Listening on http://127.0.0.1:51103
        shows a warning when going to 'outgoing products' tab

Finished in 3.95 seconds (files took 0.45949 seconds to load)
1 example, 0 failures
```

##### After

```
$ bin/rspec spec/system/admin/order_cycles/simple_spec.rb:460
Running via Spring preloader in process 79234
Run options: include {:locations=>{"./spec/system/admin/order_cycles/simple_spec.rb"=>[460]}}

As an administrator
    I want to manage simple order cycles
  as an enterprise user
    that is a manager of the coordinator
      when variants are hidden via inventory settings
        shows a warning when going to 'outgoing products' tab

Finished in 4.03 seconds (files took 0.49981 seconds to load)
1 example, 0 failures
```
2025-10-14 20:34:05 +02:00
David Rodríguez
c72f9477cd bundle update mini_magick
This is mainly to shush a lot of warnings when running the test suite,
like the following:

```
WARNING: The convert command is deprecated in IMv7, use "magick" instead of "convert" or "magick convert"
```
2025-10-14 08:17:12 +02:00
David Rodríguez
8787eed863 The PROFILE env variable should actually enable, not disable, caching
I think this may be a typo from 6d8ddd1edac17a431222c86482bceb83e8a7d32f?
2025-10-14 08:03:15 +02:00
David Rodríguez
e2b6199f26 Fix duplicate keys warnings in some views
We're passing the `id` key twice, and with different value, resulting in
warnings like:

> /path/to/app/views/producers/index.html.haml:27: warning: key :id is duplicated and overwritten on line 31

Use only the latest value passed to remove the warning.

##### Before

```
$ bundle exec rspec -e "displays in an iframe" -e "logging in with a redirect set"

(...)

Run options: include {:full_description=>/(?-mix:displays\ in\ an\ iframe)|(?-mix:logging\ in\ with\ a\ redirect\ set)/}
Capybara starting Puma...
* Version 6.5.0, codename: Sky's Version
* Min threads: 0, max threads: 4
* Listening on http://127.0.0.1:50292
/path/to/app/views/producers/index.html.haml:27: warning: key :id is duplicated and overwritten on line 31
./path/to/app/views/groups/show.html.haml:68: warning: key :id is duplicated and overwritten on line 72
Modal window with text `Unable to load map. Please check your browser settings and allow 3rd party cookies for this website.` has been opened, but you didn't wrap your code into (`accept_prompt` | `dismiss_prompt` | `accept_confirm` | `dismiss_confirm` | `accept_alert`), accepting by default
.

Finished in 4.54 seconds (files took 4.04 seconds to load)
2 examples, 0 failures
```

##### After

```
$ bundle exec rspec -e "displays in an iframe" -e "logging in with a redirect set"

(...)

Run options: include {:full_description=>/(?-mix:displays\ in\ an\ iframe)|(?-mix:logging\ in\ with\ a\ redirect\ set)/}
Capybara starting Puma...
* Version 6.5.0, codename: Sky's Version
* Min threads: 0, max threads: 4
* Listening on http://127.0.0.1:50256
.Modal window with text `Unable to load map. Please check your browser settings and allow 3rd party cookies for this website.` has been opened, but you didn't wrap your code into (`accept_prompt` | `dismiss_prompt` | `accept_confirm` | `dismiss_confirm` | `accept_alert`), accepting by default
.

Finished in 4.17 seconds (files took 4.1 seconds to load)
2 examples, 0 failures
```
2025-10-14 07:58:32 +02:00
24 changed files with 107 additions and 73 deletions

View File

@@ -20,7 +20,6 @@ STRIPE_INSTANCE_SECRET_KEY="bogus_key"
STRIPE_CUSTOMER="bogus_customer"
STRIPE_ACCOUNT="bogus_account"
STRIPE_CLIENT_ID="bogus_client_id"
STRIPE_PUBLIC_TEST_API_KEY="bogus_stripe_publishable_key"
SITE_URL="test.host"

View File

@@ -1,5 +1,5 @@
name: Linters
on: [push, pull_request]
on: [pull_request]
permissions:
contents: read # to fetch code (actions/checkout)
jobs:

View File

@@ -122,7 +122,7 @@ GEM
activemodel (= 7.1.5.2)
activesupport (= 7.1.5.2)
timeout (>= 0.4.0)
activerecord-import (1.6.0)
activerecord-import (2.2.0)
activerecord (>= 4.2)
activerecord-postgresql-adapter (0.0.1)
pg
@@ -156,8 +156,8 @@ GEM
activerecord (>= 6.1, < 7.2)
acts_as_list (1.0.4)
activerecord (>= 4.2)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
aes_key_wrap (1.1.0)
afm (0.2.2)
angular-rails-templates (1.2.1)
@@ -374,7 +374,7 @@ GEM
temple (>= 0.8.2)
thor
tilt
hashdiff (1.1.0)
hashdiff (1.2.1)
hashery (2.1.2)
hashie (5.0.0)
highline (2.0.3)
@@ -473,10 +473,10 @@ GEM
mimemagic (0.4.3)
nokogiri (~> 1)
rake
mini_magick (4.11.0)
mini_magick (4.13.2)
mini_mime (1.1.5)
mini_portile2 (2.8.6)
minitest (5.25.5)
minitest (5.26.0)
monetize (1.13.0)
money (~> 6.12)
money (6.16.0)
@@ -567,7 +567,7 @@ GEM
psych (5.2.6)
date
stringio
public_suffix (5.0.5)
public_suffix (6.0.2)
puffing-billy (4.0.2)
addressable (~> 2.5)
em-http-request (~> 1.1, >= 1.1.0)
@@ -819,13 +819,13 @@ GEM
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
state_machines (0.6.0)
state_machines-activemodel (0.9.0)
activemodel (>= 6.0)
state_machines (>= 0.6.0)
state_machines-activerecord (0.9.0)
activerecord (>= 6.0)
state_machines-activemodel (>= 0.9.0)
state_machines (0.20.0)
state_machines-activemodel (0.10.0)
activemodel (>= 7.1)
state_machines (>= 0.10.0)
state_machines-activerecord (0.31.0)
activerecord (>= 7.1)
state_machines-activemodel (>= 0.10.0)
stimulus_reflex (3.5.5)
actioncable (>= 5.2)
actionpack (>= 5.2)
@@ -841,7 +841,7 @@ GEM
stringex (2.8.6)
stringio (3.1.7)
stripe (11.1.0)
strscan (3.1.2)
strscan (3.1.5)
swd (2.0.3)
activesupport (>= 3)
attr_required (>= 0.0.5)
@@ -906,7 +906,7 @@ GEM
activesupport
faraday (~> 2.0)
faraday-follow_redirects
webmock (3.23.1)
webmock (3.25.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)

View File

@@ -1,6 +1,6 @@
angular.module('Darkswarm').directive "activeTableHubLink", (CurrentHub, CurrentOrder) ->
# Change the text of the hub link based on CurrentHub
# To be used with ofnEmptiesCart
# To be used with ofnChangeHub
# Takes "change" and "shop" as text string attributes
restrict: "A"
scope:

View File

@@ -12,7 +12,7 @@
.row
.columns.small-12
%a.cta-hub{"ng-repeat" => "hub in enterprise.hubs | filter:{id: '!'+enterprise.id} | orderBy:'-active'",
"ng-href" => "{{::hub.path}}#/shop_panel", "ofn-empties-cart" => "hub",
"ng-href" => "{{::hub.path}}#/shop_panel",
"ng-class" => "::{primary: hub.active, secondary: !hub.active}",
"ng-click" => "$close()",
"ofn-change-hub" => "hub"}

View File

@@ -65,7 +65,7 @@
.row
.small-12.columns
.active_table
%producer.active_table_node.row.animate-repeat{id: "{{producer.path}}",
%producer.active_table_node.row.animate-repeat{
"ng-repeat" => "producer in filteredEnterprises = (Enterprises.producers | searchEnterprises:query | taxons:activeTaxons | properties:activeProperties:'supplied_properties')",
"ng-controller" => "ProducerNodeCtrl",
"ng-class" => "{'closed' : !open(), 'open' : open(), 'inactive' : !producer.active}",

View File

@@ -24,7 +24,7 @@
.row
.small-12.columns
.active_table
%producer.active_table_node.row.animate-repeat{id: "{{producer.path}}",
%producer.active_table_node.row.animate-repeat{
"ng-repeat" => "producer in filteredEnterprises = (Enterprises.producers | searchEnterprises:query | taxons:activeTaxons | properties:activeProperties:'supplied_properties')",
"ng-controller" => "ProducerNodeCtrl",
"ng-class" => "{'closed' : !open(), 'open' : open(), 'inactive' : !producer.active}",

View File

@@ -3,7 +3,7 @@
= inject_json_array("shops", @shops.all, Api::ShopForOrdersSerializer)
= inject_saved_credit_cards
- if Stripe.publishable_key
- if Spree::Config.stripe_connect_enabled && Stripe.publishable_key
:javascript
angular.module('Darkswarm').value("stripeObject", Stripe("#{Stripe.publishable_key}"))
angular.module('Darkswarm').value("stripePublishableKey", "#{Stripe.publishable_key}")

View File

@@ -11,8 +11,6 @@
#cart-detail {
width: 100%;
display: block;
overflow-x: auto;
.cart-item-delete,
.bought-item-delete {

View File

@@ -35,6 +35,7 @@ module Openfoodnetwork
config.active_record.yaml_column_permitted_classes = [BigDecimal, Symbol, Time,
ActiveSupport::TimeWithZone,
ActiveSupport::TimeZone]
config.active_support.cache_format_version = 7.0
# Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded.

View File

@@ -33,7 +33,7 @@ Rails.application.configure do
# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
if Rails.root.join("tmp/caching-dev.txt").exist? || !ENV["PROFILE"] || !!ENV["DEV_CACHING"]
if Rails.root.join("tmp/caching-dev.txt").exist? || !!ENV["PROFILE"] || !!ENV["DEV_CACHING"]
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true

View File

@@ -74,9 +74,6 @@ Rails.application.configure do
allowed_warnings = [
# List strings here to allow matching deprecations.
#
# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#new-activesupport-cache-serialization-format
"config.active_support.cache_format_version",
# `Rails.application.secrets` is deprecated in favor of `Rails.application.credentials` and will be removed in Rails 7.2
"Rails.application.secrets",

View File

@@ -93,16 +93,6 @@
# }
# ** Please read carefully, this must be configured in config/application.rb **
# Change the format of the cache entry.
# Changing this default means that all new cache entries added to the cache
# will have a different format that is not supported by Rails 6.1 applications.
# Only change this value after your application is fully deployed to Rails 7.0
# and you have no plans to rollback.
# When you're ready to change format, add this to `config/application.rb` (NOT this file):
# config.active_support.cache_format_version = 7.0
# Cookie serializer: 2 options
#
# If you're upgrading and haven't set `cookies_serializer` previously, your cookie serializer

View File

@@ -1503,6 +1503,10 @@ en_CA:
invite_manager:
user_already_exists: "User already exists"
error: "Something went wrong"
tag_rules:
not_supported_type: Tag rule type not supported
confirm_delete: Are you sure you want to delete this rule ?
destroy_error: There was an issue when removing the Tag rule
order_cycles:
loading_flash:
loading_order_cycles: LOADING ORDER CYCLES

View File

@@ -18,6 +18,8 @@ module OrderManagement
end
def call!(return_url = off_session_return_url)
# if the payment requires_authorization (3D Secure), can't be authorized again
return payment if payment&.requires_authorization?
return unless payment&.checkout?
payment.authorize!(return_url)

View File

@@ -19,6 +19,15 @@ module OrderManagement
end
end
context "when the payment already requires 3D Secure authorization" do
let(:payment) { create(:payment, amount: 10, state: 'requires_authorization') }
before { allow(order).to receive(:pending_payments).once { [payment] } }
it "returns the payment without authorizing because it has already been authorized" do
expect(payment_authorize.call!).to eq payment
end
end
context "when a payment is present" do
let(:payment) { create(:payment, amount: 10) }

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env sh
#
# Test Stripe API integration and record new cassettes.
# Requires account details in .env.test.local. You can copy from Bitwarden, or [set up a new Stripe account](https://github.com/openfoodfoundation/openfoodnetwork/wiki/Setting-up-Stripe-on-an-OFN-instance)
# Requires account details in .env.test.local. See [Stripe testing](https://github.com/openfoodfoundation/openfoodnetwork/wiki/Stripe-testing) for details
set -e # Exit if any command fails

View File

@@ -46,7 +46,7 @@ WebMock.disable_net_connect!(
# in spec/support/ and its subdirectories.
Rails.root.glob("spec/support/**/*.rb").sort.each { |f| require f }
Capybara.server = :puma
Capybara.server = :puma, { Silent: true }
Capybara.disable_animation = true
Capybara.configure do |config|

View File

@@ -6,16 +6,15 @@ require 'stripe/oauth'
RSpec.describe StripeAccount do
describe "deauthorize_and_destroy", :vcr, :stripe_version do
let!(:enterprise) { create(:enterprise) }
let!(:enterprise2) { create(:enterprise) }
let(:client_id) { ENV.fetch('STRIPE_CLIENT_ID', nil) }
let(:stripe_user_id) { ENV.fetch('STRIPE_ACCOUNT', nil) }
let(:stripe_publishable_key) { ENV.fetch('STRIPE_PUBLIC_TEST_API_KEY', nil) }
let!(:stripe_account) {
create(:stripe_account, enterprise:, stripe_user_id:)
}
context "when the Stripe API disconnect fails" do
let(:stripe_user_id) { ENV.fetch('STRIPE_ACCOUNT', nil) }
before { Stripe.client_id = "bogus_client_id" }
it "destroys the record and notifies Bugsnag" do
@@ -36,10 +35,9 @@ RSpec.describe StripeAccount do
})
end
before do
Stripe.client_id = client_id
stripe_account.update!(stripe_publishable_key:, stripe_user_id: connected_account.id)
end
let(:stripe_user_id) { connected_account.id }
before { Stripe.client_id = ENV.fetch('STRIPE_CLIENT_ID', nil) }
it "destroys the record" do
# returns status 200
@@ -53,11 +51,14 @@ RSpec.describe StripeAccount do
end
context "if the account is also associated with another Enterprise" do
let!(:another_stripe_account) {
create(:stripe_account, enterprise: enterprise2, stripe_user_id:)
}
let!(:enterprise2) { create(:enterprise) }
let(:stripe_user_id) { ENV.fetch('STRIPE_ACCOUNT', nil) }
it "Doesn't make a Stripe API disconnection request " do
before do
create(:stripe_account, enterprise: enterprise2, stripe_user_id:)
end
it "doesn't make a Stripe API disconnection request " do
expect(Stripe::OAuth).not_to receive(:deauthorize)
stripe_account.deauthorize_and_destroy
expect(StripeAccount.all).not_to include(stripe_account)

View File

@@ -17,28 +17,52 @@ RSpec.describe Checkout::StripeRedirect do
context "when the payment method is a Stripe method" do
let(:payment_method) { create(:stripe_sca_payment_method) }
let(:stripe_payment) { create(:payment, payment_method_id: payment_method.id) }
let(:test_redirect_url) { "http://stripe_auth_url/" }
before do
order.payments << stripe_payment
end
it "authorizes the payment and returns the redirect path" do
expect(Orders::FindPaymentService).to receive_message_chain(:new, :last_pending_payment).
and_return(stripe_payment)
context "when payment is in checkout state" do
let(:stripe_payment) { create(:payment, payment_method_id: payment_method.id) }
expect(OrderManagement::Order::StripeScaPaymentAuthorize).to receive(:new).and_call_original
it "authorizes the payment and returns the redirect path" do
expect(Orders::FindPaymentService).to receive_message_chain(:new, :last_pending_payment).
and_return(stripe_payment)
expect(stripe_payment).to receive(:authorize!) do
# Authorization moves the payment state from checkout/processing to pending
stripe_payment.state = 'pending'
true
expect(
OrderManagement::Order::StripeScaPaymentAuthorize
).to receive(:new).and_call_original
expect(stripe_payment).to receive(:authorize!) do
# Authorization moves the payment state from checkout/processing to pending
stripe_payment.state = 'pending'
true
end
expect(stripe_payment).to receive(:redirect_auth_url).and_return(test_redirect_url)
expect(service.path).to eq test_redirect_url
end
end
expect(stripe_payment).to receive(:redirect_auth_url).and_return(test_redirect_url)
context "when payment is in requires_authorization state" do
let(:stripe_payment) {
create(
:payment,
payment_method_id: payment_method.id,
state: 'requires_authorization',
redirect_auth_url: test_redirect_url
)
}
expect(service.path).to eq test_redirect_url
it "returns the redirect path without authorizing the payment again" do
expect(Orders::FindPaymentService).to receive_message_chain(:new, :last_pending_payment).
and_return(stripe_payment)
expect(
OrderManagement::Order::StripeScaPaymentAuthorize
).to receive(:new).and_call_original
expect(stripe_payment).not_to receive(:authorize!)
expect(service.path).to eq test_redirect_url
end
end
end
end

View File

@@ -271,9 +271,8 @@ RSpec.describe '
select 'Managed distributor fee', from: 'order_cycle_coordinator_fee_0_id'
click_button 'Create'
# Wait for API requests to finish:
sleep 2
expect(page).to have_content 'Your order cycle has been created.'
click_button "Dismiss"
expect(page).to have_select 'new_supplier_id', with_options: [
"Managed supplier",

View File

@@ -142,12 +142,8 @@ RSpec.describe '
# Now the controller response will show the loading spinner again and
# the fallback mechanism will render the report later.
expect(page).to have_selector ".loading"
# Wait for the fallback mechanism:
sleep 3
expect(page).not_to have_selector ".loading"
expect(page).to have_content "First Name Last Name Billing Address Email"
expect(page).not_to have_selector ".loading"
end
end

View File

@@ -112,6 +112,21 @@ RSpec.describe '
end
end
context "with Stripe setup" do
include StripeHelper
around do |example|
with_stripe_setup { example.call }
end
it "does not cause js errors even if Stripe connect is disabled" do
allow(Spree::Config).to receive(:stripe_connect_enabled).and_return(false)
visit "/account"
expect(page).to have_content "My account"
end
end
context "as a disabled user" do
before do
user.disabled = '1'

View File

@@ -42,9 +42,8 @@ RSpec.describe 'Shops' do
it "by URL" do
pending("#9649")
visit shops_path(anchor: "/?query=xyzzy")
sleep 1
expect(page).not_to have_content distributor.name
expect(page).to have_content "Sorry, no results found for xyzzy. Try another search?"
expect(page).not_to have_content distributor.name
end
it "by typing in the search field" do