Compare commits

..

94 Commits

Author SHA1 Message Date
Ahmed Ejaz
6ad49cc080 Update all locales with the latest Transifex translations 2026-01-26 03:50:53 +05:00
Rachel Arnould
2a7e8816c0 Merge pull request #13834 from mkllnk/pay-methods
Simplify code listing available payment method types
2026-01-23 22:52:29 +01:00
Rachel Arnould
601c921b4b Merge pull request #13831 from dacook/affiliate-sales-data
[DFC Anonymized orders endpoint] Fix unit_type for affiliate sales data
2026-01-23 15:59:49 +01:00
Gaetan Craig-Riou
39fbf01e98 Merge pull request #13876 from openfoodfoundation/dependabot/npm_and_yarn/mini-css-extract-plugin-2.10.0
Bump mini-css-extract-plugin from 2.9.4 to 2.10.0
2026-01-23 10:20:46 +11:00
Gaetan Craig-Riou
69586ae5ae Merge pull request #13875 from openfoodfoundation/dependabot/npm_and_yarn/webpack-5.104.1
Bump webpack from 5.104.0 to 5.104.1
2026-01-23 10:19:27 +11:00
Gaetan Craig-Riou
c87eb05c0e Merge pull request #13874 from openfoodfoundation/dependabot/npm_and_yarn/babel/core-7.28.6
Bump @babel/core from 7.28.5 to 7.28.6
2026-01-23 10:18:30 +11:00
Gaetan Craig-Riou
a1f363c53b Merge pull request #13868 from mkllnk/spec-helper
Merge and simplify rspec config
2026-01-23 10:14:53 +11:00
dependabot[bot]
76c6362db0 Bump mini-css-extract-plugin from 2.9.4 to 2.10.0
Bumps [mini-css-extract-plugin](https://github.com/webpack/mini-css-extract-plugin) from 2.9.4 to 2.10.0.
- [Release notes](https://github.com/webpack/mini-css-extract-plugin/releases)
- [Changelog](https://github.com/webpack/mini-css-extract-plugin/blob/main/CHANGELOG.md)
- [Commits](https://github.com/webpack/mini-css-extract-plugin/compare/v2.9.4...v2.10.0)

---
updated-dependencies:
- dependency-name: mini-css-extract-plugin
  dependency-version: 2.10.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-22 09:32:58 +00:00
dependabot[bot]
5c3308de36 Bump webpack from 5.104.0 to 5.104.1
Bumps [webpack](https://github.com/webpack/webpack) from 5.104.0 to 5.104.1.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Changelog](https://github.com/webpack/webpack/blob/main/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack/compare/v5.104.0...v5.104.1)

---
updated-dependencies:
- dependency-name: webpack
  dependency-version: 5.104.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-22 09:32:50 +00:00
dependabot[bot]
a82b2c2799 Bump @babel/core from 7.28.5 to 7.28.6
Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.28.5 to 7.28.6.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.28.6/packages/babel-core)

---
updated-dependencies:
- dependency-name: "@babel/core"
  dependency-version: 7.28.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-22 09:32:43 +00:00
Maikel
4895010fe0 Merge pull request #13872 from openfoodfoundation/dependabot/npm_and_yarn/lodash-4.17.23
Bump lodash from 4.17.21 to 4.17.23
2026-01-22 14:36:50 +11:00
Maikel
962097f237 Merge pull request #13871 from openfoodfoundation/dependabot/npm_and_yarn/postcss-preset-env-10.6.1
Bump postcss-preset-env from 10.5.0 to 10.6.1
2026-01-22 14:35:59 +11:00
Maikel
941707a0df Merge pull request #13870 from openfoodfoundation/dependabot/npm_and_yarn/sass-embedded-1.97.2
Bump sass-embedded from 1.96.0 to 1.97.2
2026-01-22 14:34:31 +11:00
David Cook
f7e119d06f Merge pull request #13869 from openfoodfoundation/dependabot/npm_and_yarn/cross-spawn-7.0.6
Bump cross-spawn from 7.0.3 to 7.0.6
2026-01-22 10:19:18 +11:00
dependabot[bot]
52ee5929cf Bump lodash from 4.17.21 to 4.17.23
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.21 to 4.17.23.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.21...4.17.23)

---
updated-dependencies:
- dependency-name: lodash
  dependency-version: 4.17.23
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-21 23:05:03 +00:00
dependabot[bot]
1e58882217 Bump postcss-preset-env from 10.5.0 to 10.6.1
Bumps [postcss-preset-env](https://github.com/csstools/postcss-plugins/tree/HEAD/plugin-packs/postcss-preset-env) from 10.5.0 to 10.6.1.
- [Changelog](https://github.com/csstools/postcss-plugins/blob/main/plugin-packs/postcss-preset-env/CHANGELOG.md)
- [Commits](https://github.com/csstools/postcss-plugins/commits/HEAD/plugin-packs/postcss-preset-env)

---
updated-dependencies:
- dependency-name: postcss-preset-env
  dependency-version: 10.6.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-21 09:32:46 +00:00
dependabot[bot]
ca23f12451 Bump sass-embedded from 1.96.0 to 1.97.2
Bumps [sass-embedded](https://github.com/sass/embedded-host-node) from 1.96.0 to 1.97.2.
- [Changelog](https://github.com/sass/embedded-host-node/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sass/embedded-host-node/compare/1.96.0...1.97.2)

---
updated-dependencies:
- dependency-name: sass-embedded
  dependency-version: 1.97.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-21 09:32:39 +00:00
David Cook
cce37aa915 Add explanation for magic number 2026-01-21 17:09:33 +11:00
dependabot[bot]
f808fe9685 Bump cross-spawn from 7.0.3 to 7.0.6
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.6.
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.6)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-version: 7.0.6
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-21 05:18:48 +00:00
Gaetan Craig-Riou
dd5db396b4 Merge pull request #13828 from rioug/10298-upgrade-to-shakapaker
Upgrade to shakapaker
2026-01-21 16:17:50 +11:00
David Cook
e121a799ed Refer to unit from variant
variant_unit was moved to variant as part of product refactor.
Old products probably still had a value there, but new ones would have been appearing with nil.
2026-01-21 16:10:30 +11:00
David Cook
5dfef4a3ae Add specs for data, with product and variant grouping
Oh and by the way, we missed something in the product refactor.
2026-01-21 16:10:30 +11:00
David Cook
8236603f76 Add ability to specify variant for order
I will need this in the following commit. For existing specs where no variant is specified, a product with variant will be created (I think this is what the line item factory would have done before).
2026-01-21 16:10:30 +11:00
Gaetan Craig-Riou
315d52961a Add "v1" to locale cache key
This is to invalidate existing locale cache key, so it will pick up
image path changes in cached fragment with locale
2026-01-21 14:29:46 +11:00
Maikel Linke
dcb6f4676d Remove all unnecessary spec_helper require statements
The `.rspec` file is doing this for us.
2026-01-21 12:35:34 +11:00
Maikel Linke
3455ceb722 Use standard spec_helper filename 2026-01-21 12:09:12 +11:00
Maikel Linke
7361b2da0b Move related rspec config to one place 2026-01-21 12:09:12 +11:00
Maikel Linke
3ebacbc31a Move require statement to the right file 2026-01-21 12:09:11 +11:00
David Cook
c0bcf177e7 Merge pull request #13861 from mkllnk/bump-ruby
Bump Ruby from 3.3.10 to 3.4.8
2026-01-20 16:34:31 +11:00
David Cook
8dfede11c6 Merge pull request #13862 from mkllnk/allow_checkout_on_gateway_error
Remove unused switch to allow checkout on failures
2026-01-20 12:25:03 +11:00
Maikel Linke
bac123f223 Remove unused switch to allow checkout on failures
The inherited payment logic is complicated enough. Removing this dead
code makes it slightly simpler.
2026-01-19 14:35:54 +11:00
Maikel Linke
fdc775ae6d Style arguments forwarding 2026-01-19 10:55:24 +11:00
Maikel Linke
26b39d6626 Add convenience script to bump ruby version 2026-01-19 10:40:01 +11:00
Maikel Linke
8953e8481d Remove unnecessary bundler install script
Bundler does the same already.
2026-01-19 10:40:01 +11:00
Maikel Linke
1ce76a3166 Bump Ruby from 3.3.10p183 to 3.4.8p72 2026-01-19 10:34:34 +11:00
Maikel Linke
1c703905fe Remove now redundant install of bundler 2026-01-19 10:34:34 +11:00
David Cook
feed223ab4 Merge pull request #13528 from dacook/vine-expiry-message-13495
[VINE] Show helpful message if voucher expired
2026-01-19 09:20:18 +11:00
Gaetan Craig-Riou
90f962a886 Use compiler_strategy mtime for test environment
It fixes the issue for CI as it's faster than the digest strategy:
https://github.com/shakacode/shakapacker/blob/main/docs/configuration.md#compiler_strategy
2026-01-16 13:47:23 +11:00
Gaetan Craig-Riou
82f6484031 Add comment explaning why defer loading is disabled 2026-01-16 12:30:57 +11:00
Gaetan Craig-Riou
282fb44da4 Update all locales with the latest Transifex translations 2026-01-16 10:05:27 +11:00
Gaetan Craig-Riou
82f40d2e93 Merge pull request #13821 from piyyu/fix-import-multiple-products
Fix “Import multiple products” button route on empty products page
2026-01-16 09:55:33 +11:00
Gaetan Craig-Riou
cae1655ec3 Merge pull request #13848 from dacook/cleanup-tmp-ctrl
Remove unused file
2026-01-14 16:23:11 +11:00
David Cook
26702e6f0d Remove unused file
Low-hanging fruit 🍇
2026-01-13 14:59:26 +11:00
Gaetan Craig-Riou
8cd9e94148 Use a separate config for webpacker on CI
For some reason having webpack compile turned on for the test
environment makes system test slow, resulting in lots of failure. Assets
are precompiled for system test, so there isn't any compilation on each
request, but still test are slow.
To fix the issue, we use a separate config file for CI where webpack
compile is set turned off.
2026-01-13 14:35:36 +11:00
Gaetan Craig-Riou
a934b60f67 Make sure shipping modal gets closed
Also check the modal is not showing instead of checking it's hidden
2026-01-13 14:34:50 +11:00
Maikel
7fc9a6bf93 Merge pull request #13829 from mkllnk/ruby-3.3
Bump ruby from 3.2.9p265 to 3.3.10p183
2026-01-13 12:22:28 +11:00
David Cook
781bf940f6 Merge pull request #13837 from mkllnk/fix-seeds
Fix database seeding with admin user
2026-01-13 12:02:32 +11:00
Maikel Linke
92382ca473 Remove outdated warning
We only create a user when seeding the database and we check that
there's no user already. We don't have a use case for adding an admin
user to a database with user data.

It also referred to a spree task that doesn't exist in our code base.
2026-01-13 11:02:49 +11:00
Maikel Linke
76a3e913df Remove unnecessary load 2026-01-13 11:00:02 +11:00
Maikel Linke
23ab6bb489 Create seed admin user without prompting for details
We don't really need it. In development, we use default values. And when
preparing a new server, we set env vars.

This fixes a broken dependency on HighLine. I found removal easier than
fixing something we don't use.
2026-01-13 10:59:31 +11:00
David Cook
368da19993 Display more specific invalid_voucher message to customer
It was implemented with error code  409 in https://github.com/openfoodfoundation/vine/pull/112
2026-01-12 17:14:57 +11:00
David Cook
419f4490d6 Recognise certain voucher errors
I considered using the vine error message as the translation key (ie I18n.t(vine_voucher_validator_service.errors.#{message.parameterize.underscore}), but thought it might be more predictable to have keys explicitly defined and whitelisted like this.

These error message are still squashed by the controller, we'll deal with that next.
2026-01-12 16:25:57 +11:00
Gaetan Craig-Riou
39245d55e2 Turn defer off when loading javascript script
It seems that we have functionality that depends on the order the
scripts are executed. Using defer breaks that.
Using defer is better performance wise so we should try to address this
eventually, might need to wait till we get rid of angular.
2026-01-12 15:56:03 +11:00
Gaetan Craig-Riou
fe8200b7e8 Move babel config back to it's own file
It's need for jest to work properly.
2026-01-12 15:56:03 +11:00
David Cook
c799f15067 Update ruby-build with homebrew if installed
This is commonly used on Mac.
2026-01-12 15:09:49 +11:00
David Cook
54f1047dcb Merge pull request #13830 from mkllnk/highline
Bump highline from 2.0.3 to 3.1.2 to support newer rubies
2026-01-12 11:14:06 +11:00
Maikel
c1e599deef Merge pull request #13833 from mkllnk/nodenv
Add instructions how to install nodenv
2026-01-12 10:40:54 +11:00
Maikel Linke
f3c60148c1 Simplify filtering of Stripe 2026-01-09 16:54:25 +11:00
Maikel Linke
2e08c9c44e Simplify with defined order of payment methods 2026-01-09 16:54:21 +11:00
Maikel Linke
93f2af7e7d Lazy load payment method classes
This avoids any class reloading issues in dev, simplifies most of the
code path and opens up for refactoring.

The only reason we still load the class is to call `clean_name` on it
for the translation key. We can probably do better.
2026-01-09 16:54:02 +11:00
Maikel Linke
cb7a4b67ce Replace custom lookup with default Rails feature
Rails renders an error when you try to supply an invalid value. Our code
is safe without an allow-list and the UX doesn't allow you to select an
invalid value.
2026-01-09 16:53:06 +11:00
Maikel Linke
41a8d06326 Remove duplicate definition of payment providers 2026-01-09 15:16:36 +11:00
Maikel Linke
a957df1205 Use I18n API for readability 2026-01-09 15:16:36 +11:00
Maikel Linke
a1bdfa0a20 Move list of payment methods to where it is used 2026-01-09 15:16:36 +11:00
Maikel Linke
1adf94093e Merge related initializer code
The division came likely from Spree times.
2026-01-09 15:16:35 +11:00
Maikel Linke
476daf0d30 Add instructions how to install nodenv 2026-01-09 13:47:41 +11:00
Maikel Linke
79a9dbcf68 Bump highline from 2.0.3 to 3.1.2 to support newer rubies 2026-01-07 14:12:59 +11:00
Maikel Linke
61c7c26822 Remove version restriction on highline
It came from a very old version of the Spree code.
2026-01-07 14:09:42 +11:00
Maikel Linke
969dcae8d0 Remove unnecessary require statement 2026-01-07 14:08:10 +11:00
Maikel Linke
ce5a95ff4f Bump bundler from 2.4.19 to 2.5.22 (default gem) 2026-01-07 12:24:03 +11:00
Maikel Linke
0d5330d388 Bump ruby from 3.2.9p265 to 3.3.10p183 2026-01-07 12:21:13 +11:00
Gaetan Craig-Riou
3676acf244 Fix font link 2026-01-06 14:31:44 +11:00
Gaetan Craig-Riou
caf6b087c1 Clean up wepacker config
Disable overlayi, it covers the whole page as we have lots of warning
2026-01-06 14:31:44 +11:00
Gaetan Craig-Riou
24d6c1e386 Remove support for IE 11
Stimulus doesn't support IE 11 : https://stimulus.hotwired.dev/handbook/installing#browser-support
2026-01-06 14:31:44 +11:00
Gaetan Craig-Riou
a120e390d0 Remove added config, not needed anymore 2026-01-06 14:31:44 +11:00
Gaetan Craig-Riou
98a2bf5d47 image_pack_path is now available from Shackapaker 2026-01-06 14:31:44 +11:00
Gaetan Craig-Riou
bb0c1e7a0f Quiet sass deprecations warning for dependencies
We are not planning to upgrade foundation-sites
2026-01-06 14:31:44 +11:00
Gaetan Craig-Riou
55a15b914c Upgrade to shakapacker 6.6.0 2026-01-06 14:31:44 +11:00
Gaetan Craig-Riou
8ce14a55c8 Fix dependencies version, and update config
Trying to stay as close as possible to the default config
2026-01-06 14:31:43 +11:00
Gaetan Craig-Riou
d1f47f6956 Rename bin scripts to match new name 2026-01-06 14:31:32 +11:00
Gaetan Craig-Riou
2d50dace20 Move to shakapacker 6 and install dependencies 2026-01-06 14:31:32 +11:00
Gaetan Craig-Riou
bbbbe71bc4 Remove deprecated ~prefix
https://github.com/webpack/sass-loader/blob/main/README.md#the-style-new-api-by-default-since-16-version-and-outputstyle-old-api-options-in-production-mode
2026-01-06 14:31:32 +11:00
Gaetan Craig-Riou
b3dc76b8cf Fix configuration and scss to get webpack to compile
Move the Postcss config hack to postcss.config.js
2026-01-06 14:31:32 +11:00
Gaetan Craig-Riou
ad4b26e86d Add missing dependency for asset compilation 2026-01-06 14:31:32 +11:00
Gaetan Craig-Riou
c2a7a89381 Move extensions configuration to webpack.config.js 2026-01-06 14:31:32 +11:00
Gaetan Craig-Riou
68e3623861 Use default babel config, set up on package.json 2026-01-06 14:31:32 +11:00
Gaetan Craig-Riou
577aa55f98 Move browserlist settings to package.json 2026-01-06 14:31:32 +11:00
Gaetan Craig-Riou
b8e62b3d84 Add coffeeScript dependency 2026-01-06 14:31:32 +11:00
Gaetan Craig-Riou
dbb8e07b9a Add Sass integration
We are still using the old `ruby-sass` because it's a dependency from
`rails-sass` which is a dependcy from `select2`. It looks like the
master branch on the ofn fork get rid of the dependency, so we should
upgrading.
2026-01-06 14:31:32 +11:00
Gaetan Craig-Riou
19550ed4fe Add postcss integration 2026-01-06 14:31:32 +11:00
Gaetan Craig-Riou
4d0c710e3b Add css integration 2026-01-06 14:31:32 +11:00
Gaetan Craig-Riou
fccde70690 Upgrading to webpacker v6.0.0.rc.6
Migration guide : https://github.com/shakacode/shakapacker/blob/main/docs/v6_upgrade.md#how-to-upgrade-to-webpacker-v600rc6-from-v5
Setp 1,2,3,4
2026-01-06 14:31:25 +11:00
piyyu
0f59333cd9 Fix import multiple products button route 2025-12-26 02:10:46 +05:30
piyyu
ad4ce14486 Fix import multiple products button route 2025-12-26 00:11:09 +05:30
572 changed files with 4154 additions and 7809 deletions

View File

@@ -1,2 +0,0 @@
defaults
IE 11

1
.gitattributes vendored
View File

@@ -8,4 +8,3 @@
# Same thing for following files, but they don't have an sh extension
pre-commit eol=lf
webpack-dev-server eol=lf
install-bundler eol=lf

2
.rspec
View File

@@ -1 +1 @@
--require base_spec_helper
--require spec_helper

View File

@@ -1 +1 @@
3.2.9
3.4.8

View File

@@ -1,4 +1,4 @@
FROM ruby:3.2.9-alpine3.19 AS base
FROM ruby:3.4.8-alpine3.19 AS base
ENV LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
TZ=Europe/London \
@@ -31,4 +31,4 @@ FROM development-base
COPY . $RAILS_ROOT
COPY Gemfile Gemfile.lock ./
RUN bundle install --jobs "$(nproc)"
COPY --from=yarn-dependencies $RAILS_ROOT/node_modules ./node_modules
COPY --from=yarn-dependencies $RAILS_ROOT/node_modules ./node_modules

View File

@@ -83,11 +83,8 @@ RUN wget https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.z
# Copy code and install app dependencies
COPY . /usr/src/app/
# Install Bundler
RUN ./script/install-bundler
# Install front-end dependencies
RUN yarn install
# Run bundler install in parallel with the amount of available CPUs
RUN bundle install --jobs="$(nproc)"
RUN bundle install --jobs="$(nproc)"

View File

@@ -18,7 +18,7 @@ gem 'activemerchant'
gem 'angular-rails-templates'
gem 'ransack', '~> 4.1.0'
gem 'responders'
gem 'webpacker', '~> 5'
gem 'shakapacker', '6.6.0'
# Indirect dependency but we access it directly in JS specs.
# It turns out to be hard to upgrade but please do if you can.
@@ -49,7 +49,7 @@ gem 'acts_as_list', '1.0.4'
gem 'cancancan', '~> 1.15.0'
gem 'digest'
gem 'ffaker'
gem 'highline', '2.0.3' # Necessary for the install generator
gem 'highline'
gem 'json'
gem 'monetize', '~> 1.11'
gem 'paranoia', '~> 2.4'
@@ -126,6 +126,8 @@ gem 'angular_rails_csrf'
gem 'jquery-rails', '4.4.0'
gem 'jquery-ui-rails', '~> 4.2'
# TODO move away from sass-rails, master branch will get rid of dependency, so we can move to
# https://github.com/sass/embedded-host-node
gem "select2-rails", github: "openfoodfoundation/select2-rails", branch: "v349_with_thor_v1"
gem 'good_migrations'

View File

@@ -389,7 +389,8 @@ GEM
hashdiff (1.2.1)
hashery (2.1.2)
hashie (5.0.0)
highline (2.0.3)
highline (3.1.2)
reline
htmlentities (4.4.2)
http_parser.rb (0.8.0)
i18n (1.14.7)
@@ -614,7 +615,7 @@ GEM
rack-protection (3.2.0)
base64 (>= 0.1.0)
rack (~> 2.2, >= 2.2.4)
rack-proxy (0.7.6)
rack-proxy (0.7.7)
rack
rack-rewrite (1.5.1)
rack-session (1.0.2)
@@ -813,7 +814,12 @@ GEM
tilt (>= 1.1, < 3)
sd_notify (0.1.1)
securerandom (0.4.1)
semantic_range (3.0.0)
semantic_range (3.1.0)
shakapacker (6.6.0)
activesupport (>= 5.2)
rack-proxy (>= 0.6.1)
railties (>= 5.2)
semantic_range (>= 2.3.0)
shoulda-matchers (7.0.1)
activesupport (>= 7.1)
sidekiq (7.2.4)
@@ -941,11 +947,6 @@ GEM
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webpacker (5.4.4)
activesupport (>= 5.2)
rack-proxy (>= 0.6.1)
railties (>= 5.2)
semantic_range (>= 2.3.0)
webrick (1.9.2)
websocket-driver (0.7.7)
base64
@@ -1018,7 +1019,7 @@ DEPENDENCIES
good_migrations
haml
haml_lint
highline (= 2.0.3)
highline
i18n
i18n-js (~> 3.9.0)
i18n-tasks
@@ -1082,6 +1083,7 @@ DEPENDENCIES
rubocop-rspec_rails
sd_notify
select2-rails!
shakapacker (= 6.6.0)
shoulda-matchers
sidekiq
sidekiq-scheduler
@@ -1107,13 +1109,12 @@ DEPENDENCIES
web!
web-console
webmock
webpacker (~> 5)
whenever
wicked_pdf
wkhtmltopdf-binary
RUBY VERSION
ruby 3.2.9p265
ruby 3.4.8p72
BUNDLED WITH
2.4.19
4.0.3

View File

@@ -1,5 +1,5 @@
# Foreman Procfile. Start all dev server processes with: `foreman start`
rails: DEV_CACHING=true bundle exec rails s -p 3000
webpack: ./bin/webpack-dev-server
webpack: ./bin/webpacker-dev-server
sidekiq: DEV_CACHING=true bundle exec sidekiq -q mailers -q default

View File

@@ -1,5 +1,5 @@
# Foreman Procfile for Docker env. Start all dev server processes with: `bundle exec foreman start -f Procfile.docker`
webpack: WEBPACKER_DEV_SERVER_HOST=0.0.0.0 ./bin/webpack-dev-server
webpack: WEBPACKER_DEV_SERVER_HOST=0.0.0.0 ./bin/webpacker-dev-server
sidekiq: DEV_CACHING=true bundle exec sidekiq -q mailers -q default
rails: WEBPACKER_DEV_SERVER_HOST=0.0.0.0 DEV_CACHING=true bundle exec rails s -p 3000 -b 0.0.0.0

View File

@@ -1,2 +0,0 @@
angular.module('Darkswarm').controller "TmpCtrl", ($scope)->
$scope.test = {foo: "bar"}

View File

@@ -1,4 +1,4 @@
= render ConfirmModalComponent.new(id: dom_id(@order, :ship), confirm_reflexes: "click->Admin::OrdersReflex#ship", controller: "orders", reflex: "Admin::Orders#ship") do
= render ConfirmModalComponent.new(id: dom_id(@order, :ship), confirm_actions: "click->modal#close", confirm_reflexes: "click->Admin::OrdersReflex#ship", controller: "orders", reflex: "Admin::Orders#ship") do
%div{class: "margin-bottom-30"}
%p= t('spree.admin.orders.shipment.mark_as_shipped_message_html')
%div{class: "margin-bottom-30"}

View File

@@ -11,10 +11,10 @@ module Spree
respond_to :html
PAYMENT_METHODS = %w{
Spree::PaymentMethod::Check
Spree::Gateway::PayPalExpress
Spree::Gateway::StripeSCA
}.index_with(&:constantize).freeze
Spree::PaymentMethod::Check
}.freeze
def create
force_environment
@@ -95,7 +95,7 @@ module Spree
@payment_method = PaymentMethod.find(params[:pm_id])
end
else
@payment_method = PAYMENT_METHODS.fetch(params[:provider_type], PaymentMethod).new
@payment_method = PaymentMethod.new(type: params[:provider_type])
end
render partial: 'provider_settings'
@@ -117,7 +117,7 @@ module Spree
end
def validate_payment_method_provider
valid_payment_methods = Rails.application.config.spree.payment_methods.map(&:to_s)
valid_payment_methods = PAYMENT_METHODS
return if valid_payment_methods.include?(params[:payment_method][:type])
flash[:error] = Spree.t(:invalid_payment_provider)
@@ -133,13 +133,11 @@ module Spree
end
def load_providers
providers = Gateway.providers.sort_by(&:name)
providers = PAYMENT_METHODS.dup
unless show_stripe?
providers.reject! { |provider| stripe_provider?(provider) }
end
providers.delete("Spree::Gateway::StripeSCA") unless show_stripe?
providers
providers.map(&:constantize)
end
# Show Stripe as an option if enabled, or if the
@@ -164,10 +162,6 @@ module Spree
@payment_method.try(:type) == "Spree::Gateway::StripeSCA"
end
def stripe_provider?(provider)
provider.name.ends_with?("StripeSCA")
end
def base_params
@base_params ||= PermittedAttributes::PaymentMethod.new(params[:payment_method]).
call.to_h.with_indifferent_access

View File

@@ -90,11 +90,13 @@ class VoucherAdjustmentsController < BaseController
voucher_code: voucher_params[:voucher_code], enterprise: @order.distributor
)
voucher = vine_voucher_validator.validate
errors = vine_voucher_validator.errors
return nil if vine_voucher_validator.errors[:not_found_voucher].present?
return nil if errors[:not_found_voucher].present?
if vine_voucher_validator.errors.present?
@order.errors.add(:voucher_code, I18n.t('checkout.errors.add_voucher_error'))
if errors.present?
message = errors[:invalid_voucher] || I18n.t('checkout.errors.add_voucher_error')
@order.errors.add(:voucher_code, message)
return nil
end

View File

@@ -72,7 +72,8 @@ module ApplicationHelper
end
end
# Update "v1" to invalidate existing cache key
def cache_key_with_locale(key, locale)
Array.wrap(key) + [locale.to_s, I18nDigests.for_locale(locale)]
Array.wrap(key) + ["v1", locale.to_s, I18nDigests.for_locale(locale)]
end
end

View File

@@ -31,7 +31,6 @@ module Spree
preference :admin_products_per_page, :integer, default: 10
# Should only be true if you don't need to track inventory
preference :allow_backorder_shipping, :boolean, default: false
preference :allow_checkout_on_gateway_error, :boolean, default: false
preference :allow_guest_checkout, :boolean, default: true
preference :currency_decimal_mark, :string, default: "."
preference :currency_symbol_position, :string, default: "before"

View File

@@ -437,18 +437,13 @@ module Spree
#
# Returns:
# - true if all pending_payments processed successfully
# - true if a payment failed, ie. raised a GatewayError
# which gets rescued and converted to TRUE when
# :allow_checkout_gateway_error is set to true
# - false if a payment failed, ie. raised a GatewayError
# which gets rescued and converted to FALSE when
# :allow_checkout_on_gateway_error is set to false
# which gets rescued and converted to FALSE
#
def process_payments!
process_each_payment(&:process!)
rescue Core::GatewayError => e
result = !!Spree::Config[:allow_checkout_on_gateway_error]
errors.add(:base, e.message) && (return result)
errors.add(:base, e.message) && (return false)
end
def process_payments_offline!

View File

@@ -52,10 +52,6 @@ module Spree
.where(environment: [Rails.env, "", nil])
}
def self.providers
Rails.application.config.spree.payment_methods
end
def configured?
!stripe? || stripe_configured?
end
@@ -93,8 +89,8 @@ module Spree
type.demodulize.downcase
end
def self.find_with_destroyed(*args)
unscoped { find(*args) }
def self.find_with_destroyed(*)
unscoped { find(*) }
end
def payment_profiles_supported?
@@ -118,8 +114,8 @@ module Spree
end
def self.clean_name
i18n_key = "spree.admin.payment_methods.providers.#{name.demodulize.downcase}"
I18n.t(i18n_key)
scope = "spree.admin.payment_methods.providers"
I18n.t(name.demodulize.downcase, scope:)
end
private

View File

@@ -2,6 +2,11 @@
module Vine
class VoucherValidatorService
VINE_ERRORS = {
# https://github.com/openfoodfoundation/vine/blob/main/app/Enums/ApiResponse.php
"This voucher has expired." => :expired,
}.freeze
attr_reader :voucher_code, :errors
def initialize(voucher_code:, enterprise:)
@@ -42,8 +47,10 @@ module Vine
end
def handle_errors(response)
if response[:status] == 400
errors[:invalid_voucher] = I18n.t("vine_voucher_validator_service.errors.invalid_voucher")
if [400, 409].include?(response[:status])
message = response[:body] && JSON.parse(response[:body]).dig("meta", "message")
key = VINE_ERRORS.fetch(message, :invalid_voucher)
errors[:invalid_voucher] = I18n.t("vine_voucher_validator_service.errors.#{key}")
elsif response[:status] == 404
errors[:not_found_voucher] =
I18n.t("vine_voucher_validator_service.errors.not_found_voucher")

View File

@@ -7,5 +7,6 @@
#no-products-actions
%a{ href: "/admin/products/new", class: "button icon-plus", icon: "icon-plus" }
= t(:new_product)
%a{ href: "/admin/products/import", class: "button icon-upload secondary", icon: "icon-upload" }
%a{ href: admin_product_import_path, class: "button icon-upload secondary", icon: "icon-upload" }
= t(".import_products")

View File

@@ -13,12 +13,12 @@
- else
= favicon_link_tag "/favicon-staging.ico"
%link{href: "https://fonts.googleapis.com/css?family=Roboto:400,300italic,400italic,300,700,700italic|Oswald:300,400,700", rel: "stylesheet", type: "text/css"}
%link{href: asset_pack_path("media/fonts/OFN-v2.woff"), rel: "preload", as: "font", crossorigin: "anonymous"}
%link{href: asset_pack_path("static/OFN-v2.woff"), rel: "preload", as: "font", crossorigin: "anonymous"}
= render "layouts/matomo_tag"
= language_meta_tags
= stylesheet_pack_tag "darkswarm", "data-turbo-track": "reload", media: "screen"
= javascript_pack_tag "application", "data-turbo-track": "reload"
= javascript_pack_tag "application", "data-turbo-track": "reload", defer: false # do not use defer because our javascript currently depend on order of execution of loaded script.
= render "layouts/shopfront_script" if @shopfront_layout
= render "layouts/bugsnag_js"

View File

@@ -16,7 +16,7 @@
= stylesheet_pack_tag "darkswarm", media: "screen"
= javascript_include_tag "darkswarm/all"
= javascript_pack_tag "application"
= javascript_pack_tag "application", defer: false # do not use defer because our javascript currently depend on order of execution of loaded script.
= csrf_meta_tags

View File

@@ -25,7 +25,7 @@
= render "spree/admin/shared/translations"
= render "spree/admin/shared/routes"
= javascript_pack_tag "admin", "data-turbo-track": "reload"
= javascript_pack_tag "admin", "data-turbo-track": "reload", defer: false # do not use defer because our javascript currently depend on order of execution of loaded script.
%script
= raw "var AUTH_TOKEN = \"#{form_authenticity_token}\";"

View File

@@ -2,19 +2,19 @@
// While in feature-toggle, we inherit all files from old admin design.
// Individual files may be copied in order to replace the old files.
@import "vendor/assets/stylesheets/normalize";
@import "vendor/assets/stylesheets/responsive-tables";
@import "vendor/assets/stylesheets/jquery.powertip";
@import "~jquery-ui/themes/base/core";
@import "~jquery-ui/themes/base/button";
@import "~jquery-ui/themes/base/resizable";
@import "vendor/assets/stylesheets/jquery-ui-theme";
@import "~jquery-ui/themes/base/dialog";
@import "assets/stylesheets/normalize";
@import "assets/stylesheets/responsive-tables";
@import "assets/stylesheets/jquery.powertip";
@import "jquery-ui/themes/base/core";
@import "jquery-ui/themes/base/button";
@import "jquery-ui/themes/base/resizable";
@import "assets/stylesheets/jquery-ui-theme";
@import "jquery-ui/themes/base/dialog";
@import "../shared/ng-tags-input.min";
@import "vendor/assets/stylesheets/select2.css.scss";
@import "~flatpickr/dist/flatpickr";
@import "~flatpickr/dist/themes/material_blue";
@import "~shortcut-buttons-flatpickr/dist/themes/light";
@import "assets/stylesheets/select2";
@import "flatpickr/dist/flatpickr";
@import "flatpickr/dist/themes/material_blue";
@import "shortcut-buttons-flatpickr/dist/themes/light";
@import "../admin/globals/functions";
@import "globals/palette"; // admin_v3
@@ -123,13 +123,13 @@
@import "shared/question-mark-icon";
@import "../admin/question-mark-tooltip";
@import "~tom-select/src/scss/tom-select.default";
@import "tom-select/src/scss/tom-select.default";
@import "components/tom_select"; // admin_v3
@import "app/components/modal_component/modal_component";
@import "app/components/vertical_ellipsis_menu_component/vertical_ellipsis_menu_component"; // admin_v3 and only V3
@import "app/components/tag_list_input_component/tag_list_input_component";
@import "app/webpacker/css/admin/trix.scss";
@import "modal_component/modal_component";
@import "vertical_ellipsis_menu_component/vertical_ellipsis_menu_component"; // admin_v3 and only V3
@import "tag_list_input_component/tag_list_input_component";
@import "admin/trix";
@import "terms_of_service_banner"; // admin_v3

View File

@@ -1,10 +1,10 @@
@import 'vendor/assets/stylesheets/autocomplete';
@import 'vendor/assets/stylesheets/leaflet';
@import 'assets/stylesheets/autocomplete';
@import 'assets/stylesheets/leaflet';
@import 'variables';
@import '../shared/variables/layout';
@import '../shared/utilities';
@import '~foundation-sites/scss/foundation';
@import 'foundation-sites/scss/foundation';
@import 'big-input';
@import 'branding';
@@ -77,4 +77,4 @@ ofn-modal {
@import "../shared/question-mark-icon";
@import '../admin/shared/scroll_bar';
@import 'app/components/modal_component/modal_component';
@import 'modal_component/modal_component';

View File

@@ -1,4 +1,4 @@
@import "~foundation-sites/scss/foundation/components/global";
@import "foundation-sites/scss/foundation/components/global";
// Brand guide colours:
// International: #81c26e

View File

@@ -1,72 +1,6 @@
module.exports = function(api) {
var validEnv = ['development', 'test', 'production']
var currentEnv = api.env()
var isDevelopmentEnv = api.env('development')
var isProductionEnv = api.env('production')
var isTestEnv = api.env('test')
module.exports = function (api) {
const defaultConfigFunc = require("shakapacker/package/babel/preset.js");
const resultConfig = defaultConfigFunc(api);
if (!validEnv.includes(currentEnv)) {
throw new Error(
'Please specify a valid `NODE_ENV` or ' +
'`BABEL_ENV` environment variables. Valid values are "development", ' +
'"test", and "production". Instead, received: ' +
JSON.stringify(currentEnv) +
'.'
)
}
return {
presets: [
isTestEnv && [
'@babel/preset-env',
{
targets: {
node: 'current'
}
}
],
(isProductionEnv || isDevelopmentEnv) && [
'@babel/preset-env',
{
forceAllTransforms: true,
useBuiltIns: 'entry',
corejs: 3,
modules: false,
exclude: ['transform-typeof-symbol']
}
]
].filter(Boolean),
plugins: [
'babel-plugin-macros',
'@babel/plugin-syntax-dynamic-import',
isTestEnv && 'babel-plugin-dynamic-import-node',
'@babel/plugin-transform-destructuring',
[
'@babel/plugin-proposal-class-properties',
{
loose: true
}
],
[
'@babel/plugin-proposal-object-rest-spread',
{
useBuiltIns: true
}
],
[
'@babel/plugin-transform-runtime',
{
helpers: false
}
],
[
'@babel/plugin-transform-regenerator',
{
async: false
}
],
["@babel/plugin-proposal-private-property-in-object", { "loose": true }],
["@babel/plugin-proposal-private-methods", { "loose": true }]
].filter(Boolean)
}
}
return resultConfig;
};

View File

@@ -16,7 +16,7 @@ FileUtils.chdir APP_ROOT do
# Add necessary setup steps to this file.
puts "== Installing dependencies =="
system! "script/install-bundler"
# Check first (it's quicker), then install new gems if necessary
system("bundle check 2> /dev/null") || system!(BUNDLE_ENV, "bundle install")

View File

@@ -1,18 +1,13 @@
#!/usr/bin/env ruby
ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
ENV["NODE_ENV"] ||= "development"
ENV["NODE_OPTIONS"] ||= "--openssl-legacy-provider"
require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require "bundler/setup"
require "webpacker"
require "webpacker/webpack_runner"
ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", Pathname.new(__FILE__).realpath)
APP_ROOT = File.expand_path("..", __dir__)
Dir.chdir(APP_ROOT) do
Webpacker::WebpackRunner.run(ARGV)

View File

@@ -1,8 +1,6 @@
#!/usr/bin/env ruby
ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
ENV["NODE_ENV"] ||= "development"
ENV["NODE_OPTIONS"] ||= "--openssl-legacy-provider"
require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",

View File

@@ -1,9 +1,16 @@
#!/usr/bin/env ruby
APP_ROOT = File.expand_path('..', __dir__)
APP_ROOT = File.expand_path("..", __dir__)
Dir.chdir(APP_ROOT) do
begin
exec "yarnpkg", *ARGV
rescue Errno::ENOENT
yarn = ENV["PATH"].split(File::PATH_SEPARATOR).
select { |dir| File.expand_path(dir) != __dir__ }.
product(["yarn", "yarnpkg", "yarn.cmd", "yarn.ps1"]).
map { |dir, file| File.expand_path(file, dir) }.
find { |file| File.executable?(file) }
if yarn
exec yarn, *ARGV
else
$stderr.puts "Yarn executable was not detected in the system."
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
exit 1

View File

@@ -89,7 +89,7 @@ services:
build: .
command: >
sh -lc 'until [ -f /bundles/.Gemfile.lock.sha ] && sha256sum -c /bundles/.Gemfile.lock.sha >/dev/null 2>&1; do sleep 0.5; done;
exec ./bin/webpack-dev-server'
exec ./bin/webpacker-dev-server'
ports:
- "3035:3035"
volumes:

View File

@@ -76,14 +76,6 @@ module Openfoodnetwork
end
end
initializer "spree.register.payment_methods" do |app|
Rails.application.reloader.to_prepare do
app.config.spree.payment_methods = [
Spree::PaymentMethod::Check
]
end
end
initializer "spree.mail.settings" do |_app|
Rails.application.reloader.to_prepare do
Spree::Core::MailSettings.init
@@ -131,14 +123,6 @@ module Openfoodnetwork
end
end
# Register Spree payment methods
initializer "spree.gateway.payment_methods", :after => "spree.register.payment_methods" do |app|
Rails.application.reloader.to_prepare do
app.config.spree.payment_methods << Spree::Gateway::StripeSCA
app.config.spree.payment_methods << Spree::Gateway::PayPalExpress
end
end
initializer "ofn.reports" do |app|
module ::Reporting; end
Rails.application.reloader.to_prepare do

View File

@@ -1,10 +0,0 @@
module WebpackImageExtension
def image_pack_path(image)
# The Webpacker::Helper#resolve_path_to_image method is incredibly useful
# for nicely fetching Webpacker image paths, but it's private.
resolve_path_to_image(image)
end
end
Webpacker::Helper.include WebpackImageExtension

View File

@@ -627,6 +627,7 @@ en:
errors:
vine_api: "There was an error communicating with the API, please try again later."
invalid_voucher: "The voucher is not valid"
expired: "The voucher has expired"
not_found_voucher: "Sorry, we couldn't find that voucher, please check the code."
vine_voucher_redeemer_service:
errors:

View File

@@ -115,6 +115,67 @@ en_CA:
blank: "can't be blank"
too_short: "is too short (minimum is %{count} characters)"
errors:
messages:
content_type_invalid:
one: "has an invalid content type (authorized content type is %{authorized_human_content_types})"
other: "has an invalid content type (authorized content types are %{authorized_human_content_types})"
content_type_spoofed:
one: "has a content type that is not equivalent to the one that is detected through its content (authorized content type is %{authorized_human_content_types})"
other: "has a content type that is not equivalent to the one that is detected through its content (authorized content types are %{authorized_human_content_types})"
file_size_not_less_than: "file size must be less than %{max} (current size is %{file_size})"
file_size_not_less_than_or_equal_to: "file size must be less than or equal to %{max} (current size is %{file_size})"
file_size_not_greater_than: "file size must be greater than %{min} (current size is %{file_size})"
file_size_not_greater_than_or_equal_to: "file size must be greater than or equal to %{min} (current size is %{file_size})"
file_size_not_between: "file size must be between %{min} and %{max} (current size is %{file_size})"
file_size_not_equal_to: "file size must be equal to %{exact} (current size is %{file_size})"
total_file_size_not_less_than: "total file size must be less than %{max} (current size is %{total_file_size})"
total_file_size_not_less_than_or_equal_to: "total file size must be less than or equal to %{max} (current size is %{total_file_size})"
total_file_size_not_greater_than: "total file size must be greater than %{min} (current size is %{total_file_size})"
total_file_size_not_greater_than_or_equal_to: "total file size must be greater than or equal to %{min} (current size is %{total_file_size})"
total_file_size_not_between: "total file size must be between %{min} and %{max} (current size is %{total_file_size})"
total_file_size_not_equal_to: "total file size must be equal to %{exact} (current size is %{total_file_size})"
duration_not_less_than: "duration must be less than %{max} (current duration is %{duration})"
duration_not_less_than_or_equal_to: "duration must be less than or equal to %{max} (current duration is %{duration})"
duration_not_greater_than: "duration must be greater than %{min} (current duration is %{duration})"
duration_not_greater_than_or_equal_to: "duration must be greater than or equal to %{min} (current duration is %{duration})"
duration_not_between: "duration must be between %{min} and %{max} (current duration is %{duration})"
duration_not_equal_to: "duration must be equal to %{exact} (current duration is %{duration})"
limit_out_of_range:
zero: "no files attached (must have between %{min} and %{max} files)"
one: "only 1 file attached (must have between %{min} and %{max} files)"
other: "total number of files must be between %{min} and %{max} files (there are %{count} files attached)"
limit_min_not_reached:
zero: "no files attached (must have at least %{min} files)"
one: "only 1 file attached (must have at least %{min} files)"
other: "%{count} files attached (must have at least %{min} files)"
limit_max_exceeded:
zero: "no files attached (maximum is %{max} files)"
one: "too many files attached (maximum is %{max} files, got %{count})"
other: "too many files attached (maximum is %{max} files, got %{count})"
attachment_missing: "is missing its attachment"
media_metadata_missing: "is not a valid media file"
dimension_min_not_included_in: "must be greater than or equal to %{width} x %{height} pixels"
dimension_max_not_included_in: "must be less than or equal to %{width} x %{height} pixels"
dimension_width_not_included_in: "width is not included between %{min} and %{max} pixels"
dimension_height_not_included_in: "height is not included between %{min} and %{max} pixels"
dimension_width_not_greater_than_or_equal_to: "width must be greater than or equal to %{length} pixels"
dimension_height_not_greater_than_or_equal_to: "height must be greater than or equal to %{length} pixels"
dimension_width_not_less_than_or_equal_to: "width must be less than or equal to %{length} pixels"
dimension_height_not_less_than_or_equal_to: "height must be less than or equal to %{length} pixels"
dimension_width_not_equal_to: "width must be equal to %{length} pixels"
dimension_height_not_equal_to: "height must be equal to %{length} pixels"
aspect_ratio_not_square: "must be square (current file is %{width}x%{height}px)"
aspect_ratio_not_portrait: "must be portrait (current file is %{width}x%{height}px)"
aspect_ratio_not_landscape: "must be landscape (current file is %{width}x%{height}px)"
aspect_ratio_not_x_y: "must be %{authorized_aspect_ratios} (current file is %{width}x%{height}px)"
aspect_ratio_invalid: "has an invalid aspect ratio (valid aspect ratios are %{authorized_aspect_ratios})"
file_not_processable: "is not identified as a valid media file"
pages_not_less_than: "page count must be less than %{max} (current page count is %{pages})"
pages_not_less_than_or_equal_to: "page count must be less than or equal to %{max} (current page count is %{pages})"
pages_not_greater_than: "page count must be greater than %{min} (current page count is %{pages})"
pages_not_greater_than_or_equal_to: "page count must be greater than or equal to %{min} (current page count is %{pages})"
pages_not_between: "page count must be between %{min} and %{max} (current page count is %{pages})"
pages_not_equal_to: "page count must be equal to %{exact} (current page count is %{pages})"
not_found:
title: "The page you were looking for doesn't exist (404)"
message_html: "<b>Please try again</b> <p>This might be a temporary problem. Please click the back button to return to the previous screen or go back to <a href='/'>Home</a>and try again.</p> <b>Contact support <p>If the problem persists or is urgent, please tell us about it. Find our contact details from the global <a href='https://openfoodnetwork.org/ofn-local/' target='blank'>Open Food Network Local page</a>.</p> <p>It really helps us if you can give as much detail as possible about what the missing page is about.</p>"
@@ -520,6 +581,7 @@ en_CA:
errors:
vine_api: "There was an error communicating with the API, please try again later."
invalid_voucher: "The voucher is not valid"
expired: "The voucher has expired"
not_found_voucher: "Sorry, we couldn't find that voucher, please check the code."
vine_voucher_redeemer_service:
errors:
@@ -3908,6 +3970,8 @@ en_CA:
destroy:
success: Webhook endpoint successfully deleted
error: Webhood endpoint failed to delete
test:
success: Some test data will be sent to the webhook url
spree:
order_updated: "Order Updated"
cannot_perform_operation: "Can not perform this operation"
@@ -4014,6 +4078,7 @@ en_CA:
logourl: "Logourl"
are_you_sure_delete: "Are you sure you want to delete this record?"
confirm_delete: "Confirm Deletion"
tag_rule: "Tag Rule"
voucher: "Voucher"
configurations: "Configurations"
general_settings: "General Settings"
@@ -4897,6 +4962,8 @@ en_CA:
create_placeholder: Enter the URL of the remove webhook endpoint
event_types:
order_cycle_opened: Order Cycle Opened
payment_status_changed: Post webhook on Payment status change
test_endpoint: Test webhook endpoint
invisible_captcha:
sentence_for_humans: "Please leave empty"
timestamp_error_message: "Please try again after 5 seconds."

View File

@@ -1616,7 +1616,7 @@ hu:
has_no_shipping_methods: "%{enterprise} nem rendelkezik szállítási móddal"
has_no_enterprise_fees: "A %{enterprise}-nek nincsenek vállalkozási díjai"
flashes:
dismiss: Elutasítás
dismiss: Bezárás
side_menu:
enterprise:
primary_details: "Főbb adatok"
@@ -2620,7 +2620,7 @@ hu:
failed_to_create_enterprise: "Nem sikerült létrehozni a vállalkozást."
failed_to_create_enterprise_unknown: "Nem sikerült létrehozni a vállalkozást. Győződj meg arról, hogy minden mezőt hiánytalanul kitöltöttél."
failed_to_update_enterprise_unknown: "Nem sikerült frissíteni a vállalkozást. Győződj meg arról, hogy minden mezőt hiánytalanul kitöltöttél."
enterprise_confirm_delete_message: "Ezzel a vállalkozás által szállított %{product} is törlődik. Biztos, hogy akarod folytatni?"
enterprise_confirm_delete_message: "Ezzel a vállalkozás %{product} terméke is törlődik. Biztos, hogy akarod folytatni?"
order_not_saved_yet: "Megrendelésed még nem lett elmentve. Adj nekünk néhány másodpercet, hogy befejezzük!"
filter_by: "Szűrés"
hide_filters: "Szűrők elrejtése"
@@ -2782,7 +2782,7 @@ hu:
instagram: "Instagram"
instagram_placeholder: "pl. @instagram_handle"
limit_reached:
headline: "Ó ne!"
headline: , ne!"
message: "Elérted a korlátot!"
text: "Elérted a vállalkozások számának korlátját, amelyeknek a tulajdonosa lehetsz"
action: "Vissza a kezdőlapra"

View File

@@ -1,5 +0,0 @@
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
const environment = require('./environment')
module.exports = environment.toWebpackConfig()

View File

@@ -1,35 +0,0 @@
const { environment } = require('@rails/webpacker')
module.exports = environment
function hotfixPostcssLoaderConfig (subloader) {
const subloaderName = subloader.loader
if (subloaderName === 'postcss-loader') {
if (subloader.options.postcssOptions) {
console.log(
'\x1b[31m%s\x1b[0m',
'Remove postcssOptions workaround in config/webpack/environment.js'
)
} else {
subloader.options.postcssOptions = subloader.options.config;
delete subloader.options.config;
}
}
}
function addQuietDepsToSassLoader (subloader) {
if (subloader.loader === 'sass-loader') {
subloader.options.sassOptions = {
...subloader.options.sassOptions,
quietDeps: true
}
}
}
environment.loaders.keys().forEach(loaderName => {
const loader = environment.loaders.get(loaderName);
if (loaderName === 'sass') {
loader.use.forEach(addQuietDepsToSassLoader);
}
loader.use.forEach(hotfixPostcssLoaderConfig);
});

View File

@@ -1,5 +0,0 @@
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
const environment = require('./environment')
module.exports = environment.toWebpackConfig()

View File

@@ -1,5 +0,0 @@
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
const environment = require('./environment')
module.exports = environment.toWebpackConfig()

View File

@@ -0,0 +1,20 @@
const { webpackConfig, merge } = require("shakapacker")
const options = {
resolve: {
extensions: [".mjs", ".js", ".sass",".scss", ".css", ".module.sass", ".module.scss", ".module.css", ".png", ".svg", ".gif", ".jpeg", ".jpg", ".eot", ".ttf", ".woff"]
}
}
const OFNwebpackConfig = merge(webpackConfig, options)
// quiet deprecations in dependencies, notably foundation-sites
const scssRule = OFNwebpackConfig.module.rules.find((rule) => rule.test.test(".scss"))
const sassDefaultOptions = scssRule.use[3].options.sassOptions
scssRule.use[3].options.sassOptions = {
...sassDefaultOptions,
quietDeps: true
}
// This results in a new object copied from the mutable global
module.exports = OFNwebpackConfig

View File

@@ -8,7 +8,7 @@ default: &default
cache_path: tmp/cache/webpacker
webpack_compile_output: true
# Additional paths webpack should lookup modules
# Additional paths webpack should look up modules
# ['app/assets', 'engine/foo/app/assets']
additional_paths: [
'vendor',
@@ -25,37 +25,6 @@ default: &default
# Extract and emit a css file
extract_css: true
static_assets_extensions:
- .jpg
- .jpeg
- .png
- .gif
- .tiff
- .ico
- .svg
- .eot
- .otf
- .ttf
- .woff
- .woff2
extensions:
- .mjs
- .js
- .sass
- .scss
- .css
- .module.sass
- .module.scss
- .module.css
- .png
- .svg
- .gif
- .jpeg
- .jpg
- .eot
- .ttf
- .woff
development:
<<: *default
@@ -66,22 +35,40 @@ development:
https: false
host: localhost
port: 3035
public: localhost:3035
# Hot Module Replacement updates modules while the application is running without a full reload
hmr: false
# Inline should be set to true if using HMR
inline: true
overlay: true
# Defaults to the inverse of hmr. Uncomment to manually set this.
# live_reload: true
client:
# Should we show a full-screen overlay in the browser when there are compiler errors or warnings?
overlay: false
# May also be a string
# webSocketURL:
# hostname: "0.0.0.0"
# pathname: "/ws"
# port: 8080
# Should we use gzip compression?
compress: true
disable_host_check: true
use_local_ip: false
quiet: false
pretty: false
# Note that apps that do not check the host are vulnerable to DNS rebinding attacks
allowed_hosts: "all"
#TODO Old config
#pretty: false
pretty: true
headers:
'Access-Control-Allow-Origin': '*'
watch_options:
ignored:
- '**/node_modules/**'
- '**/*.swp'
static:
watch:
ignored:
- '**/node_modules/**'
- '**/*.swp'
test:
<<: *default
compile: true
compiler_strategy: mtime
# Compile test packs to a separate directory
public_output_path: packs-test
production: &production
<<: *default
@@ -91,9 +78,3 @@ production: &production
# Cache manifest.json for performance
cache_manifest: true
test:
<<: *default
# Compile test packs to a separate directory
public_output_path: packs-test

View File

@@ -1,57 +1,8 @@
# frozen_string_literal: true
require 'highline/import'
# see last line where we create an admin if there is none, asking for email and password
def prompt_for_admin_password
if ENV['ADMIN_PASSWORD']
password = ENV['ADMIN_PASSWORD'].dup
say "Admin Password #{password}"
else
password = ask('Password [ofn123]: ') do |q|
q.echo = false
q.validate = /^(|.{5,40})$/
q.responses[:not_valid] = 'Invalid password. Must be at least 5 characters long.'
q.whitespace = :strip
end
password = 'ofn123' if password.blank?
end
password
end
def prompt_for_admin_email
if ENV['ADMIN_EMAIL']
email = ENV['ADMIN_EMAIL'].dup
say "Admin User #{email}"
else
email = ask('Email [ofn@example.com]: ') do |q|
q.echo = true
q.whitespace = :strip
end
email = 'ofn@example.com' if email.blank?
end
email
end
def create_admin_user
attributes = read_user_attributes
load 'spree/user.rb'
if Spree::User.find_by(email: attributes[:email])
say <<~TEXT
WARNING: There is already a user with the email: #{email},
so no account changes were made. If you wish to create an additional admin
user, please run rake spree_auth:admin:create again with a different email.
TEXT
return
end
admin = Spree::User.new(attributes)
admin.skip_confirmation!
admin.skip_confirmation_notification!
@@ -60,24 +11,22 @@ def create_admin_user
ValidEmail2::Address.define_method(:valid_mx?) { true }
if admin.save
say "New admin user persisted!"
printf <<~TEXT
New admin user persisted!
Username: #{admin.email}
Password: #{admin.password}
TEXT
else
say "There was some problems with persisting new admin user:"
printf "There was some problems with persisting new admin user:\n"
admin.errors.full_messages.each do |error|
say error
printf "#{error}\n"
end
end
end
def read_user_attributes
if ENV.fetch("AUTO_ACCEPT", true)
password = ENV.fetch("ADMIN_PASSWORD", "ofn123")
email = ENV.fetch("ADMIN_EMAIL", "ofn@example.com")
else
say 'Create the admin user (press enter for defaults).'
email = prompt_for_admin_email
password = prompt_for_admin_password
end
password = ENV.fetch("ADMIN_PASSWORD", "ofn123")
email = ENV.fetch("ADMIN_EMAIL", "ofn@example.com")
{
admin: true,
@@ -88,4 +37,4 @@ def read_user_attributes
}
end
create_admin_user if Spree::User.admin.empty?
create_admin_user if Spree::User.none?

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Catalog::ProductImport::ProductsResetStrategy do
let(:products_reset) { described_class.new(excluded_items_ids) }

View File

@@ -50,7 +50,7 @@ class AffiliateSalesQuery
<<~SQL.squish
spree_products.name AS product_name,
spree_variants.display_name AS unit_name,
spree_products.variant_unit AS unit_type,
spree_variants.variant_unit AS unit_type,
spree_variants.unit_value AS units,
spree_variants.unit_presentation,
spree_line_items.price,

View File

@@ -6,7 +6,17 @@ RSpec.describe AffiliateSalesQuery do
subject(:query) { described_class }
describe ".data" do
let(:order) { create(:order_with_totals_and_distribution, :completed) }
let(:product) { create(:simple_product, name: "Tomatoes") }
let(:variant1) {
product.variants.first.tap{ |v|
v.update!(
display_name: "Tomatoes - Roma",
variant_unit: "weight", unit_value: 1000, variant_unit_scale: 1000 # 1kg
)
}
}
let!(:order1) { create(:order_with_totals_and_distribution, :completed, variant: variant1) }
let(:today) { Time.zone.today }
let(:yesterday) { Time.zone.yesterday }
let(:tomorrow) { Time.zone.tomorrow }
@@ -18,12 +28,12 @@ RSpec.describe AffiliateSalesQuery do
travel_to(Time.zone.today.noon)
end
it "returns data" do
it "returns records filtered by date" do
# Test data creation takes time.
# So I'm executing more tests in one `it` block here.
# And make it simpler to call the subject many times:
count_rows = lambda do |**args|
query.data(order.distributor, **args).count
query.data(order1.distributor, **args).count
end
# Without any filters:
@@ -47,6 +57,85 @@ RSpec.describe AffiliateSalesQuery do
# From tomorrow:
expect(count_rows.call(start_date: tomorrow)).to eq 0
end
it "returns data" do
labelled_row = query.label_row(query.data(order1.distributor).first)
expect(labelled_row).to include(
product_name: "Tomatoes",
unit_name: "Tomatoes - Roma",
unit_type: "weight",
units: 1000.to_f,
unit_presentation: "1kg",
price: 10.to_d,
distributor_postcode: order1.distributor.address.zipcode,
distributor_country: order1.distributor.address.country.name,
supplier_postcode: variant1.supplier.address.zipcode,
supplier_country: variant1.supplier.address.country.name,
quantity_sold: 1,
)
end
it "returns data stored in line item at time of order" do
# Records are updated after the orders are created
product.update! name: "Tomatoes Updated"
variant1.update! display_name: "Tomatoes - Updated Roma", price: 11
labelled_row = query.label_row(query.data(order1.distributor).first)
pending "#13220 store product and variant names"
expect(labelled_row).to include(
product_name: "Tomatoes",
unit_name: "Tomatoes - Roma",
price: 10.to_d, # this price is hardcoded in the line item factory.
)
end
context "with multiple orders" do
let!(:order2) {
create(:order_with_totals_and_distribution, :completed, variant: product.variants.first,
distributor: order1.distributor)
}
it "returns data grouped by product name" do
labelled_row = query.label_row(query.data(order1.distributor).first)
expect(labelled_row).to include(
product_name: "Tomatoes",
quantity_sold: 2,
)
end
context "and multiple variants" do
let!(:order2) {
create(:order_with_totals_and_distribution, :completed, variant: variant2,
distributor: order1.distributor)
}
let(:variant2) {
create_variant_for(product,
display_name: "Tomatoes - Cherry",
variant_unit: "weight", unit_value: 500, variant_unit_scale: 1) # 500g
}
it "returns data grouped by variant name" do
labelled_data = query.data(order1.distributor).map{ |row| query.label_row(row) }
expect(labelled_data).to include a_hash_including(
product_name: "Tomatoes",
unit_name: "Tomatoes - Roma",
quantity_sold: 1,
)
expect(labelled_data).to include a_hash_including(
product_name: "Tomatoes",
unit_name: "Tomatoes - Cherry",
quantity_sold: 1,
units: 500,
unit_presentation: "500g",
price: 10,
)
end
end
end
end
describe ".label_row" do
@@ -81,4 +170,15 @@ RSpec.describe AffiliateSalesQuery do
)
end
end
# Create variant for product, ready to add to line item
def create_variant_for(product, **attrs)
variant = product.variants.first.dup
variant.update!(
price: 10,
**attrs,
)
variant.update! on_demand: true
variant
end
end

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
module OrderManagement
module Order
RSpec.describe StripeScaPaymentAuthorize do

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe OrderManagement::Order::Updater do
let(:order) { create(:order) }
let(:updater) { OrderManagement::Order::Updater.new(order) }

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
module OrderManagement
module Stock
RSpec.describe Coordinator do

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
module OrderManagement
module Stock
RSpec.describe Estimator do

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe OrderManagement::Stock::Package do
context "base tests" do
let(:variant) { build(:variant, weight: 25.0) }

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
module OrderManagement
module Stock
RSpec.describe Packer do

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
module OrderManagement
module Stock
RSpec.describe Prioritizer do

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
module OrderManagement
module Subscriptions
RSpec.describe Count do

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe OrderManagement::Subscriptions::Estimator do
describe "estimating prices for subscription line items" do
let!(:subscription) { create(:subscription, with_items: true) }

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe OrderManagement::Subscriptions::Form do
describe "creating a new subscription" do
let!(:shop) { create(:distributor_enterprise) }

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
module OrderManagement
module Subscriptions
RSpec.describe PaymentSetup do

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe OrderManagement::Subscriptions::ProxyOrderSyncer do
describe "initialization" do
let!(:subscription) { create(:subscription) }

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
module OrderManagement
module Subscriptions
RSpec.describe StripePaymentSetup do

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe OrderManagement::Subscriptions::Summarizer do
let(:order) { create(:order) }
let(:summarizer) { described_class.new }

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe OrderManagement::Subscriptions::Summary do
let(:summary) { described_class.new(123) }

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require "spec_helper"
RSpec.describe OrderManagement::Subscriptions::Validator do
let(:owner) { create(:user) }
let(:shop) { create(:enterprise, name: "Shop", owner:) }

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require "spec_helper"
RSpec.describe OrderManagement::Subscriptions::VariantsList do
describe "variant eligibility for subscription" do
let!(:shop) { create(:distributor_enterprise) }

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
module Web
RSpec.describe CookiesPolicyHelper do
# keeps global state unchanged

View File

@@ -179,7 +179,7 @@ module.exports = {
// transform: { "\\.[jt]sx?$": "babel-jest" },
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
transformIgnorePatterns: ["/node_modules/(?!(stimulus.+)/)"],
transformIgnorePatterns: ["/node_modules/(?!stimulus)/"],
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,

View File

@@ -392,9 +392,9 @@ module Reporting
end
end
def filter_scope(*args)
def filter_scope(*)
chain_to_scope do
where(*args)
where(*)
end
end
end

View File

@@ -7,12 +7,21 @@
},
"license": "AGPL-3.0",
"dependencies": {
"@babel/core": "^7.28.5",
"@babel/plugin-transform-runtime": "^7.28.5",
"@babel/preset-env": "^7.28.5",
"@babel/runtime": "^7.28.4",
"@floating-ui/dom": "*",
"@hotwired/stimulus": "*",
"@hotwired/turbo": "*",
"@rails/webpacker": "5.4.4",
"@stimulus-components/rails-nested-form": "*",
"babel-loader": "^8.2.2",
"cable_ready": "5.0.6",
"coffee-loader": "^5.0.0",
"coffeescript": "^2.7.0",
"compression-webpack-plugin": "^9.0.0",
"css-loader": "^7.1.2",
"css-minimizer-webpack-plugin": "^7.0.4",
"flatpickr": "*",
"foundation-sites": "5.5.3",
"hotkeys-js": "*",
@@ -21,19 +30,40 @@
"leaflet": "1.9.4",
"leaflet-geosearch": "4.2.2",
"leaflet-providers": "3.0.0",
"mini-css-extract-plugin": "^2.9.4",
"moment": "*",
"mrujs": "*",
"pnp-webpack-plugin": "^1.7.0",
"postcss": "^8.5.6",
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-import": "^16.1.1",
"postcss-loader": "^8.2.0",
"postcss-preset-env": "^10.5.0",
"regenerator-transform": "^0.15.2",
"sass-embedded": "^1.96.0",
"sass-loader": "^16.0.6",
"select2": "*",
"shakapacker": "6.6.0",
"shortcut-buttons-flatpickr": "*",
"stimulus": "*",
"stimulus-autocomplete": "*",
"stimulus-flatpickr": "*",
"stimulus_reflex": "3.5.5",
"style-loader": "^4.0.0",
"terser-webpack-plugin": "^5.3.16",
"tom-select": "*",
"trix": "*",
"turbo_power": "*",
"webpack": "~4"
"webpack": "^5.104.0",
"webpack-assets-manifest": "^5.0.6",
"webpack-cli": "^4.9.2",
"webpack-merge": "^5.8.0",
"webpack-sources": "^3.3.3"
},
"browserslist": [
"defaults",
"not IE 11"
],
"devDependencies": {
"@testing-library/dom": "<11.0.0",
"jasmine-core": "~5.12.1",
@@ -44,6 +74,6 @@
"karma-coffee-preprocessor": "~1.0.1",
"karma-jasmine": "~0.3.8",
"prettier": "*",
"webpack-dev-server": "~3"
"webpack-dev-server": "^4.9.0"
}
}

22
script/bump-ruby.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/usr/bin/env sh
if [ "$#" -lt 1 ]; then
echo "Usage: $0 <new-version>"
echo "Example: $0 3.4.8"
exit 1
fi
set -ex
OLD_VERSION=$(cat .ruby-version)
NEW_VERSION=$1
PATTERN="$(echo "$OLD_VERSION" | sed 's:[]\[^$.*/]:\\&:g')"
sed -i "s/\<$PATTERN\>/$NEW_VERSION/" .ruby-version Dockerfile
script/rbenv-install.sh
# Update bundler to the version shipped with Ruby:
bundle update --bundler
git commit -a -m "Bump Ruby from $OLD_VERSION to $NEW_VERSION"

View File

@@ -1,42 +0,0 @@
#!/bin/sh
# This shell script looks for the last used Bundler version in Gemfile.lock and
# installs exactly that version, removing all other versions.
# Command line arguments are passed on to `gem install`. So you can call this
# script with with arguments:
#
# ./script/install-bundler --no-ri --no-rdoc
# This script is used by ofn-install and can by handy in your development
# environment.
# Fail if a single command fails.
set -e
# `grep`: find the occurrences of "BUNDLED WITH" (-m is unnecessary and behaves different on macOS)
# `-A`: print the next line after "BUNDLED WITH" as well
# `-F`: find exactly that string
# `tail -n 1`: take the last line, the version line
# `tr -d`: delete all spaces, the indent before the version
version="$(grep -A 1 -F "BUNDLED WITH" Gemfile.lock | tail -n 1 | tr -d '[:space:]')"
# if the length of $version is zero
if [ -z "$version" ]; then
echo >&2 "No bundler version in Gemfile.lock."
exit 1
fi
# Get the currently used bundler version.
# We ignore all errors with `2>/dev/null || true` in case there is no bundler
# or only an orphaned shim installed.
current="$(bundler --version 2>/dev/null || true)"
if [ "$current" = "Bundler version $version" ]; then
echo >&2 "Already up-to-date: $current"
exit 0
fi
# Passing on all arguments of this script with "$@".
gem install bundler -v "$version" "$@"
gem uninstall bundler -v "!= $version" 2>/dev/null || true

View File

@@ -10,6 +10,12 @@ set -e
if ! command -v nodenv > /dev/null; then
printf "Please install https://github.com/nodenv/nodenv.\n"
printf '```'"\n"
printf "git clone https://github.com/nodenv/nodenv.git ~/.nodenv\n"
printf "git clone https://github.com/nodenv/node-build.git ~/.nodenv/plugins/node-build\n"
printf "nodenv init\n"
printf 'eval "$(nodenv init -)"'"\n"
printf '```'"\n"
exit 1
fi

View File

@@ -24,7 +24,13 @@ if rbenv install --skip-existing; then
echo "Ruby is installed."
else
echo "Upgrading rbenv's ruby-build:"
git -C "$(rbenv root)"/plugins/ruby-build pull
# If installed with homebrew, use that to update
if (command -v brew && brew list --versions ruby-build); then
brew update && brew upgrade ruby-build
else
# Update with git
git -C "$(rbenv root)"/plugins/ruby-build pull
fi
rbenv install
fi

View File

@@ -1,287 +0,0 @@
# frozen_string_literal: true
# This file defines configurations that are universal to all spec types (feature, system, etc)
ENV["RAILS_ENV"] ||= 'test'
# for full configuration, see .simplecov
require 'simplecov' if ENV["COVERAGE"]
require 'pry' unless ENV['CI']
require 'view_component/test_helpers'
require_relative "../config/environment"
require 'rspec/rails'
require 'rspec/retry'
require 'capybara'
require 'paper_trail/frameworks/rspec'
require "factory_bot_rails"
require 'shoulda/matchers'
Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
with.library :rails
end
end
require 'knapsack_pro'
KnapsackPro::Adapters::RSpecAdapter.bind
if ENV["COVERAGE"] && defined?(SimpleCov)
KnapsackPro::Hooks::Queue.before_queue do
SimpleCov.command_name("rspec_ci_node_#{KnapsackPro::Config::Env.ci_node_index}")
end
end
# Allow connections to selenium whilst raising errors when connecting to external sites
require 'webmock/rspec'
WebMock.enable!
WebMock.disable_net_connect!(
allow_localhost: true,
allow: ['chromedriver.storage.googleapis.com']
)
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Rails.root.glob("spec/support/**/*.rb").sort.each { |f| require f }
Capybara.server = :puma, { Silent: true }
Capybara.disable_animation = true
Capybara.configure do |config|
config.match = :prefer_exact
config.ignore_hidden_elements = true
end
FactoryBot.use_parent_strategy = false
FactoryBot::SyntaxRunner.include FileHelper
# raise I18n exception handler
I18n.exception_handler = proc do |exception, *_|
raise exception.to_exception
end
# Disable timestamp check for test environment
InvisibleCaptcha.timestamp_enabled = false
InvisibleCaptcha.spinner_enabled = false
RSpec.configure do |config|
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
#
# Setting this to true keeps the database clean by rolling back any changes.
config.use_transactional_fixtures = true
# Some tests don't work within a transaction. Then we use DatabaseCleaner.
config.before(:each, concurrency: true) do
config.use_transactional_fixtures = false
DatabaseCleaner.strategy = :deletion, { except: ['spree_countries', 'spree_states'] }
DatabaseCleaner.start
end
config.append_after(:each, concurrency: true) do
DatabaseCleaner.clean
config.use_transactional_fixtures = true
end
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
# Show retries in test output
config.verbose_retry = true
# Force colored output, whether or not the output is a TTY
config.color_mode = :on
# Force use of expect (over should)
config.expect_with :rspec do |expectations|
expectations.syntax = :expect
# This option will default to `true` in RSpec 4. It makes the `description`
# and `failure_message` of custom matchers include text for helper methods
# defined using `chain`, e.g.:
# be_bigger_than(2).and_smaller_than(4).description
# # => "be bigger than 2 and smaller than 4"
# ...rather than:
# # => "be bigger than 2"
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
# rspec-mocks config goes here. You can use an alternate test double
# library (such as bogus or mocha) by changing the `mock_with` option here.
config.mock_with :rspec do |mocks|
# We use too many mocks at the moment. Activating the following
# feature fails a lot of specs. We should clean it up over time.
#
# Prevents you from mocking or stubbing a method that does not exist on
# a real object. This is generally recommended, and will default to
# `true` in RSpec 4.
# mocks.verify_partial_doubles = true
end
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
# have no way to turn it off -- the option exists only for backwards
# compatibility in RSpec 3). It causes shared context metadata to be
# inherited by the metadata hash of host groups and examples, rather than
# triggering implicit auto-inclusion in groups with matching metadata.
config.shared_context_metadata_behavior = :apply_to_host_groups
# Limits the available syntax to the non-monkey patched syntax that is
# recommended. For more details, see:
# https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/
config.disable_monkey_patching!
# Many RSpec users commonly either run the entire suite or an individual
# file, and it's useful to allow more verbose output when running an
# individual spec file.
if config.files_to_run.one?
# Use the documentation formatter for detailed output,
# unless a formatter has already been configured
# (e.g. via a command-line flag).
config.default_formatter = "doc"
end
config.define_derived_metadata(file_path: %r{/spec/lib/tasks/}) do |metadata|
metadata[:type] = :rake
end
# Reset locale for all specs.
config.around(:each) do |example|
locale = ENV.fetch('LOCALE', 'en_TST')
I18n.with_locale(locale) { example.run }
end
# Reset all feature toggles to prevent leaking.
config.before(:each) do
Flipper.features.each(&:remove)
OpenFoodNetwork::FeatureToggle.setup!
end
config.before(:each, :feature) do |example|
feature = example.metadata[:feature].to_s
unless OpenFoodNetwork::FeatureToggle::CURRENT_FEATURES.key?(feature)
raise "Unkown feature: #{feature}"
end
Flipper.enable(feature)
end
# Enable caching in any specs tagged with `caching: true`.
config.around(:each, :caching) do |example|
caching = ActionController::Base.perform_caching
ActionController::Base.perform_caching = example.metadata[:caching]
example.run
ActionController::Base.perform_caching = caching
end
# Show javascript errors in test output with `js_debug: true`
config.after(:each, :js_debug) do
errors = page.driver.browser.manage.logs.get(:browser)
if errors.present?
message = errors.map(&:message).join("\n")
puts message
end
end
# Appends Stripe gem version to VCR cassette directory with ':stripe_version' flag
#
# When the Stripe gem is updated, we should re-record these cassettes:
#
# ./script/test-stripe-live
#
config.around(:each, :stripe_version) do |example|
stripe_version = "Stripe-v#{Stripe::VERSION}"
cassette_library_dir, default_cassette_options = nil, nil
VCR.configure do |vcr_config|
cassette_library_dir = vcr_config.cassette_library_dir
default_cassette_options = vcr_config.default_cassette_options
vcr_config.cassette_library_dir += "/#{stripe_version}"
vcr_config.default_cassette_options = { record: :none } if ENV["CI"]
end
example.run
VCR.configure do |vcr_config|
vcr_config.cassette_library_dir = cassette_library_dir
vcr_config.default_cassette_options = default_cassette_options
end
end
# Ensure we start with consistent config settings
config.before(:each) do
reset_spree_preferences do |spree_config|
# These are all settings that differ from Spree's defaults
spree_config.shipping_instructions = true
end
CurrentConfig.clear_all
end
# Don't validate our invalid test data with expensive network requests.
config.before(:each) do
allow_any_instance_of(ValidEmail2::Address).to receive_messages(
valid_mx?: true,
valid_strict_mx?: true,
mx_server_is_in?: false
)
end
# Webmock raises errors that inherit directly from Exception (not StandardError).
# The messages contain useful information for debugging stubbed requests to external
# services (in tests), but they normally don't appear in the test output.
config.before(:all) do
ApplicationController.class_eval do
rescue_from WebMock::NetConnectNotAllowedError, with: :handle_webmock_error
def handle_webmock_error(exception)
raise exception.message
end
end
end
config.infer_spec_type_from_file_location!
# You can use `rspec -n` to run only failed specs.
config.example_status_persistence_file_path = "tmp/rspec-status.txt"
config.include_context "rake", type: :rake
# Helpers
config.include FactoryBot::Syntax::Methods
config.include JsonSpec::Helpers
config.include Rails.application.routes.url_helpers
config.include Spree::UrlHelpers
config.include Spree::MoneyHelper
config.include Spree::PaymentHelper
config.include PreferencesHelper
config.include OpenFoodNetwork::FiltersHelper
config.include OpenFoodNetwork::EnterpriseGroupsHelper
config.include OpenFoodNetwork::HtmlHelper
config.include ActiveSupport::Testing::TimeHelpers
config.include ActionView::Helpers::DateHelper
config.include OpenFoodNetwork::PerformanceHelper
config.include ActiveJob::TestHelper
config.include ReportsHelper
config.include TomSelectHelper, type: :system
config.include ViewComponent::TestHelpers, type: :component
config.include ControllerRequestsHelper, type: :controller
config.include Devise::Test::ControllerHelpers, type: :controller
config.include OpenFoodNetwork::ApiHelper, type: :controller
config.include OpenFoodNetwork::ControllerHelper, type: :controller
config.include Devise::Test::IntegrationHelpers, type: :request
config.include Features::DatepickerHelper, type: :system
config.include Features::TrixEditorHelper, type: :system
config.include DownloadsHelper, type: :system
config.include ReportsHelper, type: :system
config.include ProductsHelper, type: :system
end

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require "spec_helper"
RSpec.describe AdminTooltipComponent, type: :component do
it "displays the tooltip link" do
render_inline(described_class.new(text: "Tooltip description", link_text: "Hover here"))

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require "spec_helper"
RSpec.describe DistributorTitleComponent, type: :component do
it "displays distributor title with its name" do
render_inline(described_class.new(name: "Freddy's Farm Shop"))

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require "spec_helper"
RSpec.describe ExampleComponent, type: :component do
it "displays the h1 with the given parameter" do
render_inline(described_class.new(title: "Hello"))

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require "spec_helper"
RSpec.describe ModalComponent, type: :component do
it "renders default 'data-action' and 'data-controller'" do
render_inline(described_class.new(id: "test-id"))

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require "spec_helper"
RSpec.describe VerticalEllipsisMenuComponent, type: :component do
it "displays the included links" do
content = "<a href>Edit</a>"

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe FeatureToggleConstraint do
subject { described_class.new("baking") }
let(:request) { double(env:) }

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::BulkLineItemsController do
describe '#index' do
render_views

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::ColumnPreferencesController do
include AuthenticationHelper

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::CustomersController do
include AuthenticationHelper

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: false
require 'spec_helper'
RSpec.describe Admin::EnterpriseFeesController do
before do
allow(controller).to receive_messages spree_current_user: super_admin

View File

@@ -1,6 +1,5 @@
# frozen_string_literal: false
require 'spec_helper'
require 'open_food_network/order_cycle_permissions'
RSpec.describe Admin::EnterprisesController do

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::InventoryItemsController do
describe "create" do
context "json" do

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::InvoiceSettingsController do
describe "#update" do
let(:params) {

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::MatomoSettingsController do
describe "#update" do
let(:params) {

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::OrderCyclesController do
let!(:distributor_owner) { create(:user) }
let(:datetime_confirmation_attrs) {

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::ProductImportController do
describe "#import" do
context "when importing into inventory with inventory disabled" do

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::ProxyOrdersController do
include AuthenticationHelper

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::ReportsController do
# Given two distributors and two suppliers
let(:bill_address) { create(:address) }

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::SchedulesController do
include AuthenticationHelper

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::StripeAccountsController do
let(:enterprise) { create(:distributor_enterprise) }

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::StripeConnectSettingsController do
let(:user) { create(:user) }
let(:admin) { create(:admin_user) }

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::SubscriptionLineItemsController do
include AuthenticationHelper

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::SubscriptionsController do
include AuthenticationHelper

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::TagRulesController do
let(:format) { :turbo_stream }

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::TermsOfServiceFilesController do
context "a non-admin user" do
let(:user) { create(:user) }

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Admin::VariantOverridesController do
describe "index" do
context "not logged in" do

View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Api::V0::BaseController do
render_views
controller(Api::V0::BaseController) do

Some files were not shown because too many files have changed in this diff Show More