Compare commits

...

475 Commits

Author SHA1 Message Date
David Cook
3a3dc9eea5 Update all locales with the latest Transifex translations 2024-05-16 16:17:30 +10:00
Maikel
f81b894d5c Merge pull request #12484 from openfoodfoundation/dependabot/bundler/roadie-rails-3.2.0
chore(deps): bump roadie-rails from 3.1.0 to 3.2.0
2024-05-16 08:18:27 +10:00
Maikel
dcc8556470 Merge pull request #12483 from openfoodfoundation/dependabot/bundler/omniauth-rails_csrf_protection-1.0.2
chore(deps): bump omniauth-rails_csrf_protection from 1.0.1 to 1.0.2
2024-05-16 08:16:47 +10:00
Filipe
a854775afe Merge pull request #12470 from mkllnk/description-html-test
Sanitise HTML in long description of enterprise [read-only]
2024-05-15 20:52:30 +01:00
Filipe
b67eba2130 Merge pull request #12454 from arunguleria/12372-Add-MissingTranslations
12372-[Admin] Missing translations  page titles
2024-05-15 20:39:22 +01:00
Filipe
cb53419681 Merge pull request #12443 from MrBowmanXD/junior
Remove "ready for" info from shipping method description area at checkout #12395 (solved)
2024-05-15 20:10:58 +01:00
Filipe
b3ac6bed87 Merge pull request #12428 from cyrillefr/RedundantPresenceValidationOnBelongs_part_III
Fix RedundantPresenceValidationOnBelongs on two files
2024-05-15 18:21:52 +01:00
Filipe
59e04cc549 Merge pull request #12376 from cyrillefr/MakeShipOrderButtonWorksOnPageOrderDetails
Fix Ship Order menu choice not working
2024-05-15 17:57:25 +01:00
Filipe
39ce3163f2 Merge pull request #12441 from cyrillefr/DeleteButtonMissingBeforeSavingVariant
[BUU] Delete Button missing before saving variant
2024-05-15 17:56:13 +01:00
dependabot[bot]
f1a50313a0 chore(deps): bump roadie-rails from 3.1.0 to 3.2.0
Bumps [roadie-rails](https://github.com/Mange/roadie-rails) from 3.1.0 to 3.2.0.
- [Changelog](https://github.com/Mange/roadie-rails/blob/master/Changelog.md)
- [Commits](https://github.com/Mange/roadie-rails/compare/v3.1.0...v3.2.0)

---
updated-dependencies:
- dependency-name: roadie-rails
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-15 09:12:50 +00:00
dependabot[bot]
53c706c6a2 chore(deps): bump omniauth-rails_csrf_protection from 1.0.1 to 1.0.2
Bumps [omniauth-rails_csrf_protection](https://github.com/cookpad/omniauth-rails_csrf_protection) from 1.0.1 to 1.0.2.
- [Release notes](https://github.com/cookpad/omniauth-rails_csrf_protection/releases)
- [Commits](https://github.com/cookpad/omniauth-rails_csrf_protection/compare/v1.0.1...v1.0.2)

---
updated-dependencies:
- dependency-name: omniauth-rails_csrf_protection
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-15 09:12:25 +00:00
Maikel
ae09124946 Merge pull request #12475 from openfoodfoundation/dependabot/bundler/knapsack_pro-7.2.0
chore(deps-dev): bump knapsack_pro from 7.1.0 to 7.2.0
2024-05-15 11:21:26 +10:00
Maikel
68f12ed7f0 Merge pull request #12464 from filipefurtad0/variant_overrides_spec_to_split_checkout
Updates tests on a regular checkout
2024-05-15 11:17:03 +10:00
Gaetan Craig-Riou
1fde91e6ff Update Webmock and VCR config as per Knapsack recommendation
See : https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/CHANGELOG.md#720
2024-05-15 10:07:40 +10:00
Gaetan Craig-Riou
c94bec85d7 Merge pull request #12468 from openfoodfoundation/dependabot/bundler/nokogiri-1.16.5
chore(deps): bump nokogiri from 1.16.4 to 1.16.5
2024-05-15 09:59:29 +10:00
filipefurtad0
4e16eb9c6b Updates spec to split checkout 2024-05-14 12:19:23 +01:00
filipefurtad0
38fe36b246 Uptades tests on a regular checkout 2024-05-14 12:19:23 +01:00
dependabot[bot]
afbfc788b8 chore(deps-dev): bump knapsack_pro from 7.1.0 to 7.2.0
Bumps [knapsack_pro](https://github.com/KnapsackPro/knapsack_pro-ruby) from 7.1.0 to 7.2.0.
- [Changelog](https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v7.1.0...v7.2.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-14 11:01:59 +00:00
Maikel Linke
f089c0eff3 Keep HTML line breaks
They do appear in long_description on au_prod.
2024-05-14 12:40:58 +10:00
Maikel Linke
23a27c65be Sanitise existing HTML in Enterprise#long_description
We will add a migration to sanitise all existing descriptions but before
we do that destructive action, it's good to test this in a read-only
fashion first.
2024-05-14 12:25:58 +10:00
Maikel Linke
7b4a85f7ef Sanitise HTML in long description of enterprise
This happens only on assignment. We still need to migrate existing data.
2024-05-14 12:25:47 +10:00
Maikel
13e4d4beb6 Merge pull request #12467 from openfoodfoundation/dependabot/bundler/geocoder-1.8.3
chore(deps): bump geocoder from 1.8.2 to 1.8.3
2024-05-14 11:49:14 +10:00
Maikel
ee1537fa3f Merge pull request #12466 from openfoodfoundation/dependabot/bundler/dotenv-3.1.2
chore(deps): bump dotenv from 3.1.0 to 3.1.2
2024-05-14 11:48:28 +10:00
David Cook
00f6d01738 Remove errored variants
I found another case.
2024-05-14 11:27:04 +10:00
David Cook
da77994a89 Ignore disconnected form elements
When elements are removed from the DOM, they remain in the recordElements array. But we can simply ignore them.
We have to wait until after rails-nested-form:remove is completed before toggleFormChanged.

hmm It would be even better to remove them from the array..
2024-05-14 11:26:40 +10:00
David Cook
b45df8a723 Use built-in feature to delete new record row
I looked at the source code and found that we were missing one detail: data-new-record.
https://github.com/stimulus-components/stimulus-rails-nested-form/blob/master/src/index.ts#L32-L35

It's documented here, but it's easy to miss: https://www.stimulus-components.com/docs/stimulus-rails-nested-form/
2024-05-14 11:25:52 +10:00
cyrillefr
808f1c65f2 Requested changes on Delete Button missing
- Styling(in red) for the remove button/link in view

- A remove method to the bulk_form controller
    - removes elements from the Dom
    - removes changed elements from the binded Array in controller
    - so that menu that indicates changes disappear and blured elements
    - resume to non blurring state

- Added the corresponding specs
    - test with one, two variants
    - test with two different products
2024-05-14 11:25:22 +10:00
cyrillefr
36f3e4af02 Requested changes on Delete button missing
- cleaned haml/html
2024-05-14 11:25:22 +10:00
cyrillefr
9b10b73a65 Delete Button missing before saving variant
- used the remove option of stimulus-components/rails-nested-form lib
 - add the Remove option in the menu
 - the corresponding spec
 - the locale
2024-05-14 11:25:22 +10:00
dependabot[bot]
b2ecac27eb chore(deps): bump nokogiri from 1.16.4 to 1.16.5
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.16.4 to 1.16.5.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.16.4...v1.16.5)

---
updated-dependencies:
- dependency-name: nokogiri
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-13 23:48:01 +00:00
David Cook
1f91c2e4b5 Merge pull request #12417 from filipefurtad0/migrate_legacy_specs
Removes unused spec related to legacy checkout
2024-05-14 09:42:23 +10:00
Rachel Arnould
bd83977bf2 Merge pull request #12449 from chahmedejaz/feature/11058-change-products-order-by-name
Feature/11058 change products order by name
2024-05-13 15:29:33 +02:00
filipefurtad0
a1e2d3a93b Removes negative expect
Removes unused error message
2024-05-13 12:55:55 +01:00
David Cook
62fefd5d49 Implement required method
Most of the time this doesn't get called because source_required: false.
But sometimes it [does happen](https://app.bugsnag.com/yaycode/openfoodnetwork-uk/errors/66329690f4b6380007e8a4f8)

I have a feeling that source_required? could be moved to the superclass as payment_source_class.present?. But I don't know enough about this area of the system to try it...
2024-05-13 12:55:55 +01:00
filipefurtad0
ffdbd0d7d4 Reproduces Bugsnag error
For details see: https://app.bugsnag.com/open-food-network-canada-1/open-food-network-canada/errors/66314b2e78673c00073d2de9?filters[event.since]=30d&filters[error.status]=open&filters[search]=payment_source_class&event_id=66314b2e00e6e45d746f0000

Adds test case for Cash and Stripe payment methods

With no source
2024-05-13 12:55:55 +01:00
filipefurtad0
282acd256b Undoes changes: removes unecessary test 2024-05-13 12:55:55 +01:00
filipefurtad0
d520e3838c Removes unused spec related to legacy checkout
We can see on the respective controller spec, that having a Stripe SCA payment, with no source does not trigger the error 400, observed on the legacy checkout.
2024-05-13 12:55:52 +01:00
dependabot[bot]
fd01cc1667 chore(deps): bump geocoder from 1.8.2 to 1.8.3
Bumps [geocoder](https://github.com/alexreisner/geocoder) from 1.8.2 to 1.8.3.
- [Changelog](https://github.com/alexreisner/geocoder/blob/master/CHANGELOG.md)
- [Commits](https://github.com/alexreisner/geocoder/compare/v1.8.2...v1.8.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-13 09:46:23 +00:00
dependabot[bot]
cacff92aeb chore(deps): bump dotenv from 3.1.0 to 3.1.2
Bumps [dotenv](https://github.com/bkeepers/dotenv) from 3.1.0 to 3.1.2.
- [Release notes](https://github.com/bkeepers/dotenv/releases)
- [Changelog](https://github.com/bkeepers/dotenv/blob/main/Changelog.md)
- [Commits](https://github.com/bkeepers/dotenv/compare/v3.1.0...v3.1.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-13 09:40:12 +00:00
Gaetan Craig-Riou
1cc0089cb5 Merge pull request #12462 from openfoodfoundation/dependabot/bundler/i18n-1.14.5
chore(deps): bump i18n from 1.14.4 to 1.14.5
2024-05-13 10:35:50 +10:00
Gaetan Craig-Riou
0867f69d21 Merge pull request #12463 from openfoodfoundation/dependabot/bundler/wkhtmltopdf-binary-0.12.6.7
chore(deps): bump wkhtmltopdf-binary from 0.12.6.6 to 0.12.6.7
2024-05-13 10:09:55 +10:00
Gaetan Craig-Riou
c1088f79fe Merge pull request #12451 from mkllnk/rspec-config
Use recommended RSpec config
2024-05-13 09:56:49 +10:00
dependabot[bot]
900080e7bb chore(deps): bump wkhtmltopdf-binary from 0.12.6.6 to 0.12.6.7
Bumps [wkhtmltopdf-binary](https://github.com/zakird/wkhtmltopdf_binary_gem) from 0.12.6.6 to 0.12.6.7.
- [Release notes](https://github.com/zakird/wkhtmltopdf_binary_gem/releases)
- [Changelog](https://github.com/zakird/wkhtmltopdf_binary_gem/blob/master/CHANGELOG.md)
- [Commits](https://github.com/zakird/wkhtmltopdf_binary_gem/compare/0.12.6.6...0.12.6.7)

---
updated-dependencies:
- dependency-name: wkhtmltopdf-binary
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-10 09:42:36 +00:00
dependabot[bot]
c8e94c6658 chore(deps): bump i18n from 1.14.4 to 1.14.5
Bumps [i18n](https://github.com/ruby-i18n/i18n) from 1.14.4 to 1.14.5.
- [Release notes](https://github.com/ruby-i18n/i18n/releases)
- [Changelog](https://github.com/ruby-i18n/i18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ruby-i18n/i18n/compare/v1.14.4...v1.14.5)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-10 09:41:51 +00:00
Maikel Linke
3e9ca641ce Update all locales with the latest Transifex translations 2024-05-10 10:18:08 +10:00
Maikel
5ed3129168 Merge pull request #12456 from openfoodfoundation/dependabot/bundler/rubocop-1.63.5
chore(deps-dev): bump rubocop from 1.63.2 to 1.63.5
2024-05-10 10:16:14 +10:00
Maikel
950b607a52 Merge pull request #12455 from openfoodfoundation/dependabot/bundler/newrelic_rpm-9.9.0
chore(deps): bump newrelic_rpm from 9.8.0 to 9.9.0
2024-05-10 10:14:48 +10:00
Ahmed Ejaz
881da0f9ac 11058: add get_all_input_values 2024-05-10 04:05:29 +05:00
Maikel Linke
bc27e4bbdd Re-instate spec which uses invalid mocking
I removed it because it needed a complete rewrite and I didn't think it
was valuable enough to do so. But now that I deactivated RSpecs
validating mocks again, this spec passes and we can do that work another
time.
2024-05-10 08:56:06 +10:00
Ahmed Ejaz
b5fe19cb7d 11058: add specs 2024-05-10 02:52:57 +05:00
dependabot[bot]
ae8f2bfdc4 chore(deps-dev): bump rubocop from 1.63.2 to 1.63.5
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.63.2 to 1.63.5.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.63.2...v1.63.5)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-09 09:59:00 +00:00
dependabot[bot]
50ab72a818 chore(deps): bump newrelic_rpm from 9.8.0 to 9.9.0
Bumps [newrelic_rpm](https://github.com/newrelic/newrelic-ruby-agent) from 9.8.0 to 9.9.0.
- [Release notes](https://github.com/newrelic/newrelic-ruby-agent/releases)
- [Changelog](https://github.com/newrelic/newrelic-ruby-agent/blob/dev/CHANGELOG.md)
- [Commits](https://github.com/newrelic/newrelic-ruby-agent/compare/9.8.0...9.9.0)

---
updated-dependencies:
- dependency-name: newrelic_rpm
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-09 09:56:24 +00:00
Arun Guleria
c84be2f396 12372-Add missing translation page titles 2024-05-09 15:12:03 +05:30
Maikel Linke
8362c4a7bd Detailed output when running only one spec file 2024-05-09 12:24:42 +10:00
Maikel Linke
6317fe1b71 Disable RSpec monkey patching 2024-05-09 12:24:41 +10:00
Maikel Linke
9ca6519fb1 Recommended RSpec option: shared_context_metadata_behavior
One spec failed due to this new behaviour. Converting the shared
examples to simple blocks solved this. But the specs could probably be
written better now. I didn't invest this time.
2024-05-09 11:14:13 +10:00
Maikel Linke
6b2bb0bd32 Don't verify partial doubles because we can't fix all specs now 2024-05-09 11:14:13 +10:00
Maikel Linke
d6318b7194 Remove mocking of deleted Order methods 2024-05-09 11:14:13 +10:00
Maikel Linke
9320ed0559 And less stubbing is better.
[skip ci]
2024-05-09 11:14:13 +10:00
Maikel Linke
9c402fbdb2 Verify partial doubles
And look, we were stubbing deleted code.
2024-05-09 11:14:13 +10:00
Maikel Linke
a65189c43e Improve failure messages of chained expectations 2024-05-09 11:14:13 +10:00
David Cook
cec179333a Merge pull request #12447 from mkllnk/knapsack_pro-7.1.0
Knapsack pro 7.1.0
2024-05-09 10:30:30 +10:00
Manuel Gonçalves
110eeaf793 Removed the "ready for" information located in checkout/details
This provides the solution wanted and the best way to do it.
2024-05-09 10:14:37 +10:00
Maikel
a11b94ba4a Merge pull request #12450 from openfoodfoundation/dependabot/bundler/rubocop-rspec-2.29.2
chore(deps-dev): bump rubocop-rspec from 2.29.1 to 2.29.2
2024-05-09 09:17:36 +10:00
dependabot[bot]
10d0faa05e chore(deps-dev): bump rubocop-rspec from 2.29.1 to 2.29.2
Bumps [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) from 2.29.1 to 2.29.2.
- [Release notes](https://github.com/rubocop/rubocop-rspec/releases)
- [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.29.1...v2.29.2)

---
updated-dependencies:
- dependency-name: rubocop-rspec
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-08 09:36:29 +00:00
Ahmed Ejaz
86f88792c2 11058: add sortable products by name 2024-05-08 12:56:41 +05:00
Maikel
337eae43a6 Merge pull request #12444 from openfoodfoundation/dependabot/bundler/multi-d8182a35ef
chore(deps): bump flipper, flipper-active_record and flipper-ui
2024-05-08 14:11:09 +10:00
Maikel Linke
5f07a7f390 Check for asset compilation before each spec file
The KnapsackPro queue mode can't predict which specs it will run. So we
need to check on each file (top-level describe block) which type of spec
it is and if we need to compile assets for it.

Old versions of KnapsackPro would execute the `before(:suite)` hooks on
every batch, but now it's only run once. With this change, we do the
same as before.
2024-05-08 13:36:41 +10:00
Maikel Linke
104357d5b9 Load spec helper on RSpec boot
Knapsack is replacing some of the RSpec logic, like running before-suite
and before-all hooks. Loading the spec helper early means that Knapsack
knows about the asset compilation hook when it loads the next batch of
specs.
2024-05-08 13:31:35 +10:00
dependabot[bot]
331f9be82a chore(deps-dev): bump knapsack_pro from 6.0.4 to 7.1.0
Bumps [knapsack_pro](https://github.com/KnapsackPro/knapsack_pro-ruby) from 6.0.4 to 7.1.0.
- [Changelog](https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v6.0.4...v7.1.0)

---
updated-dependencies:
- dependency-name: knapsack_pro
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-08 10:38:19 +10:00
cyrillefr
6575ad738b Fix Ship Order Button: requested changes
- bypass rubocop class lines limit
2024-05-07 19:15:00 +02:00
cyrillefr
271d50e5ab Fix Ship Order Button: modal should close itself
- returns to the same processing for customer, invoices etc.
   that edit
 - need a bit of sleep in spec bc 2 tasks are asynchroneous
2024-05-07 19:15:00 +02:00
cyrillefr
34bb05e681 Fix 'Ship Order': integrating non regression spec
- removes the pending
 - add the click to go to the 'Order Details' page
   to check for the 'shipped' status
 - from enqueued to have_been_enqueued so the spec
   is flaky-free
2024-05-07 19:15:00 +02:00
cyrillefr
ba68f4b252 Fix 'Ship Order': requested changes
- deletes local variables in view
- factor logic in helper
2024-05-07 19:15:00 +02:00
cyrillefr
901c29c97b Fix Ship Order menu choice not working
- Front End ShipOrderComponent was missed for the menu to work
 - updated spec to test for a specific case
2024-05-07 19:15:00 +02:00
Rachel Arnould
907b154108 Merge pull request #12401 from chahmedejaz/task/11060-change-producer-category-tax-category
[BUU] Change Producer, Category and Tax Category
2024-05-07 15:10:14 +02:00
David Cook
7f40fd7adb Fix typo 2024-05-07 14:59:14 +02:00
Ahmed Ejaz
b1f20ffc14 11060: create tomselect helper module 2024-05-07 14:59:14 +02:00
Ahmed Ejaz
f07900ca4a 11060: refactor specs to have better separation of concerns 2024-05-07 14:59:14 +02:00
Ahmed Ejaz
269e69852c 11060: add style rule for the small gap 2024-05-07 14:59:14 +02:00
Ahmed Ejaz
c291ff88ff 11060: remove duplicated supplier_id 2024-05-07 14:59:14 +02:00
Ahmed Ejaz
7e555b4fcb Update app/views/admin/products_v3/_product_row.html.haml
Co-authored-by: David Cook <david@redcliffs.net>
2024-05-07 14:59:14 +02:00
Ahmed Ejaz
3d60d84fc7 add wait for flaky specs 2024-05-07 14:59:14 +02:00
Ahmed Ejaz
227b677e4d 11060: fix specs 2024-05-07 14:59:14 +02:00
Ahmed Ejaz
f386202ec2 11060: fix lint issues 2024-05-07 14:59:14 +02:00
Ahmed Ejaz
15ee4f6619 11060: add specs 2024-05-07 14:59:14 +02:00
Ahmed Ejaz
c12d6ab7f0 11060: revert 33b947be00563b67ca36475f277ceceaf8c68378 2024-05-07 14:59:14 +02:00
Ahmed Ejaz
da34e7b780 11060 - fix undefined method tax_category_options error in specs 2024-05-07 14:59:14 +02:00
Ahmed Ejaz
aad48b4670 11060 - use SearchableDropdownComponent for categories or tax categories 2024-05-07 14:59:14 +02:00
Ahmed Ejaz
f6efd47af2 11060 - use SearchableDropdownComponent for producer names 2024-05-07 14:59:14 +02:00
Ahmed Ejaz
c153ff75f3 11060 - add searchable dropdown component 2024-05-07 14:59:14 +02:00
Ahmed Ejaz
b577a81f48 11060 - add tax category field 2024-05-07 14:59:14 +02:00
Ahmed Ejaz
5050c2e02b 11060 - remove producer name from variant 2024-05-07 14:59:14 +02:00
Ahmed Ejaz
4360ddde03 11060 - add variant categories dropdown 2024-05-07 14:59:14 +02:00
Ahmed Ejaz
ec4b920f8b 11060 - implement scenario 1 2024-05-07 14:59:14 +02:00
Ahmed Ejaz
2fdaa8b9ec 11060 - implement the scenario 2 and 3 2024-05-07 14:59:14 +02:00
dependabot[bot]
8be8518bc4 chore(deps): bump flipper, flipper-active_record and flipper-ui
Bumps [flipper](https://github.com/flippercloud/flipper), [flipper-active_record](https://github.com/flippercloud/flipper) and [flipper-ui](https://github.com/flippercloud/flipper). These dependencies needed to be updated together.

Updates `flipper` from 1.2.2 to 1.3.0
- [Release notes](https://github.com/flippercloud/flipper/releases)
- [Changelog](https://github.com/flippercloud/flipper/blob/main/Changelog.md)
- [Commits](https://github.com/flippercloud/flipper/compare/v1.2.2...v1.3.0)

Updates `flipper-active_record` from 1.2.2 to 1.3.0
- [Release notes](https://github.com/flippercloud/flipper/releases)
- [Changelog](https://github.com/flippercloud/flipper/blob/main/Changelog.md)
- [Commits](https://github.com/flippercloud/flipper/compare/v1.2.2...v1.3.0)

Updates `flipper-ui` from 1.2.2 to 1.3.0
- [Release notes](https://github.com/flippercloud/flipper/releases)
- [Changelog](https://github.com/flippercloud/flipper/blob/main/Changelog.md)
- [Commits](https://github.com/flippercloud/flipper/compare/v1.2.2...v1.3.0)

---
updated-dependencies:
- dependency-name: flipper
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: flipper-active_record
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: flipper-ui
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-07 09:59:45 +00:00
Maikel
dd4fe86e9f Merge pull request #12423 from filipefurtad0/legacy_checkout_migrate_checkout_spec
Updates checkout tests to cover for out of stock variant
2024-05-07 14:07:43 +10:00
Gaetan Craig-Riou
aaaa4a4873 Merge pull request #12438 from openfoodfoundation/dependabot/bundler/spring-4.2.1
chore(deps-dev): bump spring from 4.2.0 to 4.2.1
2024-05-07 11:41:18 +10:00
Gaetan Craig-Riou
05c9c7124b Merge pull request #12440 from openfoodfoundation/dependabot/npm_and_yarn/floating-ui/dom-1.6.5
chore(deps): bump @floating-ui/dom from 1.6.4 to 1.6.5
2024-05-07 11:38:19 +10:00
David Cook
11507ba036 Merge pull request #12432 from mkllnk/migrate-n8n
Update links to n8n server
2024-05-07 09:31:26 +10:00
dependabot[bot]
b7b8efbc69 chore(deps): bump @floating-ui/dom from 1.6.4 to 1.6.5
Bumps [@floating-ui/dom](https://github.com/floating-ui/floating-ui/tree/HEAD/packages/dom) from 1.6.4 to 1.6.5.
- [Release notes](https://github.com/floating-ui/floating-ui/releases)
- [Changelog](https://github.com/floating-ui/floating-ui/blob/master/packages/dom/CHANGELOG.md)
- [Commits](https://github.com/floating-ui/floating-ui/commits/@floating-ui/dom@1.6.5/packages/dom)

---
updated-dependencies:
- dependency-name: "@floating-ui/dom"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-06 09:50:09 +00:00
dependabot[bot]
ca5f196447 chore(deps-dev): bump spring from 4.2.0 to 4.2.1
Bumps [spring](https://github.com/rails/spring) from 4.2.0 to 4.2.1.
- [Release notes](https://github.com/rails/spring/releases)
- [Changelog](https://github.com/rails/spring/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rails/spring/compare/v4.2.0...v4.2.1)

---
updated-dependencies:
- dependency-name: spring
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-06 09:08:35 +00:00
David Cook
84da904bb2 Merge pull request #12430 from mkllnk/draft-release
Remove tag template from link to draft release
2024-05-06 17:05:22 +10:00
Gaetan Craig-Riou
aa359d22a5 Merge pull request #12435 from openfoodfoundation/dependabot/npm_and_yarn/trix-2.1.1
chore(deps): bump trix from 2.1.0 to 2.1.1
2024-05-06 11:40:11 +10:00
Gaetan Craig-Riou
8ad25fdac5 Merge pull request #12433 from mkllnk/rubocop-config
Explicitely require all rubocop extensions
2024-05-06 11:39:17 +10:00
Gaetan Craig-Riou
c046d59911 Merge pull request #12418 from dacook/optimise-ci
Optimise CI
2024-05-06 11:05:28 +10:00
Gaetan Craig-Riou
f1f5e6d659 Merge pull request #12111 from openfoodfoundation/dependabot/bundler/flipper-and-flipper-active_record-and-flipper-ui-1.2.2
chore(deps): bump flipper, flipper-active_record and flipper-ui
2024-05-06 10:45:39 +10:00
dependabot[bot]
30f9f265c3 chore(deps): bump trix from 2.1.0 to 2.1.1
Bumps [trix](https://github.com/basecamp/trix) from 2.1.0 to 2.1.1.
- [Release notes](https://github.com/basecamp/trix/releases)
- [Commits](https://github.com/basecamp/trix/compare/v2.1.0...v2.1.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-03 09:53:27 +00:00
Maikel
0ddf8309c6 Merge pull request #12434 from openfoodfoundation/revert-12392-fix/duplicate-language-display-new-user-11513
Revert "Fix Duplicate Language Display on New User Creation"
2024-05-03 15:26:23 +10:00
Maikel
a75f3245a0 Revert "Fix Duplicate Language Display on New User Creation" 2024-05-03 15:07:47 +10:00
Maikel Linke
409492ce33 Explicitely require all rubocop extensions
I think that rspec-rails loaded the other extensions already but Rubocop
was suggesting these extensions to be loaded as well.

The alternative is to disable suggestions of new extensions but that
could hide new shiny tools when they become available.
2024-05-02 16:34:11 +10:00
Maikel Linke
b0a89372ab Update links to n8n server 2024-05-02 15:55:16 +10:00
Maikel Linke
03c35aaeaf Remove tag template from link to draft release
The release tag was pre-filled with `v` which was meant to help you type
the release number. But I observed multiple times now that an actual tag
named `v` was created. That tag can be quite annoying in the history.

So let's remove this tiny help to avoid mistakes. I personally use
`script/release/tag` which pre-fills the next tag already.

[skip ci]
2024-05-02 12:03:58 +10:00
Maikel Linke
2e004a026b Update all locales with the latest Transifex translations 2024-05-02 11:54:34 +10:00
Maikel Linke
ea0558c70e Replace Flipper's built-in test helper
It fails in CI and features are not seen as enabled. So we copy the
important part of the test helper into our code, which works.

It's probably about the point in time when the adapter is instantiated.
2024-05-02 11:23:30 +10:00
Mohamed ABDELLANI
75f343b42f Run rails generate flipper:update and rails db:migrate 2024-05-02 11:23:26 +10:00
dependabot[bot]
6b0de6e9e4 chore(deps): bump flipper, flipper-active_record and flipper-ui
Bumps [flipper](https://github.com/flippercloud/flipper), [flipper-active_record](https://github.com/flippercloud/flipper) and [flipper-ui](https://github.com/flippercloud/flipper). These dependencies needed to be updated together.

Updates `flipper` from 0.26.2 to 1.2.2
- [Release notes](https://github.com/flippercloud/flipper/releases)
- [Changelog](https://github.com/flippercloud/flipper/blob/main/Changelog.md)
- [Commits](https://github.com/flippercloud/flipper/compare/v0.26.2...v1.2.2)

Updates `flipper-active_record` from 0.26.2 to 1.2.2
- [Release notes](https://github.com/flippercloud/flipper/releases)
- [Changelog](https://github.com/flippercloud/flipper/blob/main/Changelog.md)
- [Commits](https://github.com/flippercloud/flipper/compare/v0.26.2...v1.2.2)

Updates `flipper-ui` from 0.26.2 to 1.2.2
- [Release notes](https://github.com/flippercloud/flipper/releases)
- [Changelog](https://github.com/flippercloud/flipper/blob/main/Changelog.md)
- [Commits](https://github.com/flippercloud/flipper/compare/v0.26.2...v1.2.2)

---
updated-dependencies:
- dependency-name: flipper
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: flipper-active_record
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: flipper-ui
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-02 11:22:56 +10:00
cyrillefr
5e18038a68 Fix RedundantPresenceValidationOnBelongs on two files
- presence: true is redundant since Rails 5.0 BUT applies
   with new default config of
   belongs_to_required_by_default to true.
   Lots of files with belongs_to_required_by_default = false
   (backward compatibility).
   So: deleting this setting implies to adding optional: true
 - added 'NOT NULL' constraints so model constraints match
   with contraints on DB tables.
 - corresponding migration files to match AR Models &
   DB tables
 - rake tasks to check corrupt data (ie: NULL/nil in id fields)
 - updated the todo
2024-05-01 15:43:09 +02:00
Gaetan Craig-Riou
94e3eee793 Update all locales with the latest Transifex translations 2024-05-01 14:44:57 +10:00
Gaetan Craig-Riou
04f77b5791 Merge pull request #12414 from cyrillefr/RedundantPresenceValidationOnBelongs_part_II
Fix RedundantPresenceValidationOnBelongs on some files (part II)
2024-05-01 13:00:47 +10:00
David Cook
71b79417b5 Merge pull request #12421 from filipefurtad0/legacy_checkout_multilingual_spec
Updates multilingual spec to test checkout steps
2024-05-01 09:55:05 +10:00
filipefurtad0
0583888963 Removes legacy checkout spec
All test cases are covered within the respective checkout step specs
2024-04-30 14:23:33 +01:00
filipefurtad0
34bde1caa9 Reverts changes on checkout steps specs
This can be squashed with the first commit of this PR
2024-04-30 14:22:30 +01:00
filipefurtad0
729c5f01d4 Adds out of stock check as helper
As shared examoples, in guest_spec.rb
2024-04-30 14:18:23 +01:00
filipefurtad0
0f80aca675 Updates checkout tests
Adds out of stock check as helper
2024-04-30 12:23:39 +01:00
cyrillefr
521e24d7a6 Requested changes on Fix RedundantPresenceValidationOnBelongs II
- product id required
 - DB + AR model
2024-04-30 09:58:24 +02:00
Gaetan Craig-Riou
92e0c218c5 Merge pull request #12420 from openfoodfoundation/dependabot/npm_and_yarn/jquery-ui-1.13.3
chore(deps): bump jquery-ui from 1.13.2 to 1.13.3
2024-04-30 10:18:37 +10:00
Gaetan Craig-Riou
40e46283a5 Merge pull request #12419 from openfoodfoundation/dependabot/npm_and_yarn/floating-ui/dom-1.6.4
chore(deps): bump @floating-ui/dom from 1.6.3 to 1.6.4
2024-04-30 10:16:36 +10:00
Gaetan Craig-Riou
49837c0665 Merge pull request #12416 from openfoodfoundation/dependabot/bundler/sidekiq-7.2.4
chore(deps): bump sidekiq from 7.2.2 to 7.2.4
2024-04-30 10:14:47 +10:00
filipefurtad0
fb5f31375a Adds localization test for checkout steps
As a logged user
2024-04-29 19:42:49 +01:00
filipefurtad0
1763c516ec Adds localization test for checkout as a guest 2024-04-29 17:44:42 +01:00
dependabot[bot]
2eebb1153b chore(deps): bump jquery-ui from 1.13.2 to 1.13.3
Bumps [jquery-ui](https://github.com/jquery/jquery-ui) from 1.13.2 to 1.13.3.
- [Release notes](https://github.com/jquery/jquery-ui/releases)
- [Commits](https://github.com/jquery/jquery-ui/compare/1.13.2...1.13.3)

---
updated-dependencies:
- dependency-name: jquery-ui
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-29 09:31:41 +00:00
dependabot[bot]
e674a66bcf chore(deps): bump @floating-ui/dom from 1.6.3 to 1.6.4
Bumps [@floating-ui/dom](https://github.com/floating-ui/floating-ui/tree/HEAD/packages/dom) from 1.6.3 to 1.6.4.
- [Release notes](https://github.com/floating-ui/floating-ui/releases)
- [Changelog](https://github.com/floating-ui/floating-ui/blob/master/packages/dom/CHANGELOG.md)
- [Commits](https://github.com/floating-ui/floating-ui/commits/@floating-ui/dom@1.6.4/packages/dom)

---
updated-dependencies:
- dependency-name: "@floating-ui/dom"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-29 09:31:21 +00:00
David Cook
7e951d4af2 Revert "Separate controllers requiring webpack for testing"
Arrgh it's not so simple.
It looks like both rspec and knapsack use glob for the pattern, so the pattern needs updating. Hmm that might not be too
 bad, but it makes it even less manageable.

Considering the system specs are a much bigger bottleneck, I'm going to avoid spending more time here.
2024-04-29 17:12:38 +10:00
David Cook
aeae16a1b4 Separate controllers requiring webpack for testing 2024-04-29 17:12:19 +10:00
David Cook
55ece0553c Revert. JS is still required for most specs
But models can still run without.

Half of the controller runs also succeeded, so we could potentially separate those ones out.
Hmm, yes only 7 of them. It would save 20s, or 16% of controller CI runtimesi which are 2min. let's try..
2024-04-29 17:02:09 +10:00
David Cook
1a55ae2035 Skip JS setup for non-JS tests
These tests don't run in the browser, therefore shouldn't need JavaScript at all.
2024-04-29 17:02:09 +10:00
David Cook
ce36b81f15 Run multiple rake tasks in one process
It saves the second unnecessary Rails boot-up (multiple seconds).
2024-04-29 17:02:09 +10:00
David Cook
6eaf0a00a0 Revert. Rails is required for the Karma rake script
But surely we could convert it to a shell or node script. Maybe next time..
2024-04-29 17:01:22 +10:00
David Cook
7c53c25aaf Skip Ruby setup for non-Ruby tests
Conversely, these tests are JS-only.
2024-04-29 17:00:56 +10:00
Gaetan Craig-Riou
442991ac7b Merge pull request #12413 from rioug/check-invalid-address-task
Add task to check for invalid address
2024-04-29 10:13:30 +10:00
David Cook
1dc5a1ab56 Merge pull request #12410 from mkllnk/dfc-website-url
Publish enterprise website with https://
2024-04-29 10:12:16 +10:00
David Cook
2e10948fff Merge pull request #12391 from kellyzhangg/8633-payments-controller-test
Add payments controller test
2024-04-29 10:09:03 +10:00
Gaetan Craig-Riou
a977bd633b Move rake file to the correct folder 2024-04-29 09:58:13 +10:00
dependabot[bot]
b0011caafa chore(deps): bump sidekiq from 7.2.2 to 7.2.4
Bumps [sidekiq](https://github.com/sidekiq/sidekiq) from 7.2.2 to 7.2.4.
- [Changelog](https://github.com/sidekiq/sidekiq/blob/main/Changes.md)
- [Commits](https://github.com/sidekiq/sidekiq/compare/v7.2.2...v7.2.4)

---
updated-dependencies:
- dependency-name: sidekiq
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-26 22:22:35 +00:00
kellyzhangg
f1f60a0a00 Merge branch 'master' into 8633-payments-controller-test 2024-04-25 12:24:31 -04:00
Kelly
ccf3d5873a style fix - remove type 2024-04-25 12:24:19 -04:00
Kelly
6b5be213a3 changed location - now in requests folder 2024-04-25 12:10:32 -04:00
filipefurtad0
57f148564c Update all locales with the latest Transifex translations 2024-04-25 16:32:56 +01:00
Filipe
e99b072442 Merge pull request #12313 from anthonyms/11482-fix-rubocop-rails-issue-has_many
Fix Rubocop Rails: Rails/HasManyOrHasOneDependent
2024-04-25 16:24:47 +01:00
Filipe
f269584b8e Merge pull request #12392 from sergioosouzaa/fix/duplicate-language-display-new-user-11513
Fix Duplicate Language Display on New User Creation
2024-04-25 16:01:09 +01:00
Filipe
4ff832693c Merge pull request #12412 from dacook/buu/fix-non-admin-saving-12403
[BUU] Fix non-admin saving
2024-04-25 12:37:11 +01:00
Rachel Arnould
09354dc80e Merge pull request #12219 from abdellani/prevent-generate-invoices-when-distributor-cannot-invoice
prevent generating invoices when order's distributor can't generate invoices
2024-04-25 12:18:49 +02:00
cyrillefr
43005672a9 Fix RedundantPresenceValidationOnBelongs on other files
- presence: true is redundant since Rails 5.0 BUT applies
   with new default config of
   belongs_to_required_by_default to true.
   Lots of files with belongs_to_required_by_default = false
   (backward compatibility).
   So: deleting this setting implies to adding optional: true
 - added 'NOT NULL' constraints so model constraints match
   with contraints on DB tables.
 - corresponding migration files to match AR Models &
   DB tables
 - rake tasks to check corrupt data (ie: NULL/nil in id fields)
 - updated the todo
2024-04-24 15:19:17 +02:00
Gaetan Craig-Riou
77a8e4d29a Print code to run to delete address if needed 2024-04-24 16:49:47 +10:00
Gaetan Craig-Riou
9583bef0d8 Per review, handle case where a model can be linked to invalid addresses 2024-04-24 16:42:13 +10:00
Gaetan Craig-Riou
040e09414b Add ofn:data:check_invalid_address_used task
It checks for invalid addresses, ie address with address1, city, phone
or country_id set to null.
It will return:
- a list of invalid address in use (associated to another
model)
- a list of invalid address not in use, ie that we can delete
2024-04-24 15:34:33 +10:00
Kelly
eda97ef3f7 fixed path 2024-04-23 22:18:45 -04:00
kellyzhangg
00742f6f0b Merge branch 'openfoodfoundation:master' into 8633-payments-controller-test 2024-04-23 22:15:58 -04:00
Kelly
64a1fd9270 removed changes to routes.rb 2024-04-23 22:15:43 -04:00
David Cook
b846d0f517 Add ability to bulk update products for product managers
I forgot to do this in #12328 [BUU] Remove Stimulus Reflex from Products screen
2024-04-24 10:56:30 +10:00
Maikel
f083e851c0 Merge pull request #12408 from filipefurtad0/stripe_registered_customer
[VCR/Stripe] Tests payment intents for offline payments
2024-04-24 10:14:28 +10:00
Maikel Linke
2acda6af74 Ignore empty string websites on DFC API 2024-04-24 09:19:11 +10:00
Kelly
c64519ae2f rewrote payments_controller_spec to be of request spec format 2024-04-23 12:02:32 -04:00
filipefurtad0
85e3d5d858 Tests payment intents for offline payments
Moves let variables outside shared examples block

Re-records cassettes
2024-04-23 12:24:00 +01:00
Anthony Musyoki
0d03cdf815 Fix Rubocop: Delete dependent stock_movements 2024-04-23 13:13:26 +03:00
Anthony Musyoki
434afb73cd Fix Rubocop: Update handling of enterprise associations 2024-04-23 12:40:58 +03:00
Anthony Musyoki
c2cbe4f0bf Fix Rubocop: Hard delete paranoid associations
As much as the associated models act_as_paranoid, it
doesnt make sense to keep them around after deleting the enterprise
2024-04-23 12:31:43 +03:00
Anthony Musyoki
645cb10864 Fix Rubocop: Do not delete Spree::Variant associations
Spree::Variant acts_as_paranoid and is thus not hard deleted
2024-04-23 12:31:43 +03:00
Anthony Musyoki
4140257fa1 Fix Rubocop: Do not delete dependent adjustments
TaxRate acts_as_paranoid iand is thus not hard_deleted
2024-04-23 12:31:43 +03:00
Anthony Musyoki
4f851bbe1f Fix Rubocop: Do not delete dependent stock_movements 2024-04-23 12:31:43 +03:00
Anthony Musyoki
1ec453df4d Fix Rubocop issue: Do not delete addresses having shipments
The reasoning is that we should not delete an address that has
ever received a shipment
2024-04-23 12:31:43 +03:00
Anthony Musyoki
5559816e12 Fix Rubocop Rails issue: Rails/HasManyOrHasOneDependent 2024-04-23 12:31:41 +03:00
Maikel Linke
5a9b9a065b DRY website fix 2024-04-23 16:49:45 +10:00
David Cook
574e8f0135 Show error message when turbo:frame-missing
Instead of replacing frame contents with unhelpful text 'Content missing'.
2024-04-23 16:48:52 +10:00
David Cook
b5cdee3d65 Rename translation key
So that it can be used for more general purposes.
2024-04-23 16:48:52 +10:00
David Cook
d0f683d279 Spec for bug 2024-04-23 16:48:52 +10:00
kellyzhangg
d875ea044d Merge branch 'openfoodfoundation:master' into 8633-payments-controller-test 2024-04-23 02:41:19 -04:00
Maikel Linke
64d633c64e Publish enterprise website with https:// 2024-04-23 13:50:46 +10:00
Gaetan Craig-Riou
8d166ed3e1 Merge pull request #12407 from cyrillefr/RedundantPresenceValidationOnBelongs_part_I
Fix RedundantPresenceValidationOnBelongs on some files
2024-04-23 10:29:48 +10:00
cyrillefr
9ae064a24f Fix RedundantPresenceValidationOnBelongs on some files
- presence: true is redundant since Rails 5.0 BUT applies
   with new default config of
   belongs_to_required_by_default to true
   Lots of files with belongs_to_required_by_default = false
   (backward compatibility)
   So: deleting this setting implies to adding optional: true
 - added 'NOT NULL' constraints so model constraints match
   with contraints on DB tables.
 - updated the todo
2024-04-22 17:36:47 +02:00
Mohamed ABDELLANI
7aad4ad652 Merge branch 'master' into prevent-generate-invoices-when-distributor-cannot-invoice 2024-04-22 10:55:39 +01:00
David Cook
4a3f4136df Merge pull request #12393 from mkllnk/lint-rubocop
Test all files with Rubocop, not just added code in the diff
2024-04-22 15:07:54 +10:00
Konrad
8e7f4ff908 Merge pull request #12333 from chahmedejaz/bugfix/12294-wrong-tax-category-display
[BUU] Fix Wrong Tax Category Display
2024-04-20 11:42:05 +02:00
Rachel Arnould
2090bc1b47 Merge pull request #12361 from dacook/buu/add-turbo
[BUU] Add Turbo for dynamic page loading
2024-04-19 11:44:17 +02:00
David Cook
38a4bfe98b Update all locales with the latest Transifex translations 2024-04-18 16:54:16 +10:00
David Cook
5b043574a2 Merge pull request #12384 from mkllnk/mail-config
Don't pass invalid auth method "None" to net-smtp
2024-04-18 16:51:51 +10:00
David Cook
e59237ef19 Merge pull request #12382 from mkllnk/dependabot-config
Allow Dependabot to open as many PRs as it likes
2024-04-18 11:06:05 +10:00
David Cook
053a88d252 Merge pull request #12363 from cyrillefr/FixRailsWhereExistsOffenses
Fix Rails/WhereExists rubocop offenses
2024-04-18 10:55:04 +10:00
Maikel
e7856d86f4 Merge pull request #12397 from openfoodfoundation/dependabot/bundler/aws-sdk-s3-1.147.0
chore(deps): bump aws-sdk-s3 from 1.146.1 to 1.147.0
2024-04-18 09:08:24 +10:00
Maikel
09ece4b35e Merge pull request #12396 from openfoodfoundation/dependabot/bundler/stripe-11.1.0
chore(deps): bump stripe from 11.0.0 to 11.1.0
2024-04-18 08:56:59 +10:00
Sergio Souza
9477725997 update tests for avaliable_locales 2024-04-18 08:55:34 +10:00
Sergio Souza
51d90e782b remove the source_locale from the avaliable_locales method 2024-04-18 08:55:34 +10:00
Maikel Linke
c4e92e7d8f Update Stripe API recordings for new version 2024-04-18 08:42:18 +10:00
Maikel
142fe542c0 Merge pull request #12370 from filipefurtad0/regression_spec_ship_order_button
Adds regression spec as shared example, for order edit subsections
2024-04-18 08:31:37 +10:00
filipefurtad0
574297343f Sets pending examples for order edit page subsections 2024-04-17 14:27:56 +01:00
dependabot[bot]
302cde6f4e chore(deps): bump aws-sdk-s3 from 1.146.1 to 1.147.0
---
updated-dependencies:
- dependency-name: aws-sdk-s3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-17 09:43:41 +00:00
dependabot[bot]
5a2f791d58 chore(deps): bump stripe from 11.0.0 to 11.1.0
Bumps [stripe](https://github.com/stripe/stripe-ruby) from 11.0.0 to 11.1.0.
- [Release notes](https://github.com/stripe/stripe-ruby/releases)
- [Changelog](https://github.com/stripe/stripe-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/stripe/stripe-ruby/compare/v11.0.0...v11.1.0)

---
updated-dependencies:
- dependency-name: stripe
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-17 09:43:21 +00:00
cyrillefr
456905e69f Fix Rails/WhereExists rubocop offenses
- after discussion, dev team decided not to follow
- this particular rule, but rather to enforce the where().exists? rule
  instead.
- cf. https://github.com/openfoodfoundation/openfoodnetwork/pull/12363
2024-04-17 10:37:18 +02:00
David Cook
a2255e62d4 Revert "Use POST for action that creates data,"
I'm not happy about it, but we need it to be a standard link to make it work. I assume it's because BulkFormController.preventLeavingChangedForm() isn't smart enough.

This reverts commit 91f0a80189.
2024-04-17 17:36:05 +10:00
David Cook
11541c9270 Disable turbo for those links
Now we can warn that "Changes that you made might not be saved"
2024-04-17 17:35:17 +10:00
David Cook
8f9d8b5fb8 Revert "Prevent frame navigations when form is changed"
It was too hacky and had issues. Let's just disable Turbo for those links for now.

This reverts commit 1d1169b478.
2024-04-17 17:26:49 +10:00
David Cook
91f0a80189 Use POST for action that creates data,
duh.

Turbo cleverly pre-fetches GET requests to save loading time. But that resulted in dozens of unwanted clones.
Attack of the clones!!!

I checked: even though this route predates the new products screen, it wasn't being used anywhere else. The old products screen uses the API instead.
2024-04-17 15:18:13 +10:00
David Cook
1d1169b478 Prevent frame navigations when form is changed
This is a hacky hack, filling a gap in Turbo.
2024-04-17 15:17:59 +10:00
David Cook
06f67488a9 Open links outside of frame by default
This page is big enough and it's hard to see how everything works. So links work like links by default (eg edit and clone). Other links and forms are special, and will reload only the frame: this is now explicit in the code.
2024-04-17 15:17:59 +10:00
David Cook
acc72514de Fix spec 2024-04-17 15:17:59 +10:00
David Cook
1abb068a00 Enable morphing?
I can't really prove if this is working, but it seems to be rendering slightly faster.
2024-04-17 15:17:59 +10:00
David Cook
508ebab75b Add loading spinner to turbo frame
That was surprisingly easy. Note that it's still shared with SR.

It hides a bit early though: when the web response returns, but before the DOM has been rendered. Something to optimise in the future.
2024-04-17 15:17:59 +10:00
David Cook
6c9a47854a Submit forms with Turbo Frame
Now the filters, pagination and product forms submit and load within the frame, and work perfectly, yay!

It's still building the whole page on the server.. I think we need Turbo Streams if we want to send back just a partial.
2024-04-17 15:17:59 +10:00
David Cook
9d6ef2f730 Avoid style issues with Turbo
But the filter dropdowns still get duplicated. So weird..
2024-04-17 15:17:59 +10:00
David Cook
f17b0d176b Enable Turbo Drive on products page
Forms now load without a full page rebuild.
This is not really faster, but a bit smoother because it avoids a full page render in the browser. The default Turbo loading indicator is shown (blue line at top).

But the bulk_update form breaks... hmm
On to the next level!
2024-04-17 15:17:59 +10:00
David Cook
72ce3a01a9 Ensure search terms and filters are retained when saving 2024-04-17 15:17:59 +10:00
Maikel Linke
eb791bed27 Test all files with Rubocop, not just added code in the diff 2024-04-17 09:44:43 +10:00
Maikel
b624965883 Merge pull request #12387 from openfoodfoundation/dependabot/bundler/redis-5.2.0
chore(deps): bump redis from 5.1.0 to 5.2.0
2024-04-17 09:06:23 +10:00
Maikel
f5b6a14aba Merge pull request #12386 from openfoodfoundation/dependabot/bundler/rubocop-1.63.2
chore(deps-dev): bump rubocop from 1.63.1 to 1.63.2
2024-04-17 09:05:02 +10:00
Maikel
a27999f224 Merge pull request #12385 from openfoodfoundation/dependabot/bundler/rspec-sql-0.0.2
chore(deps-dev): bump rspec-sql from 0.0.1 to 0.0.2
2024-04-17 08:24:03 +10:00
kellyzhangg
adad631efa Merge branch 'openfoodfoundation:master' into 8633-payments-controller-test 2024-04-16 15:34:21 -04:00
Kelly
954125b7f6 style improvements after running rubocop 2024-04-16 15:30:21 -04:00
Kelly
1ad544820c completed payments_controller_spec testing 2024-04-16 15:21:49 -04:00
Kelly
7d814e739d added objects necessary for testing - user, order, payment 2024-04-16 15:09:21 -04:00
Kelly
d163080115 added test for if user isn't logged in for payments_controller 2024-04-16 14:52:17 -04:00
Konrad
31c1eee593 Merge pull request #11958 from filipefurtad0/adds_missing_keys_from_i18n_tasks_output
Adds missing keys from i18n tasks output
2024-04-16 13:14:29 +02:00
dependabot[bot]
ef3a41203d chore(deps): bump redis from 5.1.0 to 5.2.0
Bumps [redis](https://github.com/redis/redis-rb) from 5.1.0 to 5.2.0.
- [Changelog](https://github.com/redis/redis-rb/blob/master/CHANGELOG.md)
- [Commits](https://github.com/redis/redis-rb/compare/v5.1.0...v5.2.0)

---
updated-dependencies:
- dependency-name: redis
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-16 09:58:51 +00:00
dependabot[bot]
f6f0622e9b chore(deps-dev): bump rubocop from 1.63.1 to 1.63.2
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.63.1 to 1.63.2.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.63.1...v1.63.2)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-16 09:54:23 +00:00
dependabot[bot]
0c319bea2c chore(deps-dev): bump rspec-sql from 0.0.1 to 0.0.2
Bumps [rspec-sql](https://github.com/datafoodconsortium/connector-ruby) from 0.0.1 to 0.0.2.
- [Release notes](https://github.com/datafoodconsortium/connector-ruby/releases)
- [Changelog](https://github.com/datafoodconsortium/connector-ruby/blob/main/CHANGELOG.md)
- [Commits](https://github.com/datafoodconsortium/connector-ruby/commits)

---
updated-dependencies:
- dependency-name: rspec-sql
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-16 09:53:18 +00:00
Maikel Linke
5cd53e0b5e Clean up MailSettings spec
Best viewed with whitespace ignored.
2024-04-16 16:44:12 +10:00
Maikel Linke
1fc4270613 Remove indirection from MailSettings
We can simply merge the option hashes now because they are not
conditional anymore. Well, the magic `presence` method does the
conditional logic for us now.
2024-04-16 16:40:52 +10:00
Maikel Linke
7e2fcede61 Further simplify mail options logic
We were always adding this option anyway, so why not declare it to start
with?
2024-04-16 16:40:52 +10:00
Maikel Linke
a41019fbff Simplify SMTP auth method selection
Instead of using the auth method name, let's just not supply username
and password when we don't want to authenticate. The two affected
servers AU and CA don't have credentials set anyway. This is compatible.

The specs needed changing though.
2024-04-16 16:40:50 +10:00
Maikel Linke
d6f2a531aa Don't pass invalid auth method "None" to net-smtp
It's our magic word to not pass username and password on.
2024-04-16 16:18:49 +10:00
Maikel Linke
9d09d5aff1 Allow Dependabot to open as many PRs as it likes 2024-04-16 11:19:27 +10:00
David Cook
2adb69edb0 Merge pull request #12334 from dacook/buu/optimise
[BUU] Optimisation
2024-04-16 09:53:53 +10:00
Gaetan Craig-Riou
e33da30263 Merge pull request #12379 from openfoodfoundation/dependabot/bundler/foreman-0.88.1
chore(deps-dev): bump foreman from 0.87.2 to 0.88.1
2024-04-16 09:38:37 +10:00
Gaetan Craig-Riou
c30292890d Merge pull request #12378 from openfoodfoundation/dependabot/bundler/mini_portile2-2.8.6
chore(deps): bump mini_portile2 from 2.8.5 to 2.8.6
2024-04-16 09:33:05 +10:00
Gaetan Craig-Riou
77b9f506ab Merge pull request #12377 from openfoodfoundation/dependabot/bundler/view_component-3.12.0
chore(deps): bump view_component from 3.11.0 to 3.12.0
2024-04-16 09:32:19 +10:00
Gaetan Craig-Riou
5371258125 Merge pull request #12366 from openfoodfoundation/dependabot/bundler/stripe-11.0.0
chore(deps): bump stripe from 10.15.0 to 11.0.0
2024-04-16 09:16:49 +10:00
filipefurtad0
91769574e3 Removes unecessary key your_cart_is_empty 2024-04-15 15:16:30 +01:00
filipefurtad0
bfd4b730f2 Combines keys taxon_edit and taxonomy_edit 2024-04-15 15:07:52 +01:00
filipefurtad0
d2c2e20822 Removes #connect.pane files
_learn and _connect seem to appear at the top of the homepage (and not as pane). Also, there was some hard coded URLs which seems not to be used, as the translations in the Configuration/Content section seem to work correctly.
2024-04-15 15:05:53 +01:00
filipefurtad0
269811584b Updates file to latest state
Deletes file

We only needed this file for tracking progress, during review, we should not keep it in master I think
2024-04-15 15:05:53 +01:00
filipefurtad0
83c74bcc77 Updates existing translation on master
Done to prevent/fix merge conflicts
2024-04-15 15:05:53 +01:00
filipefurtad0
f08c1ca51d Updates missing translations file 2024-04-15 15:05:53 +01:00
filipefurtad0
4a7cb601e6 Added missing keys
Adds string to missing key

To be squashed
2024-04-15 15:05:53 +01:00
filipefurtad0
579357dcfa Updates missing translations file 2024-04-15 15:05:53 +01:00
filipefurtad0
08ccdf07c9 Adds missing key thank_you_for_your_order 2024-04-15 15:05:53 +01:00
filipefurtad0
a2a951a18e Updates missing translations file 2024-04-15 15:05:53 +01:00
filipefurtad0
8a9b728ac7 Updates missing translations file 2024-04-15 15:05:53 +01:00
filipefurtad0
8f07ff49ac Adds missing keys 2024-04-15 15:05:53 +01:00
filipefurtad0
8ca019d00c updates missing translations txt file 2024-04-15 15:05:53 +01:00
filipefurtad0
eb82e30cf6 Adds keys spree.editing_state and spree.back_to_states_list 2024-04-15 15:05:53 +01:00
filipefurtad0
b1e10f3dd4 Replaces missing by existing key
I'm not sure how to trigger this error, and triggering an update error message seems appropriate too - it's sort of an edge case, perhaps this is a valid approach
2024-04-15 15:05:53 +01:00
filipefurtad0
acc036b1d7 Removes missing payement message
I've checked staging, and I could not find this message, nor the entry in the en.yml file - I think we're not rendering this message currently, hence, the removal.
2024-04-15 15:05:53 +01:00
filipefurtad0
e182365006 Replaces missing keys by existing ones 2024-04-15 15:05:53 +01:00
filipefurtad0
9926b65bd9 Removes unused haml file 2024-04-15 15:05:53 +01:00
filipefurtad0
8db716f047 Adds missing key card_type_is 2024-04-15 15:05:53 +01:00
filipefurtad0
3e27a34971 Adds missing key instance_publishable_key 2024-04-15 15:05:53 +01:00
filipefurtad0
5420910907 Adds output from i18n-tasks on missing keys 2024-04-15 15:05:53 +01:00
dependabot[bot]
bdbc9ae28b chore(deps-dev): bump foreman from 0.87.2 to 0.88.1
Bumps [foreman](https://github.com/ddollar/foreman) from 0.87.2 to 0.88.1.
- [Changelog](https://github.com/ddollar/foreman/blob/main/Changelog.md)
- [Commits](https://github.com/ddollar/foreman/compare/v0.87.2...v0.88.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-15 09:45:11 +00:00
dependabot[bot]
7fdf6f4607 chore(deps): bump mini_portile2 from 2.8.5 to 2.8.6
Bumps [mini_portile2](https://github.com/flavorjones/mini_portile) from 2.8.5 to 2.8.6.
- [Release notes](https://github.com/flavorjones/mini_portile/releases)
- [Changelog](https://github.com/flavorjones/mini_portile/blob/main/CHANGELOG.md)
- [Commits](https://github.com/flavorjones/mini_portile/compare/v2.8.5...v2.8.6)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-15 09:44:15 +00:00
dependabot[bot]
81274bd075 chore(deps): bump view_component from 3.11.0 to 3.12.0
---
updated-dependencies:
- dependency-name: view_component
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-15 09:37:37 +00:00
Gaetan Craig-Riou
4de1905e73 Merge pull request #12371 from mkllnk/suggest-rubocop-extensions
Let Rubocop suggest extensions
2024-04-15 10:04:36 +10:00
Maikel Linke
97eef4cfcd Update all locales with the latest Transifex translations 2024-04-12 14:05:46 +10:00
Maikel Linke
d9ec6e2ca3 Wait longer for real Stripe responses
When we re-record cassettes, I noticed this spec failing. We may need to
add this parameter to more specs.
2024-04-12 12:34:26 +10:00
Maikel Linke
e5323c8e82 Update Stripe API recordings for new version 2024-04-12 12:27:02 +10:00
Maikel Linke
cac9b515e0 Let Rubocop suggest extensions
We are using all suggested extensions already and it's not suggesting
anything at the moment. Using the default value for suggesting
extensions will mean that Rubocop will tell us when there's a new
recommended extension for our code base.
2024-04-12 12:06:31 +10:00
Maikel
9bb27aeac7 Merge pull request #12353 from filipefurtad0/regression_spec_#12343_improvement
Improves regression spec after reviewer feedback
2024-04-12 12:04:04 +10:00
Maikel
4109650509 Merge pull request #12364 from openfoodfoundation/dependabot/bundler/rubocop-1.63.1
chore(deps-dev): bump rubocop from 1.63.0 to 1.63.1
2024-04-12 12:02:36 +10:00
Maikel
03dffa5c96 Merge pull request #12367 from openfoodfoundation/dependabot/bundler/devise-4.9.4
chore(deps): bump devise from 4.9.3 to 4.9.4
2024-04-12 11:58:04 +10:00
Maikel
bdd47f27b8 Merge pull request #12368 from openfoodfoundation/dependabot/bundler/datafoodconsortium-connector-1.0.0.pre.alpha.12
chore(deps): bump datafoodconsortium-connector from 1.0.0.pre.alpha.11 to 1.0.0.pre.alpha.12
2024-04-12 11:57:03 +10:00
filipefurtad0
fd54a12bcb Moves methods to end of the file 2024-04-11 12:36:47 +01:00
filipefurtad0
f4108e97c7 Improves regression spec after reviewer feedback
Removes shared_examples, defines a separate method

Removes pending to bring spec to green
2024-04-11 12:33:10 +01:00
Konrad
27a4202fa4 Merge pull request #12357 from mkllnk/fix-invoice-order
Fix: preserve order of invoices in bulk print
2024-04-11 12:47:14 +02:00
dependabot[bot]
5ec1418eff chore(deps): bump datafoodconsortium-connector
Bumps [datafoodconsortium-connector](https://github.com/datafoodconsortium/connector-ruby) from 1.0.0.pre.alpha.11 to 1.0.0.pre.alpha.12.
- [Release notes](https://github.com/datafoodconsortium/connector-ruby/releases)
- [Changelog](https://github.com/datafoodconsortium/connector-ruby/blob/main/CHANGELOG.md)
- [Commits](https://github.com/datafoodconsortium/connector-ruby/compare/v1.0.0-alpha.11...v1.0.0-alpha.12)

---
updated-dependencies:
- dependency-name: datafoodconsortium-connector
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-11 10:25:29 +00:00
dependabot[bot]
38f97ffc8e chore(deps): bump devise from 4.9.3 to 4.9.4
Bumps [devise](https://github.com/heartcombo/devise) from 4.9.3 to 4.9.4.
- [Release notes](https://github.com/heartcombo/devise/releases)
- [Changelog](https://github.com/heartcombo/devise/blob/main/CHANGELOG.md)
- [Commits](https://github.com/heartcombo/devise/compare/v4.9.3...v4.9.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-11 10:23:21 +00:00
dependabot[bot]
1ae876ef96 chore(deps): bump stripe from 10.15.0 to 11.0.0
Bumps [stripe](https://github.com/stripe/stripe-ruby) from 10.15.0 to 11.0.0.
- [Release notes](https://github.com/stripe/stripe-ruby/releases)
- [Changelog](https://github.com/stripe/stripe-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/stripe/stripe-ruby/compare/v10.15.0...v11.0.0)

---
updated-dependencies:
- dependency-name: stripe
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-11 10:14:21 +00:00
dependabot[bot]
4d94826516 chore(deps-dev): bump rubocop from 1.63.0 to 1.63.1
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.63.0 to 1.63.1.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.63.0...v1.63.1)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-11 10:11:45 +00:00
Maikel
dc7c5b6748 Merge pull request #12359 from openfoodfoundation/dependabot/bundler/stripe-10.15.0
chore(deps): bump stripe from 10.14.0 to 10.15.0
2024-04-11 16:25:04 +10:00
Maikel
082b1f9411 Merge pull request #12300 from mkllnk/checkout-steps
Remove unnecessary method checkout_steps
2024-04-11 15:57:45 +10:00
David Cook
5554eee0d1 Merge pull request #12354 from openfoodfoundation/dependabot/npm_and_yarn/tar-6.2.1
chore(deps): bump tar from 6.1.11 to 6.2.1
2024-04-11 11:49:33 +10:00
Maikel Linke
34fc6283b8 Remove unused code 2024-04-11 11:46:52 +10:00
Maikel Linke
2f3b8c8573 Re-record Stripe cassettes 2024-04-11 11:45:14 +10:00
David Cook
3318c2622d Merge pull request #12352 from cyrillefr/FixRailsWhereEquals
Fix rubocop FixRailsWhereEquals
2024-04-11 11:43:03 +10:00
Maikel
f6dbb78686 Merge pull request #12360 from openfoodfoundation/dependabot/bundler/spring-4.2.0
chore(deps-dev): bump spring from 4.1.3 to 4.2.0
2024-04-11 11:40:19 +10:00
David Cook
a94901fc99 Merge pull request #12358 from openfoodfoundation/dependabot/bundler/valid_email2-5.2.3
chore(deps): bump valid_email2 from 5.2.1 to 5.2.3
2024-04-11 11:28:08 +10:00
dependabot[bot]
0be720dcb1 chore(deps): bump tar from 6.1.11 to 6.2.1
Bumps [tar](https://github.com/isaacs/node-tar) from 6.1.11 to 6.2.1.
- [Release notes](https://github.com/isaacs/node-tar/releases)
- [Changelog](https://github.com/isaacs/node-tar/blob/main/CHANGELOG.md)
- [Commits](https://github.com/isaacs/node-tar/compare/v6.1.11...v6.2.1)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-11 01:27:41 +00:00
Maikel
1459c9ee94 Merge pull request #12345 from chahmedejaz/task/12332-fix-rubocop-locale-errors
Fix Rubocop Locale Errors
2024-04-11 11:24:30 +10:00
David Cook
18d91d166e Remove temporary spec
It's likely to change frequently when there are global changes to the admin screen.
It would be better to test more directly, but I don't think worth it while everythings moving around so much.
2024-04-11 10:31:23 +10:00
David Cook
32b33de707 Optimise by pre-loading required columns
Oh boy, that's a big change.
2024-04-11 10:31:23 +10:00
David Cook
917ca790af Temporarily add db counter to query
This is going to be totally flaky so will remove soon.
2024-04-11 10:31:23 +10:00
Maikel Linke
c2c7910357 Reset I18n.local for each spec
This avoids a locale setting leaking from one spec to another. It also
means that we don't have to reset the locale in individual specs.

Also:

- `cookies` is reset automatically and we don't need to do that.
- Removed some unused code (German number format and helper methods).
2024-04-11 10:14:52 +10:00
Ahmed Ejaz
b2172ef8d8 12332 - Add around block to apply default_locale on specs 2024-04-11 10:14:52 +10:00
Ahmed Ejaz
ec61cff387 12332 - Fix rubocop Rails/I18nLocaleTexts errors
- Add en locales for the hardcodded strings
2024-04-11 10:14:50 +10:00
Ahmed Ejaz
693b9bd171 12332 - Fix rubocop Rails/I18nLocaleAssignment errors
- use I18n.with_locale method rather than direct locale assignment
2024-04-11 10:13:50 +10:00
Filipe
89033579bd Merge pull request #12328 from dacook/buu/remove-stimulus-reflex
[BUU] Remove Stimulus Reflex from Products screen
2024-04-10 21:59:59 +01:00
Konrad
b3dd51d6ac Merge pull request #12324 from chahmedejaz/task/12314-fix-rubocop-rails-helper-instance-variable
Fix Rubocop Rails/HelperInstanceVariable
2024-04-10 20:17:06 +02:00
David Cook
1425d524b9 Fix product filtering
Merges change from fb09a7f1e6
2024-04-10 15:17:56 +01:00
David Cook
e78ef120f4 TODO
I think this case got lost.
2024-04-10 15:17:56 +01:00
David Cook
129ceb01f0 Fix spec 2024-04-10 15:17:56 +01:00
David Cook
97d13597b0 Fix intermittent bug
Dunno why, but this recently started occuring for me in dev and test. Browser update?
2024-04-10 15:17:56 +01:00
David Cook
15790d3d8e Only register event listeners when needed
Otherwise there could be over 200 listeners on a page.
2024-04-10 15:17:56 +01:00
David Cook
54d0dfb141 Prevent duplicate products in search results
Dunno why, but the product was appearing once for each variant.
2024-04-10 15:17:56 +01:00
David Cook
c4b7b76e64 Avoid pagination when editing errored products 2024-04-10 15:17:56 +01:00
David Cook
fd8be37a62 Use shared page controls on products screen
This has an auto submit and can potentially work with Turbo, like on the Orders screen.
2024-04-10 15:17:56 +01:00
David Cook
0fc3d39106 Ensure pagination is retained when saving or discarding
But we have more work to do.
2024-04-10 15:17:56 +01:00
David Cook
2c71f7f1ed Discard changes by reloading the page
Now there's a popup asking to confirm, which I think is worth keeping!
2024-04-10 15:17:56 +01:00
David Cook
8696e05e66 Move index and bulk_update actions to good ol' HTTP requests
We've found that we just can't rely in StimulusReflex (and the underlying WebSockets stack) to guarantee a response to a request.
Because of this, there was intermittent issues when the server was overloaded with large requests, and the response never arrived, leaving an infinite loader, and a poor user wondering if anything was still happening.
2024-04-10 15:17:56 +01:00
David Cook
dadabcf8ad Prettify 2024-04-10 15:17:56 +01:00
David Cook
d904c2a494 Don't warn when submitting form 2024-04-10 15:17:56 +01:00
Konrad
e88335a923 Merge pull request #12303 from arunguleria/12295-translation-fixes-on-return-authorizaton
12295-Translation fixes for return authorization status
2024-04-10 14:10:08 +02:00
dependabot[bot]
6bcbbeadc4 chore(deps-dev): bump spring from 4.1.3 to 4.2.0
Bumps [spring](https://github.com/rails/spring) from 4.1.3 to 4.2.0.
- [Release notes](https://github.com/rails/spring/releases)
- [Changelog](https://github.com/rails/spring/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rails/spring/compare/v4.1.3...v4.2.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-10 10:08:27 +00:00
dependabot[bot]
9897c33a08 chore(deps): bump stripe from 10.14.0 to 10.15.0
Bumps [stripe](https://github.com/stripe/stripe-ruby) from 10.14.0 to 10.15.0.
- [Release notes](https://github.com/stripe/stripe-ruby/releases)
- [Changelog](https://github.com/stripe/stripe-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/stripe/stripe-ruby/compare/v10.14.0...v10.15.0)

---
updated-dependencies:
- dependency-name: stripe
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-10 09:59:34 +00:00
dependabot[bot]
e5e8d62c6a chore(deps): bump valid_email2 from 5.2.1 to 5.2.3
Bumps [valid_email2](https://github.com/micke/valid_email2) from 5.2.1 to 5.2.3.
- [Changelog](https://github.com/micke/valid_email2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/micke/valid_email2/compare/v5.2.1...v5.2.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-10 09:57:15 +00:00
Maikel Linke
b03bb30a8e Move ABN checks to the database 2024-04-10 17:02:18 +10:00
Maikel Linke
3382a62eb5 Simplify BulkInvoiceJob by removing checks
The check for invoiceability is already done by the reflex triggering
the job. Let's DRY the code, save time and be more flexible in the
future.

Also checking the order of actually generated PDF pages.
2024-04-10 16:52:56 +10:00
Maikel Linke
48b447500f Move selection of invoicable orders to database
It's more efficient and should allow for further optimisations.
2024-04-10 16:52:56 +10:00
Maikel Linke
16c877f7cb Fix: preserve order of invoices in bulk print 2024-04-10 14:51:55 +10:00
Maikel Linke
1d8b942acd Fix spec for invoice ordering 2024-04-10 14:03:25 +10:00
David Cook
ade4e855dc Merge pull request #12341 from mkllnk/connected-app-url
Make URL to connect app translatable
2024-04-10 10:36:49 +10:00
David Cook
d4da684f4a Merge pull request #12349 from openfoodfoundation/dependabot/bundler/rubocop-1.63.0
chore(deps-dev): bump rubocop from 1.62.1 to 1.63.0
2024-04-10 10:32:32 +10:00
cyrillefr
404fcf1f72 Fix FixRailsWhereEquals
- fixes offenses caused by RuboCop::Cop::Rails::WhereEquals cop
2024-04-09 10:44:02 +02:00
Maikel
a40b9eb44e Merge pull request #12316 from anansilva/6055-fix-rubocop-lint-constant-definition-in-block
Fix rubocop Lint/ConstantDefinitionInBlock group
2024-04-09 12:52:06 +10:00
Maikel Linke
c0010319af Avoid duplicate loading of task in spec
The new product image import spec was loading rake tasks multiple times.
That make the spec for enterprise deletion fail when executed afterwards
because the deletion task was executed twice and failed the second time.
2024-04-09 12:04:42 +10:00
Maikel
c9c94fcaa5 Merge pull request #12337 from cyrillefr/FixRailsNegateIncludeRubocopIssue
Fix Rubocop Rails/NegateInclude issues
2024-04-09 10:40:47 +10:00
Gaetan Craig-Riou
103c6e7fc0 Remove debugging line 2024-04-09 10:30:46 +10:00
Gaetan Craig-Riou
1509066b85 Apply new cop Style/MapIntoArray fix 2024-04-09 10:29:30 +10:00
Maikel
169df3fb8b Merge pull request #12343 from filipefurtad0/spec_regression_s2_12340
Adds regression spec for S2 bug #12340
2024-04-09 10:16:09 +10:00
Ana Nunes da Silva
061ff91786 Fix offense constant definition in block in validators/integer_array_validator_spec.rb 2024-04-08 11:16:38 +01:00
Ana Nunes da Silva
0aea14832a Fix offense constant definition in block in validators/date_time_string_validator_spec.rb 2024-04-08 11:16:38 +01:00
Ana Nunes da Silva
939605cb7a Fix offense constant definition in block in models/spree/preferences/preferable_spec.rb 2024-04-08 11:16:38 +01:00
Ana Nunes da Silva
b18fe8ce35 Fix offense constant definition in block in models/spree/preferences/configuration_spec.rb 2024-04-08 11:16:38 +01:00
Ana Nunes da Silva
fc3d7f8496 Fix offense constant definition in block in models/spree/gateway_spec.rb 2024-04-08 11:16:38 +01:00
Ana Nunes da Silva
3bd6c85f3b Fix offense constant definition in block in models/spree/ability_spec.rb 2024-04-08 11:16:38 +01:00
Ana Nunes da Silva
0726e4c1d0 Fix offense constant definition in block in reports/line_items_spec.rb 2024-04-08 11:16:38 +01:00
Ana Nunes da Silva
cfca7816d5 Fix offense constant definition in block in serializer_helper_spec.rb 2024-04-08 11:16:38 +01:00
Ana Nunes da Silva
f1309db0f0 Fix offense constant definition in block in spree base_controller_spec.rb 2024-04-08 11:16:38 +01:00
Ana Nunes da Silva
d726a0e3cb Fix offense constant definition in block in users.rake
This rake has tests
2024-04-08 11:16:38 +01:00
Ana Nunes da Silva
5415fa2db8 Fix offense constant definition in block in import_product_images_rake.rb
Add a test to import product images rake
2024-04-08 11:16:38 +01:00
dependabot[bot]
2772dd2e78 chore(deps-dev): bump rubocop from 1.62.1 to 1.63.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.62.1 to 1.63.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.62.1...v1.63.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-08 09:07:38 +00:00
Gaetan Craig-Riou
f4cc5d5917 Merge pull request #12342 from openfoodfoundation/dependabot/bundler/rubocop-rspec-2.29.1
chore(deps-dev): bump rubocop-rspec from 2.28.0 to 2.29.1
2024-04-08 13:30:57 +10:00
Gaetan Craig-Riou
3634032948 Merge pull request #12344 from cyrillefr/FixLintDuplicateRequireIssue
Fix Lint/DuplicateRequire issue
2024-04-08 13:15:11 +10:00
filipefurtad0
8ad4f885a0 Adds shared example for descending name ordering 2024-04-07 17:15:12 +01:00
Ahmed Ejaz
870e2b447c 12294 - add specs
- display none if no tax category is selected
- add a tax_category_column css selector for future related specs
2024-04-05 23:49:52 +05:00
cyrillefr
f57d44ba24 Fix Lint/DuplicateRequire issue
- updates the todo list
2024-04-05 17:09:14 +02:00
filipefurtad0
f618ef1201 Adds regression spec for S2 bug #12340 2024-04-05 14:46:52 +01:00
dependabot[bot]
644f0aaf75 chore(deps-dev): bump rubocop-rspec from 2.28.0 to 2.29.1
Bumps [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) from 2.28.0 to 2.29.1.
- [Release notes](https://github.com/rubocop/rubocop-rspec/releases)
- [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.28.0...v2.29.1)

---
updated-dependencies:
- dependency-name: rubocop-rspec
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-05 09:26:46 +00:00
cyrillefr
2877c793f8 Attempt to get rid of flaky spec #10027 2024-04-05 10:07:06 +02:00
Maikel Linke
91803953fe Point connect app URL to new n8n server 2024-04-05 15:35:03 +11:00
Maikel Linke
e00156a8d4 Make URL to connect app translatable
Instance managers can now change the URL in Transifex to use their own
API endpoint.
2024-04-05 14:57:13 +11:00
Maikel
fa03de33e1 Merge pull request #12335 from openfoodfoundation/dependabot/bundler/datafoodconsortium-connector-1.0.0.pre.alpha.11
chore(deps): bump datafoodconsortium-connector from 1.0.0.pre.alpha.10 to 1.0.0.pre.alpha.11
2024-04-05 10:20:58 +11:00
Maikel
16c20dbb6b Merge pull request #12339 from filipefurtad0/bump_stripe-10.14.0
Bump stripe 10.14.0
2024-04-05 10:19:51 +11:00
Maikel
403d855766 Merge pull request #12336 from openfoodfoundation/dependabot/bundler/json-2.7.2
chore(deps): bump json from 2.7.1 to 2.7.2
2024-04-05 10:16:51 +11:00
Maikel Linke
965ca5ca92 Update DFC API docs 2024-04-05 10:09:00 +11:00
dependabot[bot]
4e7fed9c4b chore(deps): bump datafoodconsortium-connector
Bumps [datafoodconsortium-connector](https://github.com/datafoodconsortium/connector-ruby) from 1.0.0.pre.alpha.10 to 1.0.0.pre.alpha.11.
- [Release notes](https://github.com/datafoodconsortium/connector-ruby/releases)
- [Changelog](https://github.com/datafoodconsortium/connector-ruby/blob/main/CHANGELOG.md)
- [Commits](https://github.com/datafoodconsortium/connector-ruby/compare/v1.0.0-alpha.10...v1.0.0-alpha.11)

---
updated-dependencies:
- dependency-name: datafoodconsortium-connector
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-05 10:06:37 +11:00
filipefurtad0
0f3b502ca6 Re-records cassettes after Stripe bump 2024-04-04 14:40:49 +01:00
filipefurtad0
d6d16316dc Bumps Stripe to v10.14.0 2024-04-04 14:34:28 +01:00
cyrillefr
84747ea064 Fix Rails::NegateInclude issues
- cop class: RuboCop::Cop::Rails::NegateInclude
 -  replaced !array.include?(2) by array.exclude?(2)
2024-04-04 14:42:42 +02:00
dependabot[bot]
94d08c6b91 chore(deps): bump json from 2.7.1 to 2.7.2
Bumps [json](https://github.com/flori/json) from 2.7.1 to 2.7.2.
- [Release notes](https://github.com/flori/json/releases)
- [Changelog](https://github.com/flori/json/blob/master/CHANGES.md)
- [Commits](https://github.com/flori/json/compare/v2.7.1...v2.7.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-04 09:51:36 +00:00
Maikel
cf9414a352 Merge pull request #12329 from openfoodfoundation/dependabot/bundler/rubocop-rspec-2.28.0
chore(deps-dev): bump rubocop-rspec from 2.27.1 to 2.28.0
2024-04-04 13:43:02 +11:00
Ahmed Ejaz
0887f0676f 12294 - Fix Wrong Tax Category Display
- Only display the tax_category name if the tax_category_id is present
- tax_category is overriden in the variant model
- if tax category is not present, then return the default tax category
2024-04-04 06:06:23 +05:00
David Cook
6cff5c81fe Fix RSpecRails/NegationBeValid
Another cop that only supports not_to instead of to_not.
2024-04-04 09:41:05 +11:00
David Cook
4db5aa593f Regenerate rubocop todo 2024-04-04 09:36:41 +11:00
David Cook
0bae5d67c6 Merge pull request #12325 from openfoodfoundation/dependabot/bundler/letter_opener-1.10.0
chore(deps-dev): bump letter_opener from 1.9.0 to 1.10.0
2024-04-04 09:28:26 +11:00
David Cook
2007b2e1b0 Merge pull request #12322 from openfoodfoundation/dependabot/bundler/debug-1.9.2
chore(deps-dev): bump debug from 1.9.1 to 1.9.2
2024-04-04 09:26:04 +11:00
David Cook
0d0a9a467c Merge pull request #12321 from openfoodfoundation/dependabot/bundler/aws-sdk-s3-1.146.1
chore(deps): bump aws-sdk-s3 from 1.146.0 to 1.146.1
2024-04-04 09:25:35 +11:00
David Cook
a4cc4e28e7 Merge pull request #12319 from openfoodfoundation/dependabot/npm_and_yarn/trix-2.1.0
chore(deps): bump trix from 2.0.10 to 2.1.0
2024-04-04 09:25:04 +11:00
Gaetan Craig-Riou
12cf626202 Update all locales with the latest Transifex translations 2024-04-03 16:48:50 +11:00
David Cook
af2e3ca703 Merge pull request #12326 from filipefurtad0/deletes_connected_accounts_after_specs
Removes Stripe accounts created for testing purposes
2024-04-03 10:37:17 +11:00
Gaetan Craig-Riou
52bc88bbd8 Merge pull request #11369 from Matt-Yorkley/product-taxon
[Product Refactor] Primary Taxon
2024-04-03 10:31:49 +11:00
David Cook
cadc2bf5d3 Merge pull request #12320 from anansilva/6055-fix-rubocop-lint-duplicate-branch
Fix rubocop Lint/DuplicateBranch group
2024-04-03 10:02:14 +11:00
dependabot[bot]
69a10f0137 chore(deps-dev): bump rubocop-rspec from 2.27.1 to 2.28.0
Bumps [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) from 2.27.1 to 2.28.0.
- [Release notes](https://github.com/rubocop/rubocop-rspec/releases)
- [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.27.1...v2.28.0)

---
updated-dependencies:
- dependency-name: rubocop-rspec
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-02 09:38:50 +00:00
Ana Nunes da Silva
eedbaaff6e Fix duplicate branch in Spree::Preferences::Preferable private method
:string, :text and :password cases have the same value
2024-04-02 10:20:17 +01:00
Ana Nunes da Silva
5fde1cc7cd Fix duplicate branch in Spree::Preference#value method
:string, :text and :password cases have the same value
2024-04-02 10:20:17 +01:00
Ana Nunes da Silva
3e796da8ff Fix duplicate branch Spree::Calculator 2024-04-02 10:20:17 +01:00
Ana Nunes da Silva
8bee48df6d Fix duplicate branch in Enterprise#category method
non_producer_sells_any and non_producer_sells_own have the same category
2024-04-02 10:20:17 +01:00
Ana Nunes da Silva
eaf32226a4 Fix duplicate branches in Spree::Admin::BaseHelper
:string case already handled by the else case
2024-04-02 10:20:17 +01:00
Maikel
97c6c97499 Merge pull request #12318 from openfoodfoundation/dependabot/bundler/newrelic_rpm-9.8.0
chore(deps): bump newrelic_rpm from 9.7.1 to 9.8.0
2024-04-02 10:42:51 +11:00
Gaetan Craig-Riou
484c037c38 Fix duplication coming from a rebase error 2024-04-02 10:18:47 +11:00
Gaetan Craig-Riou
100239c4e6 Fix #bulk_product duplicate
Remove duplicate when a product has mutiple variant in the same category
(taxon)
2024-04-02 09:59:16 +11:00
Gaetan Craig-Riou
678fa37df9 Fix duplication issue
When a product had mutiple variant assigned to the same category it
should only return the product one
2024-04-02 09:57:36 +11:00
Gaetan Craig-Riou
8c05838080 Move the category to the variant row 2024-04-02 09:57:36 +11:00
Gaetan Craig-Riou
6d1249e7f9 Update DFC supplied product 2024-04-02 09:57:36 +11:00
Matt-Yorkley
d3e62c4390 Add test for persisting taxon on variant during product creation 2024-04-02 09:43:24 +11:00
Matt-Yorkley
ac4ec36b3b Update ProductScopeQuery spec 2024-04-02 09:43:24 +11:00
Matt-Yorkley
8a364a5f48 Fix product touch spec 2024-04-02 09:43:24 +11:00
Matt-Yorkley
d959ee2358 Fix rubocop warnings 2024-04-02 09:43:24 +11:00
Matt-Yorkley
a55931c081 Reinstate sorting by arbitrary list of product categories 2024-04-02 09:42:43 +11:00
Maikel
eac278ea1f Merge pull request #12262 from filipefurtad0/vcr_stripe_accounts_controller_spec
Vcr stripe accounts controller spec
2024-04-02 09:39:53 +11:00
Matt-Yorkley
2743a8183d Disable sorting by user-defined product category order 2024-04-02 09:33:34 +11:00
Matt-Yorkley
3f2a5786bd Apply taxon from sibling variant if none is provided on variant creation 2024-04-02 09:27:37 +11:00
Matt-Yorkley
02abe5cc06 Remove dead code related to multiple product taxons 2024-04-02 09:27:37 +11:00
Matt-Yorkley
fb09a7f1e6 Fix product filtering 2024-04-02 09:27:37 +11:00
Matt-Yorkley
78495d0ace Drop unnecessary params filtering 2024-04-02 09:27:37 +11:00
Matt-Yorkley
6025491f94 Update product serializer 2024-04-02 09:27:37 +11:00
Matt-Yorkley
c5ec7e361b Update product import 2024-04-02 09:27:36 +11:00
Matt-Yorkley
d4dd3cc708 Update products v3 table 2024-04-02 09:27:36 +11:00
Matt-Yorkley
c0864405a1 Update bulk products JS spec 2024-04-02 09:27:36 +11:00
Matt-Yorkley
6e7b97879b Update DFC product importer 2024-04-02 09:27:36 +11:00
Matt-Yorkley
d281e9d1b5 Adjust factory 2024-04-02 09:27:36 +11:00
Matt-Yorkley
d9899e8af6 Update more specs 2024-04-02 09:27:36 +11:00
Matt-Yorkley
b22c42613a Update taxon querying in reports 2024-04-02 09:27:36 +11:00
Matt-Yorkley
269d3ced0c Update enterprise caching spec 2024-04-02 09:27:36 +11:00
Matt-Yorkley
861f2aef01 Update product import spec 2024-04-02 09:27:36 +11:00
Matt-Yorkley
6b3e33f607 Update Taxon associations and joins 2024-04-02 09:27:36 +11:00
Matt-Yorkley
cd601319f3 Fix factory issues 2024-04-02 09:27:36 +11:00
Matt-Yorkley
3b715875ad Update taxon association 2024-04-02 09:27:36 +11:00
Matt-Yorkley
0dbbd5ed3b Migrate primary taxon id from products to variants 2024-04-02 09:27:36 +11:00
Matt-Yorkley
65731f6c52 Update serializers and views for admin products index 2024-04-02 09:27:36 +11:00
Matt-Yorkley
3a38eeb248 Remove products taxon null constraint 2024-04-02 09:27:36 +11:00
Matt-Yorkley
2707c3137a Apply taxon to new variant when creating a new product 2024-04-02 09:27:36 +11:00
Matt-Yorkley
b30944471d Update admin forms 2024-04-02 09:27:36 +11:00
Matt-Yorkley
c805486f0a Update attribute translations 2024-04-02 09:27:36 +11:00
Matt-Yorkley
2ef266390d Move primary taxon to variant 2024-04-02 09:27:36 +11:00
Ahmed Ejaz
7b4b7c5f45 12314 - Fix specs for orders helper 2024-04-01 21:51:46 +05:00
filipefurtad0
a3b646a500 Removes connected account
Re-records relevant VCR-cassettes for CreditCardCloner examples
2024-04-01 11:37:17 +01:00
filipefurtad0
01cbcf79fa Removes connected account
Re-records relevant VCR-cassettes for CreditCardRemover examples
2024-04-01 11:37:17 +01:00
filipefurtad0
c611754272 Removes connected account
Re-records relevant VCR-cassette on stripe_sca_spec
2024-04-01 11:36:51 +01:00
filipefurtad0
66b98bd477 Removes connected account
Re-records relevant VCR-cassette on payments_stripe_spec
2024-04-01 11:36:09 +01:00
dependabot[bot]
18d1e00c47 chore(deps-dev): bump letter_opener from 1.9.0 to 1.10.0
Bumps [letter_opener](https://github.com/ryanb/letter_opener) from 1.9.0 to 1.10.0.
- [Changelog](https://github.com/ryanb/letter_opener/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ryanb/letter_opener/compare/v1.9.0...v1.10.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-01 09:13:23 +00:00
Ahmed Ejaz
05f373f541 12314 - add order parameter in OrdersHelper methods 2024-04-01 06:41:41 +05:00
Ahmed Ejaz
4ba6afa665 12314 - fix Rails/HelperInstanceVariable error
- InjectionHelper
- OrdersHelper
2024-04-01 02:19:14 +05:00
Ahmed Ejaz
ac1595e718 12314 - remove shared distributor partial
- this was only used in the enterprise show view
- the above view was deleted here 4f2389e257
- by removing this, we can remove distributor_link_class method
- it will also fix the rubocop error
2024-03-31 18:08:22 +05:00
Ahmed Ejaz
3bb44cfe6d 12314 - fix order helper rubocop errors
- remove the direct access of @order instance variable
- add an attr_reader for order and use it instead
2024-03-31 17:07:00 +05:00
Ahmed Ejaz
19e3dc077e 12314: remove Rails/HelperInstanceVariable from rubocop todo 2024-03-31 17:04:15 +05:00
filipefurtad0
33889f1255 Deletes connected account, after spec
Re-records cassettes
2024-03-29 19:02:45 +00:00
dependabot[bot]
aab01e77e0 chore(deps-dev): bump debug from 1.9.1 to 1.9.2
Bumps [debug](https://github.com/ruby/debug) from 1.9.1 to 1.9.2.
- [Release notes](https://github.com/ruby/debug/releases)
- [Commits](https://github.com/ruby/debug/compare/v1.9.1...v1.9.2)

---
updated-dependencies:
- dependency-name: debug
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-29 09:51:55 +00:00
dependabot[bot]
1b49606fca chore(deps): bump aws-sdk-s3 from 1.146.0 to 1.146.1
Bumps [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby) from 1.146.0 to 1.146.1.
- [Release notes](https://github.com/aws/aws-sdk-ruby/releases)
- [Changelog](https://github.com/aws/aws-sdk-ruby/blob/version-3/gems/aws-sdk-s3/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-ruby/commits)

---
updated-dependencies:
- dependency-name: aws-sdk-s3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-29 09:50:56 +00:00
dependabot[bot]
45ec3d759f chore(deps): bump trix from 2.0.10 to 2.1.0
Bumps [trix](https://github.com/basecamp/trix) from 2.0.10 to 2.1.0.
- [Release notes](https://github.com/basecamp/trix/releases)
- [Commits](https://github.com/basecamp/trix/compare/v2.0.10...v2.1.0)

---
updated-dependencies:
- dependency-name: trix
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-28 09:46:07 +00:00
Maikel
d8641bf576 Merge pull request #12268 from dacook/buu/change-variant-unit-11061
[BUU] Change variant unit values
2024-03-28 16:19:33 +11:00
David Cook
4498e91e90 Update all locales with the latest Transifex translations 2024-03-28 16:18:36 +11:00
David Cook
116547d2d2 Merge pull request #12305 from Pauloparakleto/feat/12297-rvm-support-script-setup
Feat/12297 rvm support script setup
2024-03-28 09:14:51 +11:00
Pauloparakleto
80db511fe5 remove rvm script. It is called directly in script/setup 2024-03-27 10:11:21 -03:00
Pauloparakleto
3a2cb3e415 call rvm directly 2024-03-27 10:11:21 -03:00
David Cook
15c93a8e95 Add -v flag to avoid script exit 2024-03-27 10:11:21 -03:00
David Cook
4a4135f261 Simplify condition, in favour of rbenv
If rbenv is installed, we'll favour that because that's what is currently supported.
2024-03-27 10:11:21 -03:00
Pauloparakleto
0cd4682e36 chore(GETTING_STARTED.md): Add RVM alternative to installation guide. 2024-03-27 10:11:10 -03:00
Pauloparakleto
1d6323c520 chore(script/rvm-install): Add support to RVM. Use rvm command to install ruby version in variable.
RVM already print the logs. No need to printf message here.
RVM already skip installation if already done with logs.
2024-03-27 10:10:21 -03:00
Pauloparakleto
8b591b7d21 chore(script/setup): Add support to RVM. Only evaluate to rbenv if rvm path is not found. 2024-03-27 10:08:50 -03:00
filipefurtad0
0b844bca8d Sets VCR tag at the beginning of the spec file
Rebases and re-records cassettes
2024-03-27 11:37:03 +00:00
filipefurtad0
1fd4c83cf1 Replaces fake with real client_it
Replaces stubs on Stripe Account Controller
2024-03-27 11:28:30 +00:00
David Cook
266e94eba8 Fixup spec 2024-03-27 20:20:20 +11:00
David Cook
b9b2c876cc Ensure value always shows
Even thought it's not valid (you can't save items with an empty name), it's disconcerting when the value suddenly disappears from view.
2024-03-27 20:20:20 +11:00
David Cook
99121943a7 Fix bug
I missed a bit in a refactor, and it wasn't covered by the spec.
2024-03-27 20:20:20 +11:00
David Cook
b2881bb169 Add JS specs
Converted using  https://www.codeconvert.ai/coffeescript-to-javascript-converter
With plenty of manual fixes required too..
2024-03-27 20:20:20 +11:00
David Cook
11b8a01220 Move Jest config to a file
With the help of 'jest --init'

I didn't end up using this, but it seems worth keeping config out of package.json
2024-03-27 20:20:20 +11:00
David Cook
924701e161 Load available units from system config
I'm not sure what's the best way to load data into javascript.. this works.
2024-03-27 20:20:20 +11:00
David Cook
1d8ed67b0b Handle unit scale changes
As discussed, this is the desired behaviour. The current screen appears to do this, but fails to save the changes.
2024-03-27 20:20:20 +11:00
David Cook
d238fc0cad TODO: optimise and fix bug 2024-03-27 20:20:20 +11:00
David Cook
4ddb2ff1e9 Generate unit display with OptionValueNamer 2024-03-27 20:20:20 +11:00
David Cook
cf31d09ad8 Prevent submitting empty value 2024-03-27 20:20:20 +11:00
David Cook
49226ffdbc Extract unit_value and unit_description values
Copied from display_as.js.coffee (ofn.admin.ofnDisplayAs.variantUnitProperties).
2024-03-27 20:20:20 +11:00
David Cook
c98956bf5a Add variant controller
This will manage the various unit fields. Maybe it should have a more specific name.
2024-03-27 20:20:16 +11:00
dependabot[bot]
28dab2fc2e chore(deps): bump newrelic_rpm from 9.7.1 to 9.8.0
Bumps [newrelic_rpm](https://github.com/newrelic/newrelic-ruby-agent) from 9.7.1 to 9.8.0.
- [Release notes](https://github.com/newrelic/newrelic-ruby-agent/releases)
- [Changelog](https://github.com/newrelic/newrelic-ruby-agent/blob/dev/CHANGELOG.md)
- [Commits](https://github.com/newrelic/newrelic-ruby-agent/compare/9.7.1...9.8.0)

---
updated-dependencies:
- dependency-name: newrelic_rpm
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-27 09:10:14 +00:00
David Cook
9beaf0a0c2 Use textContent FTW
Oh look, the test works better now too.
2024-03-27 17:35:09 +11:00
David Cook
6291cce5d1 Fix style for empty popout button
There's still an odd 1px height change on hover that I can't track down. I think it would be better to just give new variants a default of 1 (blank is not valid anyway).
2024-03-27 17:35:09 +11:00
David Cook
e589605e3c Rename popout style classes 2024-03-27 17:35:08 +11:00
David Cook
e110cd1145 Fix popout to focus first _visible_ field 2024-03-27 14:34:31 +11:00
David Cook
26723194d5 Prevent popout from updating display value
Watch out, HAML will strip an attribute with boolean false, so we need to use a string. Or reconsider using false as a default value..

I wish Jest had the rspec concept of `let`.
2024-03-27 14:34:31 +11:00
David Cook
e94fddb0f8 Style label in popout
And tweaked global style as per design.
And cleanup unused classes.
2024-03-27 14:34:31 +11:00
David Cook
4f7d50ca4b Refactor CSS to reduce scope
We don't want the fields inside the popout to be naked, so need to be more specific.
2024-03-27 14:34:31 +11:00
David Cook
f13f2cfa2f Move values to variables
I didn't end up using these, but it's probably worth keeping for consistency.
2024-03-27 14:34:31 +11:00
David Cook
4a776233db Move fields into a popout 2024-03-27 14:34:31 +11:00
David Cook
436f733213 Add variant unit fields
Unfortunately we can't use an input[type=number] because you're allowed to type text for unit_description.

These fields will be conditionally shown/hidden in upcoming steps.
2024-03-27 14:34:31 +11:00
David Cook
a5741a1ca8 Sync hidden variant unit fields
This will be necessary for managing the 'display as' state.
..or is it?
2024-03-27 14:34:19 +11:00
David Cook
45b4e6c87c Add comments
To save me or someone else having to figure it out again.
2024-03-27 14:33:32 +11:00
David Cook
189cd88848 Remove duplicate spec
Must have been an accident while merging conflicts
2024-03-27 14:33:32 +11:00
David Cook
9b040d87f6 Update spec 2024-03-27 14:33:32 +11:00
Gaetan Craig-Riou
924bb2a003 Merge pull request #12315 from openfoodfoundation/dependabot/bundler/bugsnag-6.26.4
chore(deps): bump bugsnag from 6.26.3 to 6.26.4
2024-03-27 10:07:26 +11:00
Gaetan Craig-Riou
9c06032077 Merge pull request #12312 from openfoodfoundation/dependabot/npm_and_yarn/express-4.19.2
chore(deps): bump express from 4.18.2 to 4.19.2
2024-03-27 09:29:10 +11:00
dependabot[bot]
df50485b62 chore(deps): bump bugsnag from 6.26.3 to 6.26.4
Bumps [bugsnag](https://github.com/bugsnag/bugsnag-ruby) from 6.26.3 to 6.26.4.
- [Release notes](https://github.com/bugsnag/bugsnag-ruby/releases)
- [Changelog](https://github.com/bugsnag/bugsnag-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bugsnag/bugsnag-ruby/compare/v6.26.3...v6.26.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-26 10:01:03 +00:00
dependabot[bot]
9be929e572 chore(deps): bump express from 4.18.2 to 4.19.2
Bumps [express](https://github.com/expressjs/express) from 4.18.2 to 4.19.2.
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/master/History.md)
- [Commits](https://github.com/expressjs/express/compare/4.18.2...4.19.2)

---
updated-dependencies:
- dependency-name: express
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-25 22:32:04 +00:00
Arun
0ab3c3d875 Merge branch 'master' into 12295-translation-fixes-on-return-authorizaton 2024-03-22 18:16:57 +05:30
Arun Guleria
03630f27af 12295-Translation fixes for return authorization status 2024-03-22 17:16:35 +05:30
Maikel Linke
54738fc552 Remove unnecessary method checkout_steps
It allowed introspection of a dynamic state machine. But the only two
usages of this method only referred to the first state which is always
the same. Our complicated checkout logic needs more clarity and
introducing some hardcoded state names here can only help.
2024-03-21 13:43:54 +11:00
Mohamed ABDELLANI
ee1f60808e prevent generating invoices when order's distributor can't generate invoices 2024-02-29 18:56:52 +01:00
933 changed files with 42155 additions and 8276 deletions

View File

@@ -45,7 +45,7 @@ The full process is described at https://github.com/openfoodfoundation/openfoodn
[Ready To Go]: https://github.com/orgs/openfoodfoundation/projects/8?filterQuery=status%3A%22Ready+to+go+%F0%9F%9A%80%22
[Transifex pull request]: https://github.com/openfoodfoundation/openfoodnetwork/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aopen+head%3Atransifex
[Draft new release]: https://github.com/openfoodfoundation/openfoodnetwork/releases/new?tag=v&title=v+Code+Name&body=Congrats%0A%0ADescription%0A%0A
[Draft new release]: https://github.com/openfoodfoundation/openfoodnetwork/releases/new?title=v+Code+Name&body=Congrats%0A%0ADescription%0A%0A
[releases]: https://github.com/openfoodfoundation/openfoodnetwork/releases
[#instance-managers]: https://app.slack.com/client/T02G54U79/CG7NJ966B
[#testing]: https://openfoodnetwork.slack.com/app_redirect?channel=C02TZ6X00

View File

@@ -1,3 +1,8 @@
# Dependabot configuration
#
# The `directory` and `schedule.interval` options are mandatory.
# Most of the configuration here is not used for security updates though.
version: 2
updates:
@@ -5,7 +10,7 @@ updates:
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 10
# Only specific requirements are specified in Gemfile, so don't touch it.
versioning-strategy: lockfile-only
@@ -13,5 +18,6 @@ updates:
directory: "/"
schedule:
interval: "daily"
# All versions are specified in package.json, so please update them.
versioning-strategy: increase

View File

@@ -55,6 +55,7 @@ jobs:
with:
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
# JS is required in order for webpacker to compile, in order to render templates containing image urls
- uses: actions/setup-node@v3
with:
node-version-file: .node-version
@@ -64,8 +65,7 @@ jobs:
- name: Set up database
run: |
bundle exec rake db:create
bundle exec rake db:schema:load
bundle exec rake db:create db:schema:load
- name: Run tests
env:
@@ -123,20 +123,11 @@ jobs:
with:
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- uses: actions/setup-node@v3
with:
node-version-file: .node-version
- name: Install JS dependencies
run: yarn install --frozen-lockfile
- name: Set up database
run: |
bundle exec rake db:create
bundle exec rake db:schema:load
bundle exec rake db:create db:schema:load
- name: Run tests
env:
KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: 09476e2ce491c12083df62768667c674
KNAPSACK_PRO_CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
@@ -150,7 +141,6 @@ jobs:
# https://knapsackpro.com/faq/question/how-to-split-slow-rspec-test-files-by-test-examples-by-individual-it
#KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES: true
KNAPSACK_PRO_TEST_FILE_PATTERN: "{spec/models/**/*_spec.rb}"
run: |
bundle exec rake knapsack_pro:rspec
@@ -201,8 +191,7 @@ jobs:
- name: Set up database
run: |
bundle exec rake db:create
bundle exec rake db:schema:load
bundle exec rake db:create db:schema:load
- name: Run tests
@@ -279,8 +268,7 @@ jobs:
- name: Set up database
run: |
bundle exec rake db:create
bundle exec rake db:schema:load
bundle exec rake db:create db:schema:load
- name: Run tests
@@ -348,6 +336,7 @@ jobs:
with:
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
# JS is required in order for webpacker to compile, in order to render templates linking to mail.css
- uses: actions/setup-node@v3
with:
node-version-file: .node-version
@@ -357,8 +346,7 @@ jobs:
- name: Set up database
run: |
bundle exec rake db:create
bundle exec rake db:schema:load
bundle exec rake db:create db:schema:load
- name: Run tests
@@ -426,6 +414,7 @@ jobs:
with:
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
# JS is required in order for webpacker to compile, in order to render templates linking to mail.css
- uses: actions/setup-node@v3
with:
node-version-file: .node-version
@@ -435,11 +424,9 @@ jobs:
- name: Set up database
run: |
bundle exec rake db:create
bundle exec rake db:schema:load
bundle exec rake db:create db:schema:load
- name: Run tests
env:
KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: e3b8800198d2d89b70c7edbdd85f8fd8
KNAPSACK_PRO_CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
@@ -453,8 +440,6 @@ jobs:
# https://knapsackpro.com/faq/question/how-to-split-slow-rspec-test-files-by-test-examples-by-individual-it
#KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES: true
KNAPSACK_PRO_TEST_FILE_EXCLUDE_PATTERN: "{engines/**/*_spec.rb,spec/models/**/*_spec.rb,spec/controllers/**/*_spec.rb,spec/serializers/**/*_spec.rb,spec/lib/**/*_spec.rb,spec/migrations/**/*_spec.rb,spec/system/**/*_spec.rb}"
run: |
bundle exec rake knapsack_pro:rspec
@@ -476,11 +461,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Setup redis
uses: supercharge/redis-github-action@1.4.0
with:
redis-version: 6
# Rails is required for the Karma rake script
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
@@ -493,10 +474,6 @@ jobs:
- name: Install JS dependencies
run: yarn install --frozen-lockfile
- name: Set up database
run: |
bundle exec rake db:create
bundle exec rake db:schema:load
- name: Run JS tests
run: bundle exec rake karma:run

View File

@@ -7,10 +7,11 @@ jobs:
name: runner / rubocop
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v1
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- run: git show --no-patch # the commit being tested (which is often a merge due to actions/checkout@v3)
@@ -21,6 +22,8 @@ jobs:
rubocop_extensions: rubocop-rails:gemfile rubocop-rspec:gemfile
reporter: github-pr-check
level: error
filter_mode: nofilter
use_bundler: true
fail_on_error: true
prettier:
name: runner / prettier

1
.rspec Normal file
View File

@@ -0,0 +1 @@
--require base_spec_helper

View File

@@ -5,8 +5,12 @@
# The configuration is split into three files. Look into those files for more details.
#
require:
- rubocop-capybara
- rubocop-factory_bot
- rubocop-rails
- rubocop-rspec
- rubocop-rspec_rails
inherit_from:
# The automatically generated todo list to ignore all current violations.

View File

@@ -3,7 +3,6 @@
# These are the rules we agreed upon and we work towards.
AllCops:
NewCops: enable
SuggestExtensions: false
Exclude:
- bin/**/*
- db/**/*
@@ -125,6 +124,9 @@ Rails/SkipsModelValidations:
- update_column
- update_columns
Rails/WhereExists:
EnforcedStyle: where # Cf. conversion https://github.com/openfoodfoundation/openfoodnetwork/pull/12363
Style/Documentation:
Enabled: false

View File

@@ -6,44 +6,11 @@
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 16
# Configuration parameters: AllowedMethods.
# AllowedMethods: enums
Lint/ConstantDefinitionInBlock:
Exclude:
- 'lib/tasks/import_product_images.rake'
- 'lib/tasks/users.rake'
- 'spec/controllers/spree/admin/base_controller_spec.rb'
- 'spec/helpers/serializer_helper_spec.rb'
- 'spec/lib/reports/line_items_spec.rb'
- 'spec/models/spree/ability_spec.rb'
- 'spec/models/spree/gateway_spec.rb'
- 'spec/models/spree/preferences/configuration_spec.rb'
- 'spec/models/spree/preferences/preferable_spec.rb'
- 'spec/validators/date_time_string_validator_spec.rb'
- 'spec/validators/integer_array_validator_spec.rb'
# Offense count: 6
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches.
Lint/DuplicateBranch:
Exclude:
- 'app/helpers/spree/admin/base_helper.rb'
- 'app/models/enterprise.rb'
- 'app/models/spree/calculator.rb'
- 'app/models/spree/preference.rb'
- 'app/models/spree/preferences/preferable.rb'
# Offense count: 2
Lint/DuplicateMethods:
Exclude:
- 'lib/discourse/single_sign_on.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Lint/DuplicateRequire:
Exclude:
- 'spec/lib/open_food_network/scope_variants_to_search_spec.rb'
# Offense count: 16
# Configuration parameters: AllowComments, AllowEmptyLambdas.
Lint/EmptyBlock:
@@ -197,6 +164,7 @@ Metrics/ClassLength:
- 'app/models/spree/user.rb'
- 'app/models/spree/variant.rb'
- 'app/models/spree/zone.rb'
- 'app/reflexes/admin/orders_reflex.rb'
- 'app/reflexes/products_reflex.rb'
- 'app/serializers/api/cached_enterprise_serializer.rb'
- 'app/serializers/api/enterprise_shopfront_serializer.rb'
@@ -390,41 +358,213 @@ Naming/VariableNumber:
- 'spec/models/spree/tax_rate_spec.rb'
- 'spec/requests/api/orders_spec.rb'
# Offense count: 11
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/HasManyOrHasOneDependent:
# Offense count: 142
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: ResponseMethods.
# ResponseMethods: response, last_response
RSpecRails/HaveHttpStatus:
Exclude:
- 'app/models/enterprise.rb'
- 'app/models/spree/address.rb'
- 'app/models/spree/stock_item.rb'
- 'app/models/spree/tax_rate.rb'
- 'app/models/spree/variant.rb'
# Offense count: 26
# Configuration parameters: Include.
# Include: app/helpers/**/*.rb
Rails/HelperInstanceVariable:
Exclude:
- 'app/helpers/injection_helper.rb'
- 'app/helpers/shared_helper.rb'
- 'app/helpers/spree/admin/orders_helper.rb'
- 'app/helpers/spree/orders_helper.rb'
- 'spec/controllers/admin/bulk_line_items_controller_spec.rb'
- 'spec/controllers/admin/order_cycles_controller_spec.rb'
- 'spec/controllers/admin/subscriptions_controller_spec.rb'
- 'spec/controllers/api/v0/base_controller_spec.rb'
- 'spec/controllers/api/v0/customers_controller_spec.rb'
- 'spec/controllers/api/v0/enterprises_controller_spec.rb'
- 'spec/controllers/api/v0/logos_controller_spec.rb'
- 'spec/controllers/api/v0/order_cycles_controller_spec.rb'
- 'spec/controllers/api/v0/orders_controller_spec.rb'
- 'spec/controllers/api/v0/product_images_controller_spec.rb'
- 'spec/controllers/api/v0/products_controller_spec.rb'
- 'spec/controllers/api/v0/promo_images_controller_spec.rb'
- 'spec/controllers/api/v0/reports/packing_report_spec.rb'
- 'spec/controllers/api/v0/reports_controller_spec.rb'
- 'spec/controllers/api/v0/shipments_controller_spec.rb'
- 'spec/controllers/api/v0/statuses_controller_spec.rb'
- 'spec/controllers/api/v0/taxons_controller_spec.rb'
- 'spec/controllers/api/v0/terms_and_conditions_controller_spec.rb'
- 'spec/controllers/api/v0/variants_controller_spec.rb'
- 'spec/controllers/cart_controller_spec.rb'
- 'spec/controllers/checkout_controller_spec.rb'
- 'spec/controllers/enterprises_controller_spec.rb'
- 'spec/controllers/line_items_controller_spec.rb'
- 'spec/controllers/shop_controller_spec.rb'
- 'spec/controllers/spree/admin/orders/payments/payments_controller_spec.rb'
- 'spec/controllers/spree/admin/orders_controller_spec.rb'
- 'spec/controllers/spree/admin/products_controller_spec.rb'
- 'spec/controllers/spree/credit_cards_controller_spec.rb'
- 'spec/controllers/spree/orders_controller_spec.rb'
- 'spec/controllers/stripe/callbacks_controller_spec.rb'
- 'spec/controllers/stripe/webhooks_controller_spec.rb'
- 'spec/controllers/user_passwords_controller_spec.rb'
- 'spec/controllers/user_registrations_controller_spec.rb'
- 'spec/requests/admin/images_spec.rb'
- 'spec/requests/api/routes_spec.rb'
- 'spec/requests/checkout/failed_checkout_spec.rb'
- 'spec/requests/checkout/stripe_sca_spec.rb'
- 'spec/requests/home_controller_spec.rb'
- 'spec/requests/omniauth_callbacks_controller_spec.rb'
- 'spec/services/embedded_page_service_spec.rb'
- 'spec/support/api_helper.rb'
# Offense count: 8
# Configuration parameters: Include.
# Include: spec/**/*.rb, test/**/*.rb
Rails/I18nLocaleAssignment:
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: numeric, symbolic, be_status
RSpecRails/HttpStatus:
Exclude:
- 'spec/controllers/user_registrations_controller_spec.rb'
- 'spec/helpers/i18n_helper_spec.rb'
- 'spec/models/spree/variant_spec.rb'
- 'spec/system/admin/order_cycles/list_spec.rb'
- 'spec/controllers/spree/admin/products_controller_spec.rb'
- 'spec/requests/api/orders_spec.rb'
# Offense count: 3
Rails/I18nLocaleTexts:
# Offense count: 146
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Inferences.
RSpecRails/InferredSpecType:
Exclude:
- 'app/controllers/admin/stripe_accounts_controller.rb'
- 'engines/dfc_provider/spec/requests/addresses_spec.rb'
- 'engines/dfc_provider/spec/requests/catalog_items_spec.rb'
- 'engines/dfc_provider/spec/requests/enterprise_groups/affiliated_by_spec.rb'
- 'engines/dfc_provider/spec/requests/enterprise_groups_spec.rb'
- 'engines/dfc_provider/spec/requests/enterprises_spec.rb'
- 'engines/dfc_provider/spec/requests/offers_spec.rb'
- 'engines/dfc_provider/spec/requests/persons_spec.rb'
- 'engines/dfc_provider/spec/requests/social_medias_spec.rb'
- 'engines/dfc_provider/spec/requests/supplied_products_spec.rb'
- 'engines/web/spec/helpers/cookies_policy_helper_spec.rb'
- 'spec/controllers/admin/bulk_line_items_controller_spec.rb'
- 'spec/controllers/admin/column_preferences_controller_spec.rb'
- 'spec/controllers/admin/customers_controller_spec.rb'
- 'spec/controllers/admin/enterprises_controller_spec.rb'
- 'spec/controllers/admin/inventory_items_controller_spec.rb'
- 'spec/controllers/admin/invoice_settings_controller_spec.rb'
- 'spec/controllers/admin/matomo_settings_controller_spec.rb'
- 'spec/controllers/admin/order_cycles_controller_spec.rb'
- 'spec/controllers/admin/product_import_controller_spec.rb'
- 'spec/controllers/admin/proxy_orders_controller_spec.rb'
- 'spec/controllers/admin/reports_controller_spec.rb'
- 'spec/controllers/admin/schedules_controller_spec.rb'
- 'spec/controllers/admin/stripe_accounts_controller_spec.rb'
- 'spec/controllers/admin/stripe_connect_settings_controller_spec.rb'
- 'spec/controllers/admin/subscription_line_items_controller_spec.rb'
- 'spec/controllers/admin/subscriptions_controller_spec.rb'
- 'spec/controllers/admin/tag_rules_controller_spec.rb'
- 'spec/controllers/admin/terms_of_service_files_controller_spec.rb'
- 'spec/controllers/admin/variant_overrides_controller_spec.rb'
- 'spec/controllers/api/v0/customers_controller_spec.rb'
- 'spec/controllers/api/v0/enterprise_fees_controller_spec.rb'
- 'spec/controllers/api/v0/enterprises_controller_spec.rb'
- 'spec/controllers/api/v0/exchange_products_controller_spec.rb'
- 'spec/controllers/api/v0/logos_controller_spec.rb'
- 'spec/controllers/api/v0/order_cycles_controller_spec.rb'
- 'spec/controllers/api/v0/orders_controller_spec.rb'
- 'spec/controllers/api/v0/product_images_controller_spec.rb'
- 'spec/controllers/api/v0/products_controller_spec.rb'
- 'spec/controllers/api/v0/promo_images_controller_spec.rb'
- 'spec/controllers/api/v0/reports/packing_report_spec.rb'
- 'spec/controllers/api/v0/reports_controller_spec.rb'
- 'spec/controllers/api/v0/shipments_controller_spec.rb'
- 'spec/controllers/api/v0/shops_controller_spec.rb'
- 'spec/controllers/api/v0/statuses_controller_spec.rb'
- 'spec/controllers/api/v0/terms_and_conditions_controller_spec.rb'
- 'spec/controllers/api/v0/variants_controller_spec.rb'
- 'spec/controllers/base_controller_spec.rb'
- 'spec/controllers/cart_controller_spec.rb'
- 'spec/controllers/checkout_controller_spec.rb'
- 'spec/controllers/enterprises_controller_spec.rb'
- 'spec/controllers/groups_controller_spec.rb'
- 'spec/controllers/line_items_controller_spec.rb'
- 'spec/controllers/payment_gateways/paypal_controller_spec.rb'
- 'spec/controllers/payment_gateways/stripe_controller_spec.rb'
- 'spec/controllers/registration_controller_spec.rb'
- 'spec/controllers/shop_controller_spec.rb'
- 'spec/controllers/shops_controller_spec.rb'
- 'spec/controllers/spree/admin/adjustments_controller_spec.rb'
- 'spec/controllers/spree/admin/base_controller_spec.rb'
- 'spec/controllers/spree/admin/countries_controller_spec.rb'
- 'spec/controllers/spree/admin/general_settings_controller_spec.rb'
- 'spec/controllers/spree/admin/orders/customer_details_controller_spec.rb'
- 'spec/controllers/spree/admin/orders/invoices_spec.rb'
- 'spec/controllers/spree/admin/orders/payments/payments_controller_refunds_spec.rb'
- 'spec/controllers/spree/admin/orders/payments/payments_controller_spec.rb'
- 'spec/controllers/spree/admin/orders_controller_spec.rb'
- 'spec/controllers/spree/admin/overview_controller_spec.rb'
- 'spec/controllers/spree/admin/payment_methods_controller_spec.rb'
- 'spec/controllers/spree/admin/products_controller_spec.rb'
- 'spec/controllers/spree/admin/return_authorizations_controller_spec.rb'
- 'spec/controllers/spree/admin/search_controller_spec.rb'
- 'spec/controllers/spree/admin/shipping_categories_controller_spec.rb'
- 'spec/controllers/spree/admin/shipping_methods_controller_spec.rb'
- 'spec/controllers/spree/admin/tax_rates_controller_spec.rb'
- 'spec/controllers/spree/admin/tax_settings_controller_spec.rb'
- 'spec/controllers/spree/admin/variants_controller_spec.rb'
- 'spec/controllers/spree/api_keys_controller_spec.rb'
- 'spec/controllers/spree/credit_cards_controller_spec.rb'
- 'spec/controllers/spree/orders_controller_spec.rb'
- 'spec/controllers/spree/user_sessions_controller_spec.rb'
- 'spec/controllers/spree/users_controller_spec.rb'
- 'spec/controllers/stripe/callbacks_controller_spec.rb'
- 'spec/controllers/stripe/webhooks_controller_spec.rb'
- 'spec/controllers/user_confirmations_controller_spec.rb'
- 'spec/controllers/user_passwords_controller_spec.rb'
- 'spec/controllers/user_registrations_controller_spec.rb'
- 'spec/controllers/webhook_endpoints_controller_spec.rb'
- 'spec/helpers/admin/enterprises_helper_spec.rb'
- 'spec/helpers/admin/orders_helper_spec.rb'
- 'spec/helpers/admin/reports_helper_spec.rb'
- 'spec/helpers/admin/subscriptions_helper_spec.rb'
- 'spec/helpers/application_helper_spec.rb'
- 'spec/helpers/checkout_helper_spec.rb'
- 'spec/helpers/i18n_helper_spec.rb'
- 'spec/helpers/injection_helper_spec.rb'
- 'spec/helpers/link_helper_spec.rb'
- 'spec/helpers/navigation_helper_spec.rb'
- 'spec/helpers/order_cycles_helper_spec.rb'
- 'spec/helpers/serializer_helper_spec.rb'
- 'spec/helpers/shared_helper_spec.rb'
- 'spec/helpers/shop_helper_spec.rb'
- 'spec/helpers/spree/admin/base_helper_spec.rb'
- 'spec/helpers/spree/admin/general_settings_helper_spec.rb'
- 'spec/helpers/spree/admin/orders_helper_spec.rb'
- 'spec/helpers/spree/orders_helper_spec.rb'
- 'spec/helpers/tax_helper_spec.rb'
- 'spec/helpers/terms_and_conditions_helper_spec.rb'
- 'spec/jobs/connect_app_job_spec.rb'
- 'spec/mailers/producer_mailer_spec.rb'
- 'spec/mailers/subscription_mailer_spec.rb'
- 'spec/models/column_preference_spec.rb'
- 'spec/models/connected_app_spec.rb'
- 'spec/models/customer_spec.rb'
- 'spec/models/invoice_spec.rb'
- 'spec/models/oidc_account_spec.rb'
- 'spec/models/proxy_order_spec.rb'
- 'spec/models/report_blob_spec.rb'
- 'spec/models/semantic_link_spec.rb'
- 'spec/models/spree/gateway/stripe_sca_spec.rb'
- 'spec/models/subscription_spec.rb'
- 'spec/models/tag_rule/filter_order_cycles_spec.rb'
- 'spec/models/tag_rule/filter_payment_methods_spec.rb'
- 'spec/models/tag_rule/filter_products_spec.rb'
- 'spec/models/tag_rule/filter_shipping_methods_spec.rb'
- 'spec/models/tag_rule_spec.rb'
- 'spec/models/webhook_endpoint_spec.rb'
- 'spec/requests/admin/images_spec.rb'
- 'spec/requests/admin/product_import_spec.rb'
- 'spec/requests/admin/vouchers_spec.rb'
- 'spec/requests/api/orders_spec.rb'
- 'spec/requests/api/routes_spec.rb'
- 'spec/requests/api/v1/customers_spec.rb'
- 'spec/requests/api_docs_spec.rb'
- 'spec/requests/checkout/failed_checkout_spec.rb'
- 'spec/requests/checkout/paypal_spec.rb'
- 'spec/requests/checkout/routes_spec.rb'
- 'spec/requests/checkout/stripe_sca_spec.rb'
- 'spec/requests/errors_spec.rb'
- 'spec/requests/home_controller_spec.rb'
- 'spec/requests/large_request_spec.rb'
- 'spec/requests/omniauth_callbacks_controller_spec.rb'
- 'spec/requests/spree/admin/overview_spec.rb'
- 'spec/requests/spree/admin/payments_spec.rb'
- 'spec/requests/voucher_adjustments_spec.rb'
- 'spec/routing/stripe_spec.rb'
# Offense count: 22
# Configuration parameters: IgnoreScopes, Include.
@@ -470,16 +610,6 @@ Rails/LexicallyScopedActionFilter:
- 'app/controllers/spree/admin/zones_controller.rb'
- 'app/controllers/spree/users_controller.rb'
# Offense count: 5
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/NegateInclude:
Exclude:
- 'app/controllers/admin/resource_controller.rb'
- 'app/models/calculator/weight.rb'
- 'app/models/product_import/spreadsheet_entry.rb'
- 'lib/spree/localized_number.rb'
- 'spec/support/matchers/table_matchers.rb'
# Offense count: 32
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/Pluck:
@@ -520,22 +650,12 @@ Rails/RedundantActiveRecordAllMethod:
- 'app/models/spree/variant.rb'
- 'spec/system/admin/product_import_spec.rb'
# Offense count: 20
# Offense count: 9
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/RedundantPresenceValidationOnBelongsTo:
Exclude:
- 'app/models/enterprise_fee.rb'
- 'app/models/exchange.rb'
- 'app/models/inventory_item.rb'
- 'app/models/order_cycle.rb'
- 'app/models/spree/address.rb'
- 'app/models/spree/line_item.rb'
- 'app/models/spree/order.rb'
- 'app/models/spree/product_property.rb'
- 'app/models/spree/return_authorization.rb'
- 'app/models/spree/state.rb'
- 'app/models/spree/stock_item.rb'
- 'app/models/spree/stock_movement.rb'
- 'app/models/spree/tax_rate.rb'
- 'app/models/subscription_line_item.rb'
- 'app/models/tag_rule.rb'
@@ -547,7 +667,7 @@ Rails/RelativeDateConstant:
Exclude:
- 'lib/tasks/data/remove_transient_data.rb'
# Offense count: 58
# Offense count: 56
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Include.
# Include: spec/controllers/**/*.rb, spec/requests/**/*.rb, test/controllers/**/*.rb, test/integration/**/*.rb
@@ -633,53 +753,6 @@ Rails/UnusedRenderContent:
- 'app/controllers/api/v0/taxons_controller.rb'
- 'app/controllers/api/v0/variants_controller.rb'
# Offense count: 54
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/WhereEquals:
Exclude:
- 'app/controllers/spree/admin/products_controller.rb'
- 'app/mailers/producer_mailer.rb'
- 'app/models/enterprise.rb'
- 'app/models/enterprise_fee.rb'
- 'app/models/enterprise_group.rb'
- 'app/models/enterprise_relationship.rb'
- 'app/models/exchange.rb'
- 'app/models/order_cycle.rb'
- 'app/models/product_import/entry_processor.rb'
- 'app/models/proxy_order.rb'
- 'app/models/schedule.rb'
- 'app/models/spree/line_item.rb'
- 'app/models/spree/order.rb'
- 'app/models/spree/payment_method.rb'
- 'app/models/spree/product.rb'
- 'app/models/spree/shipping_method.rb'
- 'app/models/spree/variant.rb'
- 'app/models/subscription.rb'
- 'app/serializers/api/enterprise_shopfront_serializer.rb'
- 'app/serializers/api/order_serializer.rb'
- 'lib/open_food_network/enterprise_fee_calculator.rb'
- 'lib/open_food_network/order_cycle_permissions.rb'
- 'lib/reporting/reports/products_and_inventory/base.rb'
- 'lib/tasks/data.rake'
- 'lib/tasks/data/anonymize_data.rake'
- 'lib/tasks/data/remove_transient_data.rb'
- 'spec/services/product_tag_rules_filterer_spec.rb'
# Offense count: 8
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: exists, where
Rails/WhereExists:
Exclude:
- 'app/controllers/spree/admin/overview_controller.rb'
- 'app/controllers/spree/admin/tax_rates_controller.rb'
- 'app/controllers/spree/user_sessions_controller.rb'
- 'app/models/spree/preferences/store.rb'
- 'lib/tasks/sample_data/customer_factory.rb'
- 'lib/tasks/sample_data/group_factory.rb'
- 'lib/tasks/sample_data/order_cycle_factory.rb'
- 'lib/tasks/sample_data/taxon_factory.rb'
# Offense count: 1
Security/Open:
Exclude:

View File

@@ -29,7 +29,7 @@ Fetch the latest version of `master` from `upstream` (ie. the main repo):
This project needs specific ruby/bundler versions as well as node/yarn specific versions. For a local setup you will need:
* Install or change your Ruby version according to the one specified at [.ruby-version](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/.ruby-version) file.
- To manage versions, it's recommended to use [rbenv](https://github.com/rbenv/rbenv).
- To manage versions, it's recommended to use [rbenv](https://github.com/rbenv/rbenv) or [RVM](https://rvm.io/).
* Install [nodenv](https://github.com/nodenv/nodenv) to ensure the correct [.node-version](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/.node-version) is used.
- [nodevn](https://github.com/nodenv/nodenv) is recommended as a node version manager.
* PostgreSQL database

View File

@@ -156,30 +156,30 @@ GEM
awesome_nested_set (3.6.0)
activerecord (>= 4.0.0, < 7.2)
aws-eventstream (1.3.0)
aws-partitions (1.899.0)
aws-sdk-core (3.191.4)
aws-partitions (1.914.0)
aws-sdk-core (3.192.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.78.0)
aws-sdk-kms (1.79.0)
aws-sdk-core (~> 3, >= 3.191.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.146.0)
aws-sdk-core (~> 3, >= 3.191.0)
aws-sdk-s3 (1.147.0)
aws-sdk-core (~> 3, >= 3.192.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.8)
aws-sigv4 (1.8.0)
aws-eventstream (~> 1, >= 1.0.2)
base64 (0.2.0)
bcp47_spec (0.2.1)
bcrypt (3.1.19)
bcrypt (3.1.20)
bigdecimal (3.0.2)
bindata (2.5.0)
bindex (0.8.1)
bootsnap (1.18.3)
msgpack (~> 1.2)
bugsnag (6.26.3)
bugsnag (6.26.4)
concurrent-ruby (~> 1.0)
builder (3.2.4)
bullet (7.1.6)
@@ -207,6 +207,7 @@ GEM
nokogiri (~> 1.10, >= 1.10.4)
rubyzip (>= 1.3.0, < 3)
cgi (0.3.6)
childprocess (5.0.0)
choice (0.2.0)
chronic (0.10.2)
coderay (1.1.3)
@@ -226,8 +227,9 @@ GEM
bigdecimal
rexml
crass (1.0.6)
css_parser (1.16.0)
css_parser (1.17.1)
addressable
csv (3.3.0)
cuprite (0.15)
capybara (~> 3.0)
ferrum (~> 0.14.0)
@@ -237,14 +239,14 @@ GEM
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
datafoodconsortium-connector (1.0.0.pre.alpha.10)
datafoodconsortium-connector (1.0.0.pre.alpha.12)
virtual_assembly-semantizer (~> 1.0, >= 1.0.5)
date (3.3.4)
debug (1.9.1)
debug (1.9.2)
irb (~> 1.10)
reline (>= 0.3.8)
debugger-linecache (1.2.0)
devise (4.9.3)
devise (4.9.4)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
@@ -259,7 +261,7 @@ GEM
diff-lcs (1.5.1)
digest (3.1.1)
docile (1.4.0)
dotenv (3.1.0)
dotenv (3.1.2)
email_validator (2.2.4)
activemodel
erubi (1.12.0)
@@ -285,16 +287,17 @@ GEM
websocket-driver (>= 0.6, < 0.8)
ffaker (2.23.0)
ffi (1.16.3)
flipper (0.26.2)
flipper (1.3.0)
concurrent-ruby (< 2)
flipper-active_record (0.26.2)
flipper-active_record (1.3.0)
activerecord (>= 4.2, < 8)
flipper (~> 0.26.2)
flipper-ui (0.26.2)
flipper (~> 1.3.0)
flipper-ui (1.3.0)
erubi (>= 1.0.0, < 2.0.0)
flipper (~> 0.26.2)
rack (>= 1.4, < 3)
rack-protection (>= 1.5.3, <= 4.0.0)
flipper (~> 1.3.0)
rack (>= 1.4, < 4)
rack-protection (>= 1.5.3, < 5.0.0)
rack-session (>= 1.0.2, < 3.0.0)
sanitize (< 7)
fog-aws (2.0.1)
fog-core (~> 1.38)
@@ -311,7 +314,7 @@ GEM
fog-xml (0.1.3)
fog-core
nokogiri (>= 1.5.11, < 2.0.0)
foreman (0.87.2)
foreman (0.88.1)
formatador (0.2.5)
fugit (1.8.1)
et-orbi (~> 1, >= 1.2.7)
@@ -319,7 +322,9 @@ GEM
fuubar (2.5.1)
rspec-core (~> 3.0)
ruby-progressbar (~> 1.4)
geocoder (1.8.2)
geocoder (1.8.3)
base64 (>= 0.1.0)
csv (>= 3.0.0)
globalid (1.2.1)
activesupport (>= 6.1)
gmaps4rails (2.1.2)
@@ -335,7 +340,7 @@ GEM
hashie (5.0.0)
highline (2.0.3)
htmlentities (4.3.4)
i18n (1.14.4)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
i18n-js (3.9.2)
i18n (>= 0.6.6)
@@ -346,11 +351,11 @@ GEM
activerecord (>= 3.0)
invisible_captcha (2.2.0)
rails (>= 5.2)
io-console (0.7.1)
io-console (0.7.2)
ipaddress (0.8.3)
irb (1.11.0)
irb (1.12.0)
rdoc
reline (>= 0.3.8)
reline (>= 0.4.2)
jmespath (1.6.2)
jquery-rails (4.4.0)
rails-dom-testing (>= 1, < 3)
@@ -358,7 +363,7 @@ GEM
thor (>= 0.14, < 2.0)
jquery-ui-rails (4.2.1)
railties (>= 3.2.16)
json (2.7.1)
json (2.7.2)
json-canonicalization (1.0.0)
json-jwt (1.16.6)
activesupport (>= 4.2)
@@ -383,13 +388,14 @@ GEM
activesupport (>= 4.2)
jwt (2.8.1)
base64
knapsack_pro (6.0.4)
knapsack_pro (7.2.0)
rake
language_server-protocol (3.17.0.3)
launchy (2.5.2)
launchy (3.0.0)
addressable (~> 2.8)
letter_opener (1.9.0)
launchy (>= 2.2, < 3)
childprocess (~> 5.0)
letter_opener (1.10.0)
launchy (>= 2.2, < 4)
link_header (0.0.8)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
@@ -404,7 +410,7 @@ GEM
net-smtp
marcel (1.0.2)
matrix (0.4.2)
method_source (1.0.0)
method_source (1.1.0)
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2023.1205)
@@ -413,7 +419,7 @@ GEM
rake
mini_magick (4.11.0)
mini_mime (1.1.5)
mini_portile2 (2.8.5)
mini_portile2 (2.8.6)
minitest (5.22.3)
monetize (1.13.0)
money (~> 6.12)
@@ -431,11 +437,11 @@ GEM
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.4.0.1)
net-smtp (0.5.0)
net-protocol
newrelic_rpm (9.7.1)
newrelic_rpm (9.9.0)
nio4r (2.7.0)
nokogiri (1.16.3)
nokogiri (1.16.5)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
oauth2 (1.4.11)
@@ -448,7 +454,7 @@ GEM
hashie (>= 3.4.6)
rack (>= 2.2.3)
rack-protection
omniauth-rails_csrf_protection (1.0.1)
omniauth-rails_csrf_protection (1.0.2)
actionpack (>= 4.2)
omniauth (~> 2.0)
omniauth_openid_connect (0.7.1)
@@ -476,7 +482,7 @@ GEM
parallel (1.24.0)
paranoia (2.6.3)
activerecord (>= 5.1, < 7.2)
parser (3.3.0.5)
parser (3.3.1.0)
ast (~> 2.4.1)
racc
paypal-sdk-core (0.3.4)
@@ -497,7 +503,7 @@ GEM
method_source (~> 1.0)
psych (5.1.2)
stringio
public_suffix (5.0.4)
public_suffix (5.0.5)
puma (6.4.2)
nio4r (~> 2.0)
query_count (1.1.1)
@@ -521,6 +527,8 @@ GEM
rack-proxy (0.7.6)
rack
rack-rewrite (1.5.1)
rack-session (1.0.2)
rack (< 3)
rack-test (2.1.0)
rack (>= 1.3)
rack-timeout (0.6.3)
@@ -566,7 +574,7 @@ GEM
thor (~> 1.0)
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.1.0)
rake (13.2.1)
ransack (4.1.1)
activerecord (>= 6.1.5)
activesupport (>= 6.1.5)
@@ -580,12 +588,12 @@ GEM
rdoc (6.6.3.1)
psych (>= 4.0.0)
redcarpet (3.6.0)
redis (5.1.0)
redis-client (>= 0.17.0)
redis-client (0.20.0)
redis (5.2.0)
redis-client (>= 0.22.0)
redis-client (0.22.1)
connection_pool
regexp_parser (2.9.0)
reline (0.4.1)
reline (0.5.0)
io-console (~> 0.5)
request_store (1.5.1)
rack (>= 1.4)
@@ -593,10 +601,10 @@ GEM
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.2.6)
roadie (5.2.0)
roadie (5.2.1)
css_parser (~> 1.4)
nokogiri (~> 1.15)
roadie-rails (3.1.0)
roadie-rails (3.2.0)
railties (>= 5.1, < 8.0)
roadie (~> 5.0)
rodf (1.2.0)
@@ -627,7 +635,7 @@ GEM
rspec-support (~> 3.13)
rspec-retry (0.6.2)
rspec-core (> 3.3)
rspec-sql (0.0.1)
rspec-sql (0.0.2)
activesupport
rspec
rspec-support (3.13.1)
@@ -646,7 +654,7 @@ GEM
rswag-ui (2.13.0)
actionpack (>= 3.1, < 7.2)
railties (>= 3.1, < 7.2)
rubocop (1.62.1)
rubocop (1.63.5)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
@@ -657,8 +665,8 @@ GEM
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.2)
parser (>= 3.3.0.4)
rubocop-ast (1.31.3)
parser (>= 3.3.1.0)
rubocop-capybara (2.20.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.25.1)
@@ -668,10 +676,13 @@ GEM
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rspec (2.27.1)
rubocop-rspec (2.29.2)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
rubocop-rspec_rails (~> 2.28)
rubocop-rspec_rails (2.28.3)
rubocop (~> 1.40)
ruby-graphviz (1.2.5)
rexml
ruby-progressbar (1.13.0)
@@ -681,7 +692,7 @@ GEM
rubyzip (2.3.2)
rufus-scheduler (3.8.2)
fugit (~> 1.1, >= 1.1.6)
sanitize (6.0.2)
sanitize (6.1.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
sass (3.4.25)
@@ -695,7 +706,7 @@ GEM
semantic_range (3.0.0)
shoulda-matchers (6.2.0)
activesupport (>= 5.2.0)
sidekiq (7.2.2)
sidekiq (7.2.4)
concurrent-ruby (< 2)
connection_pool (>= 2.3.0)
rack (>= 2.2.4)
@@ -713,7 +724,7 @@ GEM
spreadsheet_architect (5.0.0)
caxlsx (>= 3.3.0, < 4)
rodf (>= 1.0.0, < 2)
spring (4.1.3)
spring (4.2.1)
spring-commands-rspec (1.0.4)
spring (>= 0.9.1)
spring-commands-rubocop (0.4.0)
@@ -746,7 +757,7 @@ GEM
stimulus_reflex (>= 3.3.0)
stringex (2.8.6)
stringio (3.1.0)
stripe (10.13.0)
stripe (11.1.0)
swd (2.0.3)
activesupport (>= 3)
attr_required (>= 0.0.5)
@@ -764,7 +775,7 @@ GEM
unicode-display_width (2.5.0)
uniform_notifier (1.16.0)
uri (0.13.0)
valid_email2 (5.2.1)
valid_email2 (5.2.3)
activemodel (>= 3.2)
mail (~> 2.5)
validate_url (1.0.15)
@@ -773,7 +784,7 @@ GEM
validates_lengths_from_database (0.8.0)
activerecord (>= 4)
vcr (6.2.0)
view_component (3.11.0)
view_component (3.12.0)
activesupport (>= 5.2.0, < 8.0)
concurrent-ruby (~> 1.0)
method_source (~> 1.0)
@@ -781,7 +792,7 @@ GEM
rails (>= 5.2, < 8.0)
stimulus_reflex (>= 3.5.0.pre2)
view_component (>= 2.28.0)
virtual_assembly-semantizer (1.0.5)
virtual_assembly-semantizer (1.1.1)
json-ld (~> 3.2, >= 3.2.3)
warden (1.2.9)
rack (>= 2.0.9)
@@ -811,11 +822,11 @@ GEM
chronic (>= 0.6.3)
wicked_pdf (2.6.3)
activesupport
wkhtmltopdf-binary (0.12.6.6)
wkhtmltopdf-binary (0.12.6.7)
xml-simple (1.1.8)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.13)
zeitwerk (2.6.14)
PLATFORMS
ruby

View File

@@ -48,7 +48,7 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout
params = {
'q[name_cont]': $scope.q.query,
'q[supplier_id_eq]': $scope.q.producerFilter,
'q[primary_taxon_id_eq]': $scope.q.categoryFilter,
'q[variants_primary_taxon_id_eq]': $scope.q.categoryFilter,
'q[s]': $scope.sorting,
import_date: $scope.q.importDateFilter,
page: $scope.page,
@@ -136,6 +136,7 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout
on_hand: null
price: null
tax_category_id: null
category_id: null
DisplayProperties.setShowVariants product.id, true
@@ -217,7 +218,7 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout
filters:
'q[name_cont]': $scope.q.query
'q[supplier_id_eq]': $scope.q.producerFilter
'q[primary_taxon_id_eq]': $scope.q.categoryFilter
'q[variants_primary_taxon_id_eq]': $scope.q.categoryFilter
'q[s]': $scope.sorting
import_date: $scope.q.importDateFilter
page: $scope.page
@@ -332,9 +333,6 @@ filterSubmitProducts = (productsToFilter) ->
if product.hasOwnProperty("on_demand") and filteredVariants.length == 0 #only update if no variants present
filteredProduct.on_demand = product.on_demand
hasUpdatableProperty = true
if product.hasOwnProperty("category_id")
filteredProduct.primary_taxon_id = product.category_id
hasUpdatableProperty = true
if product.hasOwnProperty("inherits_properties")
filteredProduct.inherits_properties = product.inherits_properties
hasUpdatableProperty = true
@@ -375,6 +373,9 @@ filterSubmitVariant = (variant) ->
if variant.hasOwnProperty("tax_category_id")
filteredVariant.tax_category_id = variant.tax_category_id
hasUpdatableProperty = true
if variant.hasOwnProperty("category_id")
filteredVariant.primary_taxon_id = variant.category_id
hasUpdatableProperty = true
if variant.hasOwnProperty("display_as")
filteredVariant.display_as = variant.display_as
hasUpdatableProperty = true

View File

@@ -1,3 +1,4 @@
# Controller for "New Products" form (spree/admin/products/new)
angular.module("admin.products")
.controller "unitsCtrl", ($scope, VariantUnitManager, OptionValueNamer, UnitPrices, PriceParser) ->
$scope.product = { master: {} }
@@ -12,13 +13,15 @@ angular.module("admin.products")
$scope.variant_unit_options = VariantUnitManager.variantUnitOptions()
# Extract variant_unit and variant_unit_scale from dropdown variant_unit_with_scale,
# and update hidden product fields
$scope.processVariantUnitWithScale = ->
if $scope.product.variant_unit_with_scale
match = $scope.product.variant_unit_with_scale.match(/^([^_]+)_([\d\.]+)$/)
match = $scope.product.variant_unit_with_scale.match(/^([^_]+)_([\d\.]+)$/) # matches string like "weight_1000"
if match
$scope.product.variant_unit = match[1]
$scope.product.variant_unit_scale = parseFloat(match[2])
else
else # "items"
$scope.product.variant_unit = $scope.product.variant_unit_with_scale
$scope.product.variant_unit_scale = null
else if $scope.product.variant_unit
@@ -32,6 +35,8 @@ angular.module("admin.products")
else
$scope.product.variant_unit = $scope.product.variant_unit_scale = null
# Extract unit_value and unit_description from text field unit_value_with_description,
# and update hidden variant fields
$scope.processUnitValueWithDescription = ->
if $scope.product.master.hasOwnProperty("unit_value_with_description")
match = $scope.product.master.unit_value_with_description.match(/^([\d\.,]+(?= *|$)|)( *)(.*)$/)
@@ -45,6 +50,7 @@ angular.module("admin.products")
value = window.bigDecimal.divide(value, $scope.product.variant_unit_scale, 2) if $scope.product.master.unit_value && $scope.product.variant_unit_scale
$scope.product.master.unit_value_with_description = value + " " + $scope.product.master.unit_description
# Calculate unit price based on product price and variant_unit_scale
$scope.processUnitPrice = ->
price = $scope.product.price
scale = $scope.product.variant_unit_scale

View File

@@ -1,4 +1,5 @@
angular.module("admin.products").factory "OptionValueNamer", (VariantUnitManager) ->
# Javascript clone of VariantUnits::OptionValueNamer, for bulk product editing.
class OptionValueNamer
constructor: (@variant) ->

View File

@@ -68,7 +68,7 @@ angular.module('Darkswarm').controller "ProductsCtrl", ($scope, $sce, $filter, $
per_page: $scope.per_page,
'q[name_or_meta_keywords_or_variants_display_as_or_variants_display_name_or_supplier_name_cont]': $scope.query,
'q[with_properties][]': $scope.activeProperties,
'q[primary_taxon_id_in_any][]': $scope.activeTaxons
'q[variants_primary_taxon_id_in_any][]': $scope.activeTaxons
}
$scope.searchKeypress = (e)->

View File

@@ -0,0 +1,43 @@
# frozen_string_literal: true
class SearchableDropdownComponent < ViewComponent::Base
REMOVED_SEARCH_PLUGIN = { 'tom-select-options-value': '{ "plugins": [] }' }.freeze
MINIMUM_OPTIONS_FOR_SEARCH_FIELD = 11 # at least 11 options are required for the search field
def initialize(
form:,
name:,
options:,
selected_option:,
placeholder_value:,
include_blank: false,
aria_label: ''
)
@f = form
@name = name
@options = options
@selected_option = selected_option
@placeholder_value = placeholder_value
@include_blank = include_blank
@aria_label = aria_label
end
private
attr_reader :f, :name, :options, :selected_option, :placeholder_value, :include_blank, :aria_label
def classes
"fullwidth #{remove_search_plugin? ? 'no-input' : ''}"
end
def data
{
controller: "tom-select",
'tom-select-placeholder-value': placeholder_value
}.merge(remove_search_plugin? ? REMOVED_SEARCH_PLUGIN : {})
end
def remove_search_plugin?
@remove_search_plugin ||= options.count < MINIMUM_OPTIONS_FOR_SEARCH_FIELD
end
end

View File

@@ -0,0 +1 @@
= f.select name, options_for_select(options, selected_option), { include_blank: }, class: classes, data:, 'aria-label': aria_label

View File

@@ -2,6 +2,146 @@
module Admin
class ProductsV3Controller < Spree::Admin::BaseController
def index; end
before_action :init_filters_params
before_action :init_pagination_params
def index
fetch_products
render "index", locals: { producers:, categories:, tax_category_options:, flash: }
end
def bulk_update
product_set = product_set_from_params
product_set.collection.each { |p| authorize! :update, p }
@products = product_set.collection # use instance variable mainly for testing
if product_set.save
flash[:success] = I18n.t('admin.products_v3.bulk_update.success')
redirect_to [:index,
{ page: @page, per_page: @per_page, search_term: @search_term,
producer_id: @producer_id, category_id: @category_id }]
elsif product_set.errors.present?
@error_counts = { saved: product_set.saved_count, invalid: product_set.invalid.count }
render "index", status: :unprocessable_entity,
locals: { producers:, categories:, tax_category_options:, flash: }
end
end
def index_url(params)
"/admin/products?#{params.to_query}" # todo: fix routing so this can be automaticly generated
end
private
def init_filters_params
# params comes from the form
# _params comes from the url
# priority is given to params from the form (if present) over url params
@search_term = params[:search_term] || params[:_search_term]
@producer_id = params[:producer_id] || params[:_producer_id]
@category_id = params[:category_id] || params[:_category_id]
end
def init_pagination_params
# prority is given to element dataset (if present) over url params
@page = params[:page].presence || 1
@per_page = params[:per_page].presence || 15
@q = params.permit(q: {})[:q] || { s: 'name asc' }
end
def producers
producers = OpenFoodNetwork::Permissions.new(spree_current_user)
.managed_product_enterprises.is_primary_producer.by_name
producers.map { |p| [p.name, p.id] }
end
def categories
Spree::Taxon.order(:name).map { |c| [c.name, c.id] }
end
def tax_category_options
Spree::TaxCategory.order(:name).pluck(:name, :id)
end
def fetch_products
product_query = OpenFoodNetwork::Permissions.new(spree_current_user)
.editable_products.merge(product_scope).ransack(ransack_query).result
@pagy, @products = pagy(product_query.order(:name), items: @per_page, page: @page,
size: [1, 2, 2, 1])
end
def product_scope
user = spree_current_user
scope = if user.has_spree_role?("admin") || user.enterprises.present?
Spree::Product
else
Spree::Product.active
end
scope.includes(product_query_includes).distinct
end
def ransack_query
query = {}
query.merge!(supplier_id_in: @producer_id) if @producer_id.present?
if @search_term.present?
query.merge!(Spree::Variant::SEARCH_KEY => @search_term)
end
query.merge!(variants_primary_taxon_id_in: @category_id) if @category_id.present?
query.merge!(@q) if @q
query
end
# Optimise by pre-loading required columns
def product_query_includes
[
:image,
:supplier,
{ variants: [
:default_price,
:primary_taxon,
:product,
:stock_items,
:tax_category,
] },
]
end
# Similar to spree/admin/products_controller
def product_set_from_params
# Form field names:
# '[products][0][id]' (hidden field)
# '[products][0][name]'
# '[products][0][variants_attributes][0][id]' (hidden field)
# '[products][0][variants_attributes][0][display_name]'
#
# Resulting in params:
# "products" => {
# "0" => {
# "id" => "123"
# "name" => "Pommes",
# "variants_attributes" => {
# "0" => {
# "id" => "1234",
# "display_name" => "Large box",
# }
# }
# }
collection_hash = products_bulk_params[:products]
.transform_values { |product|
# Convert variants_attributes form hash to an array if present
product[:variants_attributes] &&= product[:variants_attributes].values
product
}.with_indifferent_access
Sets::ProductSet.new(collection_attributes: collection_hash)
end
def products_bulk_params
params.permit(products: ::PermittedAttributes::Product.attributes)
.to_h.with_indifferent_access
end
end
end

View File

@@ -229,7 +229,7 @@ module Admin
end
def member_action?
!collection_actions.include? action
collection_actions.exclude? action
end
def new_actions

View File

@@ -16,14 +16,14 @@ module Admin
authorize! :destroy, stripe_account
if stripe_account.deauthorize_and_destroy
flash[:success] = "Stripe account disconnected."
flash[:success] = I18n.t('stripe.success_code.disconnected')
else
flash[:error] = "Failed to disconnect Stripe."
flash[:error] = I18n.t('stripe.error_code.disconnect_failure')
end
redirect_to main_app.edit_admin_enterprise_path(stripe_account.enterprise)
rescue ActiveRecord::RecordNotFound
flash[:error] = "Failed to disconnect Stripe."
flash[:error] = I18n.t('stripe.error_code.disconnect_failure')
redirect_to spree.admin_dashboard_path
end

View File

@@ -70,22 +70,7 @@ module Api
end
def search_params
permitted_search_params = params.slice :q, :page, :per_page
if permitted_search_params.key? :q
permitted_search_params[:q].slice!(*permitted_ransack_params)
end
permitted_search_params
end
def permitted_ransack_params
[
"#{[:name, :meta_keywords, :variants_display_as,
:variants_display_name, :supplier_name]
.join('_or_')}_cont",
:with_properties, :primary_taxon_id_in_any
]
params.slice :q, :page, :per_page
end
def distributor

View File

@@ -19,8 +19,13 @@ module Spree
def generate
@order = Order.find_by(number: params[:order_id])
authorize! :invoice, @order
::Orders::GenerateInvoiceService.new(@order).generate_or_update_latest_invoice
if @order.distributor.can_invoice?
authorize! :invoice, @order
::Orders::GenerateInvoiceService.new(@order).generate_or_update_latest_invoice
else
flash[:error] = t(:must_have_valid_business_number,
enterprise_name: @order.distributor.name)
end
redirect_back(fallback_location: spree.admin_dashboard_path)
end

View File

@@ -175,7 +175,7 @@ module Spree
Spree::Variant.
select('DISTINCT spree_variants.import_date').
joins(:product).
where('spree_products.supplier_id IN (?)', editable_enterprises.collect(&:id)).
where(spree_products: { supplier_id: editable_enterprises.collect(&:id) }).
where.not(spree_variants: { import_date: nil }).
where(spree_variants: { deleted_at: nil }).
order('spree_variants.import_date DESC')

View File

@@ -60,7 +60,7 @@ module Spree
@insufficient_stock_lines = []
@order = order_to_update
unless @order
flash[:error] = t(:order_not_found)
flash[:error] = t(:order_not_updated)
redirect_to(main_app.root_path) && return
end
@@ -82,7 +82,7 @@ module Spree
format.html do
if params.key?(:checkout)
@order.next_transition.run_callbacks if @order.cart?
redirect_to main_app.checkout_step_path(@order.checkout_steps.first)
redirect_to main_app.checkout_step_path("address")
elsif @order.complete?
redirect_to main_app.order_path(@order)
else

View File

@@ -154,7 +154,6 @@ module InjectionHelper
end
def enterprise_injection_data
@enterprise_injection_data ||= OpenFoodNetwork::EnterpriseInjectionData.new
{ data: @enterprise_injection_data }
@enterprise_injection_data ||= { data: OpenFoodNetwork::EnterpriseInjectionData.new }
end
end

View File

@@ -1,16 +1,6 @@
# frozen_string_literal: true
module SharedHelper
def distributor_link_class(distributor)
cart = current_order(true)
@active_distributors ||= Enterprise.distributors_with_active_order_cycles
klass = "shop-distributor"
klass += " empties-cart" unless cart.line_items.empty? || cart.distributor == distributor
klass += @active_distributors.include?(distributor) ? ' active' : ' inactive'
klass
end
def enterprise_user?
spree_current_user&.enterprises&.count.to_i > 0
end

View File

@@ -33,8 +33,6 @@ module Spree
when :boolean
hidden_field_tag(name, 0) +
check_box_tag(name, 1, value, preference_field_options(options))
when :string
text_field_tag(name, value, preference_field_options(options))
when :password
password_field_tag(name, value, preference_field_options(options))
when :text
@@ -88,8 +86,6 @@ module Spree
{ size: 10, class: 'input_integer', step: :any }
when :boolean
{}
when :string
{ size: 10, class: 'input_string fullwidth' }
when :password
{ size: 10, class: 'password_string fullwidth' }
when :text

View File

@@ -3,20 +3,20 @@
module Spree
module Admin
module OrdersHelper
def event_links
def event_links(order)
links = []
links << cancel_event_link if @order.can_cancel?
links << resume_event_link if @order.can_resume?
links << cancel_event_link(order) if order.can_cancel?
links << resume_event_link(order) if order.can_resume?
links.join('&nbsp;').html_safe # rubocop:disable Rails/OutputSafety
end
def generate_invoice_button(order)
if order.distributor.can_invoice?
button_link_to t(:create_or_update_invoice), generate_admin_order_invoices_path(@order),
button_link_to t(:create_or_update_invoice), generate_admin_order_invoices_path(order),
data: { method: 'post' }, icon: 'icon-plus'
else
button_link_to t(:create_or_update_invoice), "#", data: {
confirm: t(:must_have_valid_business_number, enterprise_name: @order.distributor.name)
confirm: t(:must_have_valid_business_number, enterprise_name: order.distributor.name)
}, icon: 'icon-plus'
end
end
@@ -26,82 +26,85 @@ module Spree
end
def order_links(order)
@order ||= order
links = []
links << edit_order_link unless action_name == "edit"
links.concat(complete_order_links) if @order.complete? || @order.resumed?
links << ship_order_link if @order.ready_to_ship?
links << cancel_order_link if @order.can_cancel?
links << edit_order_link(order) unless action_name == "edit"
links.concat(complete_order_links(order)) if order.complete? || order.resumed?
links << ship_order_link if order.ready_to_ship?
links << cancel_order_link(order) if order.can_cancel?
links
end
def order_shipment_ready?(order)
order.ready_to_ship?
end
private
def complete_order_links
[resend_confirmation_link] + invoice_links
def complete_order_links(order)
[resend_confirmation_link(order)] + invoice_links(order)
end
def invoice_links
def invoice_links(order)
return [] unless Spree::Config[:enable_invoices?]
[send_invoice_link, print_invoice_link]
[send_invoice_link(order), print_invoice_link(order)]
end
def send_invoice_link
if @order.distributor.can_invoice?
send_invoice_link_with_url
def send_invoice_link(order)
if order.distributor.can_invoice?
send_invoice_link_with_url(order)
else
send_invoice_link_without_url
send_invoice_link_without_url(order)
end
end
def print_invoice_link
if @order.distributor.can_invoice?
print_invoice_link_with_url
def print_invoice_link(order)
if order.distributor.can_invoice?
print_invoice_link_with_url(order)
else
notify_about_required_enterprise_number
notify_about_required_enterprise_number(order)
end
end
def edit_order_link
def edit_order_link(order)
{ name: t(:edit_order),
url: spree.edit_admin_order_path(@order),
url: spree.edit_admin_order_path(order),
icon: 'icon-edit' }
end
def resend_confirmation_link
def resend_confirmation_link(order)
{ name: t(:resend_confirmation),
url: spree.resend_admin_order_path(@order),
url: spree.resend_admin_order_path(order),
icon: 'icon-email',
confirm: t(:confirm_resend_order_confirmation) }
end
def send_invoice_link_with_url
def send_invoice_link_with_url(order)
{ name: t(:send_invoice),
url: invoice_admin_order_path(@order),
url: invoice_admin_order_path(order),
icon: 'icon-email',
confirm: t(:confirm_send_invoice) }
end
def send_invoice_link_without_url
def send_invoice_link_without_url(order)
{ name: t(:send_invoice),
url: "#",
icon: 'icon-email',
confirm: t(:must_have_valid_business_number, enterprise_name: @order.distributor.name) }
confirm: t(:must_have_valid_business_number, enterprise_name: order.distributor.name) }
end
def print_invoice_link_with_url
def print_invoice_link_with_url(order)
{ name: t(:print_invoice),
url: spree.print_admin_order_path(@order),
url: spree.print_admin_order_path(order),
icon: 'icon-print',
target: "_blank" }
end
def notify_about_required_enterprise_number
def notify_about_required_enterprise_number(order)
{ name: t(:print_invoice),
url: "#",
icon: 'icon-print',
confirm: t(:must_have_valid_business_number, enterprise_name: @order.distributor.name) }
confirm: t(:must_have_valid_business_number, enterprise_name: order.distributor.name) }
end
def ship_order_link
@@ -110,24 +113,24 @@ module Spree
icon: 'icon-truck' }
end
def cancel_order_link
def cancel_order_link(order)
{ name: t(:cancel_order),
url: spree.fire_admin_order_path(@order.number, e: 'cancel'),
url: spree.fire_admin_order_path(order.number, e: 'cancel'),
icon: 'icon-trash' }
end
def cancel_event_link
def cancel_event_link(order)
event_label = I18n.t("cancel", scope: "actions")
button_link_to(event_label,
fire_admin_order_url(@order, e: "cancel"),
fire_admin_order_url(order, e: "cancel"),
method: :put, icon: "icon-cancel", form_id: "cancel_order_form")
end
def resume_event_link
def resume_event_link(order)
event_label = I18n.t("resume", scope: "actions")
confirm_message = I18n.t("admin.orders.edit.order_sure_want_to", event: event_label)
button_link_to(event_label,
fire_admin_order_url(@order, e: "resume"),
fire_admin_order_url(order, e: "resume"),
method: :put, icon: "icon-resume",
data: { confirm: confirm_message })
end

View File

@@ -17,17 +17,18 @@ module Spree
def changeable_orders
# Only returns open order for the current user + shop + oc combo
return @changeable_orders unless @changeable_orders.nil?
return @changeable_orders = [] unless spree_current_user &&
current_distributor && current_order_cycle
return @changeable_orders = [] unless current_distributor.allow_order_changes?
@changeable_orders ||= if spree_current_user &&
current_order_cycle && current_distributor&.allow_order_changes?
@changeable_orders = Spree::Order.complete.where(
state: 'complete',
user_id: spree_current_user.id,
distributor_id: current_distributor.id,
order_cycle_id: current_order_cycle.id
)
Spree::Order.complete.where(
state: 'complete',
user_id: spree_current_user.id,
distributor_id: current_distributor.id,
order_cycle_id: current_order_cycle.id
)
else
[]
end
end
def changeable_orders_link_path

View File

@@ -7,9 +7,10 @@ class BulkInvoiceJob < ApplicationJob
def perform(order_ids, filepath, options = {})
@options = options
orders = sorted_orders(order_ids)
orders.filter!(&:invoiceable?) if OpenFoodNetwork::FeatureToggle.enabled?(:invoices,
current_user)
# The `find` method returns records in the same order as the given ids.
orders = Spree::Order.find(order_ids)
orders.each(&method(:generate_invoice))
ensure_directory_exists filepath
@@ -21,12 +22,6 @@ class BulkInvoiceJob < ApplicationJob
private
# Ensures the records are returned in the same order the ids were originally given in
def sorted_orders(order_ids)
orders_by_id = Spree::Order.where(id: order_ids).to_a.index_by(&:id)
order_ids.map { |id| orders_by_id[id.to_i] }
end
def renderer
@renderer ||= InvoiceRenderer.new
end

View File

@@ -4,7 +4,7 @@ class ConnectAppJob < ApplicationJob
include CableReady::Broadcaster
def perform(app, token, channel: nil)
url = "https://n8n.openfoodnetwork.org.uk/webhook/regen/connect-enterprise"
url = I18n.t("connect_app.url")
event = "connect-app"
enterprise = app.enterprise
payload = {

View File

@@ -52,7 +52,7 @@ class ProducerMailer < ApplicationMailer
def distributors_pickup_times_for(line_items)
@order_cycle.distributors.
joins(:distributed_orders).
where("spree_orders.id IN (?)", line_items.map(&:order_id).uniq).
where(spree_orders: { id: line_items.map(&:order_id).uniq }).
map do |distributor|
[distributor.name, @order_cycle.pickup_time_for(distributor)]
end

View File

@@ -10,7 +10,7 @@ module Calculator
end
def set_preference(name, value)
if name == :unit_from_list && !["kg", "lb"].include?(value)
if name == :unit_from_list && ["kg", "lb"].exclude?(value)
calculable.errors.add(:preferred_unit_from_list, I18n.t(:calculator_preferred_unit_error))
else
__send__ self.class.preference_setter_method(name), value

View File

@@ -43,25 +43,31 @@ class Enterprise < ApplicationRecord
foreign_key: 'supplier_id',
dependent: :destroy
has_many :supplied_variants, through: :supplied_products, source: :variants
has_many :distributed_orders, class_name: 'Spree::Order', foreign_key: 'distributor_id'
has_many :distributed_orders, class_name: 'Spree::Order',
foreign_key: 'distributor_id',
dependent: :restrict_with_exception
belongs_to :address, class_name: 'Spree::Address'
belongs_to :business_address, optional: true, class_name: 'Spree::Address', dependent: :destroy
has_many :enterprise_fees
has_many :enterprise_fees, dependent: :restrict_with_exception
has_many :enterprise_roles, dependent: :destroy
has_many :users, through: :enterprise_roles
belongs_to :owner, class_name: 'Spree::User',
inverse_of: :owned_enterprises
has_many :distributor_payment_methods,
inverse_of: :distributor, foreign_key: :distributor_id
inverse_of: :distributor,
foreign_key: :distributor_id,
dependent: :restrict_with_exception
has_many :distributor_shipping_methods,
inverse_of: :distributor, foreign_key: :distributor_id
inverse_of: :distributor,
foreign_key: :distributor_id,
dependent: :restrict_with_exception
has_many :payment_methods, through: :distributor_payment_methods
has_many :shipping_methods, through: :distributor_shipping_methods
has_many :customers, dependent: :destroy
has_many :inventory_items, dependent: :destroy
has_many :tag_rules, dependent: :destroy
has_one :stripe_account, dependent: :destroy
has_many :vouchers
has_many :vouchers, dependent: :restrict_with_exception
has_many :connected_apps, dependent: :destroy
has_one :custom_tab, dependent: :destroy
@@ -128,6 +134,7 @@ class Enterprise < ApplicationRecord
after_create :set_default_contact
after_create :relate_to_owners_enterprises
after_rollback :restore_permalink
after_touch :touch_distributors
after_create_commit :send_welcome_email
@@ -161,7 +168,7 @@ class Enterprise < ApplicationRecord
scope :is_hub, -> { where(sells: 'any') }
scope :supplying_variant_in, lambda { |variants|
joins(supplied_products: :variants).
where('spree_variants.id IN (?)', variants).
where(spree_variants: { id: variants }).
select('DISTINCT enterprises.*')
}
@@ -205,7 +212,7 @@ class Enterprise < ApplicationRecord
").
joins('INNER JOIN exchange_variants ON (exchange_variants.exchange_id = exchanges.id)').
joins('INNER JOIN spree_variants ON (spree_variants.id = exchange_variants.variant_id)').
where('spree_variants.product_id IN (?)', product_ids).select('DISTINCT enterprises.id')
where(spree_variants: { product_id: product_ids }).select('DISTINCT enterprises.id')
where(id: exchanges)
}
@@ -214,7 +221,7 @@ class Enterprise < ApplicationRecord
if user.has_spree_role?('admin')
where(nil)
else
joins(:enterprise_roles).where('enterprise_roles.user_id = ?', user.id)
joins(:enterprise_roles).where(enterprise_roles: { user_id: user.id })
end
}
@@ -240,6 +247,16 @@ class Enterprise < ApplicationRecord
count(distinct: true)
end
# Remove any unsupported HTML.
def long_description
HtmlSanitizer.sanitize(super)
end
# Remove any unsupported HTML.
def long_description=(html)
super(HtmlSanitizer.sanitize(html))
end
def contact
contact = users.where(enterprise_roles: { receives_notifications: true }).first
contact || owner
@@ -369,10 +386,10 @@ class Enterprise < ApplicationRecord
:producer_shop # Producer with shopfront and supplies other hubs.
when "producer_sells_none"
:producer # Producer only supplies through others.
when "non_producer_sells_any"
:hub # Hub selling others products in order cycles.
when "non_producer_sells_own"
:hub # Wholesaler selling through own shopfront? Does this need a separate name or even exist?
when "non_producer_sells_any", "non_producer_sells_own"
# Hub selling others products in order cycles
# Or Wholesaler selling through own shopfront? Does this need a separate name or even exist?
:hub
when "non_producer_sells_none"
:hub_profile # Hub selling outside the system.
end
@@ -382,7 +399,7 @@ class Enterprise < ApplicationRecord
def distributed_taxons
Spree::Taxon.
joins(:products).
where('spree_products.id IN (?)', Spree::Product.in_distributor(self).select(&:id)).
where(spree_products: { id: Spree::Product.in_distributor(self).select(&:id) }).
select('DISTINCT spree_taxons.*')
end
@@ -398,7 +415,7 @@ class Enterprise < ApplicationRecord
def supplied_taxons
Spree::Taxon.
joins(:products).
where('spree_products.id IN (?)', Spree::Product.in_supplier(self).select(&:id)).
where(spree_products: { id: Spree::Product.in_supplier(self).select(&:id) }).
select('DISTINCT spree_taxons.*')
end
@@ -472,7 +489,7 @@ class Enterprise < ApplicationRecord
ExchangeVariant.joins(exchange: :order_cycle)
.merge(Exchange.outgoing)
.select("DISTINCT exchange_variants.variant_id, exchanges.receiver_id AS enterprise_id")
.where("exchanges.receiver_id = ?", id)
.where(exchanges: { receiver_id: id })
.merge(OrderCycle.active.with_distributor(id))
end

View File

@@ -21,7 +21,6 @@ class EnterpriseFee < ApplicationRecord
validates :fee_type, inclusion: { in: FEE_TYPES }
validates :name, presence: true
validates :enterprise_id, presence: true
before_save :ensure_valid_tax_category_settings
@@ -32,7 +31,7 @@ class EnterpriseFee < ApplicationRecord
if user.has_spree_role?('admin')
where(nil)
else
where('enterprise_id IN (?)', user.enterprises.select(&:id))
where(enterprise_id: user.enterprises.select(&:id))
end
}
@@ -40,7 +39,7 @@ class EnterpriseFee < ApplicationRecord
joins(:calculator).where.not(spree_calculators: { type: PER_ORDER_CALCULATORS })
}
scope :per_order, lambda {
joins(:calculator).where('spree_calculators.type IN (?)', PER_ORDER_CALCULATORS)
joins(:calculator).where(spree_calculators: { type: PER_ORDER_CALCULATORS })
}
def self.clear_all_adjustments(order)

View File

@@ -41,7 +41,7 @@ class EnterpriseGroup < ApplicationRecord
if user.has_spree_role?('admin')
where(nil)
else
where('owner_id = ?', user.id)
where(owner_id: user.id)
end
}

View File

@@ -27,12 +27,12 @@ class EnterpriseRelationship < ApplicationRecord
where('parent_id IN (?) OR child_id IN (?)', enterprises.select(&:id), enterprises.select(&:id))
}
scope :permitting, ->(enterprise_ids) { where('child_id IN (?)', enterprise_ids) }
scope :permitted_by, ->(enterprise_ids) { where('parent_id IN (?)', enterprise_ids) }
scope :permitting, ->(enterprise_ids) { where(child_id: enterprise_ids) }
scope :permitted_by, ->(enterprise_ids) { where(parent_id: enterprise_ids) }
scope :with_permission, ->(permission) {
joins(:permissions).
where('enterprise_relationship_permissions.name = ?', permission)
where(enterprise_relationship_permissions: { name: permission })
}
scope :by_name, -> { with_enterprises.order('child_enterprises.name, parent_enterprises.name') }
@@ -108,6 +108,6 @@ class EnterpriseRelationship < ApplicationRecord
def child_variant_overrides
VariantOverride.unscoped.for_hubs(child)
.joins(variant: :product).where("spree_products.supplier_id IN (?)", parent)
.joins(variant: :product).where(spree_products: { supplier_id: parent })
end
end

View File

@@ -10,8 +10,6 @@
# shopfront (outgoing products). But the set of shown products can be smaller
# than all incoming products.
class Exchange < ApplicationRecord
self.belongs_to_required_by_default = false
acts_as_taggable
belongs_to :order_cycle
@@ -24,7 +22,6 @@ class Exchange < ApplicationRecord
has_many :exchange_fees, dependent: :destroy
has_many :enterprise_fees, through: :exchange_fees
validates :order_cycle, :sender, :receiver, presence: true
validates :sender_id, uniqueness: { scope: [:order_cycle_id, :receiver_id, :incoming] }
before_destroy :delete_related_exchange_variants, prepend: true
@@ -38,8 +35,8 @@ class Exchange < ApplicationRecord
scope :outgoing, -> { where(incoming: false) }
scope :from_enterprise, lambda { |enterprise| where(sender_id: enterprise) }
scope :to_enterprise, lambda { |enterprise| where(receiver_id: enterprise) }
scope :from_enterprises, lambda { |enterprises| where('exchanges.sender_id IN (?)', enterprises) }
scope :to_enterprises, lambda { |enterprises| where('exchanges.receiver_id IN (?)', enterprises) }
scope :from_enterprises, lambda { |enterprises| where(exchanges: { sender_id: enterprises }) }
scope :to_enterprises, lambda { |enterprises| where(exchanges: { receiver_id: enterprises }) }
scope :involving, lambda { |enterprises|
where('exchanges.receiver_id IN (?) OR exchanges.sender_id IN (?)', enterprises, enterprises).
select('DISTINCT exchanges.*')
@@ -48,7 +45,7 @@ class Exchange < ApplicationRecord
where('exchanges.incoming OR exchanges.receiver_id = ?', distributor)
}
scope :with_variant, lambda { |variant|
joins(:exchange_variants).where('exchange_variants.variant_id = ?', variant)
joins(:exchange_variants).where(exchange_variants: { variant_id: variant })
}
scope :with_any_variant, lambda { |variant_ids|
joins(:exchange_variants).
@@ -57,7 +54,7 @@ class Exchange < ApplicationRecord
}
scope :with_product, lambda { |product|
joins(:exchange_variants).
where('exchange_variants.variant_id IN (?)', product.variants.select(&:id))
where(exchange_variants: { variant_id: product.variants.select(&:id) })
}
scope :by_enterprise_name, -> {
joins('INNER JOIN enterprises AS sender ON (sender.id = exchanges.sender_id)').

View File

@@ -1,14 +1,10 @@
# frozen_string_literal: true
class InventoryItem < ApplicationRecord
self.belongs_to_required_by_default = false
belongs_to :enterprise
belongs_to :variant, class_name: "Spree::Variant"
validates :variant_id, uniqueness: { scope: :enterprise_id }
validates :enterprise, presence: true
validates :variant, presence: true
validates :visible,
inclusion: { in: [true, false], message: I18n.t(:inventory_item_visibility_error) }

View File

@@ -3,8 +3,6 @@
require 'open_food_network/scope_variant_to_hub'
class OrderCycle < ApplicationRecord
self.belongs_to_required_by_default = false
searchable_attributes :orders_open_at, :orders_close_at, :coordinator_id
searchable_scopes :active, :inactive, :active_or_complete, :upcoming, :closed, :not_closed,
:dated, :undated, :soonest_opening, :soonest_closing, :most_recently_closed
@@ -44,7 +42,7 @@ class OrderCycle < ApplicationRecord
before_update :reset_processed_at, if: :will_save_change_to_orders_close_at?
after_save :sync_subscriptions, if: :opening?
validates :name, :coordinator_id, presence: true
validates :name, presence: true
validate :orders_close_at_after_orders_open_at?
preference :product_selection_from_coordinator_inventory_only, :boolean, default: false
@@ -165,13 +163,13 @@ class OrderCycle < ApplicationRecord
def attachable_distributor_payment_methods
DistributorPaymentMethod.joins(:payment_method).
merge(Spree::PaymentMethod.available).
where("distributor_id IN (?)", distributor_ids)
where(distributor_id: distributor_ids)
end
def attachable_distributor_shipping_methods
DistributorShippingMethod.joins(:shipping_method).
merge(Spree::ShippingMethod.frontend).
where("distributor_id IN (?)", distributor_ids)
where(distributor_id: distributor_ids)
end
def clone!

View File

@@ -56,7 +56,7 @@ module ProductImport
else
Spree::Variant.
joins(:product).
where('spree_products.supplier_id IN (?)', enterprise_id).
where(spree_products: { supplier_id: enterprise_id }).
count
end

View File

@@ -24,7 +24,6 @@ module ProductImport
def self.non_updatable_fields
{
category: :primary_taxon_id,
description: :description,
unit_type: :variant_unit_scale,
variant_unit_name: :variant_unit_name,
@@ -69,7 +68,7 @@ module ProductImport
def mark_as_new_variant(entry, product_id)
variant_attributes = entry.assignable_attributes.except(
'id', 'product_id', 'on_hand', 'on_demand', 'variant_unit', 'variant_unit_name',
'variant_unit_scale', 'primary_taxon_id'
'variant_unit_scale'
)
# Variant needs a product. Product needs to be assigned first in order for
# delegate to work. name= will fail otherwise.
@@ -398,7 +397,7 @@ module ProductImport
def mark_as_existing_variant(entry, existing_variant)
existing_variant.assign_attributes(
entry.assignable_attributes.except('id', 'product_id', 'variant_unit', 'variant_unit_name',
'variant_unit_scale', 'primary_taxon_id')
'variant_unit_scale')
)
check_on_hand_nil(entry, existing_variant)

View File

@@ -94,7 +94,7 @@ module ProductImport
units = UnitConverter.new(attrs)
units.converted_attributes.each do |attr, value|
if respond_to?("#{attr}=") && !NON_PRODUCT_ATTRIBUTES.include?(attr)
if respond_to?("#{attr}=") && NON_PRODUCT_ATTRIBUTES.exclude?(attr)
public_send("#{attr}=", value)
end
end

View File

@@ -17,7 +17,7 @@ class ProxyOrder < ApplicationRecord
scope :closed, -> { joins(:order_cycle).merge(OrderCycle.closed) }
scope :not_closed, -> { joins(:order_cycle).merge(OrderCycle.not_closed) }
scope :canceled, -> { where.not(proxy_orders: { canceled_at: nil }) }
scope :not_canceled, -> { where('proxy_orders.canceled_at IS NULL') }
scope :not_canceled, -> { where(proxy_orders: { canceled_at: nil }) }
scope :placed_and_open, -> {
joins(:order).not_closed
.where(spree_orders: { state: ['complete', 'resumed'] })

View File

@@ -8,7 +8,8 @@ class Schedule < ApplicationRecord
has_many :coordinators, -> { distinct }, through: :order_cycles
scope :with_coordinator, lambda { |enterprise|
joins(:order_cycles).where('coordinator_id = ?', enterprise.id)
joins(:order_cycles)
.where(order_cycles: { coordinator_id: enterprise.id })
.select('DISTINCT schedules.*')
}

View File

@@ -192,7 +192,7 @@ module Spree
OpenFoodNetwork::Permissions.new(user).managed_product_enterprises.include? product.supplier
end
can [:admin, :index], :products_v3
can [:admin, :index, :bulk_update], :products_v3
can [:create], Spree::Variant
can [:admin, :index, :read, :edit,

View File

@@ -4,19 +4,17 @@ module Spree
class Address < ApplicationRecord
include AddressDisplay
self.belongs_to_required_by_default = false
searchable_attributes :firstname, :lastname, :phone, :full_name, :full_name_reversed,
:full_name_with_comma, :full_name_with_comma_reversed
searchable_associations :country, :state
belongs_to :country, class_name: "Spree::Country"
belongs_to :state, class_name: "Spree::State"
belongs_to :state, class_name: "Spree::State", optional: true
has_one :enterprise, dependent: :restrict_with_exception
has_many :shipments
has_many :shipments, dependent: :restrict_with_exception
validates :address1, :city, :country, :phone, presence: true
validates :address1, :city, :phone, presence: true
validates :company, presence: true, unless: -> { first_name.blank? || last_name.blank? }
validates :firstname, :lastname, presence: true, if: -> do
company.blank? || company == 'unused'

View File

@@ -44,9 +44,9 @@ module Spree
# Given an object which might be an Order or a LineItem (amongst
# others), return a collection of line items.
def line_items_for(object)
if object.is_a?(Spree::LineItem)
[object]
elsif object.respond_to? :line_items
return [object] if object.is_a?(Spree::LineItem)
if object.respond_to? :line_items
object.line_items
elsif object.respond_to?(:order) && object.order.present?
object.order.line_items

View File

@@ -152,7 +152,7 @@ module Spree
end
def default_missing?
!user.credit_cards.exists?(is_default: true)
!user.credit_cards.where(is_default: true).exists?
end
def default_card_needs_updating?

View File

@@ -85,7 +85,7 @@ module Spree
scope :from_order_cycle, lambda { |order_cycle|
joins(order: :order_cycle).
where('order_cycles.id = ?', order_cycle)
where(order_cycles: { id: order_cycle })
}
# Here we are simply joining the line item to its variant and product
@@ -94,12 +94,12 @@ module Spree
scope :supplied_by_any, lambda { |enterprises|
product_ids = Spree::Product.unscoped.where(supplier_id: enterprises).select(:id)
variant_ids = Spree::Variant.unscoped.where(product_id: product_ids).select(:id)
where("spree_line_items.variant_id IN (?)", variant_ids)
where(spree_line_items: { variant_id: variant_ids })
}
scope :with_tax, -> {
joins(:adjustments).
where('spree_adjustments.originator_type = ?', 'Spree::TaxRate').
where(spree_adjustments: { originator_type: 'Spree::TaxRate' }).
select('DISTINCT spree_line_items.*')
}
@@ -110,7 +110,7 @@ module Spree
ON (spree_adjustments.adjustable_id=spree_line_items.id
AND spree_adjustments.adjustable_type = 'Spree::LineItem'
AND spree_adjustments.originator_type='Spree::TaxRate')").
where('spree_adjustments.id IS NULL')
where(spree_adjustments: { id: nil })
}
def copy_price

View File

@@ -141,7 +141,7 @@ module Spree
if user.has_spree_role?('admin')
where(nil)
else
where('spree_orders.distributor_id IN (?)', user.enterprises.select(&:id))
where(spree_orders: { distributor_id: user.enterprises.select(&:id) })
end
}
@@ -165,6 +165,7 @@ module Spree
scope :finalized, -> { where(state: FINALIZED_STATES) }
scope :complete, -> { where.not(completed_at: nil) }
scope :incomplete, -> { where(completed_at: nil) }
scope :invoiceable, -> { where(state: [:complete, :resumed]) }
scope :by_state, lambda { |state| where(state:) }
scope :not_state, lambda { |state| where.not(state:) }
@@ -213,10 +214,6 @@ module Spree
completed_at.present?
end
def invoiceable?
complete? || resumed?
end
# Indicates whether or not the user is allowed to proceed to checkout.
# Currently this is implemented as a check for whether or not there is at
# least one LineItem in the Order. Feel free to override this logic in your
@@ -697,7 +694,7 @@ module Spree
end
def registered_email?
Spree::User.exists?(email:)
Spree::User.where(email:).exists?
end
def adjustments_fetcher

View File

@@ -8,7 +8,6 @@ module Spree
class_attribute :next_event_transitions
class_attribute :previous_states
class_attribute :checkout_flow
class_attribute :checkout_steps
def self.checkout_flow(&block)
if block_given?
@@ -20,7 +19,6 @@ module Spree
end
def self.define_state_machine!
self.checkout_steps = {}
self.next_event_transitions = []
self.previous_states = [:cart]
@@ -97,7 +95,6 @@ module Spree
end
def self.go_to_state(name, options = {})
checkout_steps[name] = options
previous_states.each do |state|
add_transition({ from: state, to: name }.merge(options))
end
@@ -112,30 +109,14 @@ module Spree
@next_event_transitions ||= []
end
def self.checkout_steps
@checkout_steps ||= {}
end
def self.add_transition(options)
next_event_transitions << { options.delete(:from) => options.delete(:to) }.
merge(options)
end
def checkout_steps
steps = self.class.checkout_steps.
each_with_object([]) { |(step, options), checkout_steps|
next if options.include?(:if) && !options[:if].call(self)
checkout_steps << step
}.map(&:to_s)
# Ensure there is always a complete step
steps << "complete" unless steps.include?("complete")
steps
end
def restart_checkout_flow
update_columns(
state: checkout_steps.first,
state: "address",
updated_at: Time.zone.now,
)
end

View File

@@ -246,7 +246,7 @@ module Spree
# and this is it. Related to #1998.
# See https://github.com/spree/spree/issues/1998#issuecomment-12869105
def set_unique_identifier
self.identifier = generate_identifier while self.class.exists?(identifier:)
self.identifier = generate_identifier while self.class.where(identifier:).exists?
end
def generate_identifier

View File

@@ -29,8 +29,7 @@ module Spree
return where(nil) if user.admin?
joins(:distributors).
where('distributors_payment_methods.distributor_id IN (?)',
user.enterprises.select(&:id)).
where(distributors_payment_methods: { distributor_id: user.enterprises.select(&:id) }).
select('DISTINCT spree_payment_methods.*')
}
@@ -40,7 +39,7 @@ module Spree
}
scope :for_distributor, ->(distributor) {
joins(:distributors).where('enterprises.id = ?', distributor)
joins(:distributors).where(enterprises: { id: distributor })
}
scope :for_subscriptions, -> { where(type: Subscription::ALLOWED_PAYMENT_METHOD_TYPES) }

View File

@@ -25,6 +25,10 @@ module Spree
ActiveMerchant::Billing::Response.new(true, "", {}, {})
end
def payment_source_class
nil
end
def source_required?
false
end

View File

@@ -16,9 +16,7 @@ module Spree
def value
if self[:value_type].present?
case self[:value_type].to_sym
when :string, :text
self[:value].to_s
when :password
when :string, :text, :password
self[:value].to_s
when :decimal
BigDecimal(self[:value].to_s, exception: false)&.round(2, BigDecimal::ROUND_HALF_UP) ||

View File

@@ -111,9 +111,7 @@ module Spree
def convert_preference_value(value, type)
case type
when :string, :text
value.to_s
when :password
when :string, :text, :password
value.to_s
when :decimal
value = 0 if value.blank?

View File

@@ -28,16 +28,11 @@ module Spree
acts_as_paranoid
after_create :ensure_standard_variant
around_destroy :destruction
after_save :update_units
searchable_attributes :supplier_id, :primary_taxon_id, :meta_keywords, :sku
searchable_associations :supplier, :properties, :primary_taxon, :variants
searchable_attributes :supplier_id, :meta_keywords, :sku
searchable_associations :supplier, :properties, :variants
searchable_scopes :active, :with_properties
belongs_to :supplier, class_name: 'Enterprise', optional: false, touch: true
belongs_to :primary_taxon, class_name: 'Spree::Taxon', optional: false, touch: true
has_one :image, class_name: "Spree::Image", as: :viewable, dependent: :destroy
@@ -77,7 +72,11 @@ module Spree
# Transient attributes used temporarily when creating a new product,
# these values are persisted on the product's variant
attr_accessor :price, :display_as, :unit_value, :unit_description, :tax_category_id,
:shipping_category_id
:shipping_category_id, :primary_taxon_id
after_create :ensure_standard_variant
around_destroy :destruction
after_save :update_units
scope :with_properties, ->(*property_ids) {
left_outer_joins(:product_properties).
@@ -160,7 +159,7 @@ module Spree
scope :in_order_cycle, lambda { |order_cycle|
with_order_cycles_inner.
merge(Exchange.outgoing).
where('order_cycles.id = ?', order_cycle)
where(order_cycles: { id: order_cycle })
}
scope :in_an_active_order_cycle, lambda {
@@ -177,7 +176,7 @@ module Spree
if user.has_spree_role?('admin')
where(nil)
else
where('supplier_id IN (?)', user.enterprises.select("enterprises.id"))
where(supplier_id: user.enterprises.select("enterprises.id"))
end
}
@@ -188,10 +187,10 @@ module Spree
.with_permission(:add_to_order_cycle)
.where(enterprises: { is_primary_producer: true })
.pluck(:parent_id)
where('spree_products.supplier_id IN (?)', [enterprise.id] | permitted_producer_ids)
where(spree_products: { supplier_id: [enterprise.id] | permitted_producer_ids })
}
scope :active, lambda { where("spree_products.deleted_at IS NULL") }
scope :active, lambda { where(spree_products: { deleted_at: nil }) }
def self.group_by_products_id
group(column_names.map { |col_name| "#{table_name}.#{col_name}" })
@@ -266,8 +265,8 @@ module Spree
touch_distributors
ExchangeVariant.
where('exchange_variants.variant_id IN (?)', variants.with_deleted.
select(:id)).destroy_all
where(exchange_variants: { variant_id: variants.with_deleted.
select(:id) }).destroy_all
yield
end
@@ -284,6 +283,7 @@ module Spree
variant.unit_description = unit_description
variant.tax_category_id = tax_category_id
variant.shipping_category_id = shipping_category_id
variant.primary_taxon_id = primary_taxon_id
variants << variant
end

View File

@@ -2,12 +2,9 @@
module Spree
class ProductProperty < ApplicationRecord
self.belongs_to_required_by_default = false
belongs_to :product, class_name: "Spree::Product", touch: true
belongs_to :property, class_name: 'Spree::Property'
validates :property, presence: true
validates :value, length: { maximum: 255 }
default_scope -> { order("#{table_name}.position") }

View File

@@ -2,8 +2,6 @@
module Spree
class ReturnAuthorization < ApplicationRecord
self.belongs_to_required_by_default = false
acts_as_paranoid
belongs_to :order, class_name: 'Spree::Order', inverse_of: :return_authorizations
@@ -13,7 +11,6 @@ module Spree
before_save :force_positive_amount
before_create :generate_number
validates :order, presence: true
validates :amount, numericality: true
validate :must_have_shipped_units

View File

@@ -41,8 +41,7 @@ module Spree
where(nil)
else
joins(:distributors).
where('distributors_shipping_methods.distributor_id IN (?)',
user.enterprises.select(&:id)).
where(distributors_shipping_methods: { distributor_id: user.enterprises.select(&:id) }).
select('DISTINCT spree_shipping_methods.*')
end
}
@@ -53,7 +52,7 @@ module Spree
}
scope :for_distributor, lambda { |distributor|
joins(:distributors).
where('enterprises.id = ?', distributor)
where(enterprises: { id: distributor })
}
scope :by_name, -> { order('spree_shipping_methods.name ASC') }

View File

@@ -2,11 +2,9 @@
module Spree
class State < ApplicationRecord
self.belongs_to_required_by_default = false
belongs_to :country, class_name: 'Spree::Country'
validates :country, :name, presence: true
validates :name, presence: true
def self.find_all_by_name_or_abbr(name_or_abbr)
where('name = ? OR abbr = ?', name_or_abbr, name_or_abbr)

View File

@@ -2,15 +2,12 @@
module Spree
class StockItem < ApplicationRecord
self.belongs_to_required_by_default = false
acts_as_paranoid
belongs_to :stock_location, class_name: 'Spree::StockLocation', inverse_of: :stock_items
belongs_to :variant, -> { with_deleted }, class_name: 'Spree::Variant'
has_many :stock_movements
has_many :stock_movements, dependent: :destroy
validates :stock_location, :variant, presence: true
validates :variant_id, uniqueness: { scope: [:stock_location_id, :deleted_at] }
validates :count_on_hand, numericality: { greater_than_or_equal_to: 0, unless: :backorderable? }

View File

@@ -2,22 +2,15 @@
module Spree
class StockMovement < ApplicationRecord
self.belongs_to_required_by_default = false
belongs_to :stock_item, class_name: 'Spree::StockItem'
belongs_to :originator, polymorphic: true
belongs_to :originator, polymorphic: true, optional: true
after_create :update_stock_item_quantity
validates :stock_item, presence: true
validates :quantity, presence: true
scope :recent, -> { order('created_at DESC') }
def readonly?
!new_record?
end
private
def update_stock_item_quantity

View File

@@ -21,7 +21,7 @@ module Spree
belongs_to :zone, class_name: "Spree::Zone", inverse_of: :tax_rates
belongs_to :tax_category, class_name: "Spree::TaxCategory", inverse_of: :tax_rates
has_many :adjustments, as: :originator
has_many :adjustments, as: :originator, dependent: nil
validates :amount, presence: true, numericality: true
validates :tax_category, presence: true

View File

@@ -7,9 +7,12 @@ module Spree
acts_as_nested_set dependent: :destroy
belongs_to :taxonomy, class_name: 'Spree::Taxonomy', touch: true
has_many :products, class_name: "Spree::Product", foreign_key: "primary_taxon_id",
has_many :variants, class_name: "Spree::Variant", foreign_key: "primary_taxon_id",
inverse_of: :primary_taxon, dependent: :restrict_with_error
has_many :products, through: :variants, dependent: nil
before_create :set_permalink
validates :name, presence: true
@@ -77,7 +80,7 @@ module Spree
taxons = Spree::Taxon
.select("DISTINCT spree_taxons.id, ents_and_vars.enterprise_id")
.joins(products: :variants)
.joins(:variants)
.joins("
INNER JOIN (#{ents_and_vars.to_sql}) AS ents_and_vars
ON spree_variants.id = ents_and_vars.variant_id")

View File

@@ -13,8 +13,8 @@ module Spree
acts_as_paranoid
searchable_attributes :sku, :display_as, :display_name
searchable_associations :product, :default_price
searchable_attributes :sku, :display_as, :display_name, :primary_taxon_id
searchable_associations :product, :default_price, :primary_taxon
searchable_scopes :active, :deleted
NAME_FIELDS = ["display_name", "display_as", "weight", "unit_value", "unit_description"].freeze
@@ -28,11 +28,12 @@ module Spree
belongs_to :product, -> { with_deleted }, touch: true, class_name: 'Spree::Product'
belongs_to :tax_category, class_name: 'Spree::TaxCategory'
belongs_to :shipping_category, class_name: 'Spree::ShippingCategory', optional: false
belongs_to :primary_taxon, class_name: 'Spree::Taxon', touch: true, optional: false
delegate :name, :name=, :description, :description=, :meta_keywords, to: :product
has_many :inventory_units, inverse_of: :variant
has_many :line_items, inverse_of: :variant
has_many :inventory_units, inverse_of: :variant, dependent: nil
has_many :line_items, inverse_of: :variant, dependent: nil
has_many :stock_items, dependent: :destroy, inverse_of: :variant
has_many :stock_locations, through: :stock_items
@@ -52,7 +53,7 @@ module Spree
:currency, :currency=,
to: :find_or_build_default_price
has_many :exchange_variants
has_many :exchange_variants, dependent: nil
has_many :exchanges, through: :exchange_variants
has_many :variant_overrides, dependent: :destroy
has_many :inventory_items, dependent: :destroy
@@ -82,6 +83,7 @@ module Spree
before_validation :ensure_unit_value
before_validation :update_weight_from_unit_value, if: ->(v) { v.product.present? }
before_validation :convert_variant_weight_to_decimal
before_validation :assign_related_taxon, if: ->(v) { v.primary_taxon.blank? }
before_save :assign_units, if: ->(variant) {
variant.new_record? || variant.changed_attributes.keys.intersection(NAME_FIELDS).any?
@@ -99,7 +101,7 @@ module Spree
scope :in_order_cycle, lambda { |order_cycle|
with_order_cycles_inner.
merge(Exchange.outgoing).
where('order_cycles.id = ?', order_cycle).
where(order_cycles: { id: order_cycle }).
select('DISTINCT spree_variants.*')
}
@@ -111,8 +113,8 @@ module Spree
}
scope :for_distribution, lambda { |order_cycle, distributor|
where('spree_variants.id IN (?)', order_cycle.variants_distributed_by(distributor).
select(&:id))
where(spree_variants: { id: order_cycle.variants_distributed_by(distributor).
select(&:id) })
}
scope :visible_for, lambda { |enterprise|
@@ -159,12 +161,12 @@ module Spree
def self.active(currency = nil)
# "where(id:" is necessary so that the returned relation has no includes
# The relation without includes will not be readonly and allow updates on it
where("spree_variants.id in (?)", joins(:prices).
where(spree_variants: { id: joins(:prices).
where(deleted_at: nil).
where('spree_prices.currency' =>
currency || CurrentConfig.get(:currency)).
where.not(spree_prices: { amount: nil }).
select("spree_variants.id"))
select("spree_variants.id") })
end
def tax_category
@@ -208,6 +210,10 @@ module Spree
private
def assign_related_taxon
self.primary_taxon ||= product.variants.last&.primary_taxon
end
def check_currency
return unless currency.nil?

View File

@@ -34,8 +34,8 @@ class Subscription < ApplicationRecord
where('subscriptions.ends_at > (?) OR subscriptions.ends_at IS NULL',
Time.zone.now)
}
scope :not_canceled, -> { where('subscriptions.canceled_at IS NULL') }
scope :not_paused, -> { where('subscriptions.paused_at IS NULL') }
scope :not_canceled, -> { where(subscriptions: { canceled_at: nil }) }
scope :not_paused, -> { where(subscriptions: { paused_at: nil }) }
scope :active, -> {
not_canceled.not_ended.not_paused.where('subscriptions.begins_at <= (?)',
Time.zone.now)

View File

@@ -20,7 +20,7 @@ class ProductScopeQuery
product_query.
ransack(query_params_with_defaults).
result
result(distinct: true)
end
def find_product

View File

@@ -21,7 +21,8 @@ module Admin
def ship
@order.send_shipment_email = false unless params[:send_shipment_email]
if @order.ship
return set_param_for_controller if request.url.match?('edit')
paths = %w[edit customer payments adjustments invoices return_authorizations].freeze
return set_param_for_controller if Regexp.union(paths).match? request.url
morph dom_id(@order), render(partial: "spree/admin/orders/table_row",
locals: { order: @order.reload, success: true })
@@ -32,11 +33,18 @@ module Admin
end
def bulk_invoice(params)
visible_orders = editable_orders.where(id: params[:bulk_ids]).filter(&:invoiceable?)
if Spree::Config.enterprise_number_required_on_invoices? &&
!all_distributors_can_invoice?(visible_orders)
render_business_number_required_error(visible_orders)
return
visible_orders = editable_orders.invoiceable.where(id: params[:bulk_ids])
if Spree::Config.enterprise_number_required_on_invoices?
distributors_without_abn = Enterprise.where(
id: visible_orders.select(:distributor_id),
abn: nil,
)
if distributors_without_abn.exists?
render_business_number_required_error(distributors_without_abn)
return
end
end
cable_ready.append(
@@ -44,8 +52,13 @@ module Admin
html: render(partial: "spree/admin/orders/bulk/invoice_modal")
).broadcast
# Preserve order of bulk_ids.
# The ids are supplied in the sequence of the orders screen and may be
# sorted, for example by last name of the customer.
visible_order_ids = params[:bulk_ids].map(&:to_i) & visible_orders.pluck(:id)
BulkInvoiceJob.perform_later(
visible_orders.pluck(:id),
visible_order_ids,
"tmp/invoices/#{Time.zone.now.to_i}-#{SecureRandom.hex(2)}.pdf",
channel: SessionChannel.for_request(request),
current_user_id: current_user.id
@@ -82,8 +95,8 @@ module Admin
def send_invoices(params)
count = 0
editable_orders.where(id: params[:bulk_ids]).find_each do |o|
next unless o.distributor.can_invoice? && o.invoiceable?
editable_orders.invoiceable.where(id: params[:bulk_ids]).find_each do |o|
next unless o.distributor.can_invoice?
Spree::OrderMailer.invoice_email(o.id, current_user_id: current_user.id).deliver_later
count += 1
@@ -114,14 +127,8 @@ module Admin
params[:id] = @order.number
end
def all_distributors_can_invoice?(orders)
distributor_ids = orders.map(&:distributor_id)
Enterprise.where(id: distributor_ids, abn: nil).empty?
end
def render_business_number_required_error(orders)
distributor_ids = orders.map(&:distributor_id)
distributor_names = Enterprise.where(id: distributor_ids, abn: nil).pluck(:name)
def render_business_number_required_error(distributors)
distributor_names = distributors.pluck(:name)
flash[:error] = I18n.t(:must_have_valid_business_number,
enterprise_name: distributor_names.join(", "))

View File

@@ -5,10 +5,6 @@ class ProductsReflex < ApplicationReflex
before_reflex :init_filters_params, :init_pagination_params
def fetch
fetch_and_render_products_with_flash
end
def change_per_page
@per_page = element.value.to_i
@page = 1
@@ -16,12 +12,6 @@ class ProductsReflex < ApplicationReflex
fetch_and_render_products_with_flash
end
def filter
@page = 1
fetch_and_render_products_with_flash
end
def clear_search
@search_term = nil
@producer_id = nil
@@ -31,21 +21,6 @@ class ProductsReflex < ApplicationReflex
fetch_and_render_products_with_flash
end
def bulk_update
product_set = product_set_from_params
product_set.collection.each { |p| authorize! :update, p }
@products = product_set.collection # use instance variable mainly for testing
if product_set.save
flash[:success] = I18n.t('admin.products_v3.bulk_update.success')
elsif product_set.errors.present?
@error_counts = { saved: product_set.saved_count, invalid: product_set.invalid.count }
end
render_products_form_with_flash
end
def delete_product
id = current_id_from_element(element)
product = product_finder(id).find_product
@@ -114,8 +89,8 @@ class ProductsReflex < ApplicationReflex
html: render(partial: "admin/products_v3/content",
locals: { products: @products, pagy: @pagy, search_term: @search_term,
producer_options: producers, producer_id: @producer_id,
category_options: categories, category_id: @category_id,
flashes: flash })
category_options: categories, tax_category_options:,
category_id: @category_id, flashes: flash })
)
cable_ready.replace_state(
@@ -150,9 +125,13 @@ class ProductsReflex < ApplicationReflex
Spree::Taxon.order(:name).map { |c| [c.name, c.id] }
end
def tax_category_options
Spree::TaxCategory.order(:name).pluck(:name, :id)
end
def fetch_products
product_query = OpenFoodNetwork::Permissions.new(current_user)
.editable_products.merge(product_scope).ransack(ransack_query).result
.editable_products.merge(product_scope).ransack(ransack_query).result(distinct: true)
@pagy, @products = pagy(product_query.order(:name), items: @per_page, page: @page,
size: [1, 2, 2, 1])
end
@@ -173,7 +152,7 @@ class ProductsReflex < ApplicationReflex
if @search_term.present?
query.merge!(Spree::Variant::SEARCH_KEY => @search_term)
end
query.merge!(primary_taxon_id_in: @category_id) if @category_id.present?
query.merge!(variants_primary_taxon_id_in: @category_id) if @category_id.present?
query
end

View File

@@ -8,7 +8,6 @@ module Api
:thumb_url, :variants
has_one :supplier, key: :producer_id, embed: :id
has_one :primary_taxon, key: :category_id, embed: :id
def variants
ActiveModel::ArraySerializer.new(

View File

@@ -8,6 +8,8 @@ module Api
:display_as, :display_name, :name_to_display, :variant_overrides_count,
:price, :on_demand, :on_hand, :in_stock, :stock_location_id, :stock_location_name
has_one :primary_taxon, key: :category_id, embed: :id
def name
if object.full_name.present?
"#{object.name} - #{object.full_name}"

View File

@@ -145,7 +145,7 @@ module Api
require_shipping = type == :delivery ? 't' : 'f'
Spree::ShippingMethod.
joins(:distributor_shipping_methods).
where('distributors_shipping_methods.distributor_id = ?', enterprise.id).
where(distributors_shipping_methods: { distributor_id: enterprise.id }).
where("spree_shipping_methods.require_ship_address = '#{require_shipping}'").exists?
end
end

View File

@@ -16,7 +16,7 @@ module Api
end
def payments
object.payments.joins(:payment_method).where('state IN (?)', %w(completed pending))
object.payments.joins(:payment_method).where(state: %w(completed pending))
end
def shop_id

View File

@@ -9,8 +9,6 @@ class Api::ProductSerializer < ActiveModel::Serializer
has_many :variants, serializer: Api::VariantSerializer
has_one :primary_taxon, serializer: Api::TaxonSerializer
has_one :image, serializer: Api::ImageSerializer
has_one :supplier, serializer: Api::IdSerializer

View File

@@ -0,0 +1,15 @@
# frozen_string_literal: true
# Keeps only allowed HTML.
#
# We store some rich text as HTML in attributes of models like Enterprise.
# We offer an editor which supports certain tags but you can't insert just any
# HTML, which would be dangerous.
class HtmlSanitizer
def self.sanitize(html)
@sanitizer ||= Rails::HTML5::SafeListSanitizer.new
@sanitizer.sanitize(
html, tags: %w[h1 h2 h3 h4 p br b i u a], attributes: %w[href target],
)
end
end

View File

@@ -15,6 +15,22 @@ module OrderCycles
Spree::Product.where(id: stocked_products).group("spree_products.id")
end
# Joins on the first product variant to allow us to filter product by taxon. This is so
# enterprise can display product sorted by category in a custom order on their shopfront.
#
# Caveat, the category sorting won't work properly if there are multiple variant with different
# category for a given product.
#
def products_taxons_relation
Spree::Product.where(id: stocked_products).
joins("LEFT JOIN (
SELECT DISTINCT ON(product_id) id, product_id, primary_taxon_id
FROM spree_variants WHERE deleted_at IS NULL
) first_variant ON spree_products.id = first_variant.product_id").
select("spree_products.*, first_variant.primary_taxon_id").
group("spree_products.id, first_variant.primary_taxon_id")
end
def variants_relation
order_cycle.
variants_distributed_by(distributor).

View File

@@ -7,7 +7,7 @@ module PermittedAttributes
:id, :sku, :on_hand, :on_demand, :shipping_category_id,
:price, :unit_value, :unit_description,
:display_name, :display_as, :tax_category_id,
:weight, :height, :width, :depth
:weight, :height, :width, :depth, :taxon_ids, :primary_taxon_id
]
end
end

View File

@@ -35,7 +35,7 @@ class ProductsRenderer
@products ||= begin
results = distributed_products.
products_relation.
products_taxons_relation.
order(Arel.sql(products_order))
filter_and_paginate(results).
@@ -54,7 +54,7 @@ class ProductsRenderer
def filter_and_paginate(query)
results = query.ransack(args[:q]).result
_pagy, paginated_results = pagy(
_pagy, paginated_results = pagy_arel(
results,
page: args[:page] || 1,
items: args[:per_page] || DEFAULT_PER_PAGE
@@ -78,7 +78,7 @@ class ProductsRenderer
distributor.preferred_shopfront_taxon_order.present?
distributor
.preferred_shopfront_taxon_order
.split(",").map { |id| "spree_products.primary_taxon_id=#{id} DESC" }
.split(",").map { |id| "first_variant.primary_taxon_id=#{id} DESC" }
.join(", ") + ", spree_products.name ASC, spree_products.id ASC"
else
"spree_products.name ASC, spree_products.id"

View File

@@ -46,18 +46,12 @@ module Sets
# variant.update( { price: xx.x } )
#
def update_product_attributes(attributes)
split_taxon_ids!(attributes)
product = find_model(@collection, attributes[:id])
return if product.nil?
update_product(product, attributes)
end
def split_taxon_ids!(attributes)
attributes[:taxon_ids] = attributes[:taxon_ids].split(',') if attributes[:taxon_ids].present?
end
def update_product(product, attributes)
return false unless update_product_only_attributes(product, attributes)

View File

@@ -1,4 +1,8 @@
#products-content
%turbo-frame#products-content{ target: "_top", refresh: "morph" }
.spinner-overlay{ "data-controller": "loading", "data-products-target": "loading", class: "hidden" }
.spinner-container
.spinner
= t('.loading')
.container
.sixteen.columns
= render partial: 'admin/shared/flashes', locals: { flashes: } if defined? flashes
@@ -11,9 +15,9 @@
.container.results
.sixteen.columns
= render partial: 'sort', locals: { pagy: pagy, search_term: search_term, producer_id: producer_id, category_id: category_id }
= render partial: 'table', locals: { products: products }
- if pagy.pages > 1
= render partial: 'admin/shared/v3/pagy', locals: { pagy: pagy, reflex: "click->Products#fetch" }
= render partial: 'table', locals: { products:, producer_options:, category_options:, tax_category_options: }
- if pagy.present? && pagy.pages > 1
= render partial: 'admin/shared/stimulus_pagination', locals: { pagy: pagy }
- else
#no-products
= render partial: "no_products", locals: { search_term: search_term, producer_id: producer_id, category_id: category_id }

View File

@@ -1,4 +1,8 @@
%form{ id: "filters", 'data-reflex-serialize-form': true, 'data-reflex': 'submit->products#filter' }
= form_with url: admin_products_path, id: "filters", method: :get, data: { "search-target": "form", 'turbo-frame': "_self" } do
= hidden_field_tag :page, nil, class: "page"
= hidden_field_tag :per_page, nil, class: "per-page"
= hidden_field_tag '[q][s]', params.dig(:q, :s) || 'name asc', class: 'sort', 'data-default': 'name asc'
.query
.search-input
= text_field_tag :search_term, search_term, placeholder: t('.search_products')
@@ -15,4 +19,4 @@
data: { "controller": "tom-select", 'tom-select-placeholder-value': t('.search_for_categories')}
.submit
.search-button
= button_tag t(".search"), class: "secondary icon-search relaxed"
= button_tag t(".search"), class: "secondary icon-search relaxed", name: nil

View File

@@ -2,14 +2,16 @@
%a.image-field{ href: admin_product_images_path(product), data: { controller: "modal", reflex: "click->products#edit_image", "current-id": product.id} }
= image_tag product.image&.url(:mini) || Spree::Image.default_image_url(:mini), width: 40, height: 40
.button.secondary.mini= t('admin.products_page.image.edit')
%td.field.align-left.header
%td.field.align-left.header.naked_inputs
= f.hidden_field :id
= f.text_field :name, 'aria-label': t('admin.products_page.columns.name')
= error_message_on product, :name
%td.field
%td.field.naked_inputs
= f.text_field :sku, 'aria-label': t('admin.products_page.columns.sku')
= error_message_on product, :sku
%td.multi-field{ 'data-controller': 'toggle-control', 'data-toggle-control-match-value': 'items' }
%td.field.naked_inputs{ 'data-controller': 'toggle-control', 'data-toggle-control-match-value': 'items' }
= f.hidden_field :variant_unit
= f.hidden_field :variant_unit_scale
= f.select :variant_unit_with_scale,
options_for_select(WeightsAndMeasures.variant_unit_options, product.variant_unit_with_scale),
{},
@@ -25,17 +27,22 @@
-# empty
%td.align-right
-# empty
%td.naked_inputs
= render(SearchableDropdownComponent.new(form: f,
name: :supplier_id,
aria_label: t('.producer_field_name'),
options: producer_options,
selected_option: product.supplier_id,
placeholder_value: t('admin.products_v3.filters.search_for_producers')))
%td.align-left
.content= product.supplier&.name
%td.align-left
.content= product.primary_taxon&.name
-# empty
%td.align-left
%td.align-left
.content= product.inherits_properties ? 'YES' : 'NO' #TODO: consider using https://github.com/RST-J/human_attribute_values, else use I18n.t (also below)
%td.align-right
= render(VerticalEllipsisMenu::Component.new) do
= link_to t('admin.products_page.actions.edit'), edit_admin_product_path(product)
= link_to t('admin.products_page.actions.clone'), clone_admin_product_path(product)
= link_to t('admin.products_page.actions.edit'), edit_admin_product_path(product), 'data-turbo': false
= link_to t('admin.products_page.actions.clone'), clone_admin_product_path(product), 'data-turbo': false
%a{ "data-controller": "modal-link", "data-action": "click->modal-link#setModalDataSetOnConfirm click->modal-link#open",
"data-modal-link-target-value": "product-delete-modal", "class": "delete",
"data-modal-link-modal-dataset-value": {'data-current-id': product.id}.to_json }

View File

@@ -1,9 +1,15 @@
#sort
%div
= t(".pagination.total_html", total: pagy.count, from: pagy.from, to: pagy.to)
- if pagy.present?
= t(".pagination.total_html", total: pagy.count, from: pagy.from, to: pagy.to)
- if search_term.present? || producer_id.present? || category_id.present?
%a{ href: "#", class: "button disruptive", data: { reflex: "click->products#clear_search" } }
= t(".pagination.clear_search")
%a{ href: url_for(page: 1), class: "button disruptive", 'data-turbo-frame': "_self" }
= t(".pagination.clear_search")
%form.with-dropdown
= t(".pagination.per_page.show")
= select_tag :per_page, options_for_select([15, 25, 50, 100].collect{|i| [t('.pagination.per_page.per_page', num: i), i]}, pagy.items), class: "no-input per-page", data: { reflex: "change->products#change_per_page", controller: "tom-select", "tom-select-options-value": '{ "plugins": [] }'}
= select_tag :per_page,
options_for_select([15, 25, 50, 100].collect{|i| [t('.pagination.per_page.per_page', num: i), i]}, pagy&.items),
class: "no-input per-page",
data: { controller: "tom-select search", action: "change->search#changePerPage", "tom-select-options-value": '{ "plugins": [] }'}

View File

@@ -1,17 +1,25 @@
= form_with url: bulk_update_admin_products_path, method: :patch, id: "products-form",
= form_with url: bulk_update_admin_products_path, method: :post, id: "products-form",
builder: BulkFormBuilder,
html: { data: { reflex: 'submit->products#bulk_update', 'reflex-serialize-form': true,
controller: "bulk-form", 'bulk-form-disable-selector-value': "#sort,#filters",
'bulk-form-error-value': defined?(error_counts),
html: { data: { 'turbo-frame': "_self",
controller: "bulk-form",
'bulk-form-disable-selector-value': "#sort,#filters",
'bulk-form-error-value': defined?(@error_counts),
} } do |form|
= render(partial: "admin/shared/flashes", locals: { flashes: }) if defined? flashes
= hidden_field_tag :page, @page
= hidden_field_tag :per_page, @per_page
= hidden_field_tag :search_term, @search_term
= hidden_field_tag :producer_id, @producer_id
= hidden_field_tag :category_id, @category_id
%table.products
%colgroup
%col{ width:"56" }= # Img (size + padding)
%col= # (grow to fill) Name
%col{ width:"8%"}
%col{ width:"8%"}
%col{ width:"5%"}
%col{ width:"8%"}
%col{ width:"8%"}
%col{ width:"5%"}
%col{ width:"10%"}
%col{ width:"15%"}= # Producer
@@ -23,27 +31,29 @@
%tr
%td.form-actions-wrapper{ colspan: 12 }
.form-actions-wrapper2
%fieldset.form-actions{ class: ("hidden" unless defined?(error_counts)), 'data-bulk-form-target': "actions" }
%fieldset.form-actions{ class: ("hidden" unless defined?(@error_counts)), 'data-bulk-form-target': "actions" }
.container
.status
.modified_summary{ 'data-bulk-form-target': "changedSummary", 'data-translation-key': 'admin.products_v3.table.changed_summary'}
- if defined?(error_counts)
- if defined?(@error_counts)
.error_summary
- if error_counts[:saved] > 0
- if @error_counts[:saved] > 0
-# X products were saved correctly, but Y products could not be saved correctly. Please review errors and try again
= t('.error_summary.saved', count: error_counts[:saved]) + t('.error_summary.invalid', count: error_counts[:invalid])
= t('.error_summary.saved', count: @error_counts[:saved]) + t('.error_summary.invalid', count: @error_counts[:invalid])
- else
-# Y products could not be saved correctly. Please review errors and try again
= t('.error_summary.invalid', count: error_counts[:invalid])
= t('.error_summary.invalid', count: @error_counts[:invalid])
.form-buttons
= form.submit t('.reset'), type: :reset, class: "medium", 'data-reflex': 'click->products#fetch'
%a.button.reset.medium{ href: admin_products_path(page: @page, per_page: @per_page, search_term: @search_term, producer_id: @producer_id, category_id: @category_id), 'data-turbo': "false" }
= t('.reset')
= form.submit t('.save'), class: "medium"
%tr
%th.align-left= # image
%th.align-left.with-input= t('admin.products_page.columns.name')
= render partial: 'spree/admin/shared/stimulus_sortable_header',
locals: { column: :name, sorted: params.dig(:q, :s), default: 'name asc' }
%th.align-left.with-input= t('admin.products_page.columns.sku')
%th.align-left.with-input= t('admin.products_page.columns.unit_scale')
%th.align-right= t('admin.products_page.columns.unit')
%th.align-left.with-input= t('admin.products_page.columns.unit')
%th.align-left.with-input= t('admin.products_page.columns.price')
%th.align-left.with-input= t('admin.products_page.columns.on_hand')
%th.align-left= t('admin.products_page.columns.producer')
@@ -53,21 +63,21 @@
%th.align-right= t('admin.products_page.columns.actions')
- products.each_with_index do |product, product_index|
= form.fields_for("products", product, index: product_index) do |product_form|
%tbody.relaxed.naked_inputs{ data: { 'record-id': product_form.object.id,
controller: "nested-form",
action: 'rails-nested-form:add->bulk-form#registerElements' } }
%tbody.relaxed{ data: { 'record-id': product_form.object.id,
controller: "nested-form product",
action: 'rails-nested-form:add->bulk-form#registerElements rails-nested-form:remove->bulk-form#toggleFormChanged' } }
%tr
= render partial: 'product_row', locals: { product:, f: product_form }
= render partial: 'product_row', locals: { f: product_form, product:, producer_options: }
- product.variants.each_with_index do |variant, variant_index|
= form.fields_for("products][#{product_index}][variants_attributes][", variant, index: variant_index) do |variant_form|
%tr.condensed
= render partial: 'variant_row', locals: { variant:, f: variant_form }
%tr.condensed{ 'data-controller': "variant", 'class': "nested-form-wrapper", 'data-new-record': variant.new_record? ? "true" : false }
= render partial: 'variant_row', locals: { variant:, f: variant_form, category_options:, tax_category_options: }
= form.fields_for("products][#{product_index}][variants_attributes][NEW_RECORD", product.variants.build) do |new_variant_form|
%template{ 'data-nested-form-target': "template" }
%tr.condensed
= render partial: 'variant_row', locals: { variant: new_variant_form.object, f: new_variant_form }
%tr.condensed{ 'data-controller': "variant", 'class': "nested-form-wrapper", 'data-new-record': "true" }
= render partial: 'variant_row', locals: { variant: new_variant_form.object, f: new_variant_form, category_options:, tax_category_options: }
%tr{ 'data-nested-form-target': "target" }
%tr.condensed

View File

@@ -1,28 +1,37 @@
%td
-# empty
%td.field
%td.field.naked_inputs
= f.hidden_field :id
= f.text_field :display_name, 'aria-label': t('admin.products_page.columns.name'), placeholder: variant.product.name
= error_message_on variant, :display_name
%td.field
%td.field.naked_inputs
= f.text_field :sku, 'aria-label': t('admin.products_page.columns.sku')
= error_message_on variant, :sku
%td
-# empty
- if variant.persisted?
%td.align-right
.content= variant.unit_to_display
- else # until unit component is developed, use a basic input just so we can create new records
%td.field
= f.number_field :unit_value, 'aria-label': t('admin.products_page.columns.unit')
= error_message_on variant, :unit_value
%td.field
%td.field.popout{'data-controller': "popout", 'data-popout-update-display-value': "false"}
= f.button :unit_to_display, class: "popout__button", 'aria-label': t('admin.products_page.columns.unit'), 'data-popout-target': "button" do
= variant.unit_to_display # Show the generated summary of unit values
%div.popout__container{ style: 'display: none;', 'data-controller': 'toggle-control', 'data-popout-target': "dialog" }
.field
-# Show a composite field for unit_value and unit_description
= f.hidden_field :unit_value
= f.hidden_field :unit_description
-# todo: create a method for value_with_description
= f.text_field :unit_value_with_description,
value: [number_with_precision((variant.unit_value || 1) / (variant.product.variant_unit_scale || 1), precision: nil, strip_insignificant_zeros: true), variant.unit_description].compact_blank.join(" "),
'aria-label': t('admin.products_page.columns.unit_value'), required: true
.field
= f.label :display_as, t('admin.products_page.columns.display_as')
= f.text_field :display_as, placeholder: VariantUnits::OptionValueNamer.new(variant).name
= error_message_on variant, :unit_value
%td.field.naked_inputs
= f.text_field :price, 'aria-label': t('admin.products_page.columns.price'), value: number_to_currency(variant.price, unit: '')&.strip # TODO: add a spec to prove that this formatting is necessary. If so, it should be in a shared form helper for currency inputs
= error_message_on variant, :price
%td.field.on-hand__wrapper{'data-controller': "popout"}
%button.on-hand__button{'data-popout-target': "button", 'aria-label': t('admin.products_page.columns.on_hand')}
%td.field.popout{'data-controller': "popout"}
%button.popout__button{'data-popout-target': "button", 'aria-label': t('admin.products_page.columns.on_hand')}
= variant.on_demand ? t(:on_demand) : variant.on_hand
%div.on-hand__popout{ style: 'display: none;', 'data-controller': 'toggle-control', 'data-popout-target': "dialog" }
%div.popout__container{ style: 'display: none;', 'data-controller': 'toggle-control', 'data-popout-target': "dialog" }
.field
= f.number_field :on_hand, min: 0, 'aria-label': t('admin.products_page.columns.on_hand'), 'data-toggle-control-target': 'control', disabled: f.object.on_demand
= error_message_on variant, :on_hand
@@ -31,19 +40,33 @@
= f.check_box :on_demand, 'data-action': 'change->toggle-control#disableIfPresent change->popout#closeIfChecked'
= t(:on_demand)
%td.align-left
.content= variant.product.supplier&.name # same as product
%td.align-left
-# empty
%td.align-left
.content= variant.tax_category&.name || "None" # TODO: convert to dropdown, else translate hardcoded string.
-# empty producer name
%td.field.naked_inputs
= render(SearchableDropdownComponent.new(form: f,
name: :primary_taxon_id,
options: category_options,
selected_option: variant.primary_taxon_id,
aria_label: t('.category_field_name'),
placeholder_value: t('admin.products_v3.filters.search_for_categories')))
%td.field.naked_inputs
= render(SearchableDropdownComponent.new(form: f,
name: :tax_category_id,
options: tax_category_options,
selected_option: variant.tax_category_id,
include_blank: t('.none_tax_category'),
aria_label: t('.tax_category_field_name'),
placeholder_value: t('.search_for_tax_categories')))
%td.align-left
-# empty
%td.align-right
- if variant.persisted?
= render(VerticalEllipsisMenu::Component.new) do
= render(VerticalEllipsisMenu::Component.new) do
- if variant.persisted?
= link_to t('admin.products_page.actions.edit'), edit_admin_product_variant_path(variant.product, variant)
- if variant.product.variants.size > 1
%a{ "data-controller": "modal-link", "data-action": "click->modal-link#setModalDataSetOnConfirm click->modal-link#open",
"data-modal-link-target-value": "variant-delete-modal", "class": "delete",
"data-modal-link-modal-dataset-value": {'data-current-id': variant.id}.to_json }
= t('admin.products_page.actions.delete')
- else
%a{ 'data-action': "nested-form#remove", class: 'delete' }
= t('admin.products_page.actions.remove')

View File

@@ -1,5 +1,3 @@
- content_for :body_class do
products_v3_page
- content_for :page_title do
= t('.header.title')
- content_for :page_actions do
@@ -8,15 +6,16 @@
%li#new_product_link
= button_link_to t(:new_product), "/admin/products/new", { :icon => 'icon-plus', :id => 'admin_new_product' }
%script= render partial: "admin/shared/global_var_ofn", formats: :js,
locals: { name: :available_units_sorted, value: WeightsAndMeasures.available_units_sorted }
= render partial: 'spree/admin/shared/product_sub_menu'
#products_v3_page{ "data-controller": "products" }
.spinner-overlay{ "data-controller": "loading", "data-products-target": "loading" }
.spinner-container
.spinner
= t('.loading')
#products-content
#products_v3_page{ "data-controller": "products", 'data-turbo': true }
= render partial: "content", locals: { products: @products, pagy: @pagy, search_term: @search_term,
producer_options: producers, producer_id: @producer_id,
category_options: categories, category_id: @category_id,
tax_category_options:, flashes: flash }
- %w[product variant].each do |object_type|
= render partial: 'delete_modal', locals: { object_type: }
#modal-component

View File

@@ -0,0 +1 @@
var ofn_<%= name %> = <%= value.to_json.html_safe %>;

View File

@@ -1,15 +0,0 @@
%nav.pagy_nav.pagination{"aria-label" => "pager", :role => "navigation"}
- if pagy.prev
%a.page.prev{ href: "#", id: "pagy-prev", "data-reflex": reflex, "data-perPage": pagy.items, "data-page": pagy.prev || 1, "aria-label": "previous"}
%i.icon-chevron-left
- pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
- if item.is_a?(Integer) # page link
%a.page{ href: "#", id:"pagy-#{item}", "data-reflex": reflex, "data-perPage": pagy.items, "data-page": item, "aria-label": "page #{item}"}
= item
- elsif item.is_a?(String) # current page
%span.page.current= item
- elsif item == :gap # page gap
%span.page.gap &hellip;
- if pagy.next
%a.page.next{ href: "#", id:"pagy-next", "data-reflex": reflex, "data-perPage": pagy.items, "data-page": pagy.next || pagy.last, "aria-label": "next"}
%i.icon-chevron-right

View File

@@ -96,11 +96,6 @@
#distributor_address.panel
- if shipping_method.description.present?
%span #{shipping_method.description}
%br/
%br/
- if @order.order_cycle.pickup_time_for(@order.distributor)
= t :checkout_ready_for
= @order.order_cycle.pickup_time_for(@order.distributor)
= f.error_message_on :shipping_method, standalone: true

View File

@@ -1,27 +0,0 @@
= f.fields :bill_address, model: @order.bill_address do |bill_address|
%div.checkout-input
= bill_address.label :firstname, t("checkout.step1.your_details.first_name.label")
= bill_address.text_field :firstname, { placeholder: t("checkout.step1.your_details.first_name.placeholder") }
= f.error_message_on "bill_address.firstname"
%div.checkout-input
= bill_address.label :lastname, t("checkout.step1.your_details.last_name.label")
= bill_address.text_field :lastname, { placeholder: t("checkout.step1.your_details.last_name.placeholder") }
= f.error_message_on "bill_address.lastname"
.flex{style: "justify-content: space-between; gap: 10px;" }
%div.checkout-input{style: "flex-grow: 2;" }
= f.label :card_number, t("checkout.step2.form.card_number.label")
= f.text_field :card_number, { placeholder: t("checkout.step2.form.card_number.placeholder") }
%div.checkout-input{style: "flex: 0 1 100px;"}
= f.label :card_verification_value, t("checkout.step2.form.card_verification_value.label")
= f.number_field :card_verification_value, { placeholder: t("checkout.step2.form.card_verification_value.placeholder") }
%div.checkout-input{style: "flex: 0 1 70px;"}
= f.label :card_month, t("checkout.step2.form.card_month.label")
= f.number_field :card_month, { placeholder: t("checkout.step2.form.card_month.placeholder"), max: 12 }
%div.checkout-input{style: "flex: 0 1 70px;"}
= f.label :card_year, t("checkout.step2.form.card_year.label")
= f.number_field :card_year, { placeholder: t("checkout.step2.form.card_year.placeholder"), min: Time.now.year, max: Time.now.year + 10 }

View File

@@ -1,7 +0,0 @@
#connect.pane
.row
.small-12.medium-6.medium-offset-3.columns.text-center
%h2= t :label_connect
%p.text-normal= t :connect_body
%a.button.transparent{href: "https://openfoodnetwork.org/au/connect/"}
= t :connect_cta

View File

@@ -1,7 +0,0 @@
#learn.pane
.row
.small-12.medium-6.medium-offset-3.columns.text-center
%h2= t :label_learn
%p.text-normal= t :learn_body
%a.button.transparent{href: "https://openfoodnetwork.org/au/learn/"}
= t :learn_cta

View File

@@ -1,3 +0,0 @@
= succeed ',' do
= link_to "<strong>#{distributor.name}</strong>".html_safe, enterprise_shop_path(distributor), {class: distributor_link_class(distributor)}
%span.secondary= distributor.city

View File

@@ -5,7 +5,7 @@
- content_for :page_actions do
- if can?(:fire, @order)
%li= event_links
%li= event_links(@order)
= render partial: 'spree/admin/shared/order_links'
- if can?(:admin, Spree::Order)
%li

View File

@@ -20,5 +20,3 @@
- if @payments.any?
= render partial: 'list', locals: { payments: @payments }
- else
.alpha.twelve.columns.no-objects-found= t(:order_has_no_payments)

View File

@@ -27,8 +27,6 @@
= f.text_field :variant_unit_name, {placeholder: t('admin.products.unit_name_placeholder')}
= f.error_message_on :variant_unit_name
= render 'spree/admin/products/primary_taxon_form', f: f
= f.field_container :supplier do
= f.label :supplier, t(:spree_admin_supplier)
%br

View File

@@ -1,6 +1,6 @@
= f.field_container :primary_taxon do
= f.label :primary_taxon, t('.product_category')
= f.label :primary_taxon_id, t('.product_category')
%span.required *
%br
= f.collection_select(:primary_taxon_id, Spree::Taxon.order(:name), :id, :name, {:include_blank => true}, {:class => "select2 fullwidth"})
= f.error_message_on :primary_taxon
= f.error_message_on :primary_taxon_id

View File

@@ -24,7 +24,6 @@
%td.on_demand{ 'ng-show' => 'columns.on_demand.visible' }
%input.field{ 'ng-model' => 'product.on_demand', :name => 'on_demand', 'ofn-track-product' => 'on_demand', :type => 'checkbox', 'ng-hide' => 'hasVariants(product)' }
%td.category{ 'ng-if' => 'columns.category.visible' }
%input.fullwidth{ :type => 'text', id: "p{{product.id}}_category_id", 'ng-model' => 'product.category_id', 'ofn-taxon-autocomplete' => '', 'ofn-track-product' => 'category_id', 'multiple-selection' => 'false', placeholder: 'Category' }
%td.tax_category{ 'ng-if' => 'columns.tax_category.visible' }
%td.inherits_properties{ 'ng-show' => 'columns.inherits_properties.visible' }
%input{ 'ng-model' => 'product.inherits_properties', :name => 'inherits_properties', 'ofn-track-product' => 'inherits_properties', type: "checkbox" }

View File

@@ -21,6 +21,7 @@
%td{ 'ng-show' => 'columns.on_demand.visible' }
%input.field{ 'ng-model' => 'variant.on_demand', :name => 'variant_on_demand', 'ofn-track-variant' => 'on_demand', :type => 'checkbox' }
%td{ 'ng-show' => 'columns.category.visible' }
%input.fullwidth{ type: 'text', id: "p{{product.id}}_category_id", 'ng-model' => 'variant.category_id', 'ofn-taxon-autocomplete' => '', 'ofn-track-variant' => 'category_id', 'multiple-selection' => 'false', placeholder: 'Category' }
%td{ 'ng-show' => 'columns.tax_category.visible' }
%select.select2{ name: 'variant_tax_category_id', "ofn-track-variant": 'tax_category_id', "ng-model": 'variant.tax_category_id', "ng-options": 'tax_category.id as tax_category.name for tax_category in tax_categories' }
%option{ value: '' }= t(:none)

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