Compare commits

...

460 Commits

Author SHA1 Message Date
Maikel Linke
37441be371 Update translations 2023-05-19 14:33:23 +10:00
Maikel
0d403f4087 Merge pull request #10814 from Matt-Yorkley/serializer-eager-loading
Improve eager-loading on admin products page
2023-05-19 14:31:25 +10:00
Maikel
f943b411c5 Merge pull request #10823 from abdellani/fix-file-name-used-as-parameter
[Security] Validate product import file path
2023-05-19 14:28:09 +10:00
Maikel
7af14e37fa Merge pull request #10488 from mkllnk/dfc-connector
Serialize DFC catalog items with DFC Connector
2023-05-19 11:31:23 +10:00
Filipe
3d1b0816ed Merge pull request #10512 from abdellani/fix-tax-not-charged-when-tax-category-set-to-inherit-from-product
Prevent saving the enterprise fee when a per order calculator is selected along with 'Inherit from product'
2023-05-18 13:43:14 +01:00
Konrad
39bb1f6f41 Merge pull request #10832 from Matt-Yorkley/cloning
Clone all ExchangeVariant objects in bulk
2023-05-18 14:32:30 +02:00
David Cook
360a241402 Style fix 2023-05-18 10:07:52 +10:00
Filipe
0d23b63bbd Merge pull request #10779 from dacook/10634-remove-admin_style_v2
10634 Remove admin_style_v2 feature
2023-05-17 15:37:05 +01:00
Konrad
19caadb1a0 Merge pull request #10800 from dacook/remove-localisation
Also remove localized number logic from weight calculator
2023-05-17 14:57:26 +02:00
David Cook
c0c123a92a Remove localized number logic from weight calculator
Follow-on from a46eef291c
2023-05-17 14:10:58 +02:00
Konrad
f26bef5f98 Merge pull request #10813 from saunmanoj888/fix-fullname-search-issue-on-bulk-orders
Fix searching issue with full name on bulk order management
2023-05-17 13:58:04 +02:00
saunmanoj888
aee7645e29 Fix searching issue with full name on bulk order management 2023-05-17 13:14:10 +02:00
Konrad
02873d7596 Merge pull request #10817 from Matt-Yorkley/permissions-scoping
Scope orders before bulk actions
2023-05-17 12:44:07 +02:00
Matt-Yorkley
e1b0a03819 Scope orders before bulk actions 2023-05-17 12:03:40 +02:00
Maikel Linke
eaf3bd0bae Update spec after new import file validation 2023-05-17 15:18:29 +10:00
Mohamed ABDELLANI
fcb8550cb1 extract file path sanitizer to an independent class 2023-05-17 15:09:48 +10:00
Mohamed ABDELLANI
4d5ba6a7e6 add file path validation 2023-05-17 15:09:48 +10:00
Maikel Linke
a0d05b26d1 Spec current product import vulnerabilities
I didn't use pending specs but deliberately passing specs on wrong
behaviour. This is not how it should be but how it is at the moment.
2023-05-17 15:09:01 +10:00
Konrad
4a66b62fa7 Merge pull request #10825 from jibees/10824-remove-feature-toggle-on-white-label-feature
Activate white label feature
2023-05-16 13:50:58 +02:00
Maikel
16329e953f Merge pull request #10844 from openfoodfoundation/dependabot/npm_and_yarn/jasmine-core-5.0.0
Bump jasmine-core from 4.6.0 to 5.0.0
2023-05-16 17:50:39 +10:00
Maikel
10c918be75 Merge pull request #10732 from mkllnk/report-email
[Hidden] Notify about completed report with download link via email
2023-05-16 10:25:23 +10:00
Maikel
a979f7c8df Merge pull request #10587 from rioug/10432-vouchers-bare-minimum-checkout
10432 vouchers bare minimum checkout
2023-05-16 09:19:06 +10:00
Maikel Linke
08aff56e20 Expire report files after 1 week, maximum for S3
We didn't see this in tests which use disk storage. But AWS S3 has a
maximum of one week for URL expiry.
2023-05-15 19:41:45 +02:00
Maikel Linke
5ae04a5a3e Hide report link which only works at unknown time
It was bad UX to show a link that doesn't work straight away. At the
time, it was the only way to download the report but now we send an
email which is a much better way to go.

I leave the rest of the code because we want to implement a reflex which
shows the download link once it's ready.
2023-05-15 19:41:45 +02:00
Maikel Linke
299bc253a4 Expire report download links in a month, not 5mins 2023-05-15 19:41:45 +02:00
Maikel Linke
8a8c53ceee Add ReportMailer preview for devs 2023-05-15 19:41:45 +02:00
Maikel Linke
860fe85af9 Add report download link to email notification
I added a system spec to verify that the download link can be generated
within the mailer in a background job. ActiveStorage is a bit particular
when it comes to genererating URLs and depending on the situation it may
generate a redirect URL, a proxy URL or link directly to the storage.
But we want a redirect URL here.
2023-05-15 19:41:45 +02:00
Maikel Linke
cf5a8a26ce Notify only about slow reports
It would be annoying to get an email for reports which display on the
screen immediately.
2023-05-15 19:41:45 +02:00
Maikel Linke
1f4af7f990 Send (dummy) email when background report is done
I'll fill it out in future commits.
2023-05-15 19:41:45 +02:00
Jean-Baptiste Bellet
aaa9bac4dd Remove white_label feature toggle
White label is now activated for everyone.

+ add mock for `spec/controllers/spree/orders_controller_spec.rb`
2023-05-15 17:10:50 +02:00
jibees
d43678c68b Merge pull request #10827 from filipefurtad0/logging_out_spec
Adds test case for logging out
2023-05-15 15:33:56 +02:00
Jean-Baptiste Bellet
ec0cbc5bf9 Avoid warning by being more precise about *.erb files 2023-05-15 15:29:28 +02:00
jibees
a1e4c45daa Merge pull request #10843 from openfoodfoundation/dependabot/bundler/rubocop-1.51.0
Bump rubocop from 1.50.2 to 1.51.0
2023-05-15 15:03:24 +02:00
jibees
edeedc0704 Merge pull request #10841 from openfoodfoundation/dependabot/npm_and_yarn/floating-ui/dom-1.2.8
Bump @floating-ui/dom from 1.2.7 to 1.2.8
2023-05-15 15:02:22 +02:00
jibees
d2539b34e0 Merge pull request #10840 from openfoodfoundation/dependabot/bundler/rails-i18n-7.0.7
Bump rails-i18n from 7.0.6 to 7.0.7
2023-05-15 15:01:12 +02:00
jibees
fea3957481 Merge pull request #10845 from openfoodfoundation/dependabot/bundler/test-unit-3.5.8
Bump test-unit from 3.5.7 to 3.5.8
2023-05-15 15:00:03 +02:00
jibees
b183832fbb Merge pull request #10842 from openfoodfoundation/dependabot/bundler/capybara-3.39.1
Bump capybara from 3.39.0 to 3.39.1
2023-05-15 12:22:59 +02:00
dependabot[bot]
8a352132a0 Bump test-unit from 3.5.7 to 3.5.8
Bumps [test-unit](https://github.com/test-unit/test-unit) from 3.5.7 to 3.5.8.
- [Release notes](https://github.com/test-unit/test-unit/releases)
- [Commits](https://github.com/test-unit/test-unit/compare/3.5.7...3.5.8)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-15 10:00:55 +00:00
dependabot[bot]
0e59a5db91 Bump jasmine-core from 4.6.0 to 5.0.0
Bumps [jasmine-core](https://github.com/jasmine/jasmine) from 4.6.0 to 5.0.0.
- [Release notes](https://github.com/jasmine/jasmine/releases)
- [Changelog](https://github.com/jasmine/jasmine/blob/main/RELEASE.md)
- [Commits](https://github.com/jasmine/jasmine/compare/v4.6.0...v5.0.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-15 10:00:22 +00:00
dependabot[bot]
340fe91e07 Bump rubocop from 1.50.2 to 1.51.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.50.2 to 1.51.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.50.2...v1.51.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-15 10:00:15 +00:00
dependabot[bot]
6c126cfc33 Bump capybara from 3.39.0 to 3.39.1
Bumps [capybara](https://github.com/teamcapybara/capybara) from 3.39.0 to 3.39.1.
- [Changelog](https://github.com/teamcapybara/capybara/blob/master/History.md)
- [Commits](https://github.com/teamcapybara/capybara/compare/3.39.0...3.39.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-15 09:59:19 +00:00
dependabot[bot]
82c6eaab4e Bump @floating-ui/dom from 1.2.7 to 1.2.8
Bumps [@floating-ui/dom](https://github.com/floating-ui/floating-ui/tree/HEAD/packages/dom) from 1.2.7 to 1.2.8.
- [Release notes](https://github.com/floating-ui/floating-ui/releases)
- [Commits](https://github.com/floating-ui/floating-ui/commits/@floating-ui/dom@1.2.8/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>
2023-05-15 09:57:51 +00:00
dependabot[bot]
d4918893a7 Bump rails-i18n from 7.0.6 to 7.0.7
Bumps [rails-i18n](https://github.com/svenfuchs/rails-i18n) from 7.0.6 to 7.0.7.
- [Changelog](https://github.com/svenfuchs/rails-i18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/svenfuchs/rails-i18n/compare/v7.0.6...v7.0.7)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-15 09:57:24 +00:00
jibees
1e05bc5b5c Merge pull request #10789 from jibees/10770-bom-cancelling-an-order-always-restocks-the-line-item
BOM: when deleting the last item of order that leads to order cancellation, take into account the restock items checkbox
2023-05-15 09:50:13 +02:00
Mohamed ABDELLANI
7f52684488 add check_calculators_compatibility_with_taxes before running enterprise bulk update 2023-05-15 07:35:52 +01:00
Gaetan Craig-Riou
5eb6097101 Fix error handling when creating a voucher adjustment
I wrongly assumed that `voucher.create_adjustment` would return nil
if failing to create an adjustment. I will in fact return an
adjustment object with errors.
2023-05-15 13:42:40 +10:00
David Cook
ccff3379ea Update schema.rb
On a freshly mirrored prod db, I found these changes.

I don't know why.. but hopefully this is correct.
2023-05-15 13:42:40 +10:00
Gaetan Craig-Riou
d29119f5c5 Remove non need belongs_to associations from Adjustments
It turns out the "tax_rate" association isn't used and wasn't working.
Same for the "voucher" one, which I added to be consistent with existing
code.
Both of these weren't caught by the specs because you can't test associations
with a custome relation with 'shouda-matchers' see: https://github.com/thoughtbot/shoulda-matchers/issues/981
2023-05-15 13:42:40 +10:00
Gaetan Craig-Riou
b67f5ae154 Fixing Rubocop issue
My editor automatically remove blank character on empty line, that's
why rubocop got grumpy here.
2023-05-15 13:42:40 +10:00
Matt-Yorkley
9b1725d39f Fix model name in adjustment association 2023-05-15 13:42:40 +10:00
Gaetan Craig-Riou
b80274f49d Per review comment, Use named value on voucher submit button to distinguish between submission types
The voucher apply button is inside form that has another a submit button,
it leads to a weird situation where either one will submit the whole
payments page form. Adding a named parameter on the voucher apply button
means we can distinguish between the two by checking for the presence
of params[:apply_voucher].
2023-05-15 13:42:39 +10:00
Gaetan Craig-Riou
92bcd937dc Per review comment, remove form object from the partial
This partial is rendered inside another <form> element, nested form
don't work.
2023-05-15 13:42:39 +10:00
Gaetan Craig-Riou
0a249d7722 Fix ButtonEnableToggleController to remove hacky button disable
As per review comment, use data-disable-with="false" do prevent Rails
from automatically enabling the "Apply" button. We can then remove
the timeout hack.
2023-05-15 13:42:39 +10:00
Gaetan Craig-Riou
236f6926d9 Cleaning up left over TODOs 2023-05-15 13:42:39 +10:00
Gaetan Craig-Riou
aa526a639c Checkout payment page, enable voucher "apply" button when code entered
The "apply" button is disabled by default. If left enabled, a customer
could try to apply an empty voucher, which results in system trying
to move to the order summary step, an unexpected behaviour!
We only enable the button when something is entered in the input.
2023-05-15 13:42:39 +10:00
Gaetan Craig-Riou
e5f14177d3 Fix rubocop warning
I guess the new cops are effective :)
2023-05-15 13:42:39 +10:00
Gaetan Craig-Riou
815dcbcefe Fix translations 2023-05-15 13:42:39 +10:00
Gaetan Craig-Riou
a2e1e6ca33 Review comment, use dig to access voucher_code param 2023-05-15 13:42:39 +10:00
Gaetan Craig-Riou
2f1fe6d096 Fix rubocop warning 2023-05-15 13:42:39 +10:00
Gaetan Craig-Riou
17e32a89f8 Add VoucherAdjustmentsService to handle calculation
Refactor Voucher to move voucher adjustments calculation
to VoucherAdjustmentsService
2023-05-15 13:42:39 +10:00
Gaetan Craig-Riou
56e981d300 Refactor Voucher to get rid of CalculatedAdjustments
Voucher adjustment have complicated calculation that prevent us from
using Spree::Calculator, and we need to override CalculatedAdjustments
method, so no point using it.
We still keep the same methods to stay as consitent as possible in
regards to adjustments
2023-05-15 13:42:39 +10:00
Gaetan Craig-Riou
3f37554ff9 Add VoucherAdjustmentsController and specs
Refactor split checkout to use the new controller. But unfortunately
we can't have nested form, so adding a voucher is still handled by
SplitCheckoutController.
2023-05-15 13:42:39 +10:00
Gaetan Craig-Riou
43ab881181 Rename order association to voucher_adjustments
The name vouchers is a bit confusing as the order is linked to a
voucher adjutment and not the actual voucher
2023-05-15 13:42:39 +10:00
Gaetan Craig-Riou
fe9b94a80e Fix cart disappearing bug after adding a voucher
The split checkout page uses `mrujs` and `CableCar` to set the form as
a remote one and perform `CableCar` operation if any : https://mrujs.com/how-tos/integrate-cablecar
The previous solution broke the cart handled by angularJS, it looks like
`morpdom` (https://mrujs.com/references/remote-forms-and-links Navigation Adapter section )
was doing something that angularJS didn't like when redirecting to
the current page.
With the power of `CableCar`, we now replace the #voucher-section on the
split checkout page instead of doing a redirect.
2023-05-15 13:42:39 +10:00
Gaetan Craig-Riou
94294fa161 Voucher adjustment, add ordering by created_at
It gives us a consistent result when calling #vouchers
2023-05-15 13:42:38 +10:00
Gaetan Craig-Riou
a1ad25f217 Fix failing specs 2023-05-15 13:42:38 +10:00
Gaetan Craig-Riou
bb9d835bd8 Fix rubocop warning 2023-05-15 13:42:38 +10:00
Gaetan Craig-Riou
87cc525d27 Refactor #vouchers
Use "has_many" instead of a method
2023-05-15 13:42:38 +10:00
Gaetan Craig-Riou
4b5d6d7eac Fix voucher adjustments association
Add missing, "inverse_of" and "dependent" options. Use :nullify as
for "dependent" because we would want to keep the adjustments on order
even if the voucher is deleted.
2023-05-15 13:42:38 +10:00
Gaetan Craig-Riou
58469adfeb Adjustments spec, add association test 2023-05-15 13:42:38 +10:00
Gaetan Craig-Riou
5064bf5383 Allow voucher adjustment to be created with an amount of 0
Although unlikely, we should still be able to create a voucher amount
with. This can happen if the order.total is for instance.
2023-05-15 13:42:38 +10:00
Gaetan Craig-Riou
9789911523 Rework how voucher are applied to an order and handle tax calculation
At the time when we can apply a voucher to an order (payment step) we
don't have any data on possible taxes and payment fees. These are
calculated when we move to the summary step. So voucher are applied in
two step:
- create an "open" voucher adjustment on the order when a customer enters
a voucher code.
- when we move to the summary step, recalulate the amount and
possible tax for the voucher adjustment, once taxes and payment fees
have been included in the order. And then close the original and update
order to reflect the changes
2023-05-15 13:42:38 +10:00
Gaetan Craig-Riou
d157d91054 When voucher cover more than order total, use only amount needed
The checkout payment step will also show a warning.
The amount used is stored in the adjustment created, so we will be able
to track how much has been used down the line.
2023-05-15 13:42:38 +10:00
Gaetan Craig-Riou
3f609d3842 Add error message if adding a voucher fails
It's not really useful to the user but better than failing silently
2023-05-15 13:42:38 +10:00
Gaetan Craig-Riou
596c775af6 Add controller spec to cover voucher in split checkout 2023-05-15 13:42:38 +10:00
Gaetan Craig-Riou
74e0b0f6b5 Add voucher adjustment loading to CheckoutCallbacks
This is needed so the voucher is loaded properly when the "checkout"
partials are render via cable_car.
2023-05-15 13:42:38 +10:00
Gaetan Craig-Riou
74a8730f04 Highlight voucher on order summary step 2023-05-15 13:42:38 +10:00
Gaetan Craig-Riou
856386fcb0 SplitCheckoutController refactor add_voucher
Now all redirection/render_error happen in #update, it makes it
easier to understand.
2023-05-15 13:42:37 +10:00
Gaetan Craig-Riou
e487ed0532 Add link to remove voucher when a voucher has been applied
Improve styling to match the design
2023-05-15 13:42:37 +10:00
Gaetan Craig-Riou
b6213b25e9 add acts_as_paranoid to voucher
This is so the relation
`belongs_to :originator, -> { with_deleted }, polymorphic: true`
setup in Spree::Adjustement works as expected.
2023-05-15 13:42:37 +10:00
Gaetan Craig-Riou
a9d9b33f7d First take at adding a voucher to an order
Use voucher.create_adjustment to add an adjustment to the order
Currently doesn't take into account tax part
2023-05-15 13:42:37 +10:00
Gaetan Craig-Riou
3ec58d8791 Add #vouchers, return an array of voucher adjustments 2023-05-15 13:42:37 +10:00
Gaetan Craig-Riou
9b680e1a92 Add CalculatedAdjustments to Voucher
Vouchers are only flat rate of 10 for now, so we add a FlatRate
calculator in a before_validation callback
2023-05-15 13:42:37 +10:00
Gaetan Craig-Riou
f7ee01b9f8 Add voucher input on checkout payment's step
Voucher input is displayed  only if the distributor has any voucher
2023-05-15 13:42:37 +10:00
Maikel
4f7059d0c7 Merge pull request #10838 from filipefurtad0/fix_negative_adjustment_error
Adds minus sign to validation criteria
2023-05-15 11:07:45 +10:00
Gaetan Craig-Riou
d715b6b3bb Spec fix LocalisedNumber validation to allow negative number
As part of this PR https://github.com/openfoodfoundation/openfoodnetwork/pull/10329
LocalisedNumber validation was tightened, but that means negative number
were not valid anymore.

This commit has been cherry-picked after this fix has already been
applied. Now we just change the order of characters in the regex because
humans are used to reading the minus at the beginning of the number. But
this change doesn't change the logic at all.
2023-05-15 10:55:59 +10:00
Maikel
5045e26792 Merge pull request #10834 from mkllnk/variant-spec
Improve readability and performance of variant spec
2023-05-15 09:48:06 +10:00
filipefurtad0
0442f2da7e Fixes spec warning
An example was being ignored due to legacy syntax - WARNING: ignoring the provided expectation message argument since it is not a string or a proc.
2023-05-14 23:02:44 +01:00
filipefurtad0
e7ab839fb3 Adds minus sign as validation criteria
Removes pending from passing examples
2023-05-14 23:02:44 +01:00
filipefurtad0
596b318778 Adds spec on negative adjustment
with different localization settings

Using shared examples and setting failing

ones as pending
2023-05-14 23:02:00 +01:00
Filipe
3c7337b53a Merge pull request #10836 from jibees/10835-on-small-width-screen-the-cart-element-is-missplaced
Fix bad indentation (and hierarchy) of DOM elements causing bad rendering on small width screens
2023-05-12 11:24:49 +01:00
Jean-Baptiste Bellet
60edb4363e Fix bad indentation (and hierarchy)
`%section` must be siblings each others

introduced by https://github.com/openfoodfoundation/openfoodnetwork/pull/10772
2023-05-12 09:30:37 +02:00
Maikel Linke
6596225a99 Fix typo in VCR cassette name 2023-05-12 14:48:00 +10:00
Maikel Linke
87c4c5373b Spec more variant naming with realistic data 2023-05-12 14:10:54 +10:00
Maikel Linke
f70607259a Spec Variant#product_and_full_name with real data
Mocking skips a lot of code execution which we want to test as well.
2023-05-12 13:34:34 +10:00
Maikel Linke
ce180caad9 Test with in-memory data when possible
This should speed up specs but I observed only one second less run time.
2023-05-12 13:21:58 +10:00
Maikel Linke
01be934caf Reduce spec run time by not creating unused subject
The `variant` instance isn't used in all specs and doesn't need to be
created every time. This reduced run time from 1min5sec to 43sec on my
machine.
2023-05-12 13:21:58 +10:00
Maikel Linke
54c6559b97 Move Spree::Variant spec out of Spree module
I also discovered that some specs were just in the Spee module and not
within the `describe Variant` block. I moved them inside the block.
2023-05-12 13:21:19 +10:00
Maikel
93c0a06403 Merge pull request #10829 from filipefurtad0/flaky_order_spec_error
Splits assertions to allow JS table populate
2023-05-12 11:49:06 +10:00
Maikel Linke
636b365304 Tell Rubocop and devs about bulk insert 2023-05-12 10:30:47 +10:00
Jean-Baptiste Bellet
51d6fb81dd Fwd to request the restock_items input value when adjusting items qty 2023-05-11 22:58:44 +02:00
Jean-Baptiste Bellet
f679d8733e Pass the restock_items params to each methods and request call
+ update spec to test whether the restock item checkbox is checked or not.
2023-05-11 22:58:44 +02:00
Matt-Yorkley
b139087c5f Clone ExchangeVariant objects in bulk
An ExchangeVariant is a simple representation of a join table between Exchange and Variant. Previously this code was triggering an additional INSERT query for every variant added to the newly cloned exchange. Some exchanges have ~3000 variants! The code now creates them in bulk in a single INSERT statement. When cloning large order cycles this can improve performance by ~1000% or so.
2023-05-11 20:51:20 +01:00
Filipe
1bdb668cd3 Merge pull request #10769 from Matt-Yorkley/visible-line-items-query
Improve `Permissions::Order#visible_line_items` querying
2023-05-11 15:36:32 +01:00
filipefurtad0
d035d4bb87 Update all locales with the latest Transifex translations 2023-05-11 15:25:39 +01:00
Mohamed ABDELLANI
6771d2e7be test enterprise fees creation with tax category inheritance flag 2023-05-11 12:46:17 +01:00
Mohamed ABDELLANI
a22fe9f948 fix existing invalid enterprise fees 2023-05-11 12:46:17 +01:00
Maikel Linke
25b7f1749c Simplify error when tax rate can't be inherited
I changed the text to focus on the resolution: the user needs to choose
a tax category or a different calculator.

I associated the error to the model to prevent the attribute name from
being included in the error message. Alternatively, we could have
changed the name of the attribute to match the UI. But this error
affects the combination of two attributes, none of them is invalid on
its own.

I'm using Rails' default lazy lookup for error messages which results in
shorter code and a standard structure.

I also added a simple spec.
2023-05-11 12:46:17 +01:00
Mohamed ABDELLANI
89eb3a1967 fix existing tests 2023-05-11 12:46:17 +01:00
Mohamed ABDELLANI
7eca32e84f prevent saving the enterprise fee when a per order calculator is selected along with 'Inherit from product' 2023-05-11 12:46:17 +01:00
filipefurtad0
f5eb72c804 Adds sleep(1) 2023-05-11 11:29:24 +01:00
Konrad
2836751698 Merge pull request #10805 from jibees/10717-bo-orders-changing-customer-does-not-update-customer_id
Admin, Edit customer details for an order: when changing to another customer, update `customer_id` as well
2023-05-10 19:08:57 +02:00
Filipe
bf7a559a32 Merge pull request #10772 from Matt-Yorkley/view-caching
Locale-aware Fragment Caching
2023-05-10 11:18:08 +01:00
filipefurtad0
82f307ae61 Adds test case for logging out 2023-05-10 10:41:43 +01:00
Matt-Yorkley
d90653c682 Merge pull request #10793 from jibees/fix-webpack-configuration-use-the-default-one
Use the default webpack configuration for dev env
2023-05-10 10:09:28 +01:00
jibees
ca5300284c Merge pull request #10820 from Matt-Yorkley/js-dependencies
Remove indirect JS dependencies
2023-05-10 09:57:05 +02:00
Matt-Yorkley
406cb572ea Remove indirect JS dependencies 2023-05-10 09:27:00 +02:00
jibees
ca90b5cee2 Merge pull request #10810 from openfoodfoundation/dependabot/bundler/aws-sdk-s3-1.122.0
Bump aws-sdk-s3 from 1.121.0 to 1.122.0
2023-05-10 09:23:44 +02:00
jibees
760860a06d Merge pull request #10811 from openfoodfoundation/dependabot/bundler/knapsack_pro-3.11.0
Bump knapsack_pro from 3.10.0 to 3.11.0
2023-05-10 09:21:46 +02:00
jibees
189207f751 Merge pull request #10822 from openfoodfoundation/dependabot/bundler/debug-1.8.0
Bump debug from 1.7.2 to 1.8.0
2023-05-10 09:20:34 +02:00
Matt-Yorkley
1bd9182cea Update menu cache blocks 2023-05-09 16:46:09 +01:00
David Cook
04a5c7452e Remove admin_style_v2 description
Partially reverts 9a1b1498bf
2023-05-09 21:26:47 +10:00
David Cook
e29df5ea8f Remove unused secondary class
This partially reverts 97c3aaebb2 because it referred to the new feature toggle which has been removed.
2023-05-09 21:26:47 +10:00
David Cook
3ec659d82b Revert pull #10025
[WIP 🚧 ] Admin, behind feature toggle admin_style_v2: adjust some colors

This reverts commits 60f0a58508ce77666fa96c73d76dc0620f23daaf~1..09bcc772ff089f911a56bb
2023-05-09 21:26:47 +10:00
David Cook
be70cd7893 Revert pull #10054
[WIP 🚧 ] Admin/Orders, behind feature toggle admin_style_v2: adjust colors

This reverts commits 5cab0f7f3d495daaeb97fd786208a24355b630fe..4ef5609b0eb08fe7e48803de166ae3e979103c1b
2023-05-09 21:26:47 +10:00
David Cook
0ff540e1e3 Revert pull #10080
[WIP 🚧 ] Admin - Order edition, behind feature toggle admin_style_v2: adjust colors

This reverts commits faf106b2824f248812f523c10b688bd9b254dc14..74b618230ff736ac7929246e2c83ed95067a4dd0
2023-05-09 21:25:29 +10:00
David Cook
c21ff075de Revert pull #10131
[WIP 🚧 ] /admin/order_cycles behind feature toggle admin_style_v2

This reverts commits ccfc632149f062fca546784c7c2f14708d91a08e~1..e403a2c174def34cfa115eab038c86923482bfbf
2023-05-09 21:24:25 +10:00
dependabot[bot]
969d0b6687 Bump debug from 1.7.2 to 1.8.0
Bumps [debug](https://github.com/ruby/debug) from 1.7.2 to 1.8.0.
- [Release notes](https://github.com/ruby/debug/releases)
- [Commits](https://github.com/ruby/debug/compare/v1.7.2...v1.8.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-09 10:03:20 +00:00
Maikel Linke
3c6f55732d Add dummy product type to DFC export 2023-05-09 17:01:00 +10:00
Maikel Linke
b2e8af0cd1 Add stock to DFC Offer as well 2023-05-09 16:51:26 +10:00
Maikel Linke
c81230d334 Add old DFC API name for prototype compatibility 2023-05-09 16:51:26 +10:00
Maikel Linke
54137067dd Export variant's display_name if present
The `#name` method is simply delegated to a variant's product.
2023-05-09 16:51:26 +10:00
Maikel Linke
0c5ab783ca Update DFC API route to reflect Connector version 2023-05-09 16:51:26 +10:00
Maikel Linke
80edc44ef5 Replace SuppliedProductSerializer with DFC Connector
And remove the BaseSerializer because this was the last serializer.
2023-05-09 16:51:26 +10:00
Maikel Linke
0b808a4b1e Add product quantity to DFC export 2023-05-09 16:51:26 +10:00
Maikel Linke
1e23cf1c92 Replace EnterpriseSerializer with DFC Connector
And move same test coverage to a new builder spec.
2023-05-09 16:51:26 +10:00
Maikel Linke
683ad0f5b9 Replace PersonSerializer with DFC Connector
And the address serializer was just an empty placeholder.
2023-05-09 16:51:26 +10:00
Maikel Linke
c60d622818 List catalog items with DFC Connector 2023-05-09 16:51:25 +10:00
Maikel Linke
7f8ce08d4e Include DFC Offer in the export with valid id 2023-05-09 16:51:25 +10:00
Maikel Linke
78cf3b5a1d Serialize DFC catalog item with DFC Connector
This is work in progress. The DFC Connector uses a more recent DFC
version and other endpoints still use the old serializers. We need to
update those endpoints as well and update the version number in the API
URL.
2023-05-09 16:51:25 +10:00
Maikel Linke
5187201796 Add DFC vocabularies
- Add a script for downloading updated files.
- Add a service for easier loading of vocab files.
2023-05-09 16:51:25 +10:00
Maikel Linke
352c350840 Add gem datafoodconsortium-connector
We hope that replacing our own JSON generation with this gem will reduce
maintenance. Same for parsing DFC input.
2023-05-09 16:51:25 +10:00
David Cook
8fe20ecfbe Merge pull request #10794 from openfoodfoundation/dependabot/npm_and_yarn/babel/core-7.21.8
Bump @babel/core from 7.21.5 to 7.21.8
2023-05-09 16:37:42 +10:00
Maikel
83141ec05c Merge pull request #10818 from mkllnk/schema-order
Fixup order of statements in db schema
2023-05-09 14:21:03 +10:00
Matt-Yorkley
4b707b9310 Extract locale file digest logic to a separate class and add tests 2023-05-08 14:09:00 +01:00
Matt-Yorkley
1c277e5547 Cache some html fragments 2023-05-08 14:07:50 +01:00
Matt-Yorkley
be48a6c295 Implement cache_with_locale helper for fragment caching with locales 2023-05-08 14:07:50 +01:00
Matt-Yorkley
11f45dc2f8 Give ContentConfig an updated_at attribute and a usable cache_key 2023-05-08 14:07:50 +01:00
Konrad
4303cabe56 Merge pull request #10792 from mkllnk/feature-deletion
Remove unknown (deleted) feature toggles at boot
2023-05-08 14:49:42 +02:00
Maikel Linke
f1f3ecc4f7 Fixup order of statements in db schema
It looks like the resolution of a merge conflict introduced the wrong
ordering of schema statements. Rails wants to sort tables alphabetically
and running `./bin/rails db:migrate` on a fresh database altered the
schema.rb file. This should be fixed here.

Rails also omits the default setting of `precision: 6` since Rails 7.
The vouchers feature was developed during the upgrade to Rails 7.
2023-05-08 14:37:33 +10:00
Maikel
ad033e8d44 Merge pull request #10767 from Matt-Yorkley/remove-session-cookie-upgrader
Remove SessionCookieUpgrader from middleware
2023-05-08 12:50:42 +10:00
Gaetan Craig-Riou
f25a3650bd Merge pull request #10802 from openfoodfoundation/dependabot/bundler/ddtrace-1.11.1
Bump ddtrace from 1.11.0 to 1.11.1
2023-05-08 11:45:07 +10:00
Konrad
e4d8dd9f87 Merge pull request #10780 from dacook/enable-prettier-css
Enable prettier for Admin SCSS
2023-05-06 18:24:58 +02:00
Matt-Yorkley
1995a44848 Improve eager-loading on admin products page adn resolve issue with serializer
For some reason eager-loaded data isn't passed to nested serializers when using associations. Defining the association as a method and passing in some optional paramaters resolves the issue.

This reduces queries run by the controller action by around 75%, as well as the response times.
2023-05-06 17:15:27 +01:00
dependabot[bot]
b29d38f3fb Bump knapsack_pro from 3.10.0 to 3.11.0
Bumps [knapsack_pro](https://github.com/KnapsackPro/knapsack_pro-ruby) from 3.10.0 to 3.11.0.
- [Changelog](https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v3.10.0...v3.11.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>
2023-05-05 10:01:08 +00:00
dependabot[bot]
1c52fe1648 Bump aws-sdk-s3 from 1.121.0 to 1.122.0
Bumps [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby) from 1.121.0 to 1.122.0.
- [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-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-05 09:59:02 +00:00
David Cook
a170b93cc1 Simplify further
Co-authored-by: Maikel <maikel@email.org.au>
2023-05-05 15:34:23 +10:00
Maikel Linke
2a943ecafb Spec setting up all feature toggle names 2023-05-05 11:09:10 +10:00
Jean-Baptiste Bellet
3a1579104f Submit customer_id as params when updating customer details on order 2023-05-04 16:40:58 +02:00
jibees
ec4c7b79bf Merge pull request #10803 from openfoodfoundation/dependabot/bundler/rspec-rails-6.0.2
Bump rspec-rails from 6.0.1 to 6.0.2
2023-05-04 13:55:37 +02:00
dependabot[bot]
9f12295a89 Bump rspec-rails from 6.0.1 to 6.0.2
Bumps [rspec-rails](https://github.com/rspec/rspec-rails) from 6.0.1 to 6.0.2.
- [Release notes](https://github.com/rspec/rspec-rails/releases)
- [Changelog](https://github.com/rspec/rspec-rails/blob/main/Changelog.md)
- [Commits](https://github.com/rspec/rspec-rails/compare/v6.0.1...v6.0.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-04 09:58:54 +00:00
dependabot[bot]
46fd6b1a3a Bump ddtrace from 1.11.0 to 1.11.1
Bumps [ddtrace](https://github.com/DataDog/dd-trace-rb) from 1.11.0 to 1.11.1.
- [Release notes](https://github.com/DataDog/dd-trace-rb/releases)
- [Changelog](https://github.com/DataDog/dd-trace-rb/blob/master/CHANGELOG.md)
- [Commits](https://github.com/DataDog/dd-trace-rb/compare/v1.11.0...v1.11.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-04 09:58:25 +00:00
Jean-Baptiste Bellet
8a5608435c Update all locales with the latest Transifex translations 2023-05-03 17:30:48 +02:00
Konrad
d02d0b8847 Merge pull request #10763 from openfoodfoundation/dependabot/bundler/ddtrace-1.11.0
Bump ddtrace from 1.10.1 to 1.11.0
2023-05-03 17:27:13 +02:00
Konrad
4b6ef7796e Merge pull request #10762 from mkllnk/report-encoding
Preserve encoding of stored reports
2023-05-03 17:08:44 +02:00
Konrad
b60a6fbd05 Merge pull request #10329 from thejwuscript/9861-improve-input-validation
Improve input validation on new and edit Payment Method pages
2023-05-03 16:11:21 +02:00
jibees
2e267091f6 Merge pull request #10795 from openfoodfoundation/dependabot/bundler/knapsack_pro-3.10.0
Bump knapsack_pro from 3.9.0 to 3.10.0
2023-05-03 14:31:11 +02:00
dependabot[bot]
eb3fe1b7a5 Bump knapsack_pro from 3.9.0 to 3.10.0
Bumps [knapsack_pro](https://github.com/KnapsackPro/knapsack_pro-ruby) from 3.9.0 to 3.10.0.
- [Release notes](https://github.com/KnapsackPro/knapsack_pro-ruby/releases)
- [Changelog](https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v3.9.0...v3.10.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>
2023-05-03 10:06:11 +00:00
dependabot[bot]
61f34a23a7 Bump @babel/core from 7.21.5 to 7.21.8
Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.21.5 to 7.21.8.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.21.8/packages/babel-core)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-03 09:57:57 +00:00
Jean-Baptiste Bellet
2d7356f2bb Use the default webpack configuration for dev env
We used to override the output filename but this was a misunderstanding of an error (due to webpacke(r) incompatibles versions)

https://medium.com/@web_developer/hash-vs-chunkhash-vs-contenthash-e94d38a32208

https://github.com/webpack/webpack.js.org/issues/2096

Context: https://github.com/openfoodfoundation/openfoodnetwork/pull/10631#pullrequestreview-1410083331
2023-05-03 10:10:17 +02:00
jibees
62c2d9a290 Merge pull request #10782 from openfoodfoundation/dependabot/bundler/sidekiq-7.1.0
Bump sidekiq from 7.0.9 to 7.1.0
2023-05-03 09:56:07 +02:00
jibees
a329aab007 Merge pull request #10774 from openfoodfoundation/dependabot/npm_and_yarn/babel/core-7.21.5
Bump @babel/core and @babel/preset-env from 7.21.4 to 7.21.5
2023-05-03 09:26:10 +02:00
Maikel Linke
e24198fe85 Bump @babel/preset-env from 7.21.4 to 7.21.5
Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.21.4 to 7.21.5.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.21.5/packages/babel-preset-env)

I did this manually:

```
$ yarn upgrade "@babel/preset-env"
yarn upgrade v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > stimulus_reflex@3.5.0-rc2" has unmet peer dependency "@hotwired/stimulus@>= 3.0".
[4/4] Rebuilding all packages...
success Saved lockfile.
success Saved 35 new dependencies.
info Direct dependencies
└─ @babel/preset-env@7.21.5
info All dependencies
├─ @babel/code-frame@7.21.4
├─ @babel/helper-builder-binary-assignment-operator-visitor@7.21.5
├─ @babel/helper-function-name@7.21.0
├─ @babel/helper-module-imports@7.21.4
├─ @babel/helper-replace-supers@7.21.5
├─ @babel/helper-string-parser@7.21.5
├─ @babel/helper-wrap-function@7.20.5
├─ @babel/highlight@7.18.6
├─ @babel/parser@7.21.5
├─ @babel/plugin-transform-arrow-functions@7.21.5
├─ @babel/plugin-transform-computed-properties@7.21.5
├─ @babel/plugin-transform-for-of@7.21.5
├─ @babel/plugin-transform-modules-commonjs@7.21.5
├─ @babel/plugin-transform-regenerator@7.21.5
├─ @babel/plugin-transform-unicode-escapes@7.21.5
├─ @babel/preset-env@7.21.5
├─ @babel/regjsgen@0.8.0
├─ @babel/template@7.20.7
├─ @babel/traverse@7.21.5
├─ @jridgewell/resolve-uri@3.1.0
├─ color-convert@1.9.3
├─ escape-string-regexp@1.0.5
├─ is-core-module@2.12.0
├─ js-tokens@4.0.0
├─ jsesc@2.5.2
├─ ms@2.1.2
├─ regenerate-unicode-properties@10.1.0
├─ regenerator-runtime@0.13.11
├─ regexpu-core@5.3.2
├─ regjsparser@0.9.1
├─ to-fast-properties@2.0.0
├─ unicode-canonical-property-names-ecmascript@2.0.0
├─ unicode-match-property-ecmascript@2.0.0
├─ unicode-match-property-value-ecmascript@2.1.0
└─ unicode-property-aliases-ecmascript@2.1.0
Done in 16.54s.
```
2023-05-03 15:33:57 +10:00
Maikel Linke
b30e962cdd Remove unknown (deleted) feature toggles at boot 2023-05-03 15:20:26 +10:00
Maikel Linke
5f1f717974 Spec FeatureToggle.setup! 2023-05-03 15:02:08 +10:00
Maikel Linke
b6f2fe0e92 Avoid defining modules in specs
We avoid some indent and show how code outside of the module works.
2023-05-03 14:58:59 +10:00
dependabot[bot]
a9bf7a2498 Bump @babel/core from 7.21.4 to 7.21.5
Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.21.4 to 7.21.5.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.21.5/packages/babel-core)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-03 12:18:41 +10:00
David Cook
e11518938f Prettify admin components scss
Largely whitespace, but some other updates too, including uppercase colour codes and standardising numbers.

Best viewed with whitespace ignored.
2023-05-03 12:10:58 +10:00
David Cook
c4dc5e0718 Prettier: use double quotes by default
Unfortunately Prettier won't let you do one rule at a time (https://stackoverflow.com/q/63813336/421243), so I'll break it into file chunks.
2023-05-03 12:10:58 +10:00
David Cook
c67d61a376 Don't ignore admin scss for prettying
...and watch the changes flow in!
2023-05-03 12:09:22 +10:00
David Cook
0b4556e72b Allow line length up to 100char
Same as we have for Ruby code: https://github.com/openfoodfoundation/openfoodnetwork/blob/master/.rubocop_styleguide.yml#L78-L80

This will avoid unnecessary reformatting.
2023-05-03 12:09:22 +10:00
David Cook
8c7f92d42e Explicitly ignore each css folder
With the goal to progressively un-ignore them.
2023-05-03 12:09:22 +10:00
Konrad
21a0017352 Merge pull request #10756 from jibees/10743-admin-add-unregistered-users-modal-some-html-is-rendered-as-plain-text-instead-of-being
Admin, Add unregistered user: Fix a reflex-morph issue that lead to a HTML escaping error
2023-05-02 19:28:48 +02:00
Konrad
d115c4ce2c Merge pull request #10733 from jibees/9782-shops-list-overlapping-and-overflowing-texts-on-mobile2
Shops list: fix some overlapping and overflowing texts on mobile
2023-05-02 12:15:19 +02:00
dependabot[bot]
b05d46c3e3 Bump sidekiq from 7.0.9 to 7.1.0
Bumps [sidekiq](https://github.com/sidekiq/sidekiq) from 7.0.9 to 7.1.0.
- [Release notes](https://github.com/sidekiq/sidekiq/releases)
- [Changelog](https://github.com/sidekiq/sidekiq/blob/main/Changes.md)
- [Commits](https://github.com/sidekiq/sidekiq/compare/v7.0.9...v7.1.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-02 09:57:28 +00:00
jibees
aae0fc59fb Merge pull request #10768 from Matt-Yorkley/query-logs
Improve query logging in development
2023-05-02 11:44:19 +02:00
Gaetan Craig-Riou
d1f7cc1b2a Merge pull request #10764 from Matt-Yorkley/remove-data-hooks
Remove `data-hook` attributes
2023-05-02 16:35:46 +10:00
Gaetan Craig-Riou
964481f188 Merge pull request #10765 from Matt-Yorkley/update-webpack-packages
Update webpack packages
2023-05-02 15:19:37 +10:00
Maikel
9bca22ae3b Merge pull request #10775 from openfoodfoundation/dependabot/bundler/mini_portile2-2.8.2
Bump mini_portile2 from 2.8.1 to 2.8.2
2023-05-02 11:54:37 +10:00
dependabot[bot]
064c843c90 Bump mini_portile2 from 2.8.1 to 2.8.2
Bumps [mini_portile2](https://github.com/flavorjones/mini_portile) from 2.8.1 to 2.8.2.
- [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.1...v2.8.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-01 10:02:13 +00:00
Maikel
482d438ec9 Merge pull request #10766 from filipefurtad0/remove_asertion_on_js_element_loading_orders
Removes assertions on transient JS element - "Loading orders"
2023-05-01 13:36:44 +10:00
Maikel Linke
9f0a66659a Delete now unused SessionCookieUpgrader 2023-05-01 13:35:52 +10:00
Konrad
1176ea2a5f Merge pull request #9941 from basilawwad/conditionally-send-cancellation-email
Conditionally send cancellation email when cancelling order.
2023-04-28 21:54:42 +02:00
Matt-Yorkley
dfc651ed2c Convert Permissions::Order#visible_line_items to a relation with or query
This change looks innocuous but the result of converting this into a nice relation instead of two queries stuck together with the pipe operator (|) can make a huge difference when chaining this into subqueries. The result set is ultimately the same, but the queries can be built without first returning all the ids and then sticking those ids in an array.
2023-04-28 19:13:22 +01:00
Matt-Yorkley
f42a9e3a66 Add query_count gem in development
A very simple gem that counts the total number of queries triggered by each request and displays a little number in the log. Nice.
2023-04-28 15:02:02 +01:00
Matt-Yorkley
8d9a8d8db5 Enable verbose query logs in development
This is a new feature in Rails 7. Whenever a query is triggered it not only show you the query (as before), but also tells you (directly in the logs) exactly which line of code was responsible for triggering the query. It's unbelievably useful for debugging and performance work.
2023-04-28 14:35:16 +01:00
Matt-Yorkley
84df1bfeab Remove SessionCookieUpgrader from middleware
This was a transitional bit of code to allow us to rename our session cookies without killing active sessions and logging users out. It's done it's job, the transition is finished, and it isn't doing anything useful now. It can be removed from the middleware stack.
2023-04-28 14:01:15 +01:00
Matt-Yorkley
b9431cd121 Remove data-hook attributes 2023-04-28 13:03:13 +01:00
filipefurtad0
74d18fb6ff Removes assertions on transient JS element 2023-04-28 12:48:59 +01:00
Matt-Yorkley
5e26e49764 Update webpack packages
`webpack-cli` is a dependency of `@rails/webpacker` but needs to be at version 3.x, we can just cut it from the explicit dependecy list and the correct version will be installed.

`webpack-dev-server` version 3.x corresponds (unhelpfully) to `webpacker` 4.x, and needs to be left that way. Dependabot tries to change it occasionally, but it should not be updated to 4.x
2023-04-28 12:48:21 +01:00
dependabot[bot]
c9dada4215 Bump ddtrace from 1.10.1 to 1.11.0
Bumps [ddtrace](https://github.com/DataDog/dd-trace-rb) from 1.10.1 to 1.11.0.
- [Release notes](https://github.com/DataDog/dd-trace-rb/releases)
- [Changelog](https://github.com/DataDog/dd-trace-rb/blob/master/CHANGELOG.md)
- [Commits](https://github.com/DataDog/dd-trace-rb/compare/v1.10.1...v1.11.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-28 10:00:28 +00:00
Maikel Linke
630169f8bb Preserve encoding of stored reports
Active Storage reads stored strings as ASCII and that can clash with
Rails' default UTF-8 encoding when special characters are present.
2023-04-28 16:38:06 +10:00
Gaetan Craig-Riou
152af5e105 Merge pull request #10751 from mkllnk/mail-config
Remove unused feature to intercept emails
2023-04-28 16:28:41 +10:00
David Cook
918425fd93 Remove customised error message
We're now handling these values on the frontend, so can keep this simple.

fixes up:
 Add numericality validation for *
 Add translation for Active Record error message
2023-04-28 14:02:12 +10:00
David Cook
a46eef291c Remove localized number logic from calculators
The browser is now responsible for dealing with the decimal separator, for all numeric preferences (as input[type=number]; see Spree::Admin::BaseHelper::preference_field_tag). Calculators are the only place that numeric preferences are used.

It will enforce that only one comma or dot (depending on user's locale) is entered, thus avoiding any ambiguity, and mis-interpretation (eg 100,001 could be interpreted as more than 100 thousand or 100 with a decimal place).
2023-04-28 13:54:16 +10:00
David Cook
d2fbb0bde2 Update translations
js: admin: orders: order_state: confirmation
2023-04-27 14:49:28 +10:00
David Cook
c42dfdde10 Merge pull request #10748 from openfoodfoundation/dependabot/bundler/view_component-3.0.0
Bump view_component from 2.82.0 to 3.0.0
2023-04-27 14:46:09 +10:00
Jean-Baptiste Bellet
959dcb82e1 Morph the form itself instead of morphing a parent DOM element
This seems to avoid HTML parsing error
2023-04-26 17:41:28 +02:00
jibees
51d5817665 Merge pull request #10755 from openfoodfoundation/dependabot/bundler/i18n-1.13.0
Bump i18n from 1.12.0 to 1.13.0
2023-04-26 15:45:59 +02:00
jibees
a8384b3155 Merge pull request #10754 from openfoodfoundation/dependabot/npm_and_yarn/floating-ui/dom-1.2.7
Bump @floating-ui/dom from 1.2.6 to 1.2.7
2023-04-26 15:44:04 +02:00
Konrad
394bfd00d8 Merge pull request #10586 from jibees/10563-allow-custom-url-on-logo-click
White Label: can link an URL to the white label logo
2023-04-26 13:52:10 +02:00
dependabot[bot]
bda1a527d3 Bump i18n from 1.12.0 to 1.13.0
Bumps [i18n](https://github.com/ruby-i18n/i18n) from 1.12.0 to 1.13.0.
- [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.12.0...v1.13.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-26 09:57:48 +00:00
dependabot[bot]
77bd832dd6 Bump @floating-ui/dom from 1.2.6 to 1.2.7
Bumps [@floating-ui/dom](https://github.com/floating-ui/floating-ui/tree/HEAD/packages/dom) from 1.2.6 to 1.2.7.
- [Release notes](https://github.com/floating-ui/floating-ui/releases)
- [Commits](https://github.com/floating-ui/floating-ui/commits/@floating-ui/dom@1.2.7/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>
2023-04-26 09:57:09 +00:00
Jean-Baptiste Bellet
b1de28eeea When there is a white_label_logo_link pref. use it!
+ update spec as well

 + use an an helper to get the main logo link for a shopfront

Co-Authored-By: Maikel <maikel@email.org.au>
2023-04-26 11:04:47 +02:00
Jean-Baptiste Bellet
679fcc0114 When removing the logo, also delete white_label_logo_link preference
since it has no sense without the logo
2023-04-26 11:04:47 +02:00
Jean-Baptiste Bellet
35778ecf1d If enterprise has a white_label_logo attached, then can edit its link 2023-04-26 11:04:47 +02:00
Jean-Baptiste Bellet
70a6e9f44b Add a white_label_logo_link attribute to enterprise model 2023-04-26 11:04:47 +02:00
Jean-Baptiste Bellet
30ba29382a Avoid name collision by renaming some classes with a prefix flex-
This classes should only be used with `.flex`
2023-04-26 09:52:24 +02:00
Jean-Baptiste Bellet
9584205a8e Use .flex class in utilities.scss file
No need to have multiple definition as already included
2023-04-26 09:51:28 +02:00
Jean-Baptiste Bellet
3644dbc0fd Small fix of a prettier formatter error 2023-04-26 09:51:17 +02:00
Jean-Baptiste Bellet
05a7276c9c Create an utilities.scss file that contains some utility classes
Finally Tailwind is coming? ;)
2023-04-26 09:47:23 +02:00
David Cook
1fc60d498a Merge pull request #10746 from openfoodfoundation/dependabot/bundler/rswag-specs-2.9.0
Bump rswag-specs from 2.8.0 to 2.9.0
2023-04-26 14:08:30 +10:00
Maikel Linke
dae8703b02 Remove unused feature to intercept emails
This option came from Spree and we never used it. The config input field
is disabled in the admin interface and I checked our managed databases.

I don't think that we will want this feature in the future either.
Staging sends unmodified emails which is more realistic and we haven't
had a use case to intercept those emails. There's still the BCC option
if we need additional access.
2023-04-26 13:50:31 +10:00
Maikel
3078c599f9 Merge pull request #10747 from openfoodfoundation/dependabot/bundler/rswag-ui-2.9.0
Bump rswag-ui from 2.8.0 to 2.9.0
2023-04-26 12:04:09 +10:00
dependabot[bot]
5d91ac217d Bump rswag-specs from 2.8.0 to 2.9.0
Bumps [rswag-specs](https://github.com/rswag/rswag) from 2.8.0 to 2.9.0.
- [Release notes](https://github.com/rswag/rswag/releases)
- [Changelog](https://github.com/rswag/rswag/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rswag/rswag/compare/2.8.0...2.9.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-26 02:03:53 +00:00
Maikel
f2edb6d404 Merge pull request #10745 from openfoodfoundation/dependabot/bundler/rswag-api-2.9.0
Bump rswag-api from 2.8.0 to 2.9.0
2023-04-26 12:02:38 +10:00
David Cook
7cd1b5d5db Update link
The old project was closed in favour of a new one.
2023-04-26 09:44:58 +10:00
dependabot[bot]
ad82f66173 Bump rswag-api from 2.8.0 to 2.9.0
Bumps [rswag-api](https://github.com/rswag/rswag) from 2.8.0 to 2.9.0.
- [Release notes](https://github.com/rswag/rswag/releases)
- [Changelog](https://github.com/rswag/rswag/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rswag/rswag/compare/2.8.0...2.9.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-25 10:10:17 +00:00
dependabot[bot]
62bfa9e04c Bump view_component from 2.82.0 to 3.0.0
Bumps [view_component](https://github.com/viewcomponent/view_component) from 2.82.0 to 3.0.0.
- [Release notes](https://github.com/viewcomponent/view_component/releases)
- [Changelog](https://github.com/ViewComponent/view_component/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/viewcomponent/view_component/compare/v2.82.0...v3.0.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-25 09:38:51 +00:00
dependabot[bot]
28c9d72342 Bump rswag-ui from 2.8.0 to 2.9.0
Bumps [rswag-ui](https://github.com/rswag/rswag) from 2.8.0 to 2.9.0.
- [Release notes](https://github.com/rswag/rswag/releases)
- [Changelog](https://github.com/rswag/rswag/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rswag/rswag/compare/2.8.0...2.9.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-25 09:38:22 +00:00
jibees
7317d6ca34 Merge pull request #10742 from filipefurtad0/fix_broken_build
Considers recent changes on login test helpers
2023-04-25 11:36:56 +02:00
filipefurtad0
edb8da4b4d Considers recent changes on login test helpers
PR #10696 introduced changes on the login helpers which were not considered, when merging a recent PR; This broke the build
2023-04-24 18:35:10 +01:00
Konrad
00d5bd9165 Merge pull request #10684 from MadisonBowron/master
Fix admin product variants form to close issues #10579 & Wishlist: 430
2023-04-24 18:18:01 +02:00
Jean-Baptiste Bellet
1730c9eb60 Fix one warning: Modal window with text has been opened, ...
```
Modal window with text `An invoice for this order will be sent to the customer. Are you sure you want to continue?` has been opened, but you didn't wrap your code into (`accept_prompt` | `dismiss_prompt` | `accept_confirm` | `dismiss_confirm` | `accept_alert`), accepting by default
```
2023-04-24 15:18:35 +02:00
Jean-Baptiste Bellet
5b9815f4a3 Test that restock has been called or not, depending on checkbox checked 2023-04-24 15:03:14 +02:00
jibees
445eb45ad7 Merge pull request #10737 from openfoodfoundation/dependabot/npm_and_yarn/prettier-2.8.8
Bump prettier from 2.8.7 to 2.8.8
2023-04-24 14:43:20 +02:00
jibees
8770471ada Merge pull request #10738 from openfoodfoundation/dependabot/npm_and_yarn/karma-6.4.2
Bump karma from 6.4.1 to 6.4.2
2023-04-24 14:43:07 +02:00
dependabot[bot]
6d45940ca4 Bump karma from 6.4.1 to 6.4.2
Bumps [karma](https://github.com/karma-runner/karma) from 6.4.1 to 6.4.2.
- [Release notes](https://github.com/karma-runner/karma/releases)
- [Changelog](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md)
- [Commits](https://github.com/karma-runner/karma/compare/v6.4.1...v6.4.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-24 09:58:22 +00:00
dependabot[bot]
69383ac621 Bump prettier from 2.8.7 to 2.8.8
Bumps [prettier](https://github.com/prettier/prettier) from 2.8.7 to 2.8.8.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.7...2.8.8)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-24 09:58:05 +00:00
Maikel
945cb84127 Merge pull request #10683 from filipefurtad0/update-the-build-env-to-ubuntu-2204
Updates build environment to Ubuntu 22.04
2023-04-24 15:27:05 +10:00
Maikel
343a2db1bf Merge pull request #10722 from mkllnk/rubocop-autocorrect-script
Add script for bulk autocorrect with Rubocop
2023-04-24 10:58:43 +10:00
Maikel Linke
de8f5e13b3 Explain gotcha in case it breaks one day 2023-04-24 09:39:21 +10:00
Konrad
75b5d1fd6f Merge pull request #10712 from jibees/6133-backoffice-orders-endless-spinner-and-error-500-after-skipping-oc-selector
Admin, create new order: distributor and order cycle are now mandatory on step 1 (aka the set_distribution step)
2023-04-22 16:04:15 +02:00
Konrad
0c1606e50c Merge pull request #10728 from jibees/10718-missing-translation-confirmation-order-state
Admin, `/orders`: adds translation for order in `confirmation` state
2023-04-22 11:56:23 +02:00
jibees
fa05554f15 Merge pull request #10734 from openfoodfoundation/dependabot/npm_and_yarn/karma-chrome-launcher-3.2.0
Bump karma-chrome-launcher from 3.1.1 to 3.2.0
2023-04-21 14:13:19 +02:00
Jean-Baptiste Bellet
2cc509de15 Do not check Metrics/BlockLength for shared_examples_for block
They can contains a lot of `it` tests
2023-04-21 11:59:24 +02:00
dependabot[bot]
41afad73e4 Bump karma-chrome-launcher from 3.1.1 to 3.2.0
Bumps [karma-chrome-launcher](https://github.com/karma-runner/karma-chrome-launcher) from 3.1.1 to 3.2.0.
- [Release notes](https://github.com/karma-runner/karma-chrome-launcher/releases)
- [Changelog](https://github.com/karma-runner/karma-chrome-launcher/blob/master/CHANGELOG.md)
- [Commits](https://github.com/karma-runner/karma-chrome-launcher/compare/v3.1.1...v3.2.0)

---
updated-dependencies:
- dependency-name: karma-chrome-launcher
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-21 09:57:29 +00:00
Jean-Baptiste Bellet
b17b25516f Use a UTF-8 character 2023-04-21 10:37:20 +02:00
Jean-Baptiste Bellet
8444fca19a Fix syntax error 2023-04-21 10:36:47 +02:00
Jean-Baptiste Bellet
18d90114fe Be more responsive: use flex, ellipsis, less columns 2023-04-21 10:36:21 +02:00
Gaetan Craig-Riou
2f17a02974 Merge pull request #10726 from mkllnk/spec-email-helper
Remove useless email test setup
2023-04-21 15:43:19 +10:00
Gaetan Craig-Riou
135bc7e2f8 Removing env variable $runs_on
Seting "env" under "jobs" doesn't work it gets picked up as a job. I moved
runs_on to the top level env. but I couldn't fine a way to get it to work.
I tried all syntax I could think of: $runs_on, ${{ runs_on }}  env.runs_on,
${{ env.runs_on }} and their capitalized versions.
2023-04-21 15:14:20 +10:00
Gaetan Craig-Riou
3810d79cad Merge pull request #10695 from macanudo527/rename_inversables
Rename Inversable Method Names
2023-04-21 11:38:58 +10:00
Maikel Linke
4960402643 Update translations 2023-04-21 09:45:45 +10:00
jibees
3557c10cd6 Merge pull request #10730 from openfoodfoundation/dependabot/bundler/stringex-2.8.6
Bump stringex from 2.8.5 to 2.8.6
2023-04-20 15:50:19 +02:00
jibees
45dd421f1f Merge pull request #10729 from openfoodfoundation/dependabot/bundler/aws-sdk-s3-1.121.0
Bump aws-sdk-s3 from 1.120.1 to 1.121.0
2023-04-20 15:48:46 +02:00
Jean-Baptiste Bellet
81606e841a Canceling an order: clicking on cancel btn or cancel action in dropdown 2023-04-20 14:38:59 +02:00
basilawwad
e633670e01 Use a shared_examples for the order cancellation tests 2023-04-20 14:38:59 +02:00
Filipe
11653c9430 Merge pull request #10575 from jibees/10559-allow-upload-of-custom-header-logo
White Label: can upload a custom header logo
2023-04-20 13:27:52 +01:00
dependabot[bot]
d068094044 Bump stringex from 2.8.5 to 2.8.6
Bumps [stringex](https://github.com/rsl/stringex) from 2.8.5 to 2.8.6.
- [Release notes](https://github.com/rsl/stringex/releases)
- [Commits](https://github.com/rsl/stringex/compare/v2.8.5...v2.8.6)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-20 10:06:33 +00:00
dependabot[bot]
b892bf726e Bump aws-sdk-s3 from 1.120.1 to 1.121.0
Bumps [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby) from 1.120.1 to 1.121.0.
- [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-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-20 10:00:05 +00:00
basilawwad
fa373518fb applied modal function
Update variant_autocomplete.js.erb

Applied modal function

refactored function

fix indentation and removed old function
2023-04-20 11:46:02 +02:00
Jean-Baptiste Bellet
76357789a3 Avoid line break between state wording and its little colored circle 2023-04-20 09:09:29 +02:00
Jean-Baptiste Bellet
5dd7246b85 Rename confirm to use confirmation
`confirmation` is the state used by order model
2023-04-20 09:07:01 +02:00
Jean-Baptiste Bellet
ba45dd84dd Solves rubocop linter errors 2023-04-20 08:46:19 +02:00
Jean-Baptiste Bellet
92e2a83e0e Use Rails7 command for image variant syntax 2023-04-20 08:45:03 +02:00
Jean-Baptiste Bellet
f42f513f8c Display white_label_logo image when hide_ofn_navigation is set to true
for both desktop and mobile view
2023-04-20 08:45:03 +02:00
Jean-Baptiste Bellet
54342254b6 Do not show white label logo is hide_ofn_navigation is not checked
They are both strongly linked
2023-04-20 08:45:03 +02:00
Jean-Baptiste Bellet
470761da86 Add a simple CheckboxDisplay controller that show/hide content
depending on the checkbox state (checked or not)
2023-04-20 08:45:03 +02:00
Jean-Baptiste Bellet
6fdf9fa038 Add/Remove white label logo in enterprise preferences panel 2023-04-20 08:45:03 +02:00
Jean-Baptiste Bellet
bbec01a9cb Create a concern for reflexes that handle Enterprise update 2023-04-20 08:45:03 +02:00
Jean-Baptiste Bellet
e3001cc8c4 Add white_label_logo to enterprise model as attachment
Co-Authored-By: Maikel <maikel@email.org.au>
2023-04-20 08:45:03 +02:00
Jean-Baptiste Bellet
ad0d0e393e ConfirmModalComponent is ready to receive data-reflex
And not only `data-action`
2023-04-20 08:45:03 +02:00
Jean-Baptiste Bellet
2690ff5eb5 Add comment, which links these two files together 2023-04-20 08:45:03 +02:00
jibees
2594382488 Merge pull request #10723 from openfoodfoundation/dependabot/bundler/sidekiq-7.0.9
Bump sidekiq from 7.0.8 to 7.0.9
2023-04-20 08:31:46 +02:00
Maikel Linke
9b3cfe80ff Remove useless clearing of test emails
They are cleared by the test environment anyway.
2023-04-20 13:35:40 +10:00
Maikel Linke
04d33adaf2 Remove duplicate declaration of test mail delivery
Our test environment sets the mail delivery method already. We don't
have to do it in individual spec files.
2023-04-20 13:28:59 +10:00
Maikel Linke
915bd19d7b Remove useless email test setup
We always deliver emails these days.
2023-04-20 12:18:04 +10:00
Maikel Linke
9998025687 Remove useless test header setup for emails
Once upon a time we needed a helper to set the `from` header of emails.
This is now set in the ApplicationMailer and not necessary any more.
2023-04-20 12:15:34 +10:00
Maikel
89cb3b7c14 Merge pull request #10707 from mkllnk/mailer-previews
Fix ShipmentMailer preview autoload path
2023-04-20 11:30:25 +10:00
Maikel Linke
1955a6719c Fix commit message formatting
Git needs a blank line between the summary and the longer description.
And `echo` doesn't interpret `\n` by default.
2023-04-20 11:19:32 +10:00
Maikel Linke
f71e5ee43c Limit number of rubocop autocorrect runs
The typical use case is to create a small number of commits for a pull
request to ease the review. And you can still run it for all cops with
`-n 999` or `-n -0`.
2023-04-20 11:19:32 +10:00
Maikel Linke
0ac2358f2c Regenerate Rubocop's TODO file without timestamp 2023-04-20 10:34:35 +10:00
Filipe
3e0b358370 Merge pull request #10461 from vviekk/9978
Updating price, on_hand, on_demand validations for product import
2023-04-19 16:09:49 +01:00
Filipe
f206b7ed9e Merge pull request #10661 from mkllnk/report-download
[Hidden] Provide download link for reports generated in the background
2023-04-19 11:53:14 +01:00
dependabot[bot]
946b69242c Bump sidekiq from 7.0.8 to 7.0.9
Bumps [sidekiq](https://github.com/sidekiq/sidekiq) from 7.0.8 to 7.0.9.
- [Release notes](https://github.com/sidekiq/sidekiq/releases)
- [Changelog](https://github.com/sidekiq/sidekiq/blob/main/Changes.md)
- [Commits](https://github.com/sidekiq/sidekiq/compare/v7.0.8...v7.0.9)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-19 09:58:13 +00:00
Filipe
a409d3b97e Merge pull request #10201 from saunmanoj888/fix-invalid-image-upload
Fix corrupt and invalid image upload issue
2023-04-19 10:45:04 +01:00
Jean-Baptiste Bellet
a27b64a66b Add confirmation state translation 2023-04-19 11:32:51 +02:00
Jean-Baptiste Bellet
0f54d3950d Save can have a context: simplify then 2023-04-19 10:15:35 +02:00
Jean-Baptiste Bellet
7e306693a8 Use Rails standard naming: same name for the route and the method 2023-04-19 10:15:35 +02:00
Maikel
1f661c1e69 Merge pull request #10716 from jibees/10048-stimulusreflex-caching-warning
Adds caching by default in development environment to avoid StimulusReflex warning
2023-04-19 16:22:37 +10:00
saunmanoj888
97f51d24b8 Validate image on creating product from products/new 2023-04-19 16:11:46 +10:00
saunmanoj888
c3d274c84f Fix corrupt and invalid image upload issue 2023-04-19 16:11:46 +10:00
Maikel Linke
213fb42a05 Safely autocorrect Gemspec/RequireMFA
Inspecting 1404 files
.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................W.....................W....................................W...........................W.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

engines/catalog/catalog.gemspec:7:1: W: [Corrected] Gemspec/RequireMFA: metadata['rubygems_mfa_required'] must be set to 'true'.
Gem::Specification.new do |s| ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/catalog/catalog.gemspec:14:1: C: [Corrected] Layout/IndentationConsistency: Inconsistent indentation detected.
s.metadata['rubygems_mfa_required'] = 'true'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/dfc_provider/dfc_provider.gemspec:9:1: W: [Corrected] Gemspec/RequireMFA: metadata['rubygems_mfa_required'] must be set to 'true'.
Gem::Specification.new do |spec| ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/dfc_provider/dfc_provider.gemspec:21:1: C: [Corrected] Layout/IndentationConsistency: Inconsistent indentation detected.
spec.metadata['rubygems_mfa_required'] = 'true'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/order_management/order_management.gemspec:7:1: W: [Corrected] Gemspec/RequireMFA: metadata['rubygems_mfa_required'] must be set to 'true'.
Gem::Specification.new do |s| ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/order_management/order_management.gemspec:14:1: C: [Corrected] Layout/IndentationConsistency: Inconsistent indentation detected.
s.metadata['rubygems_mfa_required'] = 'true'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/web/web.gemspec:7:1: W: [Corrected] Gemspec/RequireMFA: metadata['rubygems_mfa_required'] must be set to 'true'.
Gem::Specification.new do |s| ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/web/web.gemspec:14:1: C: [Corrected] Layout/IndentationConsistency: Inconsistent indentation detected.
s.metadata['rubygems_mfa_required'] = 'true'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1404 files inspected, 8 offenses detected, 8 offenses corrected
2023-04-19 15:35:30 +10:00
Maikel Linke
bde46fa1e9 Safely autocorrect Gemspec/DeprecatedAttributeAssignment
Inspecting 1404 files
.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................W.....................W....................................W...........................W.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

engines/catalog/catalog.gemspec:14:3: W: [Corrected] Gemspec/DeprecatedAttributeAssignment: Do not set test_files in gemspec.
  s.test_files = Dir["test/**/*"]
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/dfc_provider/dfc_provider.gemspec:17:3: W: [Corrected] Gemspec/DeprecatedAttributeAssignment: Do not set test_files in gemspec.
  spec.test_files = Dir['spec/**/*']
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/order_management/order_management.gemspec:14:3: W: [Corrected] Gemspec/DeprecatedAttributeAssignment: Do not set test_files in gemspec.
  s.test_files = Dir["spec/**/*"]
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/web/web.gemspec:14:3: W: [Corrected] Gemspec/DeprecatedAttributeAssignment: Do not set test_files in gemspec.
  s.test_files = Dir["test/**/*"]
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1404 files inspected, 4 offenses detected, 4 offenses corrected
2023-04-19 15:35:29 +10:00
Maikel Linke
dc560d3793 Safely autocorrect Bundler/OrderedGems
Inspecting 1404 files
.C..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

Gemfile:18:1: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem angular-rails-templates should appear before rexml.
gem 'angular-rails-templates', '>= 0.3.0'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:19:1: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem awesome_nested_set should appear before rexml.
gem 'awesome_nested_set'
^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:20:1: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem ransack should appear before rexml.
gem 'ransack', '~> 2.6.0'
^^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:21:1: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem responders should appear before rexml.
gem 'responders'
^^^^^^^^^^^^^^^^
Gemfile:74:1: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem omniauth-rails_csrf_protection should appear before openid_connect.
gem 'omniauth-rails_csrf_protection'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:154:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before factory_bot_rails.
  gem 'debug', '>= 1.0.0'
  ^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:155:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before fuubar.
  gem 'debug', '>= 1.0.0'
  ^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:156:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before json_spec.
  gem 'debug', '>= 1.0.0'
  ^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:157:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before knapsack_pro.
  gem 'debug', '>= 1.0.0'
  ^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:158:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before letter_opener.
  gem 'debug', '>= 1.0.0'
  ^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:159:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before rspec-rails.
  gem 'debug', '>= 1.0.0'
  ^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:160:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before rspec-retry.
  gem 'debug', '>= 1.0.0'
  ^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:161:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before rswag-specs.
  gem 'debug', '>= 1.0.0'
  ^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:162:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before shoulda-matchers.
  gem 'debug', '>= 1.0.0'
  ^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:163:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem debug should appear before timecop.
  gem 'debug', '>= 1.0.0'
  ^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:179:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem foreman should appear before rails-erd.
  gem 'foreman'
  ^^^^^^^^^^^^^
Gemfile:180:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem listen should appear before rails-erd.
  gem 'listen'
  ^^^^^^^^^^^^
Gemfile:181:3: C: [Corrected] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem pry should appear before rails-erd.
  gem 'pry', '~> 0.13.0'
  ^^^^^^^^^^^^^^^^^^^^^^

1404 files inspected, 18 offenses detected, 18 offenses corrected
2023-04-19 15:35:29 +10:00
Maikel Linke
52f134fc9e Regenerate Rubocop's TODO file 2023-04-19 15:35:29 +10:00
Maikel Linke
c08e264afa Add script for bulk autocorrect with Rubocop
We also had an old script which wasn't used and needed manual steps.
2023-04-19 15:35:29 +10:00
Maikel
0b03152f3b Merge pull request #10697 from mkllnk/rubocop-config-update
Update Rubocop config and replace deprecated TimeWithZone#to_s with argument
2023-04-19 11:23:34 +10:00
Maikel
6f492d868c Merge pull request #10688 from mkllnk/application-mailer
Apply Rails standard to base mailer class
2023-04-19 10:29:16 +10:00
jibees
dab2a4af75 Merge pull request #10693 from jibees/10658-move-all-managed-instances-to-fully-enabled-split_checkout-toggle
Activate `split_checkout` feature by default
2023-04-18 17:33:48 +02:00
Jean-Baptiste Bellet
f7935bde34 Enable caching dy default, to avoid StimulusReflex warning
```
Heads up! 🔥

👉 StimulusReflex requires caching to be enabled. Caching allows the session to be modified during ActionCable requests.

To enable caching in development, run:

rails dev:cache
```

Documentation: https://docs.stimulusreflex.com/hello-world/setup.html#manual-configuration
2023-04-18 16:02:02 +02:00
Jean-Baptiste Bellet
61850f7e92 Remove duplicate line
Probably due to a bad merge conflict resolution

Line is already on line `#25`
2023-04-18 16:01:04 +02:00
Neal Chambers
4e32bfd70b Rename Inversable Method Names 2023-04-18 22:58:06 +09:00
jibees
7df456c1e3 Merge pull request #10715 from openfoodfoundation/dependabot/bundler/puma-6.2.2
Bump puma from 6.2.1 to 6.2.2
2023-04-18 15:04:17 +02:00
Konrad
2fa86492d1 Merge pull request #10653 from openfoodfoundation/10645-pagination-in-bom-not-aggregating-results-when-clicking-a-productvariant
BOM: When selecting a specific variant, trigger a new search that avoid pagination issues
2023-04-18 14:49:14 +02:00
Jean-Baptiste Bellet
722c660697 Do not show any links to other steps when no distribution set
distribution means tuple: distributor + order cycle
2023-04-18 14:36:47 +02:00
Jean-Baptiste Bellet
ac666a6fce Validate presence of distributor and order_cycle in set_distribution step 2023-04-18 14:36:47 +02:00
Jean-Baptiste Bellet
ba1d985932 update the set_distribution form on the same path
and use the same method `OrdersController#set_distribution`
2023-04-18 14:36:47 +02:00
Jean-Baptiste Bellet
0f28d318ac Fix rubocop error and prefer using a return clause 2023-04-18 14:36:47 +02:00
Jean-Baptiste Bellet
6172d1f2e5 Extract method on_update that will be used elsewhere 2023-04-18 14:36:47 +02:00
Jean-Baptiste Bellet
05a040b4c3 No need to ensure if the distribution is set on new action
This will be handled by validation on set_distribution action
2023-04-18 14:36:47 +02:00
Jean-Baptiste Bellet
73a81310f8 Create a new url /orders/ORDER_ID/distribution
That handles the step when distributor and order_cycle must be selected
2023-04-18 14:21:23 +02:00
dependabot[bot]
85860692ae Bump puma from 6.2.1 to 6.2.2
Bumps [puma](https://github.com/puma/puma) from 6.2.1 to 6.2.2.
- [Release notes](https://github.com/puma/puma/releases)
- [Changelog](https://github.com/puma/puma/blob/master/History.md)
- [Commits](https://github.com/puma/puma/compare/v6.2.1...v6.2.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-18 09:59:41 +00:00
jibees
8ad4d2cc2e Merge pull request #10708 from openfoodfoundation/dependabot/npm_and_yarn/webpack-dev-server-4.13.3
Bump webpack-dev-server from 4.13.2 to 4.13.3
2023-04-18 10:15:01 +02:00
David Cook
c967eca9c4 Merge pull request #10713 from openfoodfoundation/dependabot/npm_and_yarn/ansi-regex-4.1.1
Bump ansi-regex from 4.1.0 to 4.1.1 (security patch)
2023-04-18 15:34:24 +10:00
David Cook
7fff82eec3 Merge pull request #10710 from openfoodfoundation/dependabot/bundler/rubocop-1.50.2
Bump rubocop from 1.50.1 to 1.50.2
2023-04-18 15:24:40 +10:00
dependabot[bot]
c30ed0f7c8 Bump rubocop from 1.50.1 to 1.50.2
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.50.1 to 1.50.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.50.1...v1.50.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-18 04:51:38 +00:00
David Cook
cde420716b Merge pull request #10709 from openfoodfoundation/dependabot/bundler/rubocop-rails-2.19.1
Bump rubocop-rails from 2.19.0 to 2.19.1
2023-04-18 14:50:11 +10:00
David Cook
ee37c5d4a3 Merge pull request #10699 from dacook/sass-deprecations
Sass deprecations
2023-04-18 11:48:56 +10:00
dependabot[bot]
e9d236f761 Bump ansi-regex from 4.1.0 to 4.1.1
Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 4.1.0 to 4.1.1.
- [Release notes](https://github.com/chalk/ansi-regex/releases)
- [Commits](https://github.com/chalk/ansi-regex/compare/v4.1.0...v4.1.1)

---
updated-dependencies:
- dependency-name: ansi-regex
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-18 00:05:00 +00:00
Gaetan Craig-Riou
8b78c28feb Merge pull request #10702 from openfoodfoundation/dependabot/npm_and_yarn/cable_ready-5.0.0
Bump cable_ready from 5.0.0-rc2 to 5.0.0
2023-04-18 10:02:59 +10:00
David Cook
43e51cb592 Simplify login spec helpers, avoid long lines
Follow on from 5c6d9a092e
2023-04-18 10:01:23 +10:00
David Cook
6570891349 Fix linter issues
Although I don't think the size was an issue here, small hashes can easily fit on one line.
2023-04-18 09:50:08 +10:00
David Cook
0f3e2ae572 Use browser validation for calculator values
They're all numbers, so we can reliably validate in the browser, removing the need for additional validation logic.
They will still be validated server-side, and in the unlikely even that there is an error, the generic 'Calculator is invalid' message will appear, with the relevant fields highlighted red. I think that's fine.
2023-04-18 09:50:08 +10:00
David Cook
f0110d20a2 Move config to base helper
This config is relevant for all specs, including system specs.
2023-04-18 09:50:08 +10:00
David Cook
353acfd6ae Validate associated calculator with built in error handling
Except that pesky generic message was appearing. I still don't know how to control that so just deleted it.
2023-04-18 09:39:39 +10:00
David Cook
e43a018dc7 [wip] Copy each calculator error
But we still have the duplicate problem.
Wait a minute, it copies them in the same format that I am copying them. So.. I don't need to copy them at all!

Now I see that we just needed the right format in the translation file.
2023-04-18 09:39:39 +10:00
David Cook
f6fac018ea [wip] Use a custom message format for associated errors
This is much simpler. Multiple messages get combined onto one line though, which is not perfect.

And.. it still seems to duplicate the errors. Weird, it's fine on my frontend though.
2023-04-18 09:39:39 +10:00
David Cook
ce1bd12760 Consolidate specs
It takes time to set up this test case. Given that there's no interactions in the expectations, we should save time to generate it only once.
2023-04-18 09:39:39 +10:00
David Cook
364ccc2146 Add comment 2023-04-18 09:39:39 +10:00
James Wu
2a7cb50fa9 Keep and display submitted data on new payment method page 2023-04-18 09:39:39 +10:00
James Wu
29ddc68d20 Fix duplicate validation error message 2023-04-18 09:39:39 +10:00
James Wu
d40f3414ea fixup! Add translation for Active Record error message 2023-04-18 09:39:39 +10:00
James Wu
f5e2edb028 fixup! Modify Calculator validation error messages [wip]
DC: the error message has now become "Amount Invalid input".
2023-04-18 09:39:39 +10:00
James Wu
7af26e6579 Add errors for invalid input with number localization enabled 2023-04-18 09:39:39 +10:00
James Wu
824d4adf21 Rename spec file 2023-04-18 09:39:39 +10:00
James Wu
00cc8da2fc Fix rubocop class length error 2023-04-18 09:39:39 +10:00
James Wu
ae5f2cc19d Fix error saving data on new Calculator 2023-04-18 09:39:39 +10:00
James Wu
41ce4fbc16 Fix cache issue with invalid form data 2023-04-18 09:39:39 +10:00
James Wu
48753df5f0 Improve input validation and error notification 2023-04-18 09:39:39 +10:00
James Wu
1f3e66316b Modify Calculator validation error messages 2023-04-18 09:39:39 +10:00
James Wu
6b1426d0c6 Add numericality validation for PriceSack 2023-04-18 09:39:39 +10:00
James Wu
c68987c0f2 Add numericality validation for PerItem 2023-04-18 09:39:39 +10:00
James Wu
2cb25e6366 Add numericality validation for FlexiRate 2023-04-18 09:39:39 +10:00
James Wu
073f46e590 Add numericality validation for FlatRate 2023-04-18 09:39:39 +10:00
James Wu
23beea8a13 Add numericality validation for FlatPercentPerItem 2023-04-18 09:39:39 +10:00
James Wu
096e388fdf Add numericality validation for FlatPercentItemTotal 2023-04-18 09:39:39 +10:00
James Wu
3dfaf882a3 Add translation for Active Record error message 2023-04-18 09:39:39 +10:00
James Wu
7b51f45b4d Fix spelling in test description 2023-04-18 09:39:39 +10:00
James Wu
b9b2fa7c94 Fix error converting String to BigDecimal 2023-04-18 09:39:39 +10:00
James Wu
ee30d3d139 Fix PaymentMethodFactory creating extra Calculator 2023-04-18 09:39:39 +10:00
Filipe
871b2f8816 Merge pull request #10696 from mkllnk/login-as-admin
Simplify login test helpers
2023-04-17 12:14:06 +01:00
dependabot[bot]
214bdc6fbe Bump rubocop-rails from 2.19.0 to 2.19.1
Bumps [rubocop-rails](https://github.com/rubocop/rubocop-rails) from 2.19.0 to 2.19.1.
- [Release notes](https://github.com/rubocop/rubocop-rails/releases)
- [Changelog](https://github.com/rubocop/rubocop-rails/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rails/compare/v2.19.0...v2.19.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-17 10:01:45 +00:00
dependabot[bot]
d2fce053a7 Bump webpack-dev-server from 4.13.2 to 4.13.3
Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server) from 4.13.2 to 4.13.3.
- [Release notes](https://github.com/webpack/webpack-dev-server/releases)
- [Changelog](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-dev-server/compare/v4.13.2...v4.13.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-17 09:57:50 +00:00
Jean-Baptiste Bellet
11a7aa9f96 When clicking on "Clear Filters" button, to not reset variant selection
+ add some specs to cover that particular case
2023-04-17 11:08:17 +02:00
Jean-Baptiste Bellet
c0203e7091 Refactor by putting two specs into a shared_example
"It's a Surprise Tool That Will Help Us Later"
2023-04-17 11:06:23 +02:00
Maikel
44cc5cc665 Merge pull request #10677 from mkllnk/spec-helpers
Simplify spec helpers
2023-04-17 16:16:29 +10:00
Maikel Linke
6c8e383ab8 Fix ShipmentMailer preview autoload path
The Zeitwerk autoloader requires class names and file names to match. In
this case, the class had a Spree namespace without being in a spree
folder. The preview couldn't be displayed. Now it can be displayed.
2023-04-17 15:18:22 +10:00
Maikel Linke
5c6d9a092e Simplify login spec helpers, avoid long lines
The `login_as_admin_and_visit` helper was used a lot but isn't really
shorter than:

    login_as_admin
    visit path_visit

Calling those methods separately reduces line length. It also removes
the potential impression that it may be more efficient to use the
helper. Now we have less indirection if one of the calls fails and see
the failing spec line straight away.
2023-04-17 11:08:32 +10:00
Maikel Linke
8d500a2c27 Remove superflouous login test helper
It was often used with a `visit` statement after which resulted in
unnecessary page loads. There was only one case where a `visit` was
expected but it wasn't needed either.
2023-04-17 10:56:51 +10:00
Maikel Linke
425674c4e5 Remove unused return value of admin login helper
Well, there was one use of the return helper. But I don't think that
it's a very intuitive method.
2023-04-17 10:56:51 +10:00
Konrad
e91e827f29 Merge pull request #10664 from abdellani/fix-remove-duplicated-cusomter-from-mailing-list-report
Fix Repeated customer entries on Mailing List Report
2023-04-16 21:17:33 +02:00
Konrad
8f201c830a Merge pull request #10665 from abdellani/fix-remove-duplicated-cusomter-from-addresses-list-report
Fix Repeated customer entries on Addresses List Report
2023-04-16 20:40:56 +02:00
Konrad
1b536d9265 Merge pull request #10601 from abdellani/fix-v1-customers-endpoint-should-only-return-managed-enterprise-customers
fix: v1/customers endpoint should load customers of managed enterprises only
2023-04-16 16:22:02 +02:00
Mohamed ABDELLANI
1b8a9244a6 test when user is a non-persisted object 2023-04-15 06:16:40 +01:00
dependabot[bot]
a40e883d17 Bump cable_ready from 5.0.0-rc2 to 5.0.0
Bumps [cable_ready](https://github.com/stimulusreflex/cable_ready) from 5.0.0-rc2 to 5.0.0.
- [Release notes](https://github.com/stimulusreflex/cable_ready/releases)
- [Changelog](https://github.com/stimulusreflex/cable_ready/blob/main/CHANGELOG.md)
- [Commits](https://github.com/stimulusreflex/cable_ready/commits/v5.0.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-14 09:57:54 +00:00
Jean-Baptiste Bellet
6bf21d2abd SASS loader: Do not print warnings from dependencies 2023-04-14 11:09:39 +02:00
David Cook
29b9777a96 Replace deprecated sass division operator
https://sass-lang.com/documentation/breaking-changes/slash-div
> Sass currently treats / as a division operation in some contexts and a separator in others. This makes it difficult for Sass users to tell what any given / will mean, and makes it hard to work with new CSS features that use / as a separator.

There's a handy migrator:

    npm install -g sass-migrator
    sass-migrator division **/*.scss

And it cleverly avoids the need for the ugly division method in most cases.
2023-04-14 17:59:01 +10:00
David Cook
283dd84ad6 Add expected whitespace
The migrator refused to proceed until I fixed this.
2023-04-14 17:56:24 +10:00
Maikel Linke
03828c5608 Style Rails/ToSWithArgument 2023-04-14 16:34:51 +10:00
Maikel Linke
dad4061ff9 Style Rails/ToFormattedS 2023-04-14 16:32:39 +10:00
Maikel Linke
b19df0dfbf Enable new Rubocop cops
This detects an additional 639 offenses which I added to the todo file.
From now on, when Dependabot bumps rubocop the build may fail due to new
cops. But that's a great opportunity to utilise those new cops and fix
violations straight away. Otherwise we'll never get to them and lose out
on useful autocorrection, for example for updating deprecated syntax.
2023-04-14 16:28:20 +10:00
Maikel Linke
efb2ae6843 Style Rails/Pick - rubocop passes completely 2023-04-14 16:22:46 +10:00
Maikel Linke
407fca17cb Style Rails/IndexWith 2023-04-14 16:19:21 +10:00
Maikel Linke
33409725a5 Run rubocop-rails with current Rails version 7.0
This adds three new issues I will address in the next commits.

```
Offenses:

app/json_schemas/json_api_schema.rb:40:7: C: [Correctable] Rails/IndexWith: Prefer index_with over to_h { ... }.
      relationships.to_h { |name| [name, relationship_schema(name)] }
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/base.rb:18:11: C: [Correctable] Rails/IndexWith: Prefer index_with over map { ... }.to_h.
          data_attributes.map { |attr| [attr, I18n.t("header.#{attr}", scope: i18n_scope)] }.to_h
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/sales_tax/sales_tax_totals_by_order.rb:140:14: C: [Correctable] Rails/Pick: Prefer pick('sum(amount)') over pluck('sum(amount)').first.
            .pluck('sum(amount)').first || 0
             ^^^^^^^^^^^^^^^^^^^^^^^^^^

1404 files inspected, 3 offenses detected, 3 offenses autocorrectable
```
2023-04-14 16:15:13 +10:00
Maikel Linke
c70a694111 Style line length - rubocop passes completely 2023-04-14 16:12:14 +10:00
Maikel Linke
9c88c77066 Style empty lines 2023-04-14 16:05:50 +10:00
Maikel Linke
42585bb074 Remove redundant cop disable directive 2023-04-14 16:04:57 +10:00
MadisonBowron
697f2795d4 Remove arbitrary comments 2023-04-14 01:25:14 -04:00
Maikel
b0211d0930 Merge pull request #10686 from filipefurtad0/truncates_product_description
Sets too long line truncation spec as pending
2023-04-14 15:11:31 +10:00
Maikel
0675422509 Merge pull request #10678 from dacook/show-commit-in-ci
Show commit in CI
2023-04-14 14:43:44 +10:00
Maikel
5ff1b0d358 Merge pull request #10676 from filipefurtad0/fix_spec_ts_and_cs
Adds pending test for default ToS
2023-04-14 14:00:32 +10:00
Maikel Linke
43cbac7d17 Simplify report filename generation 2023-04-14 11:29:36 +10:00
Maikel Linke
98e4f867b4 Provide download link for generated reports 2023-04-14 11:29:35 +10:00
Maikel Linke
ebb15781d5 Store report's filename within the blob
For future downloads outside the ReportsController.
2023-04-14 11:29:35 +10:00
Maikel Linke
028c4f4281 Simplify ReportJob by extracting model for result
This makes the code heaps simpler.
2023-04-14 11:29:35 +10:00
Maikel Linke
ef7dfa3b4f Store reports with Active Storage
This will enable us to offer download links and clean them up
automatically.
2023-04-14 11:29:35 +10:00
Maikel Linke
71f9415d21 Use ApplicationJob as it's a Rails default 2023-04-14 11:29:35 +10:00
Maikel Linke
12848acf21 Fix typo 2023-04-14 11:29:35 +10:00
Maikel Linke
4f751c2711 Leverage test helpers for enqueued jobs
The production code calls `perform_later` and it's better to do the same
in specs. Handy test helper allow us to control the execution.

Credit to https://github.com/cyrillefr.
2023-04-14 11:29:35 +10:00
jibees
920e2564a4 Merge pull request #10692 from openfoodfoundation/dependabot/bundler/rubocop-1.50.1
Bump rubocop from 1.50.0 to 1.50.1
2023-04-13 13:45:28 +02:00
Jean-Baptiste Bellet
6b4e150e2a Active split_checkout feature by default 2023-04-13 13:21:23 +02:00
dependabot[bot]
2d43e32688 Bump rubocop from 1.50.0 to 1.50.1
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.50.0 to 1.50.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.50.0...v1.50.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-13 09:57:38 +00:00
David Cook
a6cd393c57 Update all locales with the latest Transifex translations 2023-04-13 16:45:38 +10:00
Filipe
b1060bf1c9 Merge pull request #10640 from openfoodfoundation/dependabot/bundler/stripe-8.5.0
Bump stripe from 8.3.0 to 8.5.0
2023-04-12 19:27:18 +01:00
Filipe
1bf5fbaf3a Merge pull request #10449 from macanudo527/fix_ER
Update OCs after ER Permissions are Revoked
2023-04-12 18:59:20 +01:00
Konrad
2ace3afd67 Merge pull request #10606 from thejwuscript/10116-improve-bom-sorting
Sort orders by last name
2023-04-12 16:36:45 +02:00
Konrad
0bfceb877d Merge pull request #10666 from jibees/9723-admin-missing-translation-in-payment-report
Admin, Payment reports: add missing translation for payment state
2023-04-12 15:47:23 +02:00
Filipe
c1d28b2e8f Merge pull request #10119 from binarygit/donot-hide-producers-name-in-products
Display producer's name in products inspite of hide all refs option
2023-04-12 13:07:52 +01:00
Jean-Baptiste Bellet
2841b42296 Specify truncate parameter as we don't always truncate description
Only when too long.
2023-04-12 10:34:30 +02:00
jibees
98e44e7a40 Merge pull request #10687 from openfoodfoundation/dependabot/bundler/nokogiri-1.14.3
Bump nokogiri from 1.14.2 to 1.14.3
2023-04-12 10:25:56 +02:00
jibees
51c6c19f80 Merge pull request #10669 from openfoodfoundation/dependabot/bundler/sidekiq-7.0.8
Bump sidekiq from 7.0.7 to 7.0.8
2023-04-12 10:24:59 +02:00
filipefurtad0
26947a64c0 Adds test to check pagination upon line-item selection 2023-04-12 09:58:01 +02:00
Jean-Baptiste Bellet
df5c21048a Clear on bulk submenu should reset some filters + refresh data as well 2023-04-12 09:58:01 +02:00
Jean-Baptiste Bellet
8a124fb6be BOM: once variant has been selected, refresh data with a new search
- Remove variant_filter
 - instantiate a new search to avoid pagination issues
2023-04-12 09:58:00 +02:00
filipefurtad0
7d51979c06 Updates build environment to Ubuntu 22.04
Creates environment variable to set OS version
2023-04-12 09:19:14 +02:00
Maikel Linke
ced49e0217 Apply Rails standard to base mailer class
It has the advantage that `rails generate mailer` works out of the box
and we comply with rubocop rules.
2023-04-12 16:39:20 +10:00
dependabot[bot]
75b7a1864b Bump nokogiri from 1.14.2 to 1.14.3
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.14.2 to 1.14.3.
- [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.14.2...v1.14.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-12 06:24:59 +00:00
Maikel Linke
281d0eb417 Simplify mailers with Rails default "from" setting 2023-04-12 16:15:51 +10:00
Maikel Linke
496f5199c9 Use DatabaseCleaner recommendation of late cleaning
https://github.com/DatabaseCleaner/database_cleaner#rspec-with-capybara-example
2023-04-12 14:24:07 +10:00
Maikel Linke
f13c0e1dca Bring all Rspec config for database cleaning together 2023-04-12 14:23:09 +10:00
David Cook
f801d4a4cb Move single-used variables to their own example
They were created three times each, but only used once.
2023-04-12 11:05:11 +10:00
David Cook
d94da8df1e Update comment 2023-04-12 11:04:00 +10:00
MadisonBowron
8c6e0a841c Fix rubocop extra blank line error 2023-04-11 15:35:37 -04:00
filipefurtad0
70d9cfa08e Sets too long line truncation spec as pending 2023-04-11 19:46:11 +01:00
jibees
193ae7936e Merge pull request #10681 from openfoodfoundation/dependabot/bundler/rubocop-1.50.0
Bump rubocop from 1.49.0 to 1.50.0
2023-04-11 20:40:55 +02:00
Filipe
0971e8d9b5 Merge pull request #10644 from mkllnk/report-timeout-message
[Hidden] Display a friendly message when a background report times out
2023-04-11 19:40:42 +01:00
Jean-Baptiste Bellet
e78b44b9ca Do not shows <a /> if producers is hidden
Different style as it does not open any modal
2023-04-11 14:27:57 +02:00
binarygit
c5779eff81 Do not open modal for producer's who are 'hidden' 2023-04-11 14:27:57 +02:00
Jean-Baptiste Bellet
b616c14f63 Don't hide producer's name in products despite hide all refs opt selected 2023-04-11 14:26:47 +02:00
Mohamed ABDELLANI
03cb14c926 define manage_by scope on customer model 2023-04-11 12:18:15 +01:00
Mohamed ABDELLANI
da78e06a39 load customers of managed enterprises only 2023-04-11 12:10:07 +01:00
dependabot[bot]
f4c351febf Bump rubocop from 1.49.0 to 1.50.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.49.0 to 1.50.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.49.0...v1.50.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-11 10:05:30 +00:00
Maikel Linke
30184ac6aa Background reports time out earlier than nginx
This allows us to display a friendly message before nginx displays its
default error.
2023-04-11 16:44:13 +10:00
David Cook
a123d45eca Fix spec
It's worth noting that this page hasn't been updated by this PR.
I honestly don't know why it broke, but don't care anymore. It seems the extra `login_as_admin_and_visit` was causing a race condition on one spec. It's not necessary so I've removed this context.

Best viewed with whitespace ignored.
2023-04-11 16:38:49 +10:00
James Wu
a75f16e23c Implement full_name_for_sorting 2023-04-11 15:25:20 +10:00
James Wu
546e90b286 Sort orders by last names 2023-04-11 15:25:20 +10:00
David Cook
bf9f47a000 Show commit in CI
actions/checkout@v3 actually creates a merge commit into master, to ensure you're testing the latest as close to master as possible.
That's all well and good, but quite confusing when you see errors in CI that aren't present in the actual PR branch. Hopefully this will be a clue when such confusions arise.
2023-04-11 15:22:19 +10:00
David Cook
3da6e6b5ed Link to CI page 2023-04-11 15:22:12 +10:00
Maikel Linke
111705f6f2 Clarify DatabaseCleaner use only for concurrency
Otherwise we use transactions.
2023-04-11 14:07:27 +10:00
Maikel Linke
68d5327b12 Load all spec helpers in one place
These helpers are loaded depending on the spec type. We don't need to
separate them into different files.
2023-04-11 12:56:28 +10:00
Maikel Linke
688285c374 Remove loading of unused spec helpers
We have only one feature spec left and it's loading the
system_helper instead of the spec_helper. These lines were dead code.
2023-04-11 12:14:02 +10:00
MadisonBowron
9d0a69cceb Fix admin product variants form to close issues #10579 & #430 2023-04-10 18:53:01 -04:00
Konrad
15058299d8 Merge pull request #10641 from openfoodfoundation/dependabot/npm_and_yarn/babel/preset-env-7.21.4
Bump @babel/preset-env from 7.18.2 to 7.21.4
2023-04-10 20:00:06 +02:00
filipefurtad0
4e92f33b1c DRYes spec; adds pending test for default ToS 2023-04-10 12:08:35 +01:00
Jean-Baptiste Bellet
c7cb982c9a Update browser list
```
npx update-browserslist-db@latest
```
2023-04-10 11:20:19 +02:00
Jean-Baptiste Bellet
34e9112c0a Fix dependencies warning: adds core and `plugin-transform-runtime 2023-04-10 11:20:19 +02:00
dependabot[bot]
28eb11bda5 Bump @babel/preset-env from 7.20.2 to 7.21.4
Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.20.2 to 7.21.4.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.21.4/packages/babel-preset-env)

---
updated-dependencies:
- dependency-name: "@babel/preset-env"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-10 11:20:19 +02:00
jibees
d8e82d9c88 Merge pull request #10668 from openfoodfoundation/dependabot/bundler/aws-sdk-s3-1.120.1
Bump aws-sdk-s3 from 1.120.0 to 1.120.1
2023-04-10 11:12:45 +02:00
Mohamed ABDELLANI
061fc321b4 group records before rending the report 2023-04-07 18:44:19 +01:00
Mohamed ABDELLANI
5201e54f82 group orders before rendering the report 2023-04-07 18:16:12 +01:00
jibees
5192a08082 Merge pull request #10673 from openfoodfoundation/dependabot/bundler/rubocop-rails-2.19.0
Bump rubocop-rails from 2.18.0 to 2.19.0
2023-04-07 14:33:31 +02:00
jibees
94d3f136e2 Merge pull request #10672 from openfoodfoundation/dependabot/npm_and_yarn/floating-ui/dom-1.2.6
Bump @floating-ui/dom from 1.2.5 to 1.2.6
2023-04-07 14:32:45 +02:00
dependabot[bot]
db3a923ea7 Bump rubocop-rails from 2.18.0 to 2.19.0
Bumps [rubocop-rails](https://github.com/rubocop/rubocop-rails) from 2.18.0 to 2.19.0.
- [Release notes](https://github.com/rubocop/rubocop-rails/releases)
- [Changelog](https://github.com/rubocop/rubocop-rails/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rails/compare/v2.18.0...v2.19.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-07 09:59:34 +00:00
dependabot[bot]
619eb43c57 Bump @floating-ui/dom from 1.2.5 to 1.2.6
Bumps [@floating-ui/dom](https://github.com/floating-ui/floating-ui/tree/HEAD/packages/dom) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/floating-ui/floating-ui/releases)
- [Commits](https://github.com/floating-ui/floating-ui/commits/@floating-ui/dom@1.2.6/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>
2023-04-07 09:58:01 +00:00
dependabot[bot]
5c221621d3 Bump sidekiq from 7.0.7 to 7.0.8
Bumps [sidekiq](https://github.com/sidekiq/sidekiq) from 7.0.7 to 7.0.8.
- [Release notes](https://github.com/sidekiq/sidekiq/releases)
- [Changelog](https://github.com/sidekiq/sidekiq/blob/main/Changes.md)
- [Commits](https://github.com/sidekiq/sidekiq/compare/v7.0.7...v7.0.8)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-06 09:58:23 +00:00
dependabot[bot]
60d7ed5036 Bump aws-sdk-s3 from 1.120.0 to 1.120.1
Bumps [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby) from 1.120.0 to 1.120.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>
2023-04-06 09:57:53 +00:00
Jean-Baptiste Bellet
e74328f1d7 Add i18n for payment state key
+ update spec
2023-04-06 10:28:44 +02:00
Jean-Baptiste Bellet
6abd652251 Factorize into inherited method from Base: payment_state(order) 2023-04-06 09:50:50 +02:00
dependabot[bot]
3821eede51 Bump stripe from 8.3.0 to 8.5.0
Bumps [stripe](https://github.com/stripe/stripe-ruby) from 8.3.0 to 8.5.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/v8.3.0...v8.5.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-05 16:38:33 +00:00
Maikel Linke
020af0c0e4 Explain report timeout better to user 2023-04-05 09:59:02 +10:00
Maikel Linke
00a3976905 Display a friendly message when a report times out
Once we get a download link for a report, we can display this message
sooner. But for now we just use the existing request timeout.
2023-04-04 11:08:20 +10:00
Maikel Linke
3bd8e430f9 Use Rack::Timeout for more realistic tests
The closer the test environment is to the production environment the
more realistic the tests will be, and the more code we test.

We are now able to test the app behaviour on timeouts which I want to do
for reports. We can also catch incompatibilities with the rack-timeout
gem during testing.
2023-04-04 11:08:20 +10:00
Neal Chambers
77733169fc Update OCs after ERs Permissions are Revoked 2023-04-04 09:37:13 +09:00
vviekk
54d5d0ed80 Accepting 0<unit values<1 in product import validations 2023-03-16 16:26:43 +05:30
vviekk
ac5cbcf19e Merge branch 'openfoodfoundation:master' into 9978 2023-03-16 14:30:26 +05:30
vviekk
e10ea4b686 Merge branch 'openfoodfoundation:master' into 9978 2023-03-11 11:00:03 +05:30
vviekk
913f8bbad0 Addressing comments 2023-02-26 15:50:34 +05:30
vviekk
fc951e92ac Updating price, on_hand, on_demand validations for product import 2023-02-18 13:52:35 +05:30
497 changed files with 20069 additions and 6022 deletions

View File

@@ -5,9 +5,17 @@
#
# cp .env.development .env.local
VERBOSE_QUERY_LOGS=true
SECRET_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
OFN_REDIS_URL="redis://localhost:6379/1"
OFN_REDIS_JOBS_URL="redis://localhost:6379/2"
SITE_URL="0.0.0.0:3000"
# Deactivate rack-timeout in development.
# https://github.com/zombocom/rack-timeout#configuring
RACK_TIMEOUT_SERVICE_TIMEOUT="0"
RACK_TIMEOUT_WAIT_TIMEOUT="0"
RACK_TIMEOUT_WAIT_OVERTIME="0"

View File

@@ -41,6 +41,7 @@ jobs:
- name: Scan
continue-on-error: true
run: |
git show --no-patch # the commit being tested (which is often a merge due to actions/checkout@v3)
brakeman -f sarif -o output.sarif.json .
# Upload the SARIF file generated in the previous step

View File

@@ -18,7 +18,7 @@ permissions:
jobs:
knapsack_rspec_controllers:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:10
@@ -68,7 +68,6 @@ jobs:
bundle exec rake db:schema:load
- name: Run tests
env:
KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: 864ef557d85ea8e603e086c0387d5154
KNAPSACK_PRO_CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
@@ -82,12 +81,12 @@ 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/controllers/**/*_spec.rb}"
run: |
git show --no-patch # the commit being tested (which is often a merge due to actions/checkout@v3)
bundle exec rake knapsack_pro:rspec
knapsack_rspec_models:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:10
@@ -156,7 +155,7 @@ jobs:
bundle exec rake knapsack_pro:rspec
knapsack_rspec_system_admin:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:10
@@ -234,7 +233,7 @@ jobs:
if-no-files-found: ignore
knapsack_rspec_system_consumer:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:10
@@ -312,7 +311,7 @@ jobs:
if-no-files-found: ignore
knapsack_rspec_engines:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:10
@@ -390,7 +389,7 @@ jobs:
if-no-files-found: ignore
knapsack_rspec_test_the_rest:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:10
@@ -460,7 +459,7 @@ jobs:
bundle exec rake knapsack_pro:rspec
non_knapsack_jest_karma:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:10

View File

@@ -9,7 +9,11 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v1
- uses: ruby/setup-ruby@v1
- run: git show --no-patch # the commit being tested (which is often a merge due to actions/checkout@v3)
- name: rubocop
uses: reviewdog/action-rubocop@v2
with:
@@ -32,6 +36,8 @@ jobs:
- name: Install JS dependencies
run: yarn install --frozen-lockfile
- run: git show --no-patch # the commit being tested (which is often a merge due to actions/checkout@v3)
- name: prettier
uses: EPMatt/reviewdog-action-prettier@v1
with:

View File

@@ -1,8 +1,5 @@
# Basically, ignore everythings expect app/webpacker/controllers/*.js and app/webpacker/packs/*.js
*.css
*.scss
# Except v2
!/app/webpacker/css/admin/v2/**/*.scss
*.md
*.yml
*.yaml
@@ -12,6 +9,10 @@
babel.config.js
postcss.config.js
/app/webpacker/css/darkswarm/
/app/webpacker/css/mail/
/app/webpacker/css/shared/
/app/assets/
/config/
/coverage/

View File

@@ -1 +1,3 @@
{}
{
"printWidth": 100
}

View File

@@ -2,9 +2,8 @@
#
# These are the rules we agreed upon and we work towards.
AllCops:
NewCops: disable
NewCops: enable
SuggestExtensions: false
TargetRailsVersion: 5.0
Exclude:
- 'bin/**/*'
- 'db/**/*'
@@ -41,6 +40,7 @@ Metrics/BlockLength:
"resources",
"scenario",
"shared_examples",
"shared_examples_for",
"xdescribe",
]

View File

@@ -1,19 +1,11 @@
# This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400`
# on 2023-04-01 00:21:28 UTC using RuboCop version 1.47.0.
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400 --no-auto-gen-timestamp`
# using RuboCop version 1.50.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
Bundler/OrderedGems:
Exclude:
- 'Gemfile'
# Offense count: 4
# Configuration parameters: Severity, Include.
# Include: **/*.gemspec
@@ -63,11 +55,10 @@ Layout/BlockAlignment:
Exclude:
- 'spec/services/products_renderer_spec.rb'
# Offense count: 5
# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
Layout/BlockEndNewline:
Exclude:
- 'app/controllers/admin/subscriptions_controller.rb'
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
- 'spec/system/admin/orders_spec.rb'
@@ -93,21 +84,13 @@ Layout/EmptyLinesAroundBlockBody:
- 'spec/requests/checkout/concurrency_spec.rb'
- 'spec/system/admin/order_cycles/list_spec.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
Layout/ExtraSpacing:
Exclude:
- 'spec/spec_helper.rb'
# Offense count: 3
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
Layout/FirstArgumentIndentation:
Exclude:
- 'spec/system/admin/orders_spec.rb'
- 'spec/system/admin/products_spec.rb'
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
@@ -117,7 +100,7 @@ Layout/FirstHashElementIndentation:
Exclude:
- 'spec/services/products_renderer_spec.rb'
# Offense count: 13
# Offense count: 11
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
# SupportedHashRocketStyles: key, separator, table
@@ -125,31 +108,25 @@ Layout/FirstHashElementIndentation:
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/HashAlignment:
Exclude:
- 'app/controllers/admin/subscriptions_controller.rb'
- 'app/controllers/spree/users_controller.rb'
- 'app/models/spree/image.rb'
- 'spec/migrations/migrate_customer_names_spec.rb'
- 'spec/models/enterprise_spec.rb'
- 'spec/support/request/stripe_stubs.rb'
- 'spec/system/admin/customers_spec.rb'
- 'spec/system/admin/order_spec.rb'
- 'spec/system/admin/orders_spec.rb'
- 'spec/system/admin/tag_rules_spec.rb'
- 'spec/system/consumer/shopping/cart_spec.rb'
# Offense count: 18
# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: normal, indented_internal_methods
Layout/IndentationConsistency:
Exclude:
- 'spec/system/admin/order_cycles/complex_editing_spec.rb'
- 'spec/system/admin/order_cycles/complex_updating_specific_time_spec.rb'
- 'spec/system/admin/order_cycles/simple_spec.rb'
- 'spec/system/admin/order_spec.rb'
- 'spec/system/admin/orders_spec.rb'
- 'spec/system/admin/product_import_spec.rb'
- 'spec/system/consumer/split_checkout_spec.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
@@ -165,7 +142,64 @@ Layout/LeadingCommentSpace:
Exclude:
- 'spec/system/admin/enterprises_spec.rb'
# Offense count: 603
# Offense count: 114
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: space, no_space
Layout/LineContinuationSpacing:
Exclude:
- 'app/helpers/checkout_helper.rb'
- 'engines/order_management/spec/services/order_management/order/updater_spec.rb'
- 'engines/order_management/spec/services/order_management/subscriptions/stripe_payment_setup_spec.rb'
- 'engines/web/app/helpers/web/cookies_policy_helper.rb'
- 'spec/system/admin/bulk_order_management_spec.rb'
- 'spec/system/admin/configuration/content_spec.rb'
- 'spec/system/admin/customers_spec.rb'
- 'spec/system/admin/enterprise_fees_spec.rb'
- 'spec/system/admin/enterprises/index_spec.rb'
- 'spec/system/admin/enterprises_spec.rb'
- 'spec/system/admin/order_cycles/list_spec.rb'
- 'spec/system/admin/order_cycles/simple_spec.rb'
- 'spec/system/admin/order_spec.rb'
- 'spec/system/admin/orders_spec.rb'
- 'spec/system/admin/overview_spec.rb'
- 'spec/system/admin/payment_method_spec.rb'
- 'spec/system/admin/product_import_spec.rb'
- 'spec/system/admin/subscriptions_spec.rb'
- 'spec/system/admin/tag_rules_spec.rb'
- 'spec/system/admin/users_spec.rb'
- 'spec/system/admin/variant_overrides_spec.rb'
- 'spec/system/consumer/authentication_spec.rb'
- 'spec/system/consumer/caching/shops_caching_spec.rb'
- 'spec/system/consumer/cookies_spec.rb'
- 'spec/system/consumer/shopping/cart_spec.rb'
- 'spec/system/consumer/shopping/checkout_auth_spec.rb'
- 'spec/system/consumer/shopping/checkout_spec.rb'
- 'spec/system/consumer/shopping/products_spec.rb'
- 'spec/system/consumer/shopping/shopping_spec.rb'
- 'spec/system/consumer/shopping/unit_price_spec.rb'
- 'spec/system/consumer/split_checkout_spec.rb'
# Offense count: 18
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: aligned, indented
Layout/LineEndStringConcatenationIndentation:
Exclude:
- 'app/mailers/spree/user_mailer.rb'
- 'engines/order_management/app/services/order_management/subscriptions/proxy_order_syncer.rb'
- 'engines/order_management/spec/services/order_management/subscriptions/stripe_payment_setup_spec.rb'
- 'spec/system/admin/configuration/content_spec.rb'
- 'spec/system/admin/customers_spec.rb'
- 'spec/system/admin/overview_spec.rb'
- 'spec/system/admin/payment_method_spec.rb'
- 'spec/system/admin/subscriptions_spec.rb'
- 'spec/system/admin/tag_rules_spec.rb'
- 'spec/system/consumer/caching/shops_caching_spec.rb'
- 'spec/system/consumer/cookies_spec.rb'
- 'spec/system/consumer/shopping/cart_spec.rb'
# Offense count: 615
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
@@ -378,7 +412,7 @@ Layout/TrailingEmptyLines:
Exclude:
- 'Rakefile'
# Offense count: 69
# Offense count: 70
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowInHeredoc.
Layout/TrailingWhitespace:
@@ -406,6 +440,16 @@ Layout/TrailingWhitespace:
- 'spec/system/admin/shipping_methods_spec.rb'
- 'spec/system/consumer/split_checkout_spec.rb'
# Offense count: 7
# This cop supports safe autocorrection (--autocorrect).
Lint/AmbiguousOperatorPrecedence:
Exclude:
- 'app/models/calculator/flexi_rate.rb'
- 'app/models/enterprise.rb'
- 'app/models/spree/ability.rb'
- 'app/models/spree/line_item.rb'
- 'app/models/spree/preferences/store.rb'
# Offense count: 17
# Configuration parameters: AllowedMethods.
# AllowedMethods: enums
@@ -424,6 +468,16 @@ Lint/ConstantDefinitionInBlock:
- 'spec/validators/date_time_string_validator_spec.rb'
- 'spec/validators/integer_array_validator_spec.rb'
# Offense count: 8
# 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:
@@ -435,6 +489,30 @@ Lint/DuplicateRequire:
Exclude:
- 'spec/lib/open_food_network/scope_variants_to_search_spec.rb'
# Offense count: 20
# Configuration parameters: AllowComments, AllowEmptyLambdas.
Lint/EmptyBlock:
Exclude:
- 'engines/catalog/config/routes.rb'
- 'spec/components/distributor_title_component_spec.rb'
- 'spec/components/example_component_spec.rb'
- 'spec/controllers/admin/subscription_line_items_controller_spec.rb'
- 'spec/controllers/api/v0/shipments_controller_spec.rb'
- 'spec/controllers/concerns/extra_fields_spec.rb'
- 'spec/factories.rb'
- 'spec/factories/enterprise_factory.rb'
- 'spec/jobs/order_cycle_opened_job_spec.rb'
- 'spec/jobs/subscription_placement_job_spec.rb'
- 'spec/models/product_import/entry_validator_spec.rb'
- 'spec/requests/checkout/concurrency_spec.rb'
# Offense count: 6
# Configuration parameters: AllowComments.
Lint/EmptyClass:
Exclude:
- 'spec/controllers/spree/admin/base_controller_spec.rb'
- 'spec/lib/reports/report_loader_spec.rb'
# Offense count: 1
# Configuration parameters: AllowComments.
Lint/EmptyFile:
@@ -452,6 +530,26 @@ Lint/IneffectiveAccessModifier:
Exclude:
- 'app/models/spree/user.rb'
# Offense count: 1
Lint/NoReturnInBeginEndBlocks:
Exclude:
- 'app/controllers/payment_gateways/stripe_controller.rb'
# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
Lint/NonAtomicFileOperation:
Exclude:
- 'app/services/bulk_invoice_service.rb'
# Offense count: 4
# This cop supports unsafe autocorrection (--autocorrect-all).
Lint/RedundantDirGlobSort:
Exclude:
- 'engines/catalog/spec/spec_helper.rb'
- 'engines/dfc_provider/spec/spec_helper.rb'
- 'spec/base_spec_helper.rb'
- 'spec/system_helper.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowedMethods.
@@ -482,14 +580,12 @@ Lint/UselessMethodDefinition:
Exclude:
- 'app/models/spree/gateway.rb'
# Offense count: 13
# Offense count: 3
# Configuration parameters: CheckForMethodsWithNoSideEffects.
Lint/Void:
Exclude:
- 'spec/system/admin/order_cycles/complex_editing_spec.rb'
- 'spec/system/admin/order_cycles/complex_updating_specific_time_spec.rb'
- 'spec/system/admin/order_cycles/simple_spec.rb'
- 'spec/system/admin/order_spec.rb'
# Offense count: 27
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
@@ -560,8 +656,10 @@ Metrics/BlockNesting:
Metrics/ClassLength:
Exclude:
- 'app/components/products_table_component.rb'
- 'app/controllers/admin/enterprise_fees_controller.rb'
- 'app/controllers/admin/enterprises_controller.rb'
- 'app/controllers/admin/order_cycles_controller.rb'
- 'app/controllers/admin/product_import_controller.rb'
- 'app/controllers/admin/resource_controller.rb'
- 'app/controllers/admin/schedules_controller.rb'
- 'app/controllers/admin/subscriptions_controller.rb'
@@ -746,12 +844,6 @@ Naming/AccessorMethodName:
- 'spec/support/request/shop_workflow.rb'
- 'spec/support/request/web_helper.rb'
# Offense count: 1
# Configuration parameters: AsciiConstants.
Naming/AsciiIdentifiers:
Exclude:
- 'spec/system/admin/products_spec.rb'
# Offense count: 1
# Configuration parameters: ForbiddenDelimiters.
# ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$))
@@ -791,6 +883,40 @@ Naming/VariableNumber:
- 'spec/models/spree/tax_rate_spec.rb'
- 'spec/requests/api/orders_spec.rb'
# Offense count: 9
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: ExpectedOrder, Include.
# ExpectedOrder: index, show, new, edit, create, update, destroy
# Include: app/controllers/**/*.rb
Rails/ActionOrder:
Exclude:
- 'app/controllers/admin/resource_controller.rb'
- 'app/controllers/api/v0/orders_controller.rb'
- 'app/controllers/spree/admin/images_controller.rb'
- 'app/controllers/spree/admin/invoices_controller.rb'
- 'app/controllers/spree/admin/products_controller.rb'
- 'app/controllers/spree/admin/taxons_controller.rb'
- 'app/controllers/spree/admin/variants_controller.rb'
- 'app/controllers/user_confirmations_controller.rb'
# Offense count: 15
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/ActiveRecordCallbacksOrder:
Exclude:
- 'app/models/customer.rb'
- 'app/models/enterprise.rb'
- 'app/models/enterprise_group.rb'
- 'app/models/enterprise_relationship.rb'
- 'app/models/spree/line_item.rb'
- 'app/models/spree/order.rb'
- 'app/models/spree/payment.rb'
- 'app/models/spree/product.rb'
- 'app/models/spree/return_authorization.rb'
- 'app/models/spree/user.rb'
- 'app/models/spree/variant.rb'
# Offense count: 1
# Configuration parameters: Severity, Include.
# Include: app/models/**/*.rb
@@ -810,12 +936,6 @@ Rails/ApplicationJob:
Exclude:
- 'app/jobs/report_job.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/ApplicationMailer:
Exclude:
- 'app/mailers/spree/base_mailer.rb'
# Offense count: 5
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: NilOrEmpty, NotPresent, UnlessPresent.
@@ -826,6 +946,45 @@ Rails/Blank:
- 'engines/order_management/app/services/order_management/stock/package.rb'
- 'lib/stripe/authorize_response_patcher.rb'
# Offense count: 17
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/CompactBlank:
Exclude:
- 'app/controllers/spree/admin/users_controller.rb'
- 'app/models/concerns/address_display.rb'
- 'app/models/spree/zone.rb'
- 'app/services/order_cycle_form.rb'
- 'lib/reporting/report_headers_builder.rb'
- 'lib/reporting/report_ruler.rb'
- 'lib/reporting/reports/enterprise_fee_summary/parameters.rb'
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Rails/DotSeparatedKeys:
Exclude:
- 'app/controllers/api/v1/base_controller.rb'
# Offense count: 27
# This cop supports safe autocorrection (--autocorrect).
Rails/DurationArithmetic:
Exclude:
- 'app/services/create_order_cycle.rb'
- 'spec/jobs/order_cycle_closing_job_spec.rb'
- 'spec/jobs/order_cycle_opened_job_spec.rb'
- 'spec/services/permissions/order_spec.rb'
- 'spec/services/terms_of_service_spec.rb'
- 'spec/system/admin/bulk_order_management_spec.rb'
- 'spec/system/admin/order_cycles/list_spec.rb'
- 'spec/system/admin/orders_spec.rb'
- 'spec/system/admin/reports/orders_and_fulfillment_spec.rb'
- 'spec/system/admin/reports/packing_report_spec.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Rails/ExpandedDateRange:
Exclude:
- 'app/models/spree/product.rb'
# Offense count: 5
# Configuration parameters: EnforcedStyle.
# SupportedStyles: slashes, arguments
@@ -894,17 +1053,38 @@ Rails/HelperInstanceVariable:
- 'app/helpers/spree/admin/orders_helper.rb'
- 'app/helpers/spree/orders_helper.rb'
# Offense count: 37
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Include.
# Include: app/controllers/**/*.rb
Rails/I18nLazyLookup:
Exclude:
- 'app/controllers/admin/proxy_orders_controller.rb'
# Offense count: 8
# Configuration parameters: Include.
# Include: spec/**/*.rb, test/**/*.rb
Rails/I18nLocaleAssignment:
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'
# Offense count: 3
Rails/I18nLocaleTexts:
Exclude:
- 'app/controllers/admin/stripe_accounts_controller.rb'
# Offense count: 27
# Configuration parameters: IgnoreScopes, Include.
# Include: app/models/**/*.rb
Rails/InverseOf:
Exclude:
- 'app/models/concerns/calculated_adjustments.rb'
- 'app/models/enterprise.rb'
- 'app/models/order_cycle.rb'
- 'app/models/spree/adjustment.rb'
- 'app/models/spree/country.rb'
- 'app/models/spree/credit_card.rb'
- 'app/models/spree/inventory_unit.rb'
- 'app/models/spree/line_item.rb'
- 'app/models/spree/option_type.rb'
@@ -912,9 +1092,7 @@ Rails/InverseOf:
- 'app/models/spree/payment.rb'
- 'app/models/spree/price.rb'
- 'app/models/spree/product.rb'
- 'app/models/spree/shipment.rb'
- 'app/models/spree/stock_item.rb'
- 'app/models/spree/tax_rate.rb'
- 'app/models/spree/taxonomy.rb'
- 'app/models/spree/variant.rb'
- 'app/models/subscription_line_item.rb'
@@ -944,6 +1122,19 @@ Rails/LexicallyScopedActionFilter:
- 'app/controllers/spree/admin/zones_controller.rb'
- 'app/controllers/spree/users_controller.rb'
# Offense count: 9
# 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'
- 'app/models/spree/order/checkout.rb'
- 'app/services/order_cart_reset.rb'
- 'engines/order_management/app/services/order_management/stock/estimator.rb'
- 'lib/spree/localized_number.rb'
- 'spec/support/matchers/table_matchers.rb'
# Offense count: 18
Rails/OutputSafety:
Exclude:
@@ -959,12 +1150,112 @@ Rails/OutputSafety:
- 'lib/reporting/queries/query_interface.rb'
- 'lib/spree/money.rb'
# Offense count: 29
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/Pluck:
Exclude:
- 'app/controllers/admin/variant_overrides_controller.rb'
- 'app/helpers/shop_helper.rb'
- 'app/services/cart_service.rb'
- 'app/services/sets/product_set.rb'
- 'lib/reporting/report_headers_builder.rb'
- 'spec/controllers/admin/bulk_line_items_controller_spec.rb'
- 'spec/controllers/admin/subscriptions_controller_spec.rb'
- 'spec/controllers/api/v0/order_cycles_controller_spec.rb'
- 'spec/controllers/api/v0/orders_controller_spec.rb'
- 'spec/controllers/api/v0/products_controller_spec.rb'
- 'spec/controllers/api/v0/shops_controller_spec.rb'
- 'spec/controllers/api/v0/states_controller_spec.rb'
- 'spec/controllers/api/v0/taxons_controller_spec.rb'
- 'spec/helpers/spree/admin/orders_helper_spec.rb'
- 'spec/lib/reports/lettuce_share_report_spec.rb'
- 'spec/lib/reports/users_and_enterprises_report_spec.rb'
- 'spec/serializers/api/admin/for_order_cycle/supplied_product_serializer_spec.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: conservative, aggressive
Rails/PluckInWhere:
Exclude:
- 'app/models/spree/variant.rb'
# Offense count: 28
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/RedundantPresenceValidationOnBelongsTo:
Exclude:
- 'app/models/enterprise.rb'
- 'app/models/enterprise_fee.rb'
- 'app/models/enterprise_group.rb'
- 'app/models/enterprise_relationship.rb'
- 'app/models/enterprise_role.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.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'
- 'app/models/variant_override.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/RelativeDateConstant:
Exclude:
- 'lib/tasks/data/remove_transient_data.rb'
# Offense count: 58
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Include.
# Include: spec/controllers/**/*.rb, spec/requests/**/*.rb, test/controllers/**/*.rb, test/integration/**/*.rb
Rails/ResponseParsedBody:
Exclude:
- 'spec/controllers/admin/bulk_line_items_controller_spec.rb'
- 'spec/controllers/admin/customers_controller_spec.rb'
- 'spec/controllers/admin/order_cycles_controller_spec.rb'
- 'spec/controllers/admin/proxy_orders_controller_spec.rb'
- 'spec/controllers/admin/schedules_controller_spec.rb'
- 'spec/controllers/admin/stripe_accounts_controller_spec.rb'
- 'spec/controllers/admin/subscription_line_items_controller_spec.rb'
- 'spec/controllers/admin/subscriptions_controller_spec.rb'
- 'spec/controllers/cart_controller_spec.rb'
- 'spec/controllers/line_items_controller_spec.rb'
- 'spec/controllers/spree/admin/search_controller_spec.rb'
- 'spec/controllers/spree/credit_cards_controller_spec.rb'
- 'spec/controllers/user_registrations_controller_spec.rb'
# Offense count: 4
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/RootPathnameMethods:
Exclude:
- 'spec/lib/reports/orders_and_fulfillment/order_cycle_customer_totals_report_spec.rb'
- 'spec/models/content_configuration_spec.rb'
- 'spec/models/terms_of_service_file_spec.rb'
- 'spec/system/admin/configuration/terms_of_service_files_spec.rb'
# Offense count: 13
# This cop supports safe autocorrection (--autocorrect).
Rails/RootPublicPath:
Exclude:
- 'app/controllers/concerns/request_timeouts.rb'
- 'lib/spree/core/controller_helpers/common.rb'
- 'spec/controllers/api/v0/product_images_controller_spec.rb'
- 'spec/controllers/api/v0/terms_and_conditions_controller_spec.rb'
- 'spec/models/terms_of_service_file_spec.rb'
- 'spec/system/admin/bulk_product_update_spec.rb'
- 'spec/system/admin/enterprises/terms_and_conditions_spec.rb'
- 'spec/system/consumer/shopping/checkout_spec.rb'
- 'spec/system/consumer/shopping/embedded_groups_spec.rb'
- 'spec/system/consumer/split_checkout_spec.rb'
# Offense count: 4
# Configuration parameters: ForbiddenMethods, AllowedMethods.
# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all
@@ -973,6 +1264,24 @@ Rails/SkipsModelValidations:
- 'app/models/variant_override.rb'
- 'spec/models/spree/line_item_spec.rb'
# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/SquishedSQLHeredocs:
Exclude:
- 'app/queries/customers_with_balance.rb'
- 'app/queries/outstanding_balance.rb'
- 'spec/queries/outstanding_balance_spec.rb'
# Offense count: 24
# This cop supports safe autocorrection (--autocorrect).
Rails/StripHeredoc:
Exclude:
- 'app/models/content_configuration.rb'
- 'app/queries/customers_with_balance.rb'
- 'app/queries/outstanding_balance.rb'
- 'lib/reporting/reports/enterprise_fee_summary/scope.rb'
- 'lib/tasks/data/truncate_data.rake'
# Offense count: 4
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
@@ -984,6 +1293,11 @@ Rails/TimeZone:
- 'spec/models/spree/tax_rate_spec.rb'
- 'spec/services/customer_order_cancellation_spec.rb'
# Offense count: 1
Rails/TransactionExitStatement:
Exclude:
- 'app/services/place_proxy_order.rb'
# Offense count: 5
# Configuration parameters: Include.
# Include: app/models/**/*.rb
@@ -1002,6 +1316,77 @@ Rails/UnknownEnv:
Exclude:
- 'app/models/spree/app_configuration.rb'
# Offense count: 55
# 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/queries/payments_requiring_action.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/customers/base.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: 24
# This cop supports safe autocorrection (--autocorrect).
Rails/WhereNot:
Exclude:
- 'app/controllers/spree/admin/products_controller.rb'
- 'app/models/concerns/permalink_generator.rb'
- 'app/models/enterprise.rb'
- 'app/models/enterprise_fee.rb'
- 'app/models/enterprise_relationship.rb'
- 'app/models/product_import/inventory_reset_strategy.rb'
- 'app/models/proxy_order.rb'
- 'app/models/spree/credit_card.rb'
- 'app/models/spree/product.rb'
- 'app/models/spree/variant.rb'
- 'app/models/spree/zone.rb'
- 'app/models/variant_override.rb'
- 'app/services/cap_quantity.rb'
- 'engines/catalog/app/services/catalog/product_import/products_reset_strategy.rb'
- 'engines/order_management/app/services/order_management/subscriptions/proxy_order_syncer.rb'
- 'lib/reporting/reports/users_and_enterprises/base.rb'
- 'lib/tasks/data/anonymize_data.rake'
# Offense count: 1
Security/Open:
Exclude:
@@ -1020,14 +1405,6 @@ Style/CaseEquality:
Exclude:
- 'spec/models/spree/payment_spec.rb'
# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/CaseLikeIf:
Exclude:
- 'app/controllers/admin/order_cycles_controller.rb'
- 'app/models/calculator/weight.rb'
- 'app/models/spree/payment/processing.rb'
# Offense count: 25
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
@@ -1063,6 +1440,27 @@ Style/ClassVars:
Exclude:
- 'lib/spree/core/delegate_belongs_to.rb'
# Offense count: 9
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowedVars.
Style/FetchEnvVar:
Exclude:
- 'app/helpers/discourse_helper.rb'
- 'app/models/spree/preferences/configuration.rb'
- 'app/models/spree/preferences/preferable.rb'
- 'app/services/default_country.rb'
- 'spec/base_spec_helper.rb'
- 'spec/controllers/spree/credit_cards_controller_spec.rb'
- 'spec/models/order_balance_spec.rb'
- 'spec/support/vcr_setup.rb'
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Style/FileRead:
Exclude:
- 'lib/tasks/karma.rake'
- 'spec/services/upload_sanitizer_spec.rb'
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns.
@@ -1117,27 +1515,36 @@ Style/GuardClause:
- 'spec/support/request/shop_workflow.rb'
- 'spec/system/support/precompile_assets.rb'
# Offense count: 12
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowSplatArgument.
Style/HashConversion:
Exclude:
- 'app/controllers/admin/column_preferences_controller.rb'
- 'app/controllers/admin/variant_overrides_controller.rb'
- 'app/controllers/spree/admin/products_controller.rb'
- 'app/models/order_cycle.rb'
- 'app/models/product_import/product_importer.rb'
- 'app/models/spree/shipping_method.rb'
- 'app/serializers/api/admin/exchange_serializer.rb'
- 'app/services/variants_stock_levels.rb'
- 'spec/controllers/admin/inventory_items_controller_spec.rb'
- 'spec/controllers/admin/variant_overrides_controller_spec.rb'
# Offense count: 1
# Configuration parameters: MinBranchesCount.
Style/HashLikeCase:
Exclude:
- 'app/models/enterprise.rb'
# Offense count: 11
# Offense count: 4
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: InverseMethods, InverseBlocks.
Style/InverseMethods:
Style/MapToHash:
Exclude:
- 'app/controllers/admin/resource_controller.rb'
- 'app/models/calculator/weight.rb'
- 'app/models/product_import/spreadsheet_entry.rb'
- 'app/models/spree/order/checkout.rb'
- 'app/models/spree/order_contents.rb'
- 'app/models/spree/payment.rb'
- 'app/services/order_cart_reset.rb'
- 'engines/order_management/app/services/order_management/stock/estimator.rb'
- 'lib/spree/localized_number.rb'
- 'spec/support/matchers/table_matchers.rb'
- 'lib/reporting/report_query_template.rb'
- 'lib/reporting/report_row_builder.rb'
- 'lib/reporting/reports/enterprise_fee_summary/base.rb'
- 'lib/tasks/sample_data/user_factory.rb'
# Offense count: 3
Style/MissingRespondToMissing:
@@ -1152,6 +1559,13 @@ Style/MultilineTernaryOperator:
Exclude:
- 'spec/system/admin/subscriptions_spec.rb'
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Style/NegatedIfElseCondition:
Exclude:
- 'app/mailers/spree/shipment_mailer.rb'
- 'spec/support/matchers/table_matchers.rb'
# Offense count: 22
# This cop supports safe autocorrection (--autocorrect).
Style/NestedModifier:
@@ -1167,13 +1581,18 @@ Style/NestedModifier:
- 'spec/system/admin/payments_stripe_spec.rb'
- 'spec/system/admin/reports_spec.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowedMethods.
# AllowedMethods: be, be_a, be_an, be_between, be_falsey, be_kind_of, be_instance_of, be_truthy, be_within, eq, eql, end_with, include, match, raise_error, respond_to, start_with
Style/NestedParenthesizedCalls:
# Offense count: 36
Style/OpenStructUse:
Exclude:
- 'spec/system/admin/products_spec.rb'
- 'app/helpers/injection_helper.rb'
- 'app/models/spree/shipment.rb'
- 'lib/open_food_network/enterprise_fee_calculator.rb'
- 'lib/reporting/report_row_builder.rb'
- 'lib/reporting/report_rows_builder.rb'
- 'spec/lib/reports/report_renderer_spec.rb'
- 'spec/lib/reports/report_spec.rb'
- 'spec/lib/reports/users_and_enterprises_report_spec.rb'
- 'spec/serializers/api/enterprise_serializer_spec.rb'
# Offense count: 16
# Configuration parameters: AllowedMethods.
@@ -1207,12 +1626,70 @@ Style/PreferredHashMethods:
Exclude:
- 'app/controllers/api/v0/shipments_controller.rb'
# Offense count: 16
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: same_as_string_literals, single_quotes, double_quotes
Style/QuotedSymbols:
Exclude:
- 'app/services/exchange_products_renderer.rb'
- 'lib/stripe/credit_card_cloner.rb'
- 'spec/controllers/api/v0/exchange_products_controller_spec.rb'
- 'spec/requests/api/orders_spec.rb'
- 'spec/requests/api/v1/customers_spec.rb'
- 'spec/support/request/stripe_stubs.rb'
# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Methods.
Style/RedundantArgument:
Exclude:
- 'engines/dfc_provider/app/services/authorization_control.rb'
- 'spec/support/query_counter.rb'
# Offense count: 15
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantConstantBase:
Exclude:
- 'app/controllers/checkout_controller.rb'
- 'app/controllers/split_checkout_controller.rb'
- 'app/controllers/webhook_endpoints_controller.rb'
- 'config.ru'
- 'spec/base_spec_helper.rb'
- 'spec/helpers/checkout_helper_spec.rb'
- 'spec/models/spree/order_spec.rb'
- 'spec/models/spree/payment_method_spec.rb'
- 'spec/models/spree/payment_spec.rb'
- 'spec/queries/complete_visible_orders_spec.rb'
- 'spec/services/paypal_items_builder_spec.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantDoubleSplatHashBraces:
Exclude:
- 'spec/system/support/cuprite_setup.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowComments.
Style/RedundantInitialize:
Exclude:
- 'spec/models/spree/gateway_spec.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantRegexpEscape:
Exclude:
- 'app/models/spree/order.rb'
# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantStringEscape:
Exclude:
- 'app/models/spree/calculator.rb'
- 'spec/controllers/spree/admin/shipping_methods_controller_spec.rb'
- 'spec/system/admin/enterprise_fees_spec.rb'
# Offense count: 206
Style/Send:
Exclude:

View File

@@ -57,6 +57,7 @@ TL;DR:
* Maintain a clean commit history
* Use a style consistent with the rest of the codebase
* Before submitting, [rebase your work][rebase] on the current master branch
* After submitting, be sure to check the [CI test results](ci). Click on a ❌ result to view the logged results and investigate.
From here, your pull request will progress through the [Review, Test, Merge & Deploy process][process].
@@ -70,4 +71,5 @@ From here, your pull request will progress through the [Review, Test, Merge & De
[slack-dev]: https://openfoodnetwork.slack.com/messages/C2GQ45KNU
[ofn-transifex]: https://www.transifex.com/open-food-foundation/open-food-network/
[i18n]: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Internationalisation-%28i18n%29
[welcome-dev]: https://github.com/orgs/openfoodfoundation/projects/2
[welcome-dev]: https://github.com/orgs/openfoodfoundation/projects/5
[ci]: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Continuous-Integration

12
Gemfile
View File

@@ -14,11 +14,11 @@ gem "aws-sdk-s3", require: false
gem "image_processing"
gem 'activemerchant', '>= 1.78.0'
gem 'rexml'
gem 'angular-rails-templates', '>= 0.3.0'
gem 'awesome_nested_set'
gem 'ransack', '~> 2.6.0'
gem 'responders'
gem 'rexml'
gem 'webpacker', '~> 5'
gem 'i18n'
@@ -63,6 +63,7 @@ gem 'devise-token_authenticatable'
gem 'jwt', '~> 2.3'
gem 'oauth2', '~> 1.4.7' # Used for Stripe Connect
gem 'datafoodconsortium-connector'
gem 'jsonapi-serializer'
gem 'pagy', '~> 5.1'
@@ -70,8 +71,8 @@ gem 'rswag-api'
gem 'rswag-ui'
gem 'omniauth_openid_connect'
gem 'openid_connect', '~> 1.3'
gem 'omniauth-rails_csrf_protection'
gem 'openid_connect', '~> 1.3'
gem 'angularjs-rails', '1.8.0'
gem 'bugsnag'
@@ -92,6 +93,7 @@ gem 'gmaps4rails'
gem 'mimemagic', '> 0.3.5'
gem 'paper_trail', '~> 12.1'
gem 'rack-rewrite'
gem 'rack-timeout'
gem 'roadie-rails'
gem 'hiredis'
@@ -141,7 +143,6 @@ gem "private_address_check"
group :production, :staging do
gem 'ddtrace'
gem 'rack-timeout'
gem 'sd_notify' # For better Systemd process management. Used by Puma.
end
@@ -150,6 +151,7 @@ group :test, :development do
gem 'capybara'
gem 'cuprite'
gem 'database_cleaner', require: false
gem 'debug', '>= 1.0.0'
gem "factory_bot_rails", '6.2.0', require: false
gem 'fuubar', '~> 2.5.1'
gem 'json_spec', '~> 1.1.4'
@@ -160,7 +162,6 @@ group :test, :development do
gem 'rswag-specs'
gem 'shoulda-matchers'
gem 'timecop'
gem 'debug', '>= 1.0.0'
end
group :test do
@@ -175,10 +176,11 @@ end
group :development do
gem 'debugger-linecache'
gem 'rails-erd'
gem 'foreman'
gem 'listen'
gem 'pry', '~> 0.13.0'
gem 'query_count'
gem 'rails-erd'
gem 'rubocop'
gem 'rubocop-rails'
gem 'spring'

View File

@@ -137,7 +137,7 @@ GEM
activerecord (>= 6.0, < 7.1)
acts_as_list (1.0.4)
activerecord (>= 4.2)
addressable (2.8.2)
addressable (2.8.4)
public_suffix (>= 2.0.2, < 6.0)
aes_key_wrap (1.1.0)
afm (0.2.2)
@@ -157,16 +157,16 @@ GEM
awesome_nested_set (3.5.0)
activerecord (>= 4.0.0, < 7.1)
aws-eventstream (1.2.0)
aws-partitions (1.739.0)
aws-sdk-core (3.171.0)
aws-partitions (1.760.0)
aws-sdk-core (3.171.1)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.5)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.63.0)
aws-sdk-kms (1.64.0)
aws-sdk-core (~> 3, >= 3.165.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.120.0)
aws-sdk-s3 (1.122.0)
aws-sdk-core (~> 3, >= 3.165.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.4)
@@ -191,7 +191,7 @@ GEM
railties (>= 5.2)
thread-local (>= 1.1.0)
cancancan (1.15.0)
capybara (3.39.0)
capybara (3.39.1)
addressable
matrix
mini_mime (>= 0.1.3)
@@ -219,7 +219,7 @@ GEM
matrix
ruby-rc4 (>= 0.1.5)
concurrent-ruby (1.2.2)
connection_pool (2.3.0)
connection_pool (2.4.0)
crack (0.4.5)
rexml
crass (1.0.6)
@@ -234,14 +234,16 @@ GEM
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
datafoodconsortium-connector (1.0.0.pre.alpha.6)
virtual_assembly-semantizer (~> 1.0, >= 1.0.4)
date (3.3.3)
ddtrace (1.10.1)
ddtrace (1.11.1)
debase-ruby_core_source (>= 0.10.16, <= 3.2.0)
libdatadog (~> 2.0.0.1.0)
libddwaf (~> 1.6.2.0.0)
libddwaf (~> 1.8.2.0.0)
msgpack
debase-ruby_core_source (3.2.0)
debug (1.7.2)
debug (1.8.0)
irb (>= 1.5.0)
reline (>= 0.3.1)
debugger-linecache (1.2.0)
@@ -338,7 +340,7 @@ GEM
hiredis (0.6.3)
htmlentities (4.3.4)
httpclient (2.8.3)
i18n (1.12.0)
i18n (1.13.0)
concurrent-ruby (~> 1.0)
i18n-js (3.9.2)
i18n (>= 0.6.6)
@@ -349,7 +351,7 @@ GEM
activerecord (>= 3.0)
io-console (0.6.0)
ipaddress (0.8.3)
irb (1.6.3)
irb (1.6.4)
reline (>= 0.3.0)
jmespath (1.6.2)
jquery-rails (4.4.0)
@@ -359,12 +361,20 @@ GEM
jquery-ui-rails (4.2.1)
railties (>= 3.2.16)
json (2.6.3)
json-canonicalization (0.3.1)
json-jwt (1.16.3)
activesupport (>= 4.2)
aes_key_wrap
bindata
faraday (~> 2.0)
faraday-follow_redirects
json-ld (3.2.3)
htmlentities (~> 4.3)
json-canonicalization (~> 0.3)
link_header (~> 0.0, >= 0.0.8)
multi_json (~> 1.15)
rack (~> 2.2)
rdf (~> 3.2, >= 3.2.9)
json-schema (3.0.0)
addressable (>= 2.8)
json_spec (1.1.5)
@@ -373,22 +383,23 @@ GEM
jsonapi-serializer (2.2.0)
activesupport (>= 4.2)
jwt (2.7.0)
knapsack_pro (3.9.0)
knapsack_pro (3.11.0)
rake
launchy (2.5.0)
addressable (~> 2.7)
letter_opener (1.8.1)
launchy (>= 2.2, < 3)
libdatadog (2.0.0.1.0)
libddwaf (1.6.2.0.0)
libddwaf (1.8.2.0.0)
ffi (~> 1.0)
libv8-node (16.10.0.0)
link_header (0.0.8)
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.20.0)
loofah (2.21.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
nokogiri (>= 1.12.0)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
@@ -405,7 +416,7 @@ GEM
rake
mini_magick (4.11.0)
mini_mime (1.1.2)
mini_portile2 (2.8.1)
mini_portile2 (2.8.2)
mini_racer (0.6.3)
libv8-node (~> 16.10.0.0)
minitest (5.18.0)
@@ -413,7 +424,7 @@ GEM
money (~> 6.12)
money (6.16.0)
i18n (>= 0.6.4, <= 2)
msgpack (1.6.1)
msgpack (1.7.0)
multi_json (1.15.0)
multi_xml (0.6.0)
net-imap (0.3.4)
@@ -425,8 +436,8 @@ GEM
timeout
net-smtp (0.3.3)
net-protocol
nio4r (2.5.8)
nokogiri (1.14.2)
nio4r (2.5.9)
nokogiri (1.14.4)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
oauth2 (1.4.11)
@@ -462,10 +473,10 @@ GEM
paper_trail (12.3.0)
activerecord (>= 5.2)
request_store (~> 1.1)
parallel (1.22.1)
parallel (1.23.0)
paranoia (2.6.1)
activerecord (>= 5.1, < 7.1)
parser (3.2.2.0)
parser (3.2.2.1)
ast (~> 2.4.1)
paypal-sdk-core (0.3.4)
multi_json (~> 1.0)
@@ -479,17 +490,20 @@ GEM
ruby-rc4
ttfunk
pg (1.2.3)
power_assert (2.0.2)
power_assert (2.0.3)
private_address_check (0.5.0)
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (5.0.1)
puma (6.2.1)
puma (6.2.2)
nio4r (~> 2.0)
query_count (1.1.1)
activerecord (>= 4.2)
railties (>= 4.2)
raabro (1.4.0)
racc (1.6.2)
rack (2.2.6.4)
rack (2.2.7)
rack-mini-profiler (2.3.4)
rack (>= 1.2.0)
rack-oauth2 (1.21.3)
@@ -534,7 +548,7 @@ GEM
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.5.0)
loofah (~> 2.19, >= 2.19.1)
rails-i18n (7.0.6)
rails-i18n (7.0.7)
i18n (>= 0.7, < 2)
railties (>= 6.0.0, < 8)
rails_safe_tasks (1.0.0)
@@ -554,11 +568,13 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rdf (3.2.9)
link_header (~> 0.0, >= 0.0.8)
redcarpet (3.6.0)
redis (4.8.1)
redis-client (0.14.0)
redis-client (0.14.1)
connection_pool
regexp_parser (2.7.0)
regexp_parser (2.8.0)
reline (0.3.3)
io-console (~> 0.5)
request_store (1.5.1)
@@ -583,36 +599,36 @@ GEM
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.1)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.2)
rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.3)
rspec-mocks (3.12.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-rails (6.0.1)
rspec-rails (6.0.2)
actionpack (>= 6.1)
activesupport (>= 6.1)
railties (>= 6.1)
rspec-core (~> 3.11)
rspec-expectations (~> 3.11)
rspec-mocks (~> 3.11)
rspec-support (~> 3.11)
rspec-core (~> 3.12)
rspec-expectations (~> 3.12)
rspec-mocks (~> 3.12)
rspec-support (~> 3.12)
rspec-retry (0.6.2)
rspec-core (> 3.3)
rspec-support (3.12.0)
rswag-api (2.8.0)
rswag-api (2.9.0)
railties (>= 3.1, < 7.1)
rswag-specs (2.8.0)
rswag-specs (2.9.0)
activesupport (>= 3.1, < 7.1)
json-schema (>= 2.2, < 4.0)
railties (>= 3.1, < 7.1)
rspec-core (>= 2.14)
rswag-ui (2.8.0)
rswag-ui (2.9.0)
actionpack (>= 3.1, < 7.1)
railties (>= 3.1, < 7.1)
rubocop (1.49.0)
rubocop (1.51.0)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.2.0.0)
@@ -622,9 +638,9 @@ GEM
rubocop-ast (>= 1.28.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.28.0)
rubocop-ast (1.28.1)
parser (>= 3.2.1.0)
rubocop-rails (2.18.0)
rubocop-rails (2.19.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
@@ -652,11 +668,11 @@ GEM
semantic_range (3.0.0)
shoulda-matchers (5.3.0)
activesupport (>= 5.2.0)
sidekiq (7.0.7)
sidekiq (7.1.0)
concurrent-ruby (< 2)
connection_pool (>= 2.3.0)
rack (>= 2.2.4)
redis-client (>= 0.11.0)
redis-client (>= 0.14.0)
sidekiq-scheduler (5.0.2)
rufus-scheduler (~> 3.2)
sidekiq (>= 6, < 8)
@@ -697,16 +713,16 @@ GEM
rack (>= 2, < 4)
railties (>= 5.2, < 8)
redis (>= 4.0, < 6.0)
stringex (2.8.5)
stripe (8.3.0)
stringex (2.8.6)
stripe (8.5.0)
swd (1.3.0)
activesupport (>= 3)
attr_required (>= 0.0.5)
httpclient (>= 2.4)
temple (0.8.2)
test-unit (3.5.7)
test-unit (3.5.8)
power_assert
thor (1.2.1)
thor (1.2.2)
thread-local (1.1.0)
tilt (2.1.0)
timecop (0.9.6)
@@ -726,7 +742,7 @@ GEM
activemodel (>= 3.0.0)
public_suffix
vcr (6.1.0)
view_component (2.82.0)
view_component (3.0.0)
activesupport (>= 5.2.0, < 8.0)
concurrent-ruby (~> 1.0)
method_source (~> 1.0)
@@ -734,6 +750,8 @@ GEM
rails (>= 5.2, < 8.0)
stimulus_reflex (>= 3.5.0.pre2)
view_component (>= 2.28.0)
virtual_assembly-semantizer (1.0.4)
json-ld (~> 3.2, >= 3.2.3)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.2.0)
@@ -765,7 +783,7 @@ GEM
xml-simple (1.1.8)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.7)
zeitwerk (2.6.8)
PLATFORMS
ruby
@@ -799,6 +817,7 @@ DEPENDENCIES
combine_pdf
cuprite
database_cleaner
datafoodconsortium-connector
db2fog!
ddtrace
debug (>= 1.0.0)
@@ -857,6 +876,7 @@ DEPENDENCIES
private_address_check
pry (~> 0.13.0)
puma
query_count
rack-mini-profiler (< 3.0.0)
rack-rewrite
rack-timeout

View File

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

View File

@@ -12,5 +12,6 @@ angular.module("ofn.admin", [
"admin.orders"
]).config ($httpProvider, $locationProvider, $qProvider) ->
$httpProvider.defaults.headers.common["Accept"] = "application/json, text/javascript, */*"
# for the next line, you should also probably check file: app/assets/javascripts/admin/utils/utils.js.coffee
$locationProvider.hashPrefix('')
$qProvider.errorOnUnhandledRejections(false)

View File

@@ -11,5 +11,6 @@ angular.module("admin.indexUtils").factory 'SortOptions', ->
sortingExpr
toggle: (predicate) ->
@reverse = (@predicate == predicate) && !@reverse
# predicate is a string or an array of strings
@reverse = (JSON.stringify(@predicate) == JSON.stringify(predicate)) && !@reverse
@predicate = predicate

View File

@@ -17,10 +17,12 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
]
$scope.page = 1
$scope.per_page = $scope.per_page_options[0].id
$scope.filterByVariantId = null
searchThrough = ["order_distributor_name",
"order_bill_address_phone",
"order_bill_address_firstname",
"order_bill_address_lastname",
"order_bill_address_full_name",
"variant_product_supplier_name",
"order_email",
"order_number",
@@ -68,6 +70,7 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
RequestMonitor.load LineItems.index(
"q[#{searchThrough}]": $scope.query,
"q[variant_id_eq]": $scope.filterByVariantId if $scope.filterByVariantId,
"q[order_state_not_eq]": "canceled",
"q[order_shipment_state_not_eq]": "shipped",
"q[order_completed_at_not_null]": "true",
@@ -119,16 +122,16 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
else
StatusMessage.display 'failure', t "unsaved_changes_error"
$scope.cancelOrder = (order, sendEmailCancellation) ->
$scope.cancelOrder = (order, sendEmailCancellation, restock_items) ->
return $http(
method: 'GET'
url: "/admin/orders/#{order.number}/fire?e=cancel&send_cancellation_email=#{sendEmailCancellation}")
url: "/admin/orders/#{order.number}/fire?e=cancel&send_cancellation_email=#{sendEmailCancellation}&restock_items=#{restock_items}")
$scope.deleteLineItem = (lineItem) ->
if lineItem.order.item_count == 1
ofnCancelOrderAlert((confirm, sendEmailCancellation) ->
ofnCancelOrderAlert((confirm, sendEmailCancellation, restock_items) ->
if confirm
$scope.cancelOrder(lineItem.order, sendEmailCancellation).then(->
$scope.cancelOrder(lineItem.order, sendEmailCancellation, restock_items).then(->
$scope.refreshData()
)
else
@@ -150,11 +153,11 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
willCancelOrders = true if (order.item_count == itemsPerOrder.get(order).length)
if willCancelOrders
ofnCancelOrderAlert((confirm, sendEmailCancellation) ->
ofnCancelOrderAlert((confirm, sendEmailCancellation, restock_items) ->
if confirm
itemsPerOrder.forEach (items, order) =>
if order.item_count == items.length
$scope.cancelOrder(order, sendEmailCancellation).then(-> $scope.refreshData())
$scope.cancelOrder(order, sendEmailCancellation, restock_items).then(-> $scope.refreshData())
else
Promise.all(LineItems.delete(item) for item in items).then(-> $scope.refreshData())
, "js.admin.deleting_item_will_cancel_order")
@@ -176,6 +179,17 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
$scope.setSelectedUnitsVariant = (unitsProduct,unitsVariant) ->
$scope.selectedUnitsProduct = unitsProduct
$scope.selectedUnitsVariant = unitsVariant
$scope.filterByVariantId = unitsVariant.id
$scope.page = 1
$scope.refreshData()
$scope.resetSelectedUnitsVariant = ->
$scope.selectedUnitsProduct = { }
$scope.selectedUnitsVariant = { }
$scope.filterByVariantId = null
$scope.sharedResource = false
$scope.page = 1
$scope.refreshData()
$scope.getLineItemScale = (lineItem) ->
if lineItem.units_product && lineItem.units_variant && (lineItem.units_product.variant_unit == "weight" || lineItem.units_product.variant_unit == "volume")

View File

@@ -1,6 +0,0 @@
angular.module("admin.lineItems").filter "variantFilter", ->
return (lineItems,selectedUnitsProduct,selectedUnitsVariant,sharedResource) ->
filtered = []
filtered.push lineItem for lineItem in lineItems when (angular.equals(selectedUnitsProduct,{}) ||
(lineItem.units_product.id == selectedUnitsProduct.id && (sharedResource || lineItem.units_variant.id == selectedUnitsVariant.id ) ) )
filtered

View File

@@ -15,7 +15,7 @@ $(document).ready(function() {
console.log(msg);
});
}
$('[data-hook=admin_order_edit_form] a.ship').click(handle_ship_click);
$('.admin-order-edit-form a.ship').click(handle_ship_click);
//handle shipping method edit click
$('a.edit-method').click(toggleMethodEdit);
@@ -37,7 +37,7 @@ $(document).ready(function() {
console.log(msg);
});
}
$('[data-hook=admin_order_edit_form] a.save-method').click(handle_shipping_method_save);
$('.admin-order-edit-form a.save-method').click(handle_shipping_method_save);
//handle tracking info edit/delete
@@ -64,8 +64,8 @@ $(document).ready(function() {
return Spree.url( Spree.routes.orders_api + "/" + order_number + "/shipments/" + shipmentNumber + ".json");
}
$('[data-hook=admin_order_edit_form] a.save-tracking').click(saveTrackingInfo);
$('[data-hook=admin_order_edit_form] a.delete-tracking').click(deleteTrackingInfo);
$('.admin-order-edit-form a.save-tracking').click(saveTrackingInfo);
$('.admin-order-edit-form a.delete-tracking').click(deleteTrackingInfo);
// handle note edit/delete
@@ -96,8 +96,8 @@ $(document).ready(function() {
});
}
$('[data-hook=admin_order_edit_form] a.save-note').click(saveNote);
$('[data-hook=admin_order_edit_form] a.delete-note').click(deleteNote);
$('.admin-order-edit-form a.save-note').click(saveNote);
$('.admin-order-edit-form a.delete-note').click(deleteNote);
// Makes API call for notes/tracking info
makeApiCall = function(url, params) {

View File

@@ -4,7 +4,8 @@ $(document).ready(function() {
initAlert()
initConfirm()
initCancelOrder()
initButtonCancel()
initLinkCancel()
if ($('#variant_autocomplete_template').length > 0) {
window.variantTemplate = Handlebars.compile($('#variant_autocomplete_template').text());
@@ -99,6 +100,7 @@ adjustItems = function(shipment_number, variant_id, quantity, restock_item){
doAdjustItems(shipment_number, variant_id, quantity, inventory_units, restock_item, () => {
var redirectTo = new URL(Spree.routes.cancel_order.toString());
redirectTo.searchParams.append("send_cancellation_email", sendEmailCancellation);
redirectTo.searchParams.append("restock_item", restock_item);
window.location.href = redirectTo.toString();
});
}
@@ -276,17 +278,23 @@ ofnConfirm = function(callback) {
$('#custom-confirm').show();
}
initCancelOrder = function() {
$('#cancel_order_form').submit(function(e){
ofnCancelOrderAlert((confirm, sendEmailCancellation, restock_items) => {
if (confirm) {
var redirectTo = new URL(Spree.routes.cancel_order.toString());
redirectTo.searchParams.append("send_cancellation_email", sendEmailCancellation);
redirectTo.searchParams.append("restock_items", restock_items);
window.location.href = redirectTo.toString();
}
});
e.preventDefault();
return false;
initCancelAction = function(e){
ofnCancelOrderAlert((confirm, sendEmailCancellation, restock_items) => {
if (confirm) {
var redirectTo = new URL(Spree.routes.cancel_order.toString());
redirectTo.searchParams.append("send_cancellation_email", sendEmailCancellation);
redirectTo.searchParams.append("restock_items", restock_items);
window.location.href = redirectTo.toString();
}
});
e.preventDefault();
return false;
};
initButtonCancel = function() {
$('#cancel_order_form').submit(initCancelAction)
}
initLinkCancel = function() {
$('#links-dropdown a[href$="cancel"]').click(initCancelAction);
}

View File

@@ -1,3 +1,4 @@
angular.module("admin.utils", ["templates", "ngSanitize"]).config ($httpProvider, $locationProvider) ->
# for the next line, you should also probably check file: app/assets/javascripts/admin/admin_ofn.js.coffee
$locationProvider.hashPrefix('')
$httpProvider.defaults.headers.common["Accept"] = "application/json, text/javascript, */*"

View File

@@ -2,6 +2,7 @@ angular.module('Darkswarm').factory "EnterpriseModal", ($modal, $rootScope, $htt
# Build a modal popup for an enterprise.
new class EnterpriseModal
open: (enterprise)->
return if enterprise.visible == 'hidden'
scope = $rootScope.$new(true) # Spawn an isolate to contain the enterprise
scope.embedded_layout = window.location.search.indexOf("embedded_shopfront=true") != -1

View File

@@ -1,9 +1,10 @@
# frozen_string_literal: true
class ConfirmModalComponent < ModalComponent
def initialize(id:, confirm_actions: nil, controllers: nil, message: nil)
def initialize(id:, confirm_actions: nil, controllers: nil, message: nil, confirm_reflexes: nil)
super(id: id, close_button: true)
@confirm_actions = confirm_actions
@confirm_reflexes = confirm_reflexes
@controllers = controllers
@message = message
end

View File

@@ -7,4 +7,4 @@
.modal-actions
%input{ class: "button icon-plus #{close_button_class}", type: 'button', value: t('js.admin.modals.cancel'), "data-action": "click->modal#close" }
%input{ class: "button icon-plus primary", type: 'button', value: t('js.admin.modals.confirm'), "data-action": @confirm_actions }
%input{ class: "button icon-plus primary", type: 'button', value: t('js.admin.modals.confirm'), "data-action": @confirm_actions, "data-reflex": @confirm_reflexes }

View File

@@ -18,6 +18,8 @@ module Admin
end
end
ContentConfig.updated_at = Time.zone.now
flash[:success] =
t(:successfully_updated, resource: I18n.t('admin.contents.edit.your_content'))

View File

@@ -2,6 +2,7 @@
require 'open_food_network/address_finder'
# rubocop:disable Metrics/ClassLength
module Admin
class CustomersController < Admin::ResourceController
before_action :load_managed_shops, only: :index, if: :html_request?
@@ -67,7 +68,7 @@ module Admin
def collection
if json_request? && params[:enterprise_id].present?
CustomersWithBalance.new(Customer.of(managed_enterprise_id)).query.
CustomersWithBalance.new(customers).query.
includes(
:enterprise,
{ bill_address: [:state, :country] },
@@ -79,6 +80,15 @@ module Admin
end
end
def customers
return @customers if @customers.present?
@customers = Customer.managed_by(spree_current_user)
return @customers if params[:enterprise_id].blank?
@customers = @customers.where(enterprise_id: params[:enterprise_id])
end
def managed_enterprise_id
@managed_enterprise_id ||= Enterprise.managed_by(spree_current_user).
select('enterprises.id').find_by(id: params[:enterprise_id])
@@ -120,3 +130,4 @@ module Admin
end
end
end
# rubocop:enable Metrics/ClassLength

View File

@@ -7,6 +7,7 @@ module Admin
before_action :load_enterprise_fee_set, only: :index
before_action :load_data
before_action :check_enterprise_fee_input, only: [:bulk_update]
before_action :check_calculators_compatibility_with_taxes, only: [:bulk_update]
def index
@include_calculators = params[:include_calculators].present?
@@ -119,5 +120,17 @@ module Admin
end
end
end
def check_calculators_compatibility_with_taxes
enterprise_fee_bulk_params['collection_attributes'].each do |_, enterprise_fee|
next unless enterprise_fee['inherits_tax_category'] == "true"
next unless EnterpriseFee::PER_ORDER_CALCULATORS.include?(enterprise_fee['calculator_type'])
flash[:error] = I18n.t(
'activerecord.errors.models.enterprise_fee.inherit_tax_requires_per_item_calculator'
)
return redirect_to redirect_path
end
end
end
end

View File

@@ -37,7 +37,7 @@ module Admin
end
def reset_absent_products
@importer = ProductImport::ProductImporter.new(File.new(params[:filepath]),
@importer = ProductImport::ProductImporter.new(File.new(file_path),
spree_current_user, import_into: params[:import_into], enterprises_to_reset: params[:enterprises_to_reset], updated_ids: params[:updated_ids], settings: params[:settings])
if params.key?(:enterprises_to_reset) && params.key?(:updated_ids)
@@ -56,7 +56,7 @@ module Admin
end
def process_data(method)
@importer = ProductImport::ProductImporter.new(File.new(params[:filepath]),
@importer = ProductImport::ProductImporter.new(File.new(file_path),
spree_current_user, start: params[:start], end: params[:end], settings: params[:settings])
begin
@@ -112,5 +112,25 @@ module Admin
def model_class
ProductImport::ProductImporter
end
def file_path
@file_path ||= validate_file_path(sanitize_file_path(params[:filepath]))
end
def sanitize_file_path(file_path)
FilePathSanitizer.new.sanitize(file_path, on_error: method(:raise_invalid_file_path))
end
def validate_file_path(file_path)
return file_path if file_path.to_s.match?(TEMP_FILE_PATH_REGEX)
raise_invalid_file_path
end
def raise_invalid_file_path
redirect_to '/admin/product_import', notice: I18n.t(:product_import_no_data_in_spreadsheet_notice)
raise 'Invalid File Path'
end
TEMP_FILE_PATH_REGEX = %r{^/tmp/product_import[A-Za-z0-9-]*/import\.csv$}
end
end

View File

@@ -2,6 +2,7 @@
module Admin
class ReportsController < Spree::Admin::BaseController
include ActiveStorage::SetCurrent
include ReportsActions
helper ReportsHelper
@@ -21,11 +22,13 @@ module Admin
def show
@report = report_class.new(spree_current_user, params, render: render_data?)
if report_format.present?
if params[:report_format].present?
export_report
else
show_report
end
rescue Timeout::Error
render_timeout_error
end
private
@@ -36,6 +39,7 @@ module Admin
def show_report
assign_view_data
@table = render_report_as(:html) if render_data?
render "show"
end
@@ -45,7 +49,6 @@ module Admin
@report_subtype = report_subtype
@report_title = report_title
@rendering_options = rendering_options
@table = render_report_as(:html) if render_data?
@data = Reporting::FrontendData.new(spree_current_user)
end
@@ -55,16 +58,43 @@ module Admin
def render_report_as(format)
if OpenFoodNetwork::FeatureToggle.enabled?(:background_reports, spree_current_user)
job = ReportJob.perform_later(
report_class, spree_current_user, params, format
@blob = ReportBlob.create_for_upload_later!(report_filename)
ReportJob.perform_later(
report_class, spree_current_user, params, format, @blob
)
sleep 1 until job.done?
Timeout.timeout(max_wait_time) do
sleep 1 until @blob.content_stored?
end
# This result has been rendered by Rails in safe mode already.
job.result.html_safe # rubocop:disable Rails/OutputSafety
@blob.result.html_safe # rubocop:disable Rails/OutputSafety
else
@report.render_as(format)
end
end
def render_timeout_error
assign_view_data
if @blob
@error = ".report_taking_longer_html"
@error_url = @blob.expiring_service_url
else
@error = ".report_taking_longer"
@error_url = ""
end
render "show"
end
def max_wait_time
# This value is used by rack-timeout and nginx, usually 30 seconds in
# staging and production:
server_timeout = ENV.fetch("RACK_TIMEOUT_SERVICE_TIMEOUT", "15").to_f
# Zero disables the timeout:
return 0 if server_timeout.zero?
# We want to time out earlier than nginx:
server_timeout - 2.seconds
end
end
end

View File

@@ -63,7 +63,7 @@ module Admin
options = [{ id: '0', name: 'All' }]
import_dates.collect(&:import_date).map { |i|
options.push(id: i.to_date, name: i.to_date.to_formatted_s(:long))
options.push(id: i.to_date, name: i.to_date.to_fs(:long))
}
options

View File

@@ -116,7 +116,7 @@ module Api
def product_query_includes
[
master: [:images],
master: { images: { attachment_attachment: :blob } },
variants: [:default_price, :stock_locations, :stock_items, :variant_overrides,
{ option_values: :option_type }]
]

View File

@@ -80,9 +80,7 @@ module Api
end
def visible_customers
current_api_user.customers.or(
Customer.where(enterprise_id: editable_enterprises)
)
Customer.managed_by(current_api_user)
end
def customer_params
@@ -106,10 +104,6 @@ module Api
attributes
end
def editable_enterprises
OpenFoodNetwork::Permissions.new(current_api_user).editable_enterprises.select(:id)
end
def include_options
fields = [params.fetch(:include, [])].flatten

View File

@@ -30,6 +30,8 @@ module CheckoutCallbacks
@order.manual_shipping_selection = true
@order.checkout_processing = true
@voucher_adjustment = @order.voucher_adjustments.first
redirect_to(main_app.shop_path) && return if redirect_to_shop?
redirect_to_cart_path && return unless valid_order_line_items?
end

View File

@@ -56,7 +56,7 @@ module ReportsActions
end
def report_format
params[:report_format]
params[:report_format].presence || "html"
end
def report_filename

View File

@@ -5,10 +5,15 @@ module WhiteLabel
include EnterprisesHelper
def hide_ofn_navigation(distributor = current_distributor)
return false unless OpenFoodNetwork::FeatureToggle.enabled?(:white_label)
# if the distributor has the hide_ofn_navigation preference set to true
# then we should hide the OFN navigation
@hide_ofn_navigation = distributor.hide_ofn_navigation
# if the distributor has the hide_ofn_navigation preference
# set to false, there is no need to check the white_label_logo preference
return unless @hide_ofn_navigation
@white_label_logo = distributor.white_label_logo
@white_label_distributor = distributor
end
end

View File

@@ -30,6 +30,8 @@ class SplitCheckoutController < ::BaseController
end
def update
return process_voucher if params[:apply_voucher].present?
if confirm_order || update_order
return if performed?
@@ -59,6 +61,27 @@ class SplitCheckoutController < ::BaseController
replace("#flashes", partial("shared/flashes", locals: { flashes: flash }))
end
def render_voucher_section_or_redirect
respond_to do |format|
format.cable_ready { render_voucher_section }
format.html { redirect_to checkout_step_path(:payment) }
end
end
# Using the power of cable_car we replace only the #voucher_section instead of reloading the page
def render_voucher_section
render(
status: :ok,
cable_ready: cable_car.replace(
"#voucher-section",
partial(
"split_checkout/voucher_section",
locals: { order: @order, voucher_adjustment: @order.voucher_adjustments.first }
)
)
)
end
def order_error_messages
# Remove ship_address.* errors if no shipping method is not selected
remove_ship_address_errors if no_ship_address_needed?
@@ -179,10 +202,47 @@ class SplitCheckoutController < ::BaseController
selected_shipping_method.first.require_ship_address == false
end
def process_voucher
if add_voucher
render_voucher_section_or_redirect
elsif @order.errors.present?
render_error
end
end
def add_voucher
if params.dig(:order, :voucher_code).blank?
@order.errors.add(:voucher, I18n.t('split_checkout.errors.voucher_not_found'))
return false
end
# Fetch Voucher
voucher = Voucher.find_by(code: params[:order][:voucher_code], enterprise: @order.distributor)
if voucher.nil?
@order.errors.add(:voucher, I18n.t('split_checkout.errors.voucher_not_found'))
return false
end
adjustment = voucher.create_adjustment(voucher.code, @order)
if !adjustment.valid?
@order.errors.add(:voucher, I18n.t('split_checkout.errors.add_voucher_error'))
adjustment.errors.each { |error| @order.errors.import(error) }
return false
end
true
end
def summary_step?
params[:step] == "summary"
end
def payment_step?
params[:step] == "payment"
end
def advance_order_state
return if @order.complete?
@@ -252,5 +312,14 @@ class SplitCheckoutController < ::BaseController
def recalculate_tax
@order.create_tax_charge!
@order.update_order!
apply_voucher if @order.voucher_adjustments.present?
end
def apply_voucher
VoucherAdjustmentsService.calculate(@order)
# update order to take into account the voucher we applied
@order.update_order!
end
end

View File

@@ -65,6 +65,7 @@ module Spree
params.require(:order).permit(
:email,
:use_billing,
:customer_id,
bill_address_attributes: ::PermittedAttributes::Address.attributes,
ship_address_attributes: ::PermittedAttributes::Address.attributes
)

View File

@@ -9,11 +9,9 @@ module Spree
helper CheckoutHelper
before_action :load_order, only: [:edit, :update, :fire, :resend,
:invoice, :print]
before_action :load_distribution_choices, only: [:new, :edit, :update]
:invoice, :print, :distribution]
before_action :load_distribution_choices, only: [:new, :edit, :update, :distribution]
# Ensure that the distributor is set for an order when
before_action :ensure_distribution, only: :new
before_action :require_distributor_abn, only: :invoice
respond_to :html, :json
@@ -21,8 +19,20 @@ module Spree
def new
@order = Order.create
@order.created_by = spree_current_user
@order.generate_order_number
@order.save
redirect_to spree.edit_admin_order_url(@order)
redirect_to spree.distribution_admin_order_path(@order)
end
def distribution
return if order_params.blank?
on_update
@order.assign_attributes(order_params)
return unless @order.save(context: :set_distribution_step)
redirect_to spree.admin_order_customer_path(@order)
end
def edit
@@ -33,12 +43,7 @@ module Spree
end
def update
@order.recreate_all_fees!
unless @order.cart?
@order.create_tax_charge!
@order.update_order!
end
on_update
if params[:set_distribution_step] && @order.update(order_params)
return redirect_to spree.admin_order_customer_path(@order)
@@ -105,6 +110,15 @@ module Spree
private
def on_update
@order.recreate_all_fees!
return if @order.cart?
@order.create_tax_charge!
@order.update_order!
end
def order_params
return params[:order] if params[:order].blank?
@@ -142,17 +156,6 @@ module Spree
ocs.closed +
ocs.undated
end
def ensure_distribution
unless @order
@order = Spree::Order.new
@order.generate_order_number
@order.save!
end
return if @order.distribution_set?
render 'set_distribution', locals: { order: @order }
end
end
end
end

View File

@@ -7,7 +7,6 @@ module Spree
before_action :load_data
before_action :validate_payment_method_provider, only: [:create]
before_action :load_hubs, only: [:new, :edit, :update]
before_action :validate_calculator_preferred_value, only: [:update]
respond_to :html
@@ -17,6 +16,10 @@ module Spree
@payment_method = payment_method_class.constantize.new(base_params)
@object = @payment_method
if !base_params["calculator_type"] && gateway_params["calculator_type"]
@payment_method.calculator_type = gateway_params["calculator_type"]
end
load_hubs
if @payment_method.save
@@ -44,6 +47,7 @@ module Spree
redirect_to spree.edit_admin_payment_method_path(@payment_method)
else
respond_with(@payment_method)
clear_preference_cache
end
end
@@ -182,33 +186,23 @@ module Spree
end
end
# Ensure the calculator to be updated is the correct type
if params_for_update["calculator_type"] && params_for_update["calculator_attributes"]
add_type_to_calculator_attributes(params_for_update)
end
params_for_update
end
end
def validate_calculator_preferred_value
return if calculator_preferred_values.all? do |value|
preferred_value_from_params = gateway_params.dig(:calculator_attributes, value)
preferred_value_from_params.nil? || Float(preferred_value_from_params,
exception: false)
def clear_preference_cache
@payment_method.calculator.preferences.each_key do |key|
Rails.cache.delete(@payment_method.calculator.preference_cache_key(key))
end
flash[:error] = I18n.t(:calculator_preferred_value_error)
redirect_to spree.edit_admin_payment_method_path(@payment_method)
end
def calculator_preferred_values
[
:preferred_amount,
:preferred_flat_percent,
:preferred_flat_percent,
:preferred_first_item,
:preferred_additional_item,
:preferred_max_items,
:preferred_normal_amount,
:preferred_discount_amount,
:preferred_minimal_amount
]
def add_type_to_calculator_attributes(hash)
hash["calculator_attributes"]["type"] = hash["calculator_type"]
end
end
end

View File

@@ -177,7 +177,7 @@ module Spree
def product_import_dates
options = [{ id: '0', name: '' }]
product_import_dates_query.collect(&:import_date).
map { |i| options.push(id: i.to_date, name: i.to_date.to_formatted_s(:long)) }
map { |i| options.push(id: i.to_date, name: i.to_date.to_fs(:long)) }
options
end

View File

@@ -0,0 +1,32 @@
# frozen_string_literal: true
class VoucherAdjustmentsController < BaseController
include CablecarResponses
def destroy
@order = current_order
@order.voucher_adjustments.find_by(id: params[:id])&.destroy
respond_to do |format|
format.cable_ready { render_voucher_section }
format.html { redirect_to checkout_step_path(:payment) }
end
end
private
# Using the power of cable_car we replace only the #voucher_section instead of reloading the page
def render_voucher_section
render(
status: :ok,
cable_ready: cable_car.replace(
"#voucher-section",
partial(
"split_checkout/voucher_section",
locals: { order: @order, voucher_adjustment: @order.voucher_adjustments.first }
)
)
)
end
end

View File

@@ -14,7 +14,6 @@ module Admin
producers.size == 1 ? producers.first.id : nil
end
# rubocop:disable Metrics/MethodLength
def enterprise_side_menu_items(enterprise)
is_shop = enterprise.sells != "none"
show_properties = !!enterprise.is_primary_producer
@@ -50,14 +49,8 @@ module Admin
{ name: 'tag_rules', icon_class: "icon-random", show: is_shop },
{ name: 'shop_preferences', icon_class: "icon-shopping-cart", show: is_shop },
{ name: 'users', icon_class: "icon-user", show: true },
] + [add_white_label_if_feature_activated].compact
{ name: 'white_label', icon_class: "icon-leaf", show: true },
]
end
def add_white_label_if_feature_activated
return nil unless OpenFoodNetwork::FeatureToggle.enabled?(:white_label)
{ name: 'white_label', icon_class: "icon-leaf", show: true }
end
# rubocop:enable Metrics/MethodLength
end
end

View File

@@ -68,4 +68,14 @@ module ApplicationHelper
wicked_pdf_stylesheet_pack_tag(source)
end
end
def cache_with_locale(key = nil, options = {}, &block)
cache(cache_key_with_locale(key, I18n.locale), options) do
yield(block)
end
end
def cache_key_with_locale(key, locale)
Array.wrap(key) + [locale.to_s, I18nDigests.for_locale(locale)]
end
end

View File

@@ -87,4 +87,10 @@ module EnterprisesHelper
main_app.producers_url
end
end
def main_logo_link(enterprise)
return enterprise.white_label_logo_link if enterprise&.white_label_logo_link.present?
main_app.root_path
end
end

View File

@@ -3,8 +3,8 @@
module ReportsHelper
def report_order_cycle_options(order_cycles)
order_cycles.map do |oc|
orders_open_at = oc.orders_open_at&.to_s(:short) || 'NA'
orders_close_at = oc.orders_close_at&.to_s(:short) || 'NA'
orders_open_at = oc.orders_open_at&.to_fs(:short) || 'NA'
orders_close_at = oc.orders_close_at&.to_fs(:short) || 'NA'
["#{oc.name} &nbsp; (#{orders_open_at} - #{orders_close_at})".html_safe, oc.id]
end
end

View File

@@ -29,8 +29,8 @@ module Spree
def preference_field_tag(name, value, options)
case options[:type]
when :integer
text_field_tag(name, value, preference_field_options(options))
when :integer, :decimal
number_field_tag(name, value, preference_field_options(options))
when :boolean
hidden_field_tag(name, 0) +
check_box_tag(name, 1, value, preference_field_options(options))
@@ -49,8 +49,8 @@ module Spree
def preference_field_for(form, field, options, object)
case options[:type]
when :integer
form.text_field(field, preference_field_options(options))
when :integer, :decimal
form.number_field(field, preference_field_options(options))
when :boolean
form.check_box(field, preference_field_options(options))
when :string
@@ -80,26 +80,24 @@ module Spree
end
def preference_field_options(options)
field_options = case options[:type]
when :integer
{ size: 10,
class: 'input_integer' }
when :boolean
{}
when :string
{ size: 10,
class: 'input_string fullwidth' }
when :password
{ size: 10,
class: 'password_string fullwidth' }
when :text
{ rows: 15,
cols: 85,
class: 'fullwidth' }
else
{ size: 10,
class: 'input_string fullwidth' }
end
field_options =
case options[:type]
when :integer
{ size: 10, class: 'input_integer', step: 1 }
when :decimal
# Allow any number of decimal places
{ 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
{ rows: 15, cols: 85, class: 'fullwidth' }
else
{ size: 10, class: 'input_string fullwidth' }
end
field_options.merge!(
readonly: options[:readonly],

View File

@@ -34,7 +34,6 @@ module Spree
link = link_to_with_icon(options[:icon], titleized_label, destination_url)
css_classes << 'tab-with-icon'
else
titleized_label = raw("<span class='text'>#{titleized_label}</span>")
link = link_to(titleized_label, destination_url)
end

View File

@@ -105,15 +105,14 @@ module Spree
def cancel_order_link
{ name: t(:cancel_order),
url: spree.fire_admin_order_path(@order.number, e: 'cancel'),
icon: 'icon-trash',
confirm: t(:are_you_sure) }
icon: 'icon-trash' }
end
def cancel_event_link
event_label = I18n.t("cancel", scope: "actions")
button_link_to(event_label,
fire_admin_order_url(@order, e: "cancel"),
method: :put, icon: "icon-remove", form_id: "cancel_order_form")
method: :put, icon: "icon-cancel", form_id: "cancel_order_form")
end
def resume_event_link

View File

@@ -1,34 +1,25 @@
# frozen_string_literal: true
# Renders a report and saves it to a temporary file.
class ReportJob < ActiveJob::Base
def perform(report_class, user, params, format)
# Renders a report and stores it in a given blob.
class ReportJob < ApplicationJob
NOTIFICATION_TIME = 5.seconds
def perform(report_class, user, params, format, blob)
start_time = Time.zone.now
report = report_class.new(user, params, render: true)
result = report.render_as(format)
write(result)
blob.store(result)
execution_time = Time.zone.now - start_time
email_result(user, blob) if execution_time > NOTIFICATION_TIME
end
def done?
@done ||= File.file?(filename)
end
def result
@result ||= read_result
end
private
def write(result)
File.write(filename, result, mode: "wb")
end
def read_result
File.read(filename)
ensure
File.unlink(filename)
end
def filename
Rails.root.join("tmp/report-#{job_id}")
def email_result(user, blob)
ReportMailer.with(
to: user.email,
blob: blob,
).report_ready.deliver_later
end
end

View File

@@ -37,7 +37,7 @@ class JsonApiSchema
end
def relationship_properties
relationships.to_h { |name| [name, relationship_schema(name)] }
relationships.index_with { |name| relationship_schema(name) }
end
# Example

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
class ApplicationMailer < ActionMailer::Base
# Inline stylesheets
include Roadie::Rails::Automatic
helper TermsAndConditionsHelper
default from: -> { Spree::Config[:mails_from] }
layout 'mailer'
def money(amount)
Spree::Money.new(amount).to_s
end
helper_method :money
protected
def roadie_options
# This lets us specify assets using relative paths in email templates
super.merge(url_options: { host: URI(main_app.root_url).host })
end
end

View File

@@ -1,7 +1,7 @@
# frozen_string_literal: true
require 'devise/mailers/helpers'
class EnterpriseMailer < Spree::BaseMailer
class EnterpriseMailer < ApplicationMailer
include Devise::Mailers::Helpers
include I18nHelper
@@ -12,7 +12,6 @@ class EnterpriseMailer < Spree::BaseMailer
enterprise: @enterprise.name,
sitename: Spree::Config[:site_name])
mail(to: enterprise.contact.email,
from: from_address,
subject: subject)
end
end
@@ -20,12 +19,10 @@ class EnterpriseMailer < Spree::BaseMailer
def manager_invitation(enterprise, user)
@enterprise = enterprise
@instance = Spree::Config[:site_name]
@instance_email = from_address
I18n.with_locale valid_locale(@enterprise.owner) do
subject = t('enterprise_mailer.invite_manager.subject', enterprise: @enterprise.name)
mail(to: user.email,
from: from_address,
subject: subject)
end
end

View File

@@ -1,6 +1,6 @@
# frozen_string_literal: true
class PaymentMailer < Spree::BaseMailer
class PaymentMailer < ApplicationMailer
include I18nHelper
def authorize_payment(payment)
@@ -8,7 +8,7 @@ class PaymentMailer < Spree::BaseMailer
subject = I18n.t('spree.payment_mailer.authorize_payment.subject',
distributor: @payment.order.distributor.name)
I18n.with_locale valid_locale(@payment.order.user) do
mail(to: payment.order.email, from: from_address, subject: subject)
mail(to: payment.order.email, subject: subject)
end
end
@@ -19,7 +19,6 @@ class PaymentMailer < Spree::BaseMailer
order: @payment.order)
I18n.with_locale valid_locale(shop_owner) do
mail(to: shop_owner.email,
from: from_address,
subject: subject)
end
end

View File

@@ -1,6 +1,6 @@
# frozen_string_literal: true
class ProducerMailer < Spree::BaseMailer
class ProducerMailer < ApplicationMailer
include I18nHelper
def order_cycle_report(producer, order_cycle)
@@ -14,7 +14,6 @@ class ProducerMailer < Spree::BaseMailer
mail(
to: @producer.contact.email,
from: from_address,
subject: subject,
reply_to: @coordinator.contact.email,
cc: @coordinator.contact.email

View File

@@ -0,0 +1,12 @@
# frozen_string_literal: true
class ReportMailer < ApplicationMailer
def report_ready
# When we are in a background job then we don't have an HTTP request object
# and we need to tell ActiveStorage the hostname to generate URLs.
ActiveStorage::Current.url_options ||= url_options
@blob = params[:blob]
mail(params)
end
end

View File

@@ -1,28 +0,0 @@
# frozen_string_literal: true
module Spree
class BaseMailer < ActionMailer::Base
# Inline stylesheets
include Roadie::Rails::Automatic
helper TermsAndConditionsHelper
layout 'mailer'
def from_address
Spree::Config[:mails_from]
end
def money(amount)
Spree::Money.new(amount).to_s
end
helper_method :money
protected
def roadie_options
# This lets us specify assets using relative paths in email templates
super.merge(url_options: { host: URI(main_app.root_url).host })
end
end
end

View File

@@ -1,7 +1,7 @@
# frozen_string_literal: true
module Spree
class OrderMailer < BaseMailer
class OrderMailer < ApplicationMailer
helper 'checkout'
helper SpreeCurrencyHelper
helper Spree::PaymentMethodsHelper
@@ -13,7 +13,6 @@ module Spree
@order = find_order(order_or_order_id)
I18n.with_locale valid_locale(@order.user) do
mail(to: @order.email,
from: from_address,
subject: mail_subject(t('spree.order_mailer.cancel_email.subject'), resend))
end
end
@@ -23,7 +22,6 @@ module Spree
I18n.with_locale valid_locale(@order.distributor.owner) do
subject = I18n.t('spree.order_mailer.cancel_email_for_shop.subject')
mail(to: @order.distributor.contact.email,
from: from_address,
subject: subject)
end
end
@@ -33,7 +31,6 @@ module Spree
I18n.with_locale valid_locale(@order.user) do
subject = mail_subject(t('spree.order_mailer.confirm_email.subject'), resend)
mail(to: @order.email,
from: from_address,
subject: subject,
reply_to: @order.distributor.contact.email)
end
@@ -44,7 +41,6 @@ module Spree
I18n.with_locale valid_locale(@order.user) do
subject = mail_subject(t('spree.order_mailer.confirm_email.subject'), resend)
mail(to: @order.distributor.contact.email,
from: from_address,
subject: subject)
end
end
@@ -56,7 +52,6 @@ module Spree
attach_file("invoice-#{@order.number}.pdf", pdf)
I18n.with_locale valid_locale(@order.user) do
mail(to: @order.email,
from: from_address,
subject: mail_subject(t(:invoice), false),
reply_to: @order.distributor.contact.email)
end

View File

@@ -1,12 +1,12 @@
# frozen_string_literal: true
module Spree
class ShipmentMailer < BaseMailer
class ShipmentMailer < ApplicationMailer
def shipped_email(shipment, delivery:)
@shipment = shipment.respond_to?(:id) ? shipment : Spree::Shipment.find(shipment)
@delivery = delivery
subject = base_subject
mail(to: @shipment.order.email, from: from_address, subject: subject)
mail(to: @shipment.order.email, subject: subject)
end
private

View File

@@ -1,11 +1,11 @@
# frozen_string_literal: true
module Spree
class TestMailer < BaseMailer
class TestMailer < ApplicationMailer
def test_email(user)
recipient = user.respond_to?(:id) ? user : Spree::User.find(user)
subject = "#{Spree::Config[:site_name]} #{t('spree.test_mailer.test_email.subject')}"
mail(to: recipient.email, from: from_address, subject: subject)
mail(to: recipient.email, subject: subject)
end
end
end

View File

@@ -3,7 +3,7 @@
# This mailer is configured to be the Devise mailer
# Some methods here override Devise::Mailer methods
module Spree
class UserMailer < BaseMailer
class UserMailer < ApplicationMailer
include I18nHelper
helper MailerHelper
@@ -16,7 +16,7 @@ module Spree
"#{I18n.t('spree.user_mailer.reset_password_instructions.subject')}"
I18n.with_locale valid_locale(user) do
mail(to: user.email, from: from_address, subject: subject)
mail(to: user.email, subject: subject)
end
end
@@ -24,7 +24,7 @@ module Spree
def signup_confirmation(user)
@user = user
I18n.with_locale valid_locale(@user) do
mail(to: user.email, from: from_address,
mail(to: user.email,
subject: t(:welcome_to) + ' ' + Spree::Config[:site_name])
end
end
@@ -39,7 +39,6 @@ module Spree
I18n.with_locale valid_locale(@user) do
subject = t('spree.user_mailer.confirmation_instructions.subject')
mail(to: confirmation_email_address,
from: from_address,
subject: subject)
end
end

View File

@@ -1,6 +1,6 @@
# frozen_string_literal: true
class SubscriptionMailer < Spree::BaseMailer
class SubscriptionMailer < ApplicationMailer
helper 'checkout'
helper MailerHelper
helper ShopMailHelper
@@ -37,7 +37,6 @@ class SubscriptionMailer < Spree::BaseMailer
@shop = Enterprise.find(summary.shop_id)
@summary = summary
mail(to: @shop.contact.email,
from: from_address,
subject: "#{Spree::Config[:site_name]} #{t('subscription_mailer.placement_summary_email.subject')}")
end
@@ -45,7 +44,6 @@ class SubscriptionMailer < Spree::BaseMailer
@shop = Enterprise.find(summary.shop_id)
@summary = summary
mail(to: @shop.contact.email,
from: from_address,
subject: "#{Spree::Config[:site_name]} #{t('subscription_mailer.confirmation_summary_email.subject')}")
end
@@ -56,7 +54,6 @@ class SubscriptionMailer < Spree::BaseMailer
confirm_email_subject = t('spree.order_mailer.confirm_email.subject')
subject = "#{Spree::Config[:site_name]} #{confirm_email_subject} ##{order.number}"
mail(to: order.email,
from: from_address,
subject: subject,
reply_to: order.distributor.contact.email)
end

View File

@@ -1,14 +1,11 @@
# frozen_string_literal: false
require 'spree/localized_number'
module Calculator
class FlatPercentItemTotal < Spree::Calculator
extend Spree::LocalizedNumber
preference :flat_percent, :decimal, default: 0
localize_number :preferred_flat_percent
validates :preferred_flat_percent,
numericality: true
def self.description
Spree.t(:flat_percent)

View File

@@ -1,18 +1,15 @@
# frozen_string_literal: true
require 'spree/localized_number'
class Calculator::FlatPercentPerItem < Spree::Calculator
# Spree's FlatPercentItemTotal calculator sums all amounts, and then calculates a percentage
# on them.
# In the cart, we display line item individual amounts rounded, so to have consistent
# calculations we do the same internally. Here, we round adjustments at the individual
# item level first, then multiply by the item quantity.
extend Spree::LocalizedNumber
preference :flat_percent, :decimal, default: 0
localize_number :preferred_flat_percent
validates :preferred_flat_percent,
numericality: true
def self.description
I18n.t(:flat_percent_per_item)

View File

@@ -1,14 +1,11 @@
# frozen_string_literal: false
require 'spree/localized_number'
module Calculator
class FlatRate < Spree::Calculator
extend Spree::LocalizedNumber
preference :amount, :decimal, default: 0
localize_number :preferred_amount
validates :preferred_amount,
numericality: true
def self.description
I18n.t(:flat_rate_per_order)

View File

@@ -1,17 +1,14 @@
# frozen_string_literal: false
require 'spree/localized_number'
module Calculator
class FlexiRate < Spree::Calculator
extend Spree::LocalizedNumber
preference :first_item, :decimal, default: 0.0
preference :additional_item, :decimal, default: 0.0
preference :max_items, :integer, default: 0
localize_number :preferred_first_item,
:preferred_additional_item
validates :preferred_first_item,
:preferred_additional_item,
numericality: true
def self.description
I18n.t(:flexible_rate)

View File

@@ -1,14 +1,11 @@
# frozen_string_literal: false
require 'spree/localized_number'
module Calculator
class PerItem < Spree::Calculator
extend Spree::LocalizedNumber
preference :amount, :decimal, default: 0
localize_number :preferred_amount
validates :preferred_amount,
numericality: true
def self.description
I18n.t(:flat_rate_per_item)

View File

@@ -1,18 +1,15 @@
# frozen_string_literal: false
require 'spree/localized_number'
module Calculator
class PriceSack < Spree::Calculator
extend Spree::LocalizedNumber
preference :minimal_amount, :decimal, default: 0
preference :normal_amount, :decimal, default: 0
preference :discount_amount, :decimal, default: 0
localize_number :preferred_minimal_amount,
:preferred_normal_amount,
:preferred_discount_amount
validates :preferred_minimal_amount,
:preferred_normal_amount,
:preferred_discount_amount,
numericality: true
def self.description
I18n.t(:price_sack)

View File

@@ -1,15 +1,10 @@
# frozen_string_literal: true
require 'spree/localized_number'
module Calculator
class Weight < Spree::Calculator
extend Spree::LocalizedNumber
preference :unit_from_list, :string, default: "kg"
preference :per_unit, :decimal, default: 0.0
localize_number :preferred_per_unit
def self.description
I18n.t('spree.weight')
end

View File

@@ -4,4 +4,8 @@ module AddressDisplay
def full_name_reverse
[lastname, firstname].reject(&:blank?).join(" ")
end
def full_name_for_sorting
[last_name, first_name].reject(&:blank?).join(", ")
end
end

View File

@@ -83,4 +83,19 @@ class ContentConfiguration < Spree::Preferences::Configuration
# User Guide
preference :user_guide_link, :string, default: 'https://guide.openfoodnetwork.org/'
# ContentConfig Caching
preference :updated_at_timestamp, :integer, default: Time.zone.today.to_time.to_i
def updated_at
Time.zone.at updated_at_timestamp
end
def updated_at=(time)
self.updated_at_timestamp = time.to_i
end
def cache_key
"ContentConfig:#{updated_at_timestamp}"
end
end

View File

@@ -35,6 +35,7 @@ class Customer < ApplicationRecord
uniqueness: { scope: :enterprise_id, message: I18n.t('validation_msg_is_associated_with_an_exising_customer') }
scope :of, ->(enterprise) { where(enterprise_id: enterprise) }
scope :managed_by, ->(user) { user&.persisted? ? where(user: user).or(of(Enterprise.managed_by(user))) : none }
before_create :associate_user

View File

@@ -15,6 +15,10 @@ class Enterprise < ApplicationRecord
medium: { resize_to_fill: [720, 156] },
large: { resize_to_fill: [1200, 260] },
}.freeze
WHITE_LABEL_LOGO_SIZES = {
default: { gravity: "Center", resize_to_fill: [217, 44] },
mobile: { gravity: "Center", resize_to_fill: [75, 26] },
}.freeze
VALID_INSTAGRAM_REGEX = %r{\A[a-zA-Z0-9._]{1,30}([^/-]*)\z}
searchable_attributes :sells, :is_primary_producer, :name
@@ -84,9 +88,14 @@ class Enterprise < ApplicationRecord
has_one_attached :logo
has_one_attached :promo_image
has_one_attached :terms_and_conditions
has_one_attached :white_label_logo
validates :logo, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
validates :promo_image, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
validates :logo,
processable_image: true,
content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
validates :promo_image,
processable_image: true,
content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
validates :terms_and_conditions, content_type: {
in: "application/pdf",
message: I18n.t(:enterprise_terms_and_conditions_type_error),
@@ -267,8 +276,7 @@ class Enterprise < ApplicationRecord
def plus_parents_and_order_cycle_producers(order_cycles)
oc_producer_ids = Exchange.in_order_cycle(order_cycles).incoming.pluck :sender_id
Enterprise.not_hidden.is_primary_producer
.parents_of_one_union_others(id, oc_producer_ids | [id])
Enterprise.is_primary_producer.parents_of_one_union_others(id, oc_producer_ids | [id])
end
def relatives_including_self
@@ -299,6 +307,14 @@ class Enterprise < ApplicationRecord
)
end
def white_label_logo_url(name = :default)
return unless white_label_logo.variable?
Rails.application.routes.url_helpers.url_for(
white_label_logo.variant(WHITE_LABEL_LOGO_SIZES[name])
)
end
def website
strip_url self[:website]
end

View File

@@ -58,6 +58,12 @@ class EnterpriseFee < ApplicationRecord
elsif inherits_tax_category_changed?
self.tax_category_id = nil if inherits_tax_category?
end
if inherits_tax_category? && PER_ORDER_CALCULATORS.include?(calculator_type)
errors.add(:base, :inherit_tax_requires_per_item_calculator)
throw :abort
end
true
end
end

View File

@@ -28,8 +28,12 @@ class EnterpriseGroup < ApplicationRecord
has_one_attached :logo
has_one_attached :promo_image
validates :logo, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
validates :promo_image, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
validates :logo,
processable_image: true,
content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
validates :promo_image,
processable_image: true,
content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
scope :by_position, -> { order('position ASC') }
scope :on_front_page, -> { where(on_front_page: true) }

View File

@@ -13,6 +13,7 @@ class EnterpriseRelationship < ApplicationRecord
after_save :update_permissions_of_child_variant_overrides
before_destroy :revoke_all_child_variant_overrides
before_destroy :destroy_related_exchanges
scope :with_enterprises, -> {
joins("
@@ -102,6 +103,10 @@ class EnterpriseRelationship < ApplicationRecord
child_variant_overrides.update_all(permission_revoked_at: Time.zone.now)
end
def destroy_related_exchanges
Exchange.where(sender: parent, receiver: child, incoming: true).destroy_all
end
def child_variant_overrides
VariantOverride.unscoped.for_hubs(child)
.joins(variant: :product).where("spree_products.supplier_id IN (?)", parent)

View File

@@ -1,5 +1,15 @@
# frozen_string_literal: true
class EnterpriseRelationshipPermission < ApplicationRecord
belongs_to :enterprise_relationship
default_scope { order('name') }
before_destroy :destroy_related_exchanges
def destroy_related_exchanges
return if name != "add_to_order_cycle"
Exchange
.where(sender: enterprise_relationship.parent,
receiver: enterprise_relationship.child, incoming: true).destroy_all
end
end

View File

@@ -86,9 +86,9 @@ class Exchange < ApplicationRecord
exchange = dup
exchange.order_cycle = new_order_cycle
exchange.enterprise_fee_ids = enterprise_fee_ids
exchange.variant_ids = variant_ids
exchange.tag_ids = tag_ids
exchange.save!
clone_all_exchange_variants(exchange.id)
exchange
end
@@ -105,4 +105,17 @@ class Exchange < ApplicationRecord
receiver.touch_later
end
private
# An Order Cycle can have thousands of ExchangeVariants.
# It's a simple association without any callbacks on creation. So we can
# insert in bulk and improve the performance tenfold for large order cycles.
def clone_all_exchange_variants(exchange_id)
return unless variant_ids.any?
ExchangeVariant.insert_all( # rubocop:disable Rails/SkipsModelValidations
variant_ids.map{ |variant_id| { variant_id: variant_id, exchange_id: exchange_id } }
)
end
end

View File

@@ -3,4 +3,9 @@
class ExchangeVariant < ApplicationRecord
belongs_to :exchange
belongs_to :variant, class_name: 'Spree::Variant'
after_destroy :destroy_related_outgoing_variants
def destroy_related_outgoing_variants
VariantDeleter.new.destroy_related_outgoing_variants(variant_id, exchange.order_cycle)
end
end

View File

@@ -39,6 +39,8 @@ module ProductImport
enterprise_validation(entry)
unit_fields_validation(entry)
variant_of_product_validation(entry)
price_validation(entry)
on_hand_on_demand_validation(entry)
next if entry.enterprise_id.blank?
@@ -170,6 +172,11 @@ module ProductImport
error: I18n.t('admin.product_import.model.blank'))
end
unless is_numeric(entry.units) && entry.units.to_f > 0
mark_as_invalid(entry, attribute: 'units',
error: I18n.t('admin.product_import.model.incorrect_value'))
end
return if import_into_inventory?
# unit_type must be valid type
@@ -189,6 +196,42 @@ module ProductImport
error: I18n.t('admin.product_import.model.conditional_blank'))
end
def is_numeric(value)
return true unless Float(value, exception: false).nil?
end
def price_validation(entry)
return if is_numeric(entry.price)
error_string = if empty_or_placeholder_value(entry.price)
'admin.product_import.model.blank'
else
'admin.product_import.model.incorrect_value'
end
mark_as_invalid(entry, attribute: 'price', error: I18n.t(error_string))
end
def on_hand_on_demand_validation(entry)
on_hand_present_numeric = !empty_or_placeholder_value(entry.on_hand) &&
is_numeric(entry.on_hand)
on_hand_value = entry.on_hand&.to_i
on_demand_present_numeric = !empty_or_placeholder_value(entry.on_demand) &&
is_numeric(entry.on_demand)
on_demand_value = entry.on_demand&.to_i
return if (on_hand_present_numeric && on_hand_value >= 0) ||
(on_demand_present_numeric && on_demand_value == 1)
mark_as_invalid(entry, attribute: 'on_hand',
error: I18n.t('admin.product_import.model.incorrect_value'))
mark_as_invalid(entry, attribute: 'on_demand',
error: I18n.t('admin.product_import.model.incorrect_value'))
end
def empty_or_placeholder_value(value)
value.blank? || value.to_s.strip == "-"
end
def variant_of_product_validation(entry)
return if entry.producer.blank? || entry.name.blank?
@@ -293,8 +336,7 @@ module ProductImport
entry.primary_taxon_id = @spreadsheet_data.categories_index[category_name]
else
mark_as_invalid(entry, attribute: "category",
error: I18n.t(:error_not_found_in_database,
name: category_name))
error: I18n.t('admin.product_import.model.category_not_found'))
end
end

43
app/models/report_blob.rb Normal file
View File

@@ -0,0 +1,43 @@
# frozen_string_literal: true
# Stores a generated report.
class ReportBlob < ActiveStorage::Blob
# AWS S3 limits URL expiry to one week.
LIFETIME = 1.week
def self.create_for_upload_later!(filename)
# ActiveStorage discourages modifying a blob later but we need a blob
# before we know anything about the report file. It enables us to use the
# same blob in the controller to read the result.
create_before_direct_upload!(
filename: filename,
byte_size: 0,
checksum: "0",
content_type: content_type(filename),
).tap do |blob|
ActiveStorage::PurgeJob.set(wait: LIFETIME).perform_later(blob)
end
end
def self.content_type(filename)
MIME::Types.of(filename).first&.to_s || "application/octet-stream"
end
def store(content)
io = StringIO.new(content)
upload(io, identify: false)
save!
end
def content_stored?
@content_stored ||= reload.checksum != "0"
end
def result
@result ||= download.force_encoding(Encoding::UTF_8)
end
def expiring_service_url
url(expires_in: LIFETIME)
end
end

View File

@@ -274,7 +274,7 @@ module Spree
# Enterprise User can access orders that are placed inside a OC they coordinate
order.order_cycle&.coordinated_by?(user)
end
can [:admin, :bulk_management, :managed], Spree::Order do
can [:admin, :bulk_management, :managed, :distribution], Spree::Order do
user.admin? || user.enterprises.any?(&:is_distributor)
end
can [:admin, :create, :show, :poll], :invoice

View File

@@ -4,7 +4,7 @@ module Spree
class Address < ApplicationRecord
include AddressDisplay
searchable_attributes :firstname, :lastname, :phone
searchable_attributes :firstname, :lastname, :phone, :full_name
searchable_associations :country, :state
belongs_to :country, class_name: "Spree::Country"
@@ -28,6 +28,12 @@ module Spree
alias_attribute :last_name, :lastname
delegate :name, to: :state, prefix: true, allow_nil: true
ransacker :full_name, formatter: proc { |value| value.to_s } do |parent|
Arel::Nodes::SqlLiteral.new(
"CONCAT(#{parent.table_name}.firstname, ' ', #{parent.table_name}.lastname)"
)
end
def self.default
new(country: DefaultCountry.country)
end

View File

@@ -42,9 +42,6 @@ module Spree
belongs_to :order, class_name: "Spree::Order"
belongs_to :tax_category, class_name: 'Spree::TaxCategory'
belongs_to :tax_rate, -> { where spree_adjustments: { originator_type: 'Spree::TaxRate' } },
foreign_key: 'originator_id'
validates :label, presence: true
validates :amount, numericality: true

View File

@@ -88,7 +88,6 @@ module Spree
# Default mail headers settings
preference :mails_from, :string, default: 'ofn@example.com'
preference :mail_bcc, :string, default: 'ofn@example.com'
preference :intercept_email, :string, default: nil
# Default smtp settings
preference :mail_host, :string, default: 'localhost'

View File

@@ -11,8 +11,10 @@ module Spree
has_one_attached :attachment
validates :attachment, attached: true,
content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
validates :attachment,
attached: true,
processable_image: true,
content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
validate :no_attachment_errors
def variant(name)

View File

@@ -62,6 +62,13 @@ module Spree
has_many :line_item_adjustments, through: :line_items, source: :adjustments
has_many :shipment_adjustments, through: :shipments, source: :adjustments
has_many :all_adjustments, class_name: 'Spree::Adjustment', dependent: :destroy
has_many :voucher_adjustments,
-> {
where(originator_type: 'Voucher')
.order("#{Spree::Adjustment.table_name}.created_at ASC")
},
class_name: 'Spree::Adjustment',
dependent: :destroy
belongs_to :order_cycle
belongs_to :distributor, class_name: 'Enterprise'
@@ -97,6 +104,8 @@ module Spree
validates :email, presence: true,
format: /\A([\w.%+\-']+)@([\w\-]+\.)+(\w{2,})\z/i,
if: :require_email
validates :order_cycle, presence: true, on: :set_distribution_step
validates :distributor, presence: true, on: :set_distribution_step
make_permalink field: :number

View File

@@ -63,7 +63,7 @@ module Spree
# first unshipped that's leaving from a stock_location that stocks this variant
def determine_target_shipment(variant)
target_shipment = order.shipments.detect do |shipment|
(shipment.ready? || shipment.pending?) && shipment.include?(variant)
(shipment.ready? || shipment.pending?) && shipment.contains?(variant)
end
target_shipment || order.shipments.detect do |shipment|

View File

@@ -17,6 +17,7 @@ module Spree
validates :name, presence: true
validate :distributor_validation
validates_associated :calculator
after_initialize :init
@@ -40,9 +41,8 @@ module Spree
where(id: non_unique_matches.map(&:id))
}
scope :for_distributor, lambda { |distributor|
joins(:distributors).
where('enterprises.id = ?', distributor)
scope :for_distributor, ->(distributor) {
joins(:distributors).where('enterprises.id = ?', distributor)
}
scope :for_subscriptions, -> { where(type: Subscription::ALLOWED_PAYMENT_METHOD_TYPES) }

View File

@@ -22,7 +22,8 @@ module Spree
when :password
self[:value].to_s
when :decimal
BigDecimal(self[:value].to_s).round(2, BigDecimal::ROUND_HALF_UP)
BigDecimal(self[:value].to_s, exception: false)&.round(2, BigDecimal::ROUND_HALF_UP) ||
self[:value]
when :integer
self[:value].to_i
when :boolean

View File

@@ -117,7 +117,7 @@ module Spree
value.to_s
when :decimal
value = 0 if value.blank?
BigDecimal(value.to_s).round(2, BigDecimal::ROUND_HALF_UP)
BigDecimal(value.to_s, exception: false)&.round(2, BigDecimal::ROUND_HALF_UP) || value
when :integer
value.to_i
when :boolean

View File

@@ -114,6 +114,7 @@ module Spree
presence: { if: ->(p) { %w(weight volume).include? p.variant_unit } }
validates :variant_unit_name,
presence: { if: ->(p) { p.variant_unit == 'items' } }
validate :validate_image_for_master
attr_accessor :option_values_hash
@@ -474,5 +475,11 @@ module Spree
requested = permalink.presence || permalink_was.presence || name.presence || 'product'
self.permalink = create_unique_permalink(requested.parameterize)
end
def validate_image_for_master
return if master.images.all?(&:valid?)
errors.add(:base, I18n.t('spree.admin.products.image_not_processable'))
end
end
end

View File

@@ -246,7 +246,7 @@ module Spree
@tracking_url ||= shipping_method.build_tracking_url(tracking)
end
def include?(variant)
def contains?(variant)
inventory_units_for(variant).present?
end

View File

@@ -61,7 +61,7 @@ module Spree
# Here we allow checkout with shipping methods without zones (see issue #3928 for details)
# and also checkout with addresses outside of the zones of the selected shipping method
# This method could be used, like in Spree, to validate shipping method zones on checkout.
def include?(address)
def delivers_to?(address)
address.present?
end

View File

@@ -69,7 +69,8 @@ module Spree
return 0 unless category
address ||= Address.new(country_id: DefaultCountry.id)
rate = category.tax_rates.detect { |tax_rate| tax_rate.zone.include? address }.try(:amount)
rate = category.tax_rates
.detect { |tax_rate| tax_rate.zone.contains_address? address }.try(:amount)
rate || 0
end

View File

@@ -24,7 +24,7 @@ module Spree
# do nothing - just here to satisfy the form
end
def include?(address)
def contains_address?(address)
return false unless address
members.any? do |zone_member|
@@ -44,7 +44,7 @@ module Spree
def self.match(address)
return unless matches = includes(:zone_members).
order('zone_members_count', 'created_at').
select { |zone| zone.include? address }
select { |zone| zone.contains_address? address }
['state', 'country'].each do |zone_kind|
if match = matches.detect { |zone| zone_kind == zone.kind }

View File

@@ -1,8 +1,15 @@
# frozen_string_literal: false
class Voucher < ApplicationRecord
acts_as_paranoid
belongs_to :enterprise
has_many :adjustments,
as: :originator,
class_name: 'Spree::Adjustment',
dependent: :nullify
validates :code, presence: true, uniqueness: { scope: :enterprise_id }
def value
@@ -12,4 +19,31 @@ class Voucher < ApplicationRecord
def display_value
Spree::Money.new(value)
end
# Ideally we would use `include CalculatedAdjustments` to be consistent with other adjustments,
# but vouchers have complicated calculation so we can't easily use Spree::Calculator. We keep
# the same method to stay as consistent as possible.
#
# Creates a new voucher adjustment for the given order
def create_adjustment(label, order)
amount = compute_amount(order)
adjustment_attributes = {
amount: amount,
originator: self,
order: order,
label: label,
mandatory: false,
state: "open",
tax_category: nil
}
order.adjustments.create(adjustment_attributes)
end
# We limit adjustment to the maximum amount needed to cover the order, ie if the voucher
# covers more than the order.total we only need to create an adjustment covering the order.total
def compute_amount(order)
-value.clamp(0, order.total)
end
end

View File

@@ -2,7 +2,7 @@
class BulkActionsInOrdersListReflex < ApplicationReflex
def resend_confirmation_email(order_ids)
orders(order_ids).find_each do |o|
editable_orders.where(id: order_ids).find_each do |o|
Spree::OrderMailer.confirm_email_for_customer(o.id, true).deliver_later if can? :resend, o
end
@@ -11,7 +11,7 @@ class BulkActionsInOrdersListReflex < ApplicationReflex
def send_invoice(order_ids)
count = 0
orders(order_ids).find_each do |o|
editable_orders.where(id: order_ids).find_each do |o|
next unless o.distributor.can_invoice? && (o.resumed? || o.complete?)
Spree::OrderMailer.invoice_email(o.id).deliver_later
@@ -29,7 +29,7 @@ class BulkActionsInOrdersListReflex < ApplicationReflex
morph "#flashes", render(partial: "shared/flashes", locals: { flashes: flash })
end
def orders(order_ids)
Spree::Order.where(id: order_ids)
def editable_orders
Permissions::Order.new(current_user).editable_orders
end
end

View File

@@ -2,7 +2,7 @@
class CancelOrdersReflex < ApplicationReflex
def confirm(params)
OrdersBulkCancelService.new(params).call
OrdersBulkCancelService.new(params, current_user).call
cable_ready.dispatch_event(name: "modal:close")
# flash[:success] = Spree.t(:order_updated)
end

View File

@@ -0,0 +1,12 @@
# frozen_string_literal: true
module EnterpriseConcern
extend ActiveSupport::Concern
included do
before_reflex do
@enterprise = Enterprise.find_by(permalink: params[:id])
authorize! :update, @enterprise
end
end
end

View File

@@ -0,0 +1,26 @@
# frozen_string_literal: true
class WhiteLabelReflex < ApplicationReflex
include EnterpriseConcern
delegate :view_context, to: :controller
def remove_logo
@enterprise.update!(white_label_logo: nil)
# delete the white_label_logo_link attribute as well since it has no meaning without the logo
@enterprise.update!(white_label_logo_link: "")
f = ActionView::Helpers::FormBuilder.new(:enterprise, @enterprise, view_context, {})
html = with_locale {
render(partial: "admin/enterprises/form/white_label",
locals: { f: f, enterprise: @enterprise })
}
morph "#white_label_panel", html
flash[:success] = with_locale {
I18n.t("admin.enterprises.form.white_label.remove_logo_success")
}
cable_ready.dispatch_event(name: "modal:close")
morph "#flashes", render(partial: "shared/flashes", locals: { flashes: flash })
end
end

View File

@@ -14,7 +14,8 @@ module Api
:logo, :promo_image, :terms_and_conditions,
:terms_and_conditions_file_name, :terms_and_conditions_updated_at,
:preferred_invoice_order_by_supplier, :preferred_product_low_stock_display,
:visible, :hide_ofn_navigation
:visible, :hide_ofn_navigation, :white_label_logo,
:white_label_logo_link
has_one :owner, serializer: Api::Admin::UserSerializer
has_many :users, serializer: Api::Admin::UserSerializer
@@ -29,6 +30,10 @@ module Api
attachment_urls(object.promo_image, Enterprise::PROMO_IMAGE_SIZES)
end
def white_label_logo
attachment_urls(object.white_label_logo, Enterprise::WHITE_LABEL_LOGO_SIZES)
end
def terms_and_conditions
return unless object.terms_and_conditions.attached?

View File

@@ -3,8 +3,10 @@
module Api
module Admin
class OrderSerializer < ActiveModel::Serializer
attributes :id, :number, :user_id, :full_name, :email, :phone, :completed_at,
:completed_at_utc_iso8601, :display_total,
include AddressDisplay
attributes :id, :number, :user_id, :full_name, :full_name_for_sorting, :email, :phone,
:completed_at, :completed_at_utc_iso8601, :display_total,
:edit_path, :state, :payment_state, :shipment_state,
:payments_path, :ready_to_ship, :ready_to_capture, :created_at,
:distributor_name, :special_instructions, :display_outstanding_balance,
@@ -17,6 +19,14 @@ module Api
object.billing_address.nil? ? "" : ( object.billing_address.full_name || "" )
end
def first_name
object.billing_address&.first_name || ""
end
def last_name
object.billing_address&.last_name || ""
end
def distributor_name
object.distributor&.name
end

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