Compare commits

...

729 Commits

Author SHA1 Message Date
filipefurtad0
a39c465692 Update all locales with the latest Transifex translations 2023-08-24 21:36:53 +01:00
Filipe
cc3b7c68ae Merge pull request #11208 from dacook/buu-editing-11059
[BUU] Change name of my products 🚧
2023-08-24 21:19:52 +01:00
Filipe
10bc2a3ee6 Merge pull request #11430 from abdellani/fix-updating-invoices-data
fix order invoice generator must update the latest invoice
2023-08-24 20:58:37 +01:00
Filipe
020276a248 Merge pull request #11418 from macanudo527/fix_rubocop_7
Fix Rails and Style Autocorrect Rubocop Errors
2023-08-24 10:29:45 +01:00
Filipe
c5e1444613 Merge pull request #11206 from macanudo527/fix_class_length
Add Form Object to Schedules Controller
2023-08-24 09:28:50 +01:00
Konrad
c90b244a96 Merge pull request #11415 from abdellani/snail-when-setting-unit-value-to-0
fix Snail when setting "0" in the unit value field
2023-08-24 10:04:26 +02:00
Konrad
6ec022b731 Merge pull request #11391 from rioug/11362-fix-error-creating-percentage-voucher
[Vouchers] fix error when creating a percentage voucher
2023-08-24 09:09:30 +02:00
David Cook
3c617a51e0 Merge pull request #11433 from openfoodfoundation/dependabot/bundler/mime-types-3.5.1
chore(deps): bump mime-types from 3.5.0 to 3.5.1
2023-08-24 15:11:09 +10:00
David Cook
a96b712eb2 Merge pull request #11432 from openfoodfoundation/dependabot/bundler/activerecord-import-1.5.0
chore(deps): bump activerecord-import from 1.4.1 to 1.5.0
2023-08-24 15:10:02 +10:00
David Cook
4a877fe019 Merge pull request #11426 from mkllnk/style-has-many
Allow has_and_belongs_to_many to reduce code
2023-08-24 15:03:17 +10:00
dependabot[bot]
f0dce7765c chore(deps): bump activerecord-import from 1.4.1 to 1.5.0
Bumps [activerecord-import](https://github.com/zdennis/activerecord-import) from 1.4.1 to 1.5.0.
- [Changelog](https://github.com/zdennis/activerecord-import/blob/master/CHANGELOG.md)
- [Commits](https://github.com/zdennis/activerecord-import/compare/v1.4.1...v1.5.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-24 02:54:17 +00:00
Maikel
79211bd856 Merge pull request #11438 from openfoodfoundation/dependabot/bundler/aws-sdk-s3-1.133.0
chore(deps): bump aws-sdk-s3 from 1.132.1 to 1.133.0
2023-08-24 12:52:39 +10:00
Maikel
fba55fe9fd Merge pull request #11437 from openfoodfoundation/dependabot/bundler/rails-7.0.7.2
chore(deps): bump rails from 7.0.7 to 7.0.7.2
2023-08-24 12:51:08 +10:00
Maikel
d6572d9fde Merge pull request #11434 from openfoodfoundation/dependabot/bundler/knapsack_pro-5.4.1
chore(deps-dev): bump knapsack_pro from 5.3.5 to 5.4.1
2023-08-24 12:46:33 +10:00
Neal Chambers
a363f88f2c Put Subscriptions back into Schedules Controller 2023-08-24 09:18:35 +09:00
Neal Chambers
7eab4d64ba Update .rubocop_todo.yml 2023-08-24 09:17:55 +09:00
Neal Chambers
134cbb4f04 Add Form Object to Fix Metrics/ClassLength 2023-08-24 09:17:53 +09:00
David Cook
a8d37d0899 Apply suggestions from code review
Rails is clever enough to not query the database without ids

Co-authored-by: Maikel <maikel@email.org.au>
2023-08-24 08:48:27 +10:00
Filipe
1021fd94b5 Merge pull request #11419 from openfoodfoundation/dependabot/bundler/stripe-9.0.0
chore(deps): bump stripe from 8.6.0 to 9.0.0
2023-08-23 17:35:29 +01:00
Mohamed ABDELLANI
928494af23 use Invoice#latest to fetch the most recent invoice 2023-08-23 11:57:30 +01:00
dependabot[bot]
cd9bf6a62e chore(deps): bump stripe from 8.6.0 to 9.0.0
Bumps [stripe](https://github.com/stripe/stripe-ruby) from 8.6.0 to 9.0.0.
- [Release notes](https://github.com/stripe/stripe-ruby/releases)
- [Changelog](https://github.com/stripe/stripe-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/stripe/stripe-ruby/compare/v8.6.0...v9.0.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-23 11:42:43 +01:00
dependabot[bot]
ea46d15ad4 chore(deps): bump aws-sdk-s3 from 1.132.1 to 1.133.0
Bumps [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby) from 1.132.1 to 1.133.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-08-23 02:28:35 +00:00
dependabot[bot]
752d77110d chore(deps): bump rails from 7.0.7 to 7.0.7.2
Bumps [rails](https://github.com/rails/rails) from 7.0.7 to 7.0.7.2.
- [Release notes](https://github.com/rails/rails/releases)
- [Commits](https://github.com/rails/rails/compare/v7.0.7...v7.0.7.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-23 02:28:07 +00:00
Maikel
57c44ffc72 Merge pull request #11429 from openfoodfoundation/dependabot/bundler/newrelic_rpm-9.4.2
chore(deps): bump newrelic_rpm from 9.4.1 to 9.4.2
2023-08-23 12:24:53 +10:00
Maikel
9bfb59d45f Merge pull request #11428 from openfoodfoundation/dependabot/bundler/rubocop-1.56.1
chore(deps-dev): bump rubocop from 1.56.0 to 1.56.1
2023-08-23 12:23:43 +10:00
Konrad
3aca33b8a6 Merge pull request #11230 from macanudo527/fix_products_controller
Add Query Object to Product Model to Fix Metrics/ClassLength
2023-08-22 11:38:09 +02:00
Mohamed ABDELLANI
b082475c35 update product's unit_value validation 2023-08-22 10:28:27 +01:00
dependabot[bot]
067ddb7bcd chore(deps-dev): bump knapsack_pro from 5.3.5 to 5.4.1
Bumps [knapsack_pro](https://github.com/KnapsackPro/knapsack_pro-ruby) from 5.3.5 to 5.4.1.
- [Changelog](https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v5.3.5...v5.4.1)

---
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-08-22 09:04:55 +00:00
dependabot[bot]
238249e8ec chore(deps): bump mime-types from 3.5.0 to 3.5.1
Bumps [mime-types](https://github.com/mime-types/ruby-mime-types) from 3.5.0 to 3.5.1.
- [Changelog](https://github.com/mime-types/ruby-mime-types/blob/main/History.md)
- [Commits](https://github.com/mime-types/ruby-mime-types/compare/v3.5.0...v3.5.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-22 09:03:13 +00:00
Mohamed ABDELLANI
a896d414c2 optimize system test 2023-08-22 09:16:47 +01:00
Mohamed ABDELLANI
3ab288f435 fix product's unit value validation 2023-08-22 09:16:47 +01:00
Mohamed ABDELLANI
d4dbc0adb5 fix unit_value initialization on the product duplicator 2023-08-22 09:16:47 +01:00
Mohamed ABDELLANI
a9e4159839 validate unit_value > 0 on product model 2023-08-22 09:16:47 +01:00
David Cook
2edf504d65 Ignore long classes for now
As much as I hate to add to this list, this is still a work in progress so it's not worth refactoring at this point.
2023-08-22 11:51:05 +10:00
David Cook
b0e77df226 Style form actions area 2023-08-22 11:51:05 +10:00
David Cook
fccde964bf Enable 'medium' style for reset buttons 2023-08-22 11:46:56 +10:00
David Cook
7bf79441c8 Update link colours to match new design 2023-08-22 11:40:58 +10:00
David Cook
3cc5d7ba1d Copy form styles to v3 2023-08-22 11:40:58 +10:00
David Cook
37d1113e4c Align row headers with input contents
Inputs add extra padding, so we add the same padding to the header. Using an opt-in class, because I think we won't want this on all columns.
2023-08-22 11:40:58 +10:00
David Cook
8440c44a6f Remove unused style 2023-08-22 11:40:58 +10:00
David Cook
2b09ec7c21 [fixup] Left line for row hover 2023-08-22 11:40:58 +10:00
David Cook
be24247df2 [wip] Left line for row hover
But it's not perfect. Can we use a pseudo element instead?
2023-08-22 11:40:58 +10:00
David Cook
565ea23175 Hide borders from inputs until hover 2023-08-22 11:40:58 +10:00
David Cook
ef63c520c0 Aggregate errors 2023-08-22 11:40:58 +10:00
David Cook
a70f392654 Show error messages
It's kinda hard to test reflexes..
2023-08-22 11:40:58 +10:00
David Cook
a0dba001bc Attempt to save all records in bulk update
Before, it would abort after the first invalid record, and it doesn't tell you about the others. This way you find out about all at once.

This affects the existing Bulk Edit Products screen, and can result in longer error messages than before. But I would argue that's a good thing.

I think this is technically optional for BUU at this point, but a helpful improvement.
2023-08-22 11:40:58 +10:00
David Cook
71c36585bc Retain order when saving.
Perhaps this should be tested in the system spec too ("I can rename a product and still see it after saving"). But I'd like to find the compromise to avoid bulking up system specs too much. I think it's covered well enough by the reflex spec?
2023-08-22 11:40:58 +10:00
David Cook
6ffe1ec1ad Retain the order of products in the collection 2023-08-22 11:40:58 +10:00
David Cook
ae3cd6f7e0 Add bulk_update product form for product name
(For now at least,) we use one big standard Rails form, and ModelSet to update each record.
Submitting with Reflex allows us to manage the loading state along with the rest of the page (although I would rather use the built in HTTP POST standard).

Aria-label makes it a bit easier for testing (and accessibility software of course!). Technically it should have been aria-labelledby="id_of_column_header" but that would have resulted in more HTML and processing, which seemed silly.

Best viewed with whitespace ignored.
2023-08-22 11:40:58 +10:00
David Cook
a98242e5b4 Capybara: enable_aria_label 2023-08-22 11:40:58 +10:00
David Cook
e37a499125 Merge pull request #11383 from jibees/11274-buu-as-a-single-producer-i-should-not-be-able-to-see-the-producer-dropdown
🚧 Products V3: Do not display "Producers" selector if only one is possible
2023-08-22 11:33:12 +10:00
Maikel Linke
31d87ca087 Show producer filter only when multiple options
Also introducing a view spec here because the code was incorrectly
refactored before. The execution of the view spec takes only 100ms
which is much faster than a system spec.
2023-08-22 10:00:06 +10:00
Jean-Baptiste Bellet
6582a875c6 Do not display "Producers" selector if only one is possible
Fix #11274

Co-Authored-By: David Cook <david@redcliffs.net>
2023-08-22 10:00:06 +10:00
David Cook
71b297b5b5 Merge pull request #11417 from jibees/11410-go-back-to-top-after-selecting-a-page-in-pagination
🚧 BUU: Once products are loaded, scroll higher, ie. just above filters
2023-08-22 09:20:31 +10:00
Konrad
391d06130d Merge pull request #11395 from duleorlovic/google-map-region
Add Google map region parameter
2023-08-21 18:14:56 +02:00
Mohamed ABDELLANI
aaf1d22ccc fix order invoice generator must update the latest invoice 2023-08-21 16:10:05 +01:00
dependabot[bot]
397f365fe6 chore(deps): bump newrelic_rpm from 9.4.1 to 9.4.2
Bumps [newrelic_rpm](https://github.com/newrelic/newrelic-ruby-agent) from 9.4.1 to 9.4.2.
- [Release notes](https://github.com/newrelic/newrelic-ruby-agent/releases)
- [Changelog](https://github.com/newrelic/newrelic-ruby-agent/blob/dev/CHANGELOG.md)
- [Commits](https://github.com/newrelic/newrelic-ruby-agent/compare/9.4.1...9.4.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-21 09:28:35 +00:00
dependabot[bot]
c97b5b3693 chore(deps-dev): bump rubocop from 1.56.0 to 1.56.1
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.56.0 to 1.56.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.56.0...v1.56.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-08-21 09:27:48 +00:00
Maikel
af73720157 Merge pull request #11423 from openfoodfoundation/dependabot/bundler/puma-6.3.1
chore(deps): bump puma from 6.3.0 to 6.3.1
2023-08-21 14:04:20 +10:00
Maikel Linke
ff18270898 Allow has_and_belongs_to_many to reduce code
The Rails/HasAndBelongsToMany rule wants model classes for all
many-to-many relationship tables in the database. But our team thinks
that it's useful to declare has_and_belongs_to_many relationships which
don't require an additional model.
2023-08-21 10:12:33 +10:00
Neal Chambers
0b6b750706 Clarify Product Scope Query Spec 2023-08-20 13:01:34 +09:00
Neal Chambers
fc47c57603 Add helper method to products controller and Use query object 2023-08-20 13:00:39 +09:00
Neal Chambers
9e82ab8a0f Remove query scopes from product model 2023-08-20 13:00:39 +09:00
Neal Chambers
c125c42a6d Add Tests for Product Scope Query 2023-08-20 13:00:39 +09:00
Neal Chambers
a867f7c543 Add Product Scope Query 2023-08-20 13:00:36 +09:00
Maikel Linke
eb204c9e5b Style HashSyntax and reduce line length 2023-08-20 12:33:43 +09:00
Maikel Linke
e0acc25808 Fix subscription spec and add more coverage
One spec was only passing due to a bug. The setup wasn't complete and
despite the variant being unavailable in the order cycle it was reported
as being available. The order cycle has now been set up correctly.

Another spec was added to cover an edge case lead to a bug before this
pull request. When all subscription items where unavailable, all were
marked as available.
2023-08-20 12:33:43 +09:00
Neal Chambers
bc559b966c Safely autocorrect Style/FetchEnvVar
Inspecting 1483 files
..............................................................................................................................................................C.............................................................................................................................................................................CC.............................................................................................................................................................................C.................................................................................................................................................................................................................................................................................................................................................................C.................................................................................C..............................................................................................................................................................................................C.....................................................................................................................................................................................................................................C......................................................................................................................

Offenses:

app/helpers/discourse_helper.rb:9:5: C: [Corrected] Style/FetchEnvVar: Use ENV.fetch('DISCOURSE_URL') or ENV.fetch('DISCOURSE_URL', nil) instead of ENV['DISCOURSE_URL'].
    ENV['DISCOURSE_URL']
    ^^^^^^^^^^^^^^^^^^^^
app/models/spree/preferences/configuration.rb:35:10: C: [Corrected] Style/FetchEnvVar: Use ENV.fetch('RAILS_CACHE_ID') or ENV.fetch('RAILS_CACHE_ID', nil) instead of ENV['RAILS_CACHE_ID'].
        [ENV['RAILS_CACHE_ID'], self.class.name, name].flatten.join('::').underscore
         ^^^^^^^^^^^^^^^^^^^^^
app/models/spree/preferences/preferable.rb:84:10: C: [Corrected] Style/FetchEnvVar: Use ENV.fetch("RAILS_CACHE_ID") or ENV.fetch("RAILS_CACHE_ID", nil) instead of ENV["RAILS_CACHE_ID"].
        [ENV["RAILS_CACHE_ID"], self.class.name, name, id].join('::').underscore
         ^^^^^^^^^^^^^^^^^^^^^
app/services/default_country.rb:13:40: C: [Corrected] Style/FetchEnvVar: Use ENV.fetch("DEFAULT_COUNTRY_CODE") or ENV.fetch("DEFAULT_COUNTRY_CODE", nil) instead of ENV["DEFAULT_COUNTRY_CODE"].
    Spree::Country.cached_find_by(iso: ENV["DEFAULT_COUNTRY_CODE"]) || Spree::Country.first
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/services/default_country.rb:13:73: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
    Spree::Country.cached_find_by(iso: ENV.fetch("DEFAULT_COUNTRY_CODE",
                                                                        ^
app/services/default_country.rb:13:101: C: [Corrected] Layout/LineLength: Line is too long. [102/100]
    Spree::Country.cached_find_by(iso: ENV.fetch("DEFAULT_COUNTRY_CODE", nil)) || Spree::Country.first
                                                                                                    ^^
app/services/default_country.rb:14:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
nil)) || Spree::Country.first
^^^
spec/base_spec_helper.rb:51:49: C: [Corrected] Style/FetchEnvVar: Use ENV.fetch("SITE_URL") or ENV.fetch("SITE_URL", nil) instead of ENV["SITE_URL"].
ActionMailer::Base.default_url_options[:host] = ENV["SITE_URL"]
                                                ^^^^^^^^^^^^^^^
spec/controllers/spree/credit_cards_controller_spec.rb:8:20: C: [Corrected] Style/FetchEnvVar: Use ENV.fetch('STRIPE_SECRET_TEST_API_KEY') or ENV.fetch('STRIPE_SECRET_TEST_API_KEY', nil) instead of ENV['STRIPE_SECRET_TEST_API_KEY'].
    let(:secret) { ENV['STRIPE_SECRET_TEST_API_KEY'] }
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/models/order_balance_spec.rb:48:70: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
      expect(order_balance.display_amount).to eq(Spree::Money.new(20,
                                                                     ^
spec/models/order_balance_spec.rb:48:81: C: [Corrected] Style/FetchEnvVar: Use ENV.fetch('currency') or ENV.fetch('currency', nil) instead of ENV['currency'].
      expect(order_balance.display_amount).to eq(Spree::Money.new(20, currency: ENV['currency']))
                                                                                ^^^^^^^^^^^^^^^
spec/models/order_balance_spec.rb:48:101: C: [Corrected] Layout/LineLength: Line is too long. [108/100]
      expect(order_balance.display_amount).to eq(Spree::Money.new(20, currency: ENV.fetch('currency', nil)))
                                                                                                    ^^^^^^^^
spec/models/order_balance_spec.rb:49:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
currency: ENV.fetch('currency', nil)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/models/order_balance_spec.rb:49:98: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
                                                                  currency: ENV.fetch('currency',
                                                                                                 ^
spec/models/order_balance_spec.rb:49:101: C: [Corrected] Layout/LineLength: Line is too long. [104/100]
                                                                  currency: ENV.fetch('currency', nil)))
                                                                                                    ^^^^
spec/models/order_balance_spec.rb:50:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
nil)))
^^^
spec/support/vcr_setup.rb:10:50: C: [Corrected] Style/FetchEnvVar: Use ENV.fetch('STRIPE_SECRET_TEST_API_KEY') or ENV.fetch('STRIPE_SECRET_TEST_API_KEY', nil) instead of ENV['STRIPE_SECRET_TEST_API_KEY'].
  config.filter_sensitive_data('<HIDDEN_KEY>') { ENV['STRIPE_SECRET_TEST_API_KEY'] }
                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/support/vcr_setup.rb:11:55: C: [Corrected] Style/FetchEnvVar: Use ENV.fetch('STRIPE_CUSTOMER') or ENV.fetch('STRIPE_CUSTOMER', nil) instead of ENV['STRIPE_CUSTOMER'].
  config.filter_sensitive_data('<HIDDEN_CUSTOMER>') { ENV['STRIPE_CUSTOMER'] }
                                                      ^^^^^^^^^^^^^^^^^^^^^^

1483 files inspected, 18 offenses detected, 18 offenses corrected
2023-08-20 12:33:43 +09:00
Neal Chambers
fd795d8513 Safely autocorrect Style/BlockComments
Inspecting 1483 files
....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C......................................................

Offenses:

spec/system/admin/tag_rules_spec.rb:209:1: C: [Corrected] Style/BlockComments: Do not use block comments.
=begin ...
^^^^^^
spec/system/admin/tag_rules_spec.rb:217:101: C: Layout/LineLength: Line is too long. [103/100]
      #       expect(default_fsm_tag_rule.preferred_matched_shipping_methods_visibility).to eq "hidden"
                                                                                                    ^^^
spec/system/admin/tag_rules_spec.rb:241:1: C: [Corrected] Layout/CommentIndentation: Incorrect indentation detected (column 0 instead of 6).
#       expect(foc_tag_rule.preferred_matched_order_cycles_visibility).to eq "hidden"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1483 files inspected, 3 offenses detected, 2 offenses corrected
2023-08-20 12:33:43 +09:00
Neal Chambers
06e217c527 Safely autocorrect Rails/WhereNot
Inspecting 1483 files
........................................................................................................................C..................................................................................................................C...........CC.C..........................................C......C..........C.........................C......................CC..........C........................................................................................................................C.......................................................................................................C........................................................C...........................................................................................................................................C......................................C.........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

app/controllers/spree/admin/products_controller.rb:183:11: C: [Corrected] Rails/WhereNot: Use where.not(spree_variants: { import_date: nil }) instead of manually constructing negated SQL in where.
          where('spree_variants.import_date IS NOT NULL').
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/concerns/permalink_generator.rb:37:26: C: [Corrected] Rails/WhereNot: Use where.not(id: id) instead of manually constructing negated SQL in where.
      scope_with_deleted.where('id != ?', id)
                         ^^^^^^^^^^^^^^^^^^^^
app/models/concerns/permalink_generator.rb:37:40: C: [Corrected] Style/HashSyntax: Omit the hash value.
      scope_with_deleted.where.not(id: id)
                                       ^^
app/models/enterprise.rb:152:7: C: [Corrected] Rails/WhereNot: Use where.not(enterprises: { id: ready_enterprises }) instead of manually constructing negated SQL in where.
      where("enterprises.id NOT IN (?)", ready_enterprises)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/enterprise.rb:158:31: C: [Corrected] Rails/WhereNot: Use where.not(sells: 'none') instead of manually constructing negated SQL in where.
  scope :is_distributor, -> { where('sells != ?', 'none') }
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/enterprise.rb:479:17: C: [Corrected] Rails/WhereNot: Use where.not(id: id) instead of manually constructing negated SQL in where.
    dups = dups.where('id != ?', id) unless new_record?
                ^^^^^^^^^^^^^^^^^^^^
app/models/enterprise.rb:534:43: C: [Corrected] Rails/WhereNot: Use where.not(enterprises: { id: self }) instead of manually constructing negated SQL in where.
    enterprises = owner.owned_enterprises.where('enterprises.id != ?', self)
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/enterprise.rb:583:7: C: [Corrected] Rails/WhereNot: Use where.not(enterprises: { id: id }) instead of manually constructing negated SQL in where.
      where('enterprises.id != ?', id).
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/enterprise_fee.rb:40:24: C: [Corrected] Rails/WhereNot: Use where.not(spree_calculators: { type: PER_ORDER_CALCULATORS }) instead of manually constructing negated SQL in where.
    joins(:calculator).where('spree_calculators.type NOT IN (?)', PER_ORDER_CALCULATORS)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/enterprise_relationship.rb:78:19: C: [Corrected] Rails/WhereNot: Use where.not(name: perms) instead of manually constructing negated SQL in where.
      permissions.where('name NOT IN (?)', perms).destroy_all
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/product_import/inventory_reset_strategy.rb:27:16: C: [Corrected] Rails/WhereNot: Use where.not(id: excluded_items_ids) instead of manually constructing negated SQL in where.
      relation.where('id NOT IN (?)', excluded_items_ids)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/proxy_order.rb:19:25: C: [Corrected] Rails/WhereNot: Use where.not(proxy_orders: { canceled_at: nil }) instead of manually constructing negated SQL in where.
  scope :canceled, -> { where('proxy_orders.canceled_at IS NOT NULL') }
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/credit_card.rb:26:39: C: [Corrected] Rails/WhereNot: Use where.not(gateway_customer_profile_id: nil) instead of manually constructing negated SQL in where.
    scope :with_payment_profile, -> { where('gateway_customer_profile_id IS NOT NULL') }
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/product.rb:166:9: C: [Corrected] Rails/WhereNot: Use where.not(order_cycles: { id: nil }) instead of manually constructing negated SQL in where.
        where('order_cycles.id IS NOT NULL')
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/variant.rb:94:30: C: [Corrected] Rails/WhereNot: Use where.not(deleted_at: nil) instead of manually constructing negated SQL in where.
    scope :deleted, lambda { where('deleted_at IS NOT NULL') }
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/variant.rb:165:43: C: [Corrected] Rails/WhereNot: Use where.not(spree_prices: { amount: nil }) instead of manually constructing negated SQL in where.
                                          where('spree_prices.amount IS NOT NULL').
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/zone.rb:141:19: C: [Corrected] Rails/WhereNot: Use where.not(id: id) instead of manually constructing negated SQL in where.
      Spree::Zone.where('id != ?', id).update_all(default_tax: false) if default_tax
                  ^^^^^^^^^^^^^^^^^^^^
app/models/spree/zone.rb:141:33: C: [Corrected] Style/HashSyntax: Omit the hash value.
      Spree::Zone.where.not(id: id).update_all(default_tax: false) if default_tax
                                ^^
app/models/variant_override.rb:32:7: C: [Corrected] Rails/WhereNot: Use where.not(variant_overrides: { import_date: nil }) instead of manually constructing negated SQL in where.
      where('variant_overrides.import_date IS NOT NULL').
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/services/cap_quantity.rb:45:22: C: [Corrected] Rails/WhereNot: Use where.not(variant_id: available_variants_for.select(&:id)) instead of manually constructing negated SQL in where.
    order.line_items.where('variant_id NOT IN (?)', available_variants_for.select(&:id))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/catalog/app/services/catalog/product_import/products_reset_strategy.rb:32:18: C: [Corrected] Rails/WhereNot: Use where.not(spree_variants: { id: excluded_items_ids }) instead of manually constructing negated SQL in where.
        relation.where('spree_variants.id NOT IN (?)', excluded_items_ids)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
engines/order_management/app/services/order_management/subscriptions/proxy_order_syncer.rb:78:18: C: [Corrected] Rails/WhereNot: Use where.not(order_cycle_id: order_cycle_ids) instead of manually constructing negated SQL in where.
        orphaned.where('order_cycle_id NOT IN (?)', order_cycle_ids)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/users_and_enterprises/base.rb:27:14: C: [Corrected] Rails/WhereNot: Use where.not(enterprises: { id: nil }) instead of manually constructing negated SQL in where.
            .where("enterprises.id IS NOT NULL")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/users_and_enterprises/base.rb:39:14: C: [Corrected] Rails/WhereNot: Use where.not(enterprise_id: nil) instead of manually constructing negated SQL in where.
            .where("enterprise_id IS NOT NULL")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/users_and_enterprises/base.rb:40:14: C: [Corrected] Rails/WhereNot: Use where.not(user_id: nil) instead of manually constructing negated SQL in where.
            .where("user_id IS NOT NULL")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/tasks/data/anonymize_data.rake:50:16: C: [Corrected] Rails/WhereNot: Use where.not(user_id: nil) instead of manually constructing negated SQL in where.
      Customer.where("user_id IS NOT NULL")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1483 files inspected, 26 offenses detected, 26 offenses corrected
2023-08-20 12:33:43 +09:00
Konrad
241239ac68 Merge pull request #11379 from dacook/respond_to-not_found
Respond to all formats for "not found" error
2023-08-18 18:47:09 +02:00
Konrad
0dc8996701 Merge pull request #11295 from Matt-Yorkley/scope-error
Remove product display_as cell
2023-08-18 18:16:16 +02:00
Konrad
df7d42a420 Merge pull request #11352 from abdellani/remove-dead-code-bulk-invoice
Remove dead code related to bulk invoice printing
2023-08-18 18:14:01 +02:00
Matt-Yorkley
2b9b79c828 Remove product display_as cell
This was attempting to reference the master variant, which is now gone. Fixes an Angular scope error.
2023-08-18 17:38:36 +02:00
Konrad
f3b09508ff Merge pull request #11347 from abdellani/fix-edit-order-button
fix cancel order button
2023-08-18 17:07:42 +02:00
Konrad
d8bc479a70 Merge pull request #11387 from jibees/10957-missing-translation-invalid-url
Admin, White Label: add translation for invalid URL in white label context
2023-08-18 15:59:39 +02:00
dependabot[bot]
fcb3a74b64 chore(deps): bump puma from 6.3.0 to 6.3.1
Bumps [puma](https://github.com/puma/puma) from 6.3.0 to 6.3.1.
- [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.3.0...v6.3.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-18 09:10:32 +00:00
Jean-Baptiste Bellet
2abfa623f0 Once products start loading, scroll higher, ie. just above filters
can see the loading spinner then
2023-08-18 10:20:10 +02:00
jibees
5395bc56f8 Merge pull request #11416 from jibees/11197-buu-no-results-page-and-number-of-results-tweaks
🚧 BUU: No results page and number of results tweaks
2023-08-18 10:14:09 +02:00
Jean-Baptiste Bellet
06fccd8618 Totally hide input above its container 2023-08-18 09:46:57 +02:00
Jean-Baptiste Bellet
47115a0daf Change default label for searched products 2023-08-18 09:46:57 +02:00
Jean-Baptiste Bellet
721baa4d3f Increase button size 2023-08-18 09:46:57 +02:00
Jean-Baptiste Bellet
117c373985 Add "remove-sign" icon before text in disruptive button 2023-08-18 09:46:57 +02:00
Jean-Baptiste Bellet
d27b2084ed Do not underline text when it's a button 2023-08-18 09:46:56 +02:00
Jean-Baptiste Bellet
e4479e7935 Increase button height when no result 2023-08-18 09:46:56 +02:00
Jean-Baptiste Bellet
f5e7738c78 Introduce relaxed, regular and condensed button for specify height 2023-08-18 09:46:56 +02:00
Jean-Baptiste Bellet
5de0d79ca2 Increase distance from search container to 136px
116px + 20px (gap) = 136px
2023-08-18 09:46:56 +02:00
Jean-Baptiste Bellet
4219d0aa08 Change font size and weight 2023-08-18 09:46:56 +02:00
Maikel Linke
0acdf5833f Update all locales with the latest Transifex translations 2023-08-18 15:54:00 +10:00
David Cook
01f0de2f4e Merge pull request #11405 from macanudo527/fix_rubocop_rails_errors
Fix rubocop rails errors
2023-08-18 11:54:17 +10:00
David Cook
7a04f63d62 Merge pull request #11407 from jibees/10878-buu-pagination-tweaks
🚧 BUU: Pagination tweaks
2023-08-18 09:25:55 +10:00
jibees
e82ff80582 Merge pull request #11420 from openfoodfoundation/dependabot/bundler/newrelic_rpm-9.4.1
chore(deps): bump newrelic_rpm from 9.4.0 to 9.4.1
2023-08-17 13:46:47 +02:00
dependabot[bot]
47ca35c38e chore(deps): bump newrelic_rpm from 9.4.0 to 9.4.1
Bumps [newrelic_rpm](https://github.com/newrelic/newrelic-ruby-agent) from 9.4.0 to 9.4.1.
- [Release notes](https://github.com/newrelic/newrelic-ruby-agent/releases)
- [Changelog](https://github.com/newrelic/newrelic-ruby-agent/blob/dev/CHANGELOG.md)
- [Commits](https://github.com/newrelic/newrelic-ruby-agent/compare/9.4.0...9.4.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-17 09:28:40 +00:00
Neal Chambers
fe5288c015 Update .rubocop_todo.yml 2023-08-17 16:45:52 +09:00
Neal Chambers
3c9afcf360 Fix Rails/CompactBlank 2023-08-17 16:43:13 +09:00
Neal Chambers
871a8e6f2c Fix Rails/Blank 2023-08-17 16:42:46 +09:00
Neal Chambers
b78bbd2629 Fix Rails/ApplicationController 2023-08-17 16:42:41 +09:00
Jean-Baptiste Bellet
fa4dda9976 Finally, remove disabled rule that is unused
We only display active link
2023-08-17 09:26:10 +02:00
Jean-Baptiste Bellet
394e964b91 Specify for element that have href attr: the ones we want to hover 2023-08-17 09:26:10 +02:00
Jean-Baptiste Bellet
e7d36ed772 Let link have the cursor: pointer by default, and specify only for current 2023-08-17 09:26:10 +02:00
Jean-Baptiste Bellet
2405dfdaa3 Refine and adjust position of icon in button 2023-08-17 09:26:10 +02:00
Jean-Baptiste Bellet
1a8a4ee72b Change size of pagination
"it becomes extremely long for big catalogues"
2023-08-17 09:26:10 +02:00
Jean-Baptiste Bellet
66a106b1c9 hide pagination for single page catalogue
+ update specs then
2023-08-17 09:26:10 +02:00
Jean-Baptiste Bellet
3fb8726c6a Do not display arrows if they're disabled 2023-08-17 09:06:26 +02:00
Jean-Baptiste Bellet
b1ea77e611 Remove white background from dots 2023-08-17 09:06:26 +02:00
Jean-Baptiste Bellet
c252de87b6 Specify cursor in order to not be text 2023-08-17 09:06:26 +02:00
Jean-Baptiste Bellet
5fc4f7bdaf Design hover (like current) 2023-08-17 09:06:26 +02:00
Jean-Baptiste Bellet
9d8325c0d9 font weight to be 600 2023-08-17 09:06:26 +02:00
Jean-Baptiste Bellet
d914644c35 change not selected font color to $near-black, also for arrows 2023-08-17 09:06:26 +02:00
Jean-Baptiste Bellet
06af58e923 increase distance between arrows and numbers to be 36px 2023-08-17 09:06:26 +02:00
Jean-Baptiste Bellet
6e29dd95ef Increase distance between numbers to be 8px 2023-08-17 09:06:26 +02:00
Jean-Baptiste Bellet
a2da3c2f61 Better management of margin/gap between each button with flex display 2023-08-17 09:06:26 +02:00
Jean-Baptiste Bellet
9396e75806 Increase padding top and padding bottom 2023-08-17 09:06:26 +02:00
Maikel
5762492511 Merge pull request #11392 from dacook/release-template
Release template
2023-08-17 16:47:49 +10:00
Maikel
6377149e18 Merge pull request #11400 from jibees/buu-update/refactor-tests
🚧 BUU: refactor/improve testing
2023-08-17 16:32:00 +10:00
David Cook
a854dccf04 Simplify tag steps
Co-authored-by: Maikel <maikel@email.org.au>
2023-08-17 16:09:06 +10:00
Maikel
d0559d2a6c Merge pull request #11413 from openfoodfoundation/dependabot/bundler/newrelic_rpm-9.4.0
chore(deps): bump newrelic_rpm from 9.3.1 to 9.4.0
2023-08-17 15:36:28 +10:00
Maikel
27dcad205e Merge pull request #11337 from macanudo527/fix_rubocop_6
Fix autocorrect Rails Cops 2
2023-08-17 10:39:34 +10:00
jibees
132d2e792e Merge pull request #11406 from openfoodfoundation/dependabot/bundler/timecop-0.9.8
chore(deps-dev): bump timecop from 0.9.6 to 0.9.8
2023-08-16 17:07:56 +02:00
dependabot[bot]
21e38c424f chore(deps): bump newrelic_rpm from 9.3.1 to 9.4.0
Bumps [newrelic_rpm](https://github.com/newrelic/newrelic-ruby-agent) from 9.3.1 to 9.4.0.
- [Release notes](https://github.com/newrelic/newrelic-ruby-agent/releases)
- [Changelog](https://github.com/newrelic/newrelic-ruby-agent/blob/dev/CHANGELOG.md)
- [Commits](https://github.com/newrelic/newrelic-ruby-agent/compare/9.3.1...9.4.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-16 14:41:10 +00:00
jibees
afe05f1932 Merge pull request #11414 from openfoodfoundation/dependabot/bundler/rails-i18n-7.0.8
chore(deps): bump rails-i18n from 7.0.7 to 7.0.8
2023-08-16 16:40:05 +02:00
dependabot[bot]
33d5e8436f chore(deps): bump rails-i18n from 7.0.7 to 7.0.8
Bumps [rails-i18n](https://github.com/svenfuchs/rails-i18n) from 7.0.7 to 7.0.8.
- [Changelog](https://github.com/svenfuchs/rails-i18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/svenfuchs/rails-i18n/compare/v7.0.7...v7.0.8)

---
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-08-16 09:49:57 +00:00
jibees
33fc5bd409 Merge pull request #11409 from dacook/script-update
Don't show extra red messages when gems missing
2023-08-16 09:01:20 +02:00
David Cook
9bef8b74f8 Merge pull request #11401 from jibees/some-buu-design-updates
🚧 BUU: some design updates + one small code fix
2023-08-16 11:41:33 +10:00
Maikel
fd7b00ac7f Merge pull request #11323 from mkllnk/dfc-import-context
Use known, statically cached DFC context
2023-08-16 11:35:57 +10:00
David Cook
b49de7d49e Simplify spec
What if Zucchini didn't appear at all? Better to test that the two products appear on the same page, in the correct order.
2023-08-16 11:13:54 +10:00
David Cook
412dac7556 Don't show extra red messages when gems missing
When a gem is missing, it looks like a big ugly error. But we don't need to see this, because bundle install will run next and tell us which gems its installing.

Bundle check isn't actually necessary because bundle install will handle this, but for some reason it's 300ms slower. So I chose to keep 'check' to help keep this script nice and quick.
2023-08-16 09:56:24 +10:00
David Cook
b320a1d289 Create release tag early for greater clarity
This way, it's clearer in the repo what is going to be released, and we don't need to copy/paste commit IDs.

([skip ci] because this branch only touches .md file)
2023-08-15 21:47:32 +10:00
David Cook
1cd87c170b Use new staging deployment method 2023-08-15 21:35:12 +10:00
David Cook
8b9d483227 Add more detailed notes for current process 2023-08-15 21:35:10 +10:00
Matt-Yorkley
70ba027603 Merge pull request #11221 from Matt-Yorkley/product-shipping-category
[Product Refactor] Shipping Category
2023-08-15 11:12:56 +01:00
dependabot[bot]
cd5c7e8fc7 chore(deps-dev): bump timecop from 0.9.6 to 0.9.8
Bumps [timecop](https://github.com/travisjeffery/timecop) from 0.9.6 to 0.9.8.
- [Changelog](https://github.com/travisjeffery/timecop/blob/master/History.md)
- [Commits](https://github.com/travisjeffery/timecop/compare/v0.9.6...v0.9.8)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-15 09:18:16 +00:00
David Cook
f4a6bec25d Code fix
Cache result.
2023-08-15 08:36:50 +02:00
Jean-Baptiste Bellet
200550588a Be as clause as possible from native <select />
Still need to wrap/ellipsis selected item...
2023-08-15 08:36:50 +02:00
Jean-Baptiste Bellet
0c11ea5868 Use tom-select to have a designed dropdown
Not sure this is the best solution, since it's not exactly the right usage of tom-select
2023-08-15 08:36:50 +02:00
Jean-Baptiste Bellet
6fe069608c Re-adjust tom-select to match admin v3 style 2023-08-15 08:36:50 +02:00
Jean-Baptiste Bellet
223d350b43 Use grid instead of flex in order to be more fixed and less flexible ;) 2023-08-15 08:36:50 +02:00
Jean-Baptiste Bellet
2814368670 Adjust inside container to content without any padding 2023-08-15 08:36:50 +02:00
David Cook
1155bd42ea Reflex test to reveal collation sorting varies on different OS...
https://dba.stackexchange.com/questions/106964/why-is-my-postgresql-order-by-case-insensitive

Uncommented, the spec fails on macOS (BSD).. but succeeds in Ubuntu (Linux). Weird.
2023-08-15 08:36:22 +02:00
David Cook
0f086df12b Setup StimulusReflex testing [add gem]
Surprisingly, the StimulusReflex framework [doesn't have many resources for testing](https://docs.stimulusreflex.com/appendices/testing.html), but thankfully someone's made a gem.
2023-08-15 08:36:22 +02:00
David Cook
e816228959 Sort products by name in ascending order
The order is specified above in fetch_products. I'm guessing this line was unintentional?

Original requirment doesn't say ascending but I think it's safe to assume (issue#10694).
2023-08-15 08:36:22 +02:00
David Cook
6dbfb36e52 Spec: use url helpers
To be consistent with other specs.
2023-08-15 08:36:22 +02:00
David Cook
9a3820db4f Tidy up spec
Although 'describe' and 'context' are the same simple constructs to label groups of examples, to humans they mean:
 * Describe a particular domain of functionality
 * Context means a different environment, IE something has been set up differently (generally with before and/or let blocks)

Also the default 'before' is :each, so we don't need to specify it.
2023-08-15 08:36:22 +02:00
David Cook
757ba27908 Optimise spec: only create objects when needed
Moving the 'clear filters' and 'no results' tests up into the first context.
2023-08-15 08:36:22 +02:00
David Cook
2a4d5af552 Remove redundant test
This is already covered in the following test.
2023-08-15 08:36:21 +02:00
David Cook
8949f1dc2e Convert route to resource
I don't know why the route helper now has "index" in the name.
2023-08-15 08:36:21 +02:00
jibees
364ae5c0c6 Merge pull request #11404 from rioug/11402-invoice-data-generator-fix-flacky-test
Invoice data generator, fix flaky test
2023-08-15 08:34:53 +02:00
Gaetan Craig-Riou
5a2155aeb7 Use the same sorting when choosing a line item to update
The presenter uses order.sorted_line_items, so use the same method
when picking up the line item to update.
2023-08-15 11:33:02 +10:00
David Cook
2196cd5be8 Merge pull request #11381 from openfoodfoundation/release_v4.4.7
Update translations for release v4.4.7
2023-08-15 10:21:34 +10:00
David Cook
8b666c67d6 Fix typo
🤦 Always, always preview changes before committing.
2023-08-15 09:54:42 +10:00
David Cook
54328d7b98 Mention browser limitations 2023-08-15 09:53:39 +10:00
Matt-Yorkley
75f246109f Fix assignment of default shipping category in variant new/edit pages 2023-08-14 21:02:48 +01:00
Matt-Yorkley
811a8cde7f Use optional: false instead of validates: presence 2023-08-14 21:02:48 +01:00
Matt-Yorkley
97d9aadb69 Update specs 2023-08-14 21:02:48 +01:00
Matt-Yorkley
dea2adc3d6 Update EntryValidator 2023-08-14 21:02:48 +01:00
Matt-Yorkley
42d04b6581 Update OrderAvailableShippingMethods service 2023-08-14 21:02:47 +01:00
Matt-Yorkley
a712eac333 Update shipping_category in /lib and /engines 2023-08-14 21:02:47 +01:00
Matt-Yorkley
5e0e60dfd6 Update reports 2023-08-14 21:02:47 +01:00
Matt-Yorkley
724c08c94d Set default shipping_category if absent 2023-08-14 21:02:47 +01:00
Matt-Yorkley
c18c525d9f Save shipping category selection to new variant when creating a new product 2023-08-14 21:02:47 +01:00
Matt-Yorkley
e3c488306c Migrate data for shipping_category_id 2023-08-14 21:02:47 +01:00
Matt-Yorkley
eefc356472 Update shipping_category usage in admin pages 2023-08-14 21:02:47 +01:00
Matt-Yorkley
0c634cf04f Update shipping_category permitted attributes 2023-08-14 21:02:47 +01:00
Matt-Yorkley
57d6fa006c Update shipping_category association in models 2023-08-14 21:02:47 +01:00
Matt-Yorkley
e2caebc374 Add shipping_category to variants table 2023-08-14 21:00:02 +01:00
Neal Chambers
ec49065739 Reword image_exists? to use Rails.public_path 2023-08-14 17:29:11 +09:00
Neal Chambers
e5740a82bd Safely autocorrect Rails/StripHeredoc
Inspecting 1484 files
........................................................................................................................................................................................................................................................C.........................................................................................................................................CC...........................................................................................................................................................................................................................................................................................................................................................................................C.......................................................................C....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

app/models/content_configuration.rb:74:48: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
  preference :footer_links_md, :text, default: <<-EOS.strip_heredoc
                                               ^^^^^^^^^^^^^^^^^^^^
app/queries/customers_with_balance.rb:23:5: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
    <<-SQL.strip_heredoc
    ^^^^^^^^^^^^^^^^^^^^
app/queries/outstanding_balance.rb:32:5: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
    <<-SQL.strip_heredoc
    ^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:71:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
            <<-JOIN_STRING.strip_heredoc
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:84:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
            <<-JOIN_STRING.strip_heredoc
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:96:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
            <<-JOIN_STRING.strip_heredoc
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:109:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
            <<-JOIN_STRING.strip_heredoc
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:119:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
            <<-JOIN_STRING.strip_heredoc
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:135:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
            <<-JOIN_STRING.strip_heredoc
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:151:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
            <<-JOIN_STRING.strip_heredoc
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:161:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
            <<-JOIN_STRING.strip_heredoc
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:168:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
            <<-JOIN_STRING.strip_heredoc
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:182:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
            <<-JOIN_STRING.strip_heredoc
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:192:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
            <<-JOIN_STRING.strip_heredoc
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:208:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
            <<-JOIN_STRING.strip_heredoc
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:218:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
            <<-JOIN_STRING.strip_heredoc
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:228:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
            <<-JOIN_STRING.strip_heredoc
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:235:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
            <<-JOIN_STRING.strip_heredoc
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:253:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
            <<-JOIN_STRING.strip_heredoc
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:274:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
            <<-JOIN_STRING.strip_heredoc
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:289:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
            <<-JOIN_STRING.strip_heredoc
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:310:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
            <<-JOIN_STRING.strip_heredoc
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:369:15: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
              <<-JOIN_STRING.strip_heredoc
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/tasks/data/truncate_data.rake:35:17: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
      message = <<-MSG.strip_heredoc
                ^^^^^^^^^^^^^^^^^^^^
lib/tasks/data/truncate_data.rake:36:1: C: [Corrected] Layout/HeredocIndentation: Use 2 spaces for indentation in a heredoc.
      \n ...
^^^^^^^^

1484 files inspected, 25 offenses detected, 25 offenses corrected
2023-08-14 17:29:11 +09:00
Neal Chambers
94f1b89a9f Safely autocorrect Rails/RootPublicPath
Inspecting 1484 files
.............................................................................................C........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.........................................................................................C..........C..........................................................................................................................................................................................................................................................................................................C....................................................................................................................................................................C...................C.............................................................C.C.......C....................

Offenses:

app/controllers/concerns/request_timeouts.rb:19:22: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
               file: Rails.root.join("public/500.html"),
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/spree/core/controller_helpers/common.rb:45:30: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
                       file: Rails.root.join("public/404.html"),
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/controllers/api/v0/product_images_controller_spec.rb:13:22: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
    let(:pdf_path) { Rails.root.join("public/Terms-of-service.pdf") }
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/controllers/api/v0/terms_and_conditions_controller_spec.rb:15:31: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
      let(:terms_file_path) { Rails.root.join("public/Terms-of-service.pdf") }
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/models/terms_of_service_file_spec.rb:6:25: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
  let(:pdf) { File.open(Rails.root.join("public/Terms-of-service.pdf")) }
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/bulk_product_update_spec.rb:907:37: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
        attach_file 'image-upload', Rails.root.join("public/500.jpg"), visible: false
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/enterprises/terms_and_conditions_spec.rb:27:30: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
      let(:original_terms) { Rails.root.join("public/Terms-of-service.pdf") }
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/enterprises/terms_and_conditions_spec.rb:28:29: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
      let(:updated_terms) { Rails.root.join("public/Terms-of-ServiceUK.pdf") }
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/consumer/shopping/checkout_spec.rb:94:9: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
        Rails.root.join("public/Terms-of-service.pdf"),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/consumer/shopping/embedded_groups_spec.rb:18:9: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
        Rails.root.join("public/embedded-group-preview.html")
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/consumer/shopping/embedded_groups_spec.rb:26:9: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
        Rails.root.join("public/embedded-group-preview.html")
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/consumer/split_checkout_spec.rb:986:35: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
        let(:system_terms_path) { Rails.root.join("public/Terms-of-service.pdf") }
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/consumer/split_checkout_spec.rb:987:33: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
        let(:shop_terms_path) { Rails.root.join("public/Terms-of-ServiceUK.pdf") }
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1484 files inspected, 13 offenses detected, 13 offenses corrected
2023-08-14 17:29:11 +09:00
Neal Chambers
b60fd6b572 Safely autocorrect Rails/I18nLazyLookup
Inspecting 1484 files
.......................................C....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

app/controllers/admin/proxy_orders_controller.rb:16:35: C: [Corrected] Rails/I18nLazyLookup: Use "lazy" lookup for the text used in controllers.
        render json: { errors: [t('admin.proxy_orders.cancel.could_not_cancel_the_order')] },
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/controllers/admin/proxy_orders_controller.rb:25:35: C: [Corrected] Rails/I18nLazyLookup: Use "lazy" lookup for the text used in controllers.
        render json: { errors: [t('admin.proxy_orders.resume.could_not_resume_the_order')] },
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1484 files inspected, 2 offenses detected, 2 offenses corrected
2023-08-14 17:29:11 +09:00
Neal Chambers
aaf2181768 Safely autocorrect Rails/FilePath
Inspecting 1484 files
.............................................................................................................................................................................................................................................................................................................C.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C....................C.....................................................................................................................................................................................................................................................................C.........................................................................................................................................................................................................C...........................................................................................................................................................

Offenses:

app/models/product_import/product_importer.rb:290:35: C: [Corrected] Rails/FilePath: Prefer Rails.root.join('path/to').
      return unless @file.path == Rails.root.join('tmp', 'product_import').to_s
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/tasks/karma.rake:42:5: C: [Corrected] Rails/FilePath: Prefer Rails.root.join('path/to').
    "#{Rails.root.join(I18n::JS::DEFAULT_EXPORT_DIR_PATH)}/translations.js"
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/tasks/karma.rake:42:5: C: [Correctable] Style/RedundantInterpolation: Prefer to_s over string interpolation.
    "#{Rails.root.join(I18n::JS::DEFAULT_EXPORT_DIR_PATH, 'translations.js')}"
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/tasks/karma.rake:42:59: C: [Corrected] Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations.
    "#{Rails.root.join(I18n::JS::DEFAULT_EXPORT_DIR_PATH, "translations.js")}"
                                                          ^^^^^^^^^^^^^^^^^
spec/base_spec_helper.rb:58:25: C: [Corrected] Rails/FilePath: Prefer Rails.root.join('path/to').
  config.fixture_path = "#{::Rails.root}/spec/fixtures"
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/base_spec_helper.rb:58:25: C: [Correctable] Style/RedundantInterpolation: Prefer to_s over string interpolation.
  config.fixture_path = "#{Rails.root.join('spec/fixtures')}"
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/base_spec_helper.rb:58:44: C: [Corrected] Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations.
  config.fixture_path = "#{Rails.root.join("spec/fixtures")}"
                                           ^^^^^^^^^^^^^^^
spec/models/content_configuration_spec.rb:15:19: C: [Corrected] Rails/FilePath: Prefer Rails.root.join('path/to').to_s.
      File.exist?(File.join(Rails.root, 'public', default_url))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/models/content_configuration_spec.rb:15:19: C: [Corrected] Rails/RootPublicPath: Use Rails.public_path.
      File.exist?(Rails.root.join('public', default_url).to_s)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/support/downloads_helper.rb:7:5: C: [Corrected] Rails/FilePath: Prefer Rails.root.join('path/to').
    Rails.root.join("tmp", "capybara")
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1484 files inspected, 10 offenses detected, 8 offenses corrected, 2 more offenses can be corrected with `rubocop -A`
2023-08-14 17:29:11 +09:00
Neal Chambers
c36728625d Regenerate Rubocop's TODO file 2023-08-14 17:29:08 +09:00
Maikel Linke
91e4fb18ed Use input labels in Voucher system spec
It's more robust, and closer to what the user sees and does. It's also
verifying that the labels are correctly connected to the inputs.
2023-08-14 12:46:13 +10:00
Maikel Linke
ba53f31309 Use new hash syntax in Voucher spec 2023-08-14 12:40:54 +10:00
Maikel Linke
160cdc7f8e Clarify Voucher request spec not a controller spec 2023-08-14 12:25:56 +10:00
Maikel Linke
4b0e910dff Simplify default values in Voucher form 2023-08-14 12:23:00 +10:00
Maikel Linke
efe2dfff8e Let Rails handle Voucher type building 2023-08-14 11:51:34 +10:00
Maikel Linke
4d5e1ffb3b Simplify VouchersController with single param name
The Voucher form now deals with a generic Voucher instead of a subclass
which makes the naming easier and is less confusing when changing types.
2023-08-14 11:39:59 +10:00
Mohamed ABDELLANI
8370d7ce83 Update app/views/spree/admin/shared/_order_links.html.haml
Co-authored-by: jibees <jb.bellet@gmail.com>
2023-08-13 13:12:56 +01:00
Dusan Orlovic
b360e2ffaa Add Google map region parameter 2023-08-13 08:56:04 +02:00
Konrad
99daab07b7 Merge pull request #11297 from mkllnk/require-belongs-to--part2
Require belongs_to associations by default
2023-08-12 17:09:03 +02:00
Matt-Yorkley
613802f477 Update stage.yml 2023-08-11 13:50:34 +01:00
Matt-Yorkley
99907dc3a6 Update stage.yml 2023-08-11 13:48:31 +01:00
Matt-Yorkley
7084d0cb40 Update stage.yml 2023-08-11 13:44:38 +01:00
Matt-Yorkley
e33b0af6fe Update stage.yml 2023-08-11 13:42:14 +01:00
Matt-Yorkley
6dfeecead1 Update stage.yml 2023-08-11 13:30:35 +01:00
Rachel Arnould
5afe45d922 Merge pull request #11382 from jibees/11273-buu-remove-new_products_page-feature-toggle
🔧 Remove `new_products_page` and all associated controllers/components/...
2023-08-11 11:43:49 +02:00
David Cook
5a96f285c1 Update release title 2023-08-11 16:24:11 +10:00
David Cook
1a58914e43 Categories release notes by dependencies label
https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes
2023-08-11 16:13:22 +10:00
Gaetan Craig-Riou
06f986ff52 Allow for creating a voucher with either flat or percentage rate
In the scenario when you get an error when trying to create a
percentage voucher, on the subsequent try we would be dealing with
a "percentage rate voucher". The code now handle any type of voucher
2023-08-11 16:09:48 +10:00
Gaetan Craig-Riou
61e6d55872 Merge pull request #10821 from rioug/10727-vouchers-percentage-rate
[Vouchers] Percentage rate
2023-08-11 16:06:09 +10:00
Gaetan Craig-Riou
a2def2424c Add a comment around the use of safe_constantize
It triggers a Brakeman error that can be safely ignored
2023-08-11 15:41:45 +10:00
Gaetan Craig-Riou
9c9a6234e1 Per review, clean up voucher specs
Add explicit 'order.item_total' to make specs more readable
2023-08-11 15:41:45 +10:00
Gaetan Craig-Riou
054eac0822 Use a better describe
Co-authored-by: David Cook <david@redcliffs.net>
2023-08-11 15:41:45 +10:00
Gaetan Craig-Riou
e6b53c0a42 Per review , Simplify creation of Voucher
We now check against known type to instanciate the correct voucher
instead of using a case
2023-08-11 15:41:45 +10:00
Gaetan Craig-Riou
3f63cfbc27 Fix Rubocop warning 2023-08-11 15:41:45 +10:00
Gaetan Craig-Riou
e8b374d0f2 Remove left over comment 2023-08-11 15:41:45 +10:00
Gaetan Craig-Riou
2828bd098d Refactor VoucherAdjustment service
We are taking advantage of having a FlatRate and a PercentageRate
model to simplify the code a little
2023-08-11 15:41:34 +10:00
Gaetan Craig-Riou
29a38467d2 Fix admin pages to work with refactored vouchers 2023-08-11 14:54:23 +10:00
Gaetan Craig-Riou
46e04ca7ee Refactor voucher: 3 percentage rate voucher 2023-08-11 14:54:23 +10:00
Gaetan Craig-Riou
def594ab81 Refactor voucher: 2 FlatRate voucher 2023-08-11 14:54:23 +10:00
Gaetan Craig-Riou
204f3933d0 Refactor voucher: 1 base voucher class
Refactor voucher to use a single table inheritance. It will simplify the
code and remove a bunch of conditional
2023-08-11 14:54:23 +10:00
Gaetan Craig-Riou
959e2308dd Add system specs for percentage based voucher
Similar to tax included in price scenario, adds a test for percentage
based voucher to check the adjustments are recalculated when needed.
Plus fix tax incluced in price specs to use new factory
2023-08-11 14:51:36 +10:00
Gaetan Craig-Riou
70bd714369 Finish calculation for percentage voucher
Add calculation when tax is not included in price
2023-08-11 14:51:36 +10:00
Gaetan Craig-Riou
cdb33aa0d0 Add calculation for percentage voucher
It include calculation for order with taxes included in the price
2023-08-11 14:30:48 +10:00
David Cook
e536393f02 Merge pull request #11389 from mkllnk/session_store
Remove ignored session store config
2023-08-11 14:27:44 +10:00
Gaetan Craig-Riou
cc9069e9c6 Add voucher type to admin screen
Plus specs
2023-08-11 14:19:26 +10:00
Gaetan Craig-Riou
619285ad4a Add voucher_type to voucher
And update related specs
voucher_type doesn't do anything for now.
2023-08-11 14:19:25 +10:00
Gaetan Craig-Riou
1be8daaf86 Add specs to cover re calculation
It is important that the calculated voucher adjustments don't change
if they are recalculated and it is equally important that they are
updated if the order has changed
2023-08-11 14:19:25 +10:00
David Cook
6ee6ad2b86 [fixup] Remove unnecessary template name
This was left over after trying different things to get this working.
2023-08-11 14:14:32 +10:00
Maikel
fc8e39987a Merge pull request #11385 from openfoodfoundation/dependabot/bundler/aws-sdk-s3-1.132.1
chore(deps): bump aws-sdk-s3 from 1.132.0 to 1.132.1
2023-08-11 11:39:14 +10:00
Maikel Linke
7fe74e811e Remove ignored session store config
We set the session store in an initializer and therefore the development
config was overridden without having any effect.
2023-08-11 10:27:37 +10:00
Maikel Linke
a34a351cee Stabilise flaky spec with deterministic row order 2023-08-11 10:14:47 +10:00
Maikel
146b09dc57 Spec EnterpriseFee tax_category association
Co-authored-by: David Cook <david@redcliffs.net>
2023-08-11 10:14:47 +10:00
Maikel Linke
efbf1d6b8f Stabilise flaky assertion on PDF text
The PDF reader can't always place text elements in the right place. So
something that should be in one line can be in multiple lines and those
lines can be in a different order. I'm asserting the moving parts
separately as done in other places of this spec.
2023-08-11 10:14:47 +10:00
Maikel Linke
1b6eeb0928 Reduce line length of PaymentMethod class
Rubocop was complaining. So I found code that could be simplified and
specced it before refactoring.
2023-08-11 10:14:47 +10:00
Maikel Linke
faeb8ae8f8 Fix Exchange clone tagging
The validation of ActsAsTaggableOn::Taggable failed when trying to copy
tag ids during cloning. But I found that it's totally unnecessary
because `Exchange.dup` copies the `tag_list` attribute already and it
gets saved correctly. There's an existing spec for this.
2023-08-11 10:14:47 +10:00
Maikel Linke
4a13576f78 Remove now superfluous belongs_to default declaration 2023-08-11 10:14:47 +10:00
Maikel Linke
e6c679cb34 Apply belongs_to_required_by_default to all models
Unless they state otherwise.

The new standard also changes the default behaviour of the Shoulda
matcher in Rspec. It now defaults to asserting that an association is
required. That needed some spec updates.

In one case, Spree::Product, I also had to update the model because the
presence validation was somehow not recognised by the Shoulda matcher.
The error message may change slightly but the outcome should be the
same.
2023-08-11 10:14:47 +10:00
Maikel Linke
8ef6966891 Declare old belongs_to default on remaining models
It would take ages to go through all files now and assess all belongs_to
associations. So I just declare the old default and then we can move on
and apply the new default for the application while these classes still
use the old one. All new models will then use the new default which is
the goal of this excercise and we can refactor old classes when we touch
them anyway.
2023-08-11 10:14:43 +10:00
Maikel Linke
252f809463 Require CustomTab.belongs_to by default 2023-08-11 10:14:15 +10:00
Maikel Linke
070d1e722e Require EnterpriseRole.belongs_to by default 2023-08-11 10:14:14 +10:00
Maikel Linke
4dd2955400 Require EnterpriseRelationshipPermission.belongs_to by default
I had to change some specs to keep them simple but I don't think
anything is broken. In one case, it would have needed a lot more setup
to make the spec work. But in production, the permissions are never used
with ModelSet, for example.
2023-08-11 10:13:48 +10:00
Maikel Linke
cb494b84f2 Require EnterpriseRelationship.belongs_to by default 2023-08-11 10:13:29 +10:00
Maikel Linke
4b630f187b Require EnterpriseGroup.belongs_to by default 2023-08-11 10:13:10 +10:00
Maikel Linke
13b2f37884 Require EnterpriseFee.belongs_to by default 2023-08-11 10:13:09 +10:00
Maikel Linke
87ccfc94ef Require Enterprise.belongs_to by default
And remove a duplicate spec.
2023-08-11 10:13:09 +10:00
Konrad
60212f92c3 Merge pull request #11270 from rioug/9553-removing-cutomer-tag-when-search-for-tag
Fix removing customer tag when using search bar for said tag
2023-08-11 00:11:55 +02:00
Konrad
c3414143e6 Merge pull request #11222 from Matt-Yorkley/checkout-controller
Reduce controller size
2023-08-10 23:28:57 +02:00
Konrad
f59e681826 Merge pull request #11259 from cillian/single-line-voucher-code
Don't allow multi-line voucher codes
2023-08-10 23:09:55 +02:00
Jean-Baptiste Bellet
5b4b37032c Add translation for invalid URL in white label context 2023-08-10 15:22:35 +02:00
Matt-Yorkley
df077caafa Merge pull request #11375 from Matt-Yorkley/drop-unused-tables
Drop unused tables
2023-08-10 12:28:14 +01:00
Matt-Yorkley
f19d66f4d6 Drop unused tables 2023-08-10 12:27:31 +01:00
Matt-Yorkley
688b411e97 Merge pull request #11374 from Matt-Yorkley/drop-variant-master-column
Drop :is_master column from variants table
2023-08-10 12:25:59 +01:00
Matt-Yorkley
b82f368bec Drop :is_master column from variants table 2023-08-10 12:25:18 +01:00
Matt-Yorkley
128d5c29bd Merge pull request #11373 from Matt-Yorkley/drop-options-tables
Drop option_types and option_values tables
2023-08-10 12:21:39 +01:00
jibees
95612a8cb6 Merge pull request #11384 from openfoodfoundation/dependabot/bundler/rails-7.0.7
chore(deps): bump rails from 7.0.6 to 7.0.7
2023-08-10 12:13:07 +02:00
dependabot[bot]
4bbd9e9d49 chore(deps): bump aws-sdk-s3 from 1.132.0 to 1.132.1
Bumps [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby) from 1.132.0 to 1.132.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-08-10 09:55:40 +00:00
dependabot[bot]
f08a7ea254 chore(deps): bump rails from 7.0.6 to 7.0.7
Bumps [rails](https://github.com/rails/rails) from 7.0.6 to 7.0.7.
- [Release notes](https://github.com/rails/rails/releases)
- [Commits](https://github.com/rails/rails/compare/v7.0.6...v7.0.7)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-10 09:53:38 +00:00
Jean-Baptiste Bellet
3b68674896 Remove new_products_page and all associated controller/components/
new_products_page` is dead, long live `admin_style_v3` !
2023-08-10 10:02:45 +02:00
jibees
f58fedfc86 Merge pull request #11376 from mkllnk/flaky-voucher-spec
Stabilise flaky checkout spec with voucher
2023-08-10 09:10:59 +02:00
David Cook
b58d15b5ed Update all locales with the latest Transifex translations 2023-08-10 16:54:26 +10:00
David Cook
f64a24a5bb Respond to all formats with html 2023-08-10 16:14:08 +10:00
David Cook
c191158a97 Use the newer syntax 2023-08-10 14:52:04 +10:00
Matt-Yorkley
5c0329ce17 Drop option_types and option_values tables 2023-08-10 11:52:10 +10:00
Maikel
8db8d6de8d Merge pull request #11372 from Matt-Yorkley/remove-variant-position
Remove unused variant :position attribute
2023-08-10 11:48:55 +10:00
Maikel
507803c2dc Merge pull request #11371 from jibees/8443-missing-translation-passwords-not-matching-or-too-short
Account creation: translate some messages around password creation
2023-08-10 11:40:56 +10:00
Maikel Linke
04bba2adf1 Stabilise flaky checkout spec with voucher
While applying a voucher the spec tried to proceed the checkout before
the voucher update completed rendering. It failed when the machine was
slow.

With rspec-slow-repeate I got 100% fail rate before and 100% pass after
this change.
2023-08-10 10:05:01 +10:00
Maikel
926c8aed94 Merge pull request #11354 from abdellani/fix-rename-invoice-generate-update-button
rename 'new invoice' button to 'create or update invoice'
2023-08-10 09:59:11 +10:00
Mohamed ABDELLANI
620dd70dd7 rename 'new invoice' button to 'create or update invoice' 2023-08-10 09:35:13 +10:00
Matt-Yorkley
a33b6e0ec9 Update variant sorting 2023-08-09 18:30:56 +01:00
Matt-Yorkley
e65efe0f85 Remove unused variant :position attribute 2023-08-09 18:24:46 +01:00
Rachel Arnould
4505beff98 Merge pull request #11327 from bouaik/fix-display-invoice-tab-for-completed-resumed-canceled-only
Fix display invoice tab for completed, resumed and canceled orders only
2023-08-09 18:37:02 +02:00
Jean-Baptiste Bellet
1f5dc1f864 Add ActiveRecords messages for translation in account creation 2023-08-09 16:58:08 +02:00
Rachel Arnould
2b108dfeee Merge pull request #11116 from abdellani/fix-show-date-only-on-invoices-list
render date without time on invoices list
2023-08-09 14:33:40 +02:00
jibees
249dea56f3 Merge pull request #11366 from openfoodfoundation/dependabot/bundler/rubocop-1.56.0
chore(deps-dev): bump rubocop from 1.55.1 to 1.56.0
2023-08-09 11:35:25 +02:00
dependabot[bot]
467a63cf12 chore(deps-dev): bump rubocop from 1.55.1 to 1.56.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.55.1 to 1.56.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.55.1...v1.56.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-08-09 09:20:52 +00:00
Konrad
89d8fa0306 Merge pull request #11346 from Matt-Yorkley/remove-multiple-taxons
[Product Refactor] Remove multiple taxons
2023-08-09 11:19:11 +02:00
Maikel
655fdf3fff Merge pull request #11353 from abdellani/remove-duplicated-keys-in-en-yml
Remove duplicated keys in en yml
2023-08-09 13:42:01 +10:00
Maikel
d149f71199 Merge pull request #11365 from dacook/setup-reduce-output
Setup script tweaks
2023-08-09 11:45:47 +10:00
Maikel
b50fa216eb Merge pull request #11117 from rioug/10857-voucher-error-moving-between-summary-and-cart-take2
[vouchers] error moving between summary and cart pages
2023-08-09 11:14:52 +10:00
David Cook
91c874737a Combine rake tasks to save time
The log:clear task seems to take quite a bit of time. At least we can speed up a bit by only booting up Rails once.

I'm more likely to run the script if it's quick ;)
2023-08-09 10:28:41 +10:00
David Cook
9d79c7cda7 Reduce bundler install output
bundle install always shows a very long list of all gems. But we really only want to know about the new gems being installed. Thankfully there's an option for that.
2023-08-09 10:26:11 +10:00
Matt-Yorkley
6fee1d2dde Use dependent: :restrict_with_error on Taxon/Product association 2023-08-08 11:36:31 +01:00
David Cook
1706b8b4bc fixup: Drop spree_products_taxons join table
Make it reversible for dev or staging.
2023-08-08 11:36:31 +01:00
David Cook
a9ca07f4fb fixup Update specs
Delete empty describe block
2023-08-08 11:36:31 +01:00
Matt-Yorkley
321047d663 Update specs 2023-08-08 11:36:31 +01:00
Matt-Yorkley
3d83ca01f7 Drop spree_products_taxons join table 2023-08-08 11:36:31 +01:00
Matt-Yorkley
3655f3019d Update products and inventory report 2023-08-08 11:36:31 +01:00
Matt-Yorkley
38d9f4f1da Update product v3 table 2023-08-08 11:36:31 +01:00
Matt-Yorkley
e4a49f5d02 Update product duplication 2023-08-08 11:36:31 +01:00
Matt-Yorkley
820f9530b2 Update product serializer 2023-08-08 11:36:31 +01:00
Matt-Yorkley
8d01e1f024 Update taxon specs 2023-08-08 11:36:31 +01:00
Matt-Yorkley
33d40ed750 Update association 2023-08-08 11:36:31 +01:00
Matt-Yorkley
cffd7073e2 Delete unused method 2023-08-08 11:36:31 +01:00
Matt-Yorkley
3898af2c37 Update factories and tests 2023-08-08 11:36:31 +01:00
Matt-Yorkley
a93809b75f Remove associated abilities 2023-08-08 11:36:31 +01:00
Matt-Yorkley
a69ab2ef71 Remove multiple taxons on products functionality 2023-08-08 11:36:31 +01:00
Mohamed ABDELLANI
982f30399f merge :errors values under one key 2023-08-08 10:34:11 +01:00
Mohamed ABDELLANI
024a01ba94 remove duplicated keys on en.yml 2023-08-08 10:34:05 +01:00
Mohamed ABDELLANI
70b61eb481 remove bulk invoice service 2023-08-08 08:41:33 +01:00
Mohamed ABDELLANI
fc01ffc509 remove InvoicesController#create 2023-08-08 08:38:32 +01:00
Gaetan Craig-Riou
fe6075319e Merge pull request #11344 from openfoodfoundation/dependabot/bundler/mime-types-3.5.0
chore(deps): bump mime-types from 3.4.1 to 3.5.0
2023-08-08 16:43:47 +10:00
Gaetan Craig-Riou
bb375ccee5 Merge pull request #11343 from openfoodfoundation/dependabot/npm_and_yarn/stimulus-3.2.2
chore(deps): bump stimulus from 3.2.1 to 3.2.2
2023-08-08 16:41:45 +10:00
Mohamed ABDELLANI
c185a47592 render the confirm model on the same component that includes the action on the order. 2023-08-08 07:32:20 +01:00
Gaetan Craig-Riou
6f10907555 Fix rubocop warnings 2023-08-08 15:37:05 +10:00
Gaetan Craig-Riou
a64023c3df Apply review suggestion, simplify code slightly 2023-08-08 15:29:23 +10:00
Gaetan Craig-Riou
4e468c81f9 Handle updating customer attribute when directive is destroyed
Handle any customer attribute not just tags
2023-08-08 15:29:22 +10:00
Gaetan Craig-Riou
41dbad629b Add system spec to cover deleting data when filtering
covers tag scenario and code scenario
2023-08-08 15:29:22 +10:00
Gaetan Craig-Riou
f96bd51344 Rework form to allow displaying the save bar when no result
When filtering by a tag, and then removing the tag on the filtered
customers, it let us show the save bar once the last customer has been
removed from the filtered list.
2023-08-08 15:28:13 +10:00
Gaetan Craig-Riou
dba8809057 Handle deleting tag when directive destroyed 2023-08-08 15:28:13 +10:00
dependabot[bot]
df76710ae8 chore(deps): bump mime-types from 3.4.1 to 3.5.0
Bumps [mime-types](https://github.com/mime-types/ruby-mime-types) from 3.4.1 to 3.5.0.
- [Changelog](https://github.com/mime-types/ruby-mime-types/blob/main/History.md)
- [Commits](https://github.com/mime-types/ruby-mime-types/compare/v3.4.1...v3.5.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-07 09:56:54 +00:00
dependabot[bot]
1af30bdff4 chore(deps): bump stimulus from 3.2.1 to 3.2.2
Bumps [stimulus](https://github.com/stimulusjs/stimulus) from 3.2.1 to 3.2.2.
- [Release notes](https://github.com/stimulusjs/stimulus/releases)
- [Changelog](https://github.com/hotwired/stimulus/blob/main/CHANGELOG.md)
- [Commits](https://github.com/stimulusjs/stimulus/compare/v3.2.1...v3.2.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-07 09:52:05 +00:00
Gaetan Craig-Riou
b731e8319b Merge pull request #11339 from openfoodfoundation/dependabot/npm_and_yarn/js-big-decimal-2.0.4
chore(deps): bump js-big-decimal from 2.0.1 to 2.0.4
2023-08-07 11:46:10 +10:00
Gaetan Craig-Riou
430aa685ce Merge pull request #11321 from mkllnk/dev-user-valid
Skip online domain validation of dev user email
2023-08-07 11:27:31 +10:00
Maikel
ccc5975517 Merge pull request #11320 from dacook/css-cleanup
SCSS cleanup
2023-08-07 10:23:49 +10:00
Maikel
4b0bffa095 Merge pull request #11256 from rioug/10997-add-new-relic-gem
Add new relic gem
2023-08-07 10:17:59 +10:00
Gaetan Craig-Riou
0103942dcb Disable new relic agent by default
It can be enable as needed by setting NEW_RELIC_AGENT_ENABLED env
variable to true and setting a license key
2023-08-07 09:37:36 +10:00
Gaetan Craig-Riou
de52ff4abf Move New Relic out of production, staging group 2023-08-07 09:37:36 +10:00
Gaetan Craig-Riou
5793cb14ee Add generated configuration 2023-08-07 09:37:36 +10:00
Gaetan Craig-Riou
c3d26b1900 Add the New Relic gem 2023-08-07 09:37:36 +10:00
Rachel Arnould
1b1279aa56 Merge pull request #11192 from abdellani/bulk-invoice-printing
fix Bulk invoice printing/sending
2023-08-04 12:02:43 +02:00
dependabot[bot]
760d237288 chore(deps): bump js-big-decimal from 2.0.1 to 2.0.4
Bumps [js-big-decimal](https://github.com/royNiladri/js-big-decimal) from 2.0.1 to 2.0.4.
- [Release notes](https://github.com/royNiladri/js-big-decimal/releases)
- [Commits](https://github.com/royNiladri/js-big-decimal/compare/v2.0.1...v2.0.4)

---
updated-dependencies:
- dependency-name: js-big-decimal
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-04 09:24:25 +00:00
Cillian O'Ruanaidh
d026438edc Revert "Validate voucher code length doesn't exceed the database column length i.e. 255 characters"
This reverts commit 0d0df82522.
2023-08-04 10:24:21 +01:00
Cillian O'Ruanaidh
9eba266efc Strip leading and trailing whitespace from code on assignment instead of before validation
Co-authored-by: Maikel <maikel@email.org.au>
2023-08-04 10:15:22 +01:00
Cillian O'Ruanaidh
ab0d899a17 Revert "Validate voucher code doesn't contain new line characters"
This reverts commit 0c0b85f4c4.
2023-08-04 10:04:14 +01:00
Gaetan Craig-Riou
6ed35f4cc1 Per review, delete only incomplete payments
Use destroy_all so we don't have to manually delete the payment fees
adjustment
2023-08-04 17:03:31 +10:00
Maikel Linke
ad37c401e5 Update translations 2023-08-04 13:48:29 +10:00
David Cook
42230c07b2 Merge pull request #11312 from macanudo527/fix_rubocop_5
Fix autocorrect Rails Cops
2023-08-04 11:13:52 +10:00
bouaik
41d649404f make suggested changes 2023-08-04 00:55:35 +01:00
Maikel
2b18effe6d Merge pull request #11322 from macanudo527/fix_remaining_line_length
Fix remaining Layout/LineLength Rubocop Errors
2023-08-04 09:34:00 +10:00
Maikel
64398066ce Merge pull request #11324 from openfoodfoundation/dependabot/npm_and_yarn/js-big-decimal-2.0.1
chore(deps): bump js-big-decimal from 1.4.1 to 2.0.1
2023-08-04 09:20:30 +10:00
Matt-Yorkley
dd9bdd9c0e Move address params handling into Checkout::Params 2023-08-04 08:43:15 +10:00
Matt-Yorkley
13a7c19a06 Extract checkout step(s) validation to a service 2023-08-04 08:43:15 +10:00
Matt-Yorkley
82b8bb74a1 Remove #before_save_hook method and clarify it's intention 2023-08-04 08:43:15 +10:00
Matt-Yorkley
f3899ee251 Extract some related methods to CheckoutSteps concern 2023-08-04 08:43:15 +10:00
Matt-Yorkley
d1bcdde49f Simplify split checkout errors 2023-08-04 08:43:15 +10:00
Filipe
69dfd53658 Merge pull request #11254 from rioug/11130-add-product-filter-order-report
11130 add product filter order report
2023-08-03 16:08:44 +01:00
Filipe
5c67d522b8 Merge pull request #11209 from openfoodfoundation/dependabot/npm_and_yarn/stimulus_reflex-3.5.0-rc3
chore(deps): bump stimulus_reflex from 3.5.0-rc2 to 3.5.0-rc3 + cable_ready from 5.0.0.rc2 to 5.0.1
2023-08-03 16:01:40 +01:00
Mohamed ABDELLANI
6c53f3b8b0 move pretty_date helper into invoice presenter 2023-08-03 15:12:02 +01:00
Mohamed ABDELLANI
c21ffd338b fix only date is expected on the invoices list table.
time is not supposed to be rendered on the invoices list table (only date)
2023-08-03 15:12:02 +01:00
Mohamed ABDELLANI
5358802ab5 replace Presenter#invoice_date with a delagator 2023-08-03 15:11:58 +01:00
Mohamed ABDELLANI
9a3aef525a add distributor's phone number to list of attributes to serialize 2023-08-03 15:06:04 +01:00
Mohamed ABDELLANI
d044959cec fix date formatting
implement a new helper `pretty_date`
2023-08-03 14:55:26 +01:00
Mohamed ABDELLANI
1a8c0f18b7 order invoices by "created_at desc" on the default scope 2023-08-03 14:55:26 +01:00
Mohamed ABDELLANI
8fecc9db4b render date without time on invoices list
+ sort invoices in the reverse order of the creation time
2023-08-03 14:55:26 +01:00
Mohamed ABDELLANI
24b1918df5 implment blank? on Address presenter
To keep the same method calls that are used on the legacy invoice template. I needed to redefine blank? on the address presenter.
2023-08-03 14:53:40 +01:00
Mohamed ABDELLANI
4449484402 replace double with instance_double 2023-08-03 14:53:40 +01:00
Mohamed ABDELLANI
2fb112aecd import BulkInvoiceJob#perform spec
1. remove the mocks
2. test the content of the generated pdf
3. remove the test of private methods
2023-08-03 14:53:40 +01:00
Mohamed ABDELLANI
c89c8a69bc optimize OrderMailer#invoice_email spec
Check if the email was sent without raising an error
Check if the email has an attached pdf
2023-08-03 14:52:45 +01:00
Mohamed ABDELLANI
9b80676d7d update the logic to send invoice
When the invoices feature is enabled, for every order, we check if
1. a new invoice must be generated
2. or, the latest invoice needs to be updated

the invoice rendrer input depends on the invoices flag.
if the feature is enabled, the input is supposed to be an invoice presenter
2023-08-03 14:52:45 +01:00
Mohamed ABDELLANI
7daa4d3a63 simplify filtering condition to select only invoiceable orders on OrdersReflex 2023-08-03 14:52:45 +01:00
Mohamed ABDELLANI
5ae2545918 Update app/jobs/bulk_invoice_job.rb
Co-authored-by: David Cook <david@redcliffs.net>
2023-08-03 14:52:45 +01:00
Mohamed ABDELLANI
687760046b update the bulk invoice job to print invoiceable orders
the invoices feature is enabled:
1. we filter non-invoiceable order
2. for each invoiceable order, we check if we need to generate a new invoice or update the latest invoice
2023-08-03 14:52:45 +01:00
Mohamed ABDELLANI
c921250d68 implement Spree::Order#invoiceable?
This will be used to filter the orders when running bulk print
2023-08-03 14:52:45 +01:00
Mohamed ABDELLANI
4f6ab69add implement OrderInvoiceGenerator service 2023-08-03 14:52:45 +01:00
Mohamed ABDELLANI
f24af3feb0 extract invoice printing logic into a seperated method 2023-08-03 14:52:45 +01:00
bouaik
0c849f08fd fix tests 2023-08-03 13:04:16 +01:00
bouaik
2c08602664 fix display invoice tab 2023-08-03 11:25:31 +01:00
Filipe
46cb1add63 Merge pull request #11126 from abdellani/show-invoice-number-on-invoices
Show invoice number on invoices
2023-08-03 10:48:34 +01:00
Filipe
c0a4bccb3e Merge pull request #11156 from Matt-Yorkley/product-tax-category
[Product Refactor] Tax category
2023-08-03 10:29:40 +01:00
dependabot[bot]
106938ddbf chore(deps): bump js-big-decimal from 1.4.1 to 2.0.1
Bumps [js-big-decimal](https://github.com/royNiladri/js-big-decimal) from 1.4.1 to 2.0.1.
- [Release notes](https://github.com/royNiladri/js-big-decimal/releases)
- [Commits](https://github.com/royNiladri/js-big-decimal/compare/v1.4.1...v2.0.1)

---
updated-dependencies:
- dependency-name: js-big-decimal
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-03 09:19:52 +00:00
Maikel Linke
f96636072e Use original DFC Connector.export implementation
We wanted to use our own context before but now I found a better way for
the connector to cache the context and therfore we can use the original
implementation again.
2023-08-03 16:45:31 +10:00
Maikel Linke
1daed8c29c Always load our DFC Connector patches
We want to use the preloaded context when exporting documents as well.
2023-08-03 16:45:30 +10:00
Maikel Linke
ff359664a9 Use cached DFC context 2023-08-03 16:45:30 +10:00
Neal Chambers
f5f9b80de7 Update .rubocop_todo.yml 2023-08-03 09:49:51 +09:00
Neal Chambers
a4f270bdec Fix Layout/LineLength 2023-08-03 09:49:47 +09:00
David Cook
32cc776725 Merge pull request #11177 from cyrillefr/Registration_of_an_enterprise_name_already_taken_stops_registration_process
Registration of an enterprise name already taken stops registration process
2023-08-03 10:37:47 +10:00
Maikel Linke
c8511ecd0d Remove superfluous line
The `<<` operation saves the association already.
2023-08-03 10:26:59 +10:00
Maikel Linke
6056c59301 Skip online domain validation of dev user email
We improved the email address validation to check the domain for
existing DNS entries. But our default user has the example.com domain
which is not resolved by my internet service provider.

I couldn't find a better way to deactivate this one check than
overriding the method in the validator. The code does not affect other
parts of the app unless you run multiple rake tasks in the same command
line with the database setup.
2023-08-03 10:22:00 +10:00
Maikel
76b7a9ea14 Merge pull request #11307 from openfoodfoundation/dependabot/npm_and_yarn/floating-ui/dom-1.5.1
chore(deps): bump @floating-ui/dom from 1.4.5 to 1.5.1
2023-08-03 10:04:31 +10:00
David Cook
293e135a45 Move variables to one variables file
Note that color-tbl-border is not needed in the new admin_v3 styles.
2023-08-03 09:49:29 +10:00
David Cook
0aa4c144b9 Rename disabled button variable
TIL that underscores and dashes are treated the same in SCSS variables.
2023-08-03 09:49:29 +10:00
David Cook
1a02e108a5 Use red colour from the palette
It's very similar.
2023-08-03 09:49:29 +10:00
David Cook
9610281ed3 Rename variables 2023-08-03 09:49:29 +10:00
David Cook
b46e6c462d Rename table border variable
There are other vars named brd, but I think border is clearer and doesn't need to be abreviated here.
2023-08-03 09:49:29 +10:00
David Cook
c4a335548a Rename warning color variable
To match the others in the variables file.

Also `warning-orange` was unused.
2023-08-03 09:49:29 +10:00
David Cook
01a9095121 Move some variables to the palette 2023-08-03 09:49:29 +10:00
David Cook
2f801d346d Prettify some more css files 2023-08-03 09:49:29 +10:00
David Cook
14e07e38d3 Remove depdenency on darkswarm/mixins 2023-08-03 09:49:29 +10:00
David Cook
bf9cd09462 Remove dependence on darkswarm variables
There were all sorts of dependencies hiding in there, and it was overwriting some of the admin variables. Better to keep things separate and simple.

I discovered that there was one legitimate reason for importing them though: for styling the trix editor. I can't think of a good way to safely import them without affecting the other variables, so I just hardcoded the colours for now.
2023-08-03 09:47:44 +10:00
David Cook
9207724779 Copy legacy variables
I'd like to go through and remove these, but it will have to happen another day.
2023-08-03 09:47:44 +10:00
David Cook
828df3ed82 Consistently use red in forms
Errors and required fields now use the colour from the palette. The error messages in the old design are a bit darker now, but I think it's clearer. And it makes the new design look way better.

Also snuck in a tiny padding tweak.
2023-08-03 09:47:44 +10:00
Maikel
9c6e0418cb Merge pull request #11317 from openfoodfoundation/dependabot/bundler/knapsack_pro-5.3.5
chore(deps-dev): bump knapsack_pro from 5.3.4 to 5.3.5
2023-08-03 08:18:52 +10:00
Filipe
f816d4b2d6 Merge pull request #11235 from jibees/11223-notices-tab-on-shopfront-persisting-after-selecting-an-order-cycle
Shopfront: On non-shop tab, when changing OC, switch to shop tab and hides non-shop tab content
2023-08-02 16:02:23 +01:00
Konrad
27e3a65440 Merge pull request #11234 from jibees/10867-vouchers-vouchers-page-is-shown-for-profile-enterprises
Show vouchers panel only if enterprise sells products (own or any)
2023-08-02 13:11:29 +02:00
Konrad
44d25dbb6a Merge pull request #11299 from cillian/order-name-sorting
Sort orders by last name, then first name i.e. the same way bulk order management works
2023-08-02 11:30:25 +02:00
Konrad
12f6457ab2 Merge pull request #11302 from bouaik/margin-guest-checkout
fix margin in guest checkout
2023-08-02 10:57:12 +02:00
Maikel
b73dfed4e9 Merge pull request #11308 from openfoodfoundation/dependabot/bundler/rubocop-1.55.1
chore(deps-dev): bump rubocop from 1.55.0 to 1.55.1
2023-08-02 16:29:36 +10:00
Maikel
7886e25f83 Merge pull request #11303 from macanudo527/fix_rubocop_script
Add file limit to Rubocop Autocorrect Script
2023-08-02 14:36:20 +10:00
dependabot[bot]
bff74e9472 chore(deps-dev): bump knapsack_pro from 5.3.4 to 5.3.5
Bumps [knapsack_pro](https://github.com/KnapsackPro/knapsack_pro-ruby) from 5.3.4 to 5.3.5.
- [Changelog](https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v5.3.4...v5.3.5)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-02 03:17:45 +00:00
David Cook
ff76e3afa1 Merge pull request #11263 from mkllnk/dfc-connector-context
Dfc connector context
2023-08-02 13:16:28 +10:00
David Cook
44d1066e5c Merge pull request #11310 from Matt-Yorkley/image-magick
Rescue ImageMagick errors
2023-08-02 10:26:46 +10:00
Neal Chambers
0d2e2fa42c Add skip for cops that couldn't be autocorrected 2023-08-02 09:11:00 +09:00
Konrad
bc01207fec Merge pull request #11281 from jibees/11205-white-label-logo-image-not-displaying-correctly-on-mobile
White label: Update mobile variant size for white label logo to fit the same ratio
2023-08-02 00:10:14 +02:00
bouaik
5681c45a9e use classes like logged in checkout 2023-08-01 22:08:56 +01:00
Maikel Linke
bebdaace4b Prefer plain text in spec expectations 2023-08-01 23:06:26 +02:00
cyrillefr
d4c864a118 Add testing for modal warning that name is already in use 2023-08-01 23:06:26 +02:00
cyrillefr
057754305d Useless 'end' at end of coffeescript block 2023-08-01 23:06:26 +02:00
cyrillefr
05d610e598 Spec for (re)enabling 'Create Profile' button if not returning promise 2023-08-01 23:06:26 +02:00
cyrillefr
ae1e6032f6 Enable 'Create Profile' button via callback in case of not returning promise 2023-08-01 23:06:26 +02:00
Neal Chambers
f47f6efcd0 Safely autocorrect Rails/DurationArithmetic
Inspecting 1481 files
...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.C.................................................................................................................................................................................................................................................................................C..............C..........................................................C...............................C....C..........CC................................................................

Offenses:

app/services/create_order_cycle.rb:41:24: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
      orders_close_at: Time.zone.now + 1.month
                       ^^^^^^^^^^^^^^^^^^^^^^^
spec/jobs/order_cycle_closing_job_spec.rb:7:74: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
    create(:order_cycle, automatic_notifications: true, orders_close_at: Time.zone.now - 1.minute)
                                                                         ^^^^^^^^^^^^^^^^^^^^^^^^
spec/jobs/order_cycle_closing_job_spec.rb:10:74: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
    create(:order_cycle, automatic_notifications: true, orders_close_at: Time.zone.now + 1.minute)
                                                                         ^^^^^^^^^^^^^^^^^^^^^^^^
spec/jobs/order_cycle_closing_job_spec.rb:13:75: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
    create(:order_cycle, automatic_notifications: false, orders_close_at: Time.zone.now - 1.minute)
                                                                          ^^^^^^^^^^^^^^^^^^^^^^^^
spec/jobs/order_cycle_opened_job_spec.rb:7:42: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
    create(:order_cycle, orders_open_at: Time.zone.now - 1.hour)
                                         ^^^^^^^^^^^^^^^^^^^^^^
spec/jobs/order_cycle_opened_job_spec.rb:13:42: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
    create(:order_cycle, orders_open_at: Time.zone.now + 1.minute)
                                         ^^^^^^^^^^^^^^^^^^^^^^^^
spec/services/permissions/order_spec.rb:26:58: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
                                           completed_at: Time.zone.now - 1.year)
                                                         ^^^^^^^^^^^^^^^^^^^^^^
spec/services/terms_of_service_spec.rb:21:71: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
      allow(customer).to receive(:terms_and_conditions_accepted_at) { Time.zone.now - 1.week }
                                                                      ^^^^^^^^^^^^^^^^^^^^^^
spec/services/terms_of_service_spec.rb:22:59: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
      allow(TermsOfServiceFile).to receive(:updated_at) { Time.zone.now - 2.weeks }
                                                          ^^^^^^^^^^^^^^^^^^^^^^^
spec/services/terms_of_service_spec.rb:36:71: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
      allow(customer).to receive(:terms_and_conditions_accepted_at) { Time.zone.now - 1.week }
                                                                      ^^^^^^^^^^^^^^^^^^^^^^
spec/services/terms_of_service_spec.rb:38:45: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
        ActiveStorage::Blob.new(created_at: Time.zone.now - 2.weeks)
                                            ^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/bulk_order_management_spec.rb:647:57: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
                                          completed_at: Time.zone.now + 1.week,
                                                        ^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/bulk_order_management_spec.rb:652:57: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
                                          completed_at: Time.zone.now + 2.weeks,
                                                        ^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/bulk_order_management_spec.rb:661:40: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
          oc3.update!(orders_close_at: Time.zone.now + 2.weeks)
                                       ^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/bulk_order_management_spec.rb:662:39: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
          oc3.update!(orders_open_at: Time.zone.now + 1.week)
                                      ^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_cycles/list_spec.rb:128:18: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
    oc_open_at = Time.zone.now - 2.weeks
                 ^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_cycles/list_spec.rb:129:19: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
    oc_close_at = Time.zone.now + 2.weeks
                  ^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/orders_spec.rb:289:40: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
          order2.update!(completed_at: Time.zone.now - 2.weeks)
                                       ^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/orders_spec.rb:290:40: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
          order3.update!(completed_at: Time.zone.now - 3.weeks)
                                       ^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/orders_spec.rb:291:40: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
          order4.update!(completed_at: Time.zone.now - 4.weeks)
                                       ^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/orders_spec.rb:292:40: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
          order5.update!(completed_at: Time.zone.now - 5.weeks)
                                       ^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/reports/orders_and_fulfillment_spec.rb:113:31: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
        let(:completed_at1) { Time.zone.now - 1500.hours } # 1500 hours in the past
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/reports/orders_and_fulfillment_spec.rb:114:31: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
        let(:completed_at2) { Time.zone.now - 1700.hours } # 1700 hours in the past
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/reports/orders_and_fulfillment_spec.rb:115:33: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
        let(:datetime_start1) { Time.zone.now - 1600.hours } # 1600 hours in the past
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/reports/orders_and_fulfillment_spec.rb:116:33: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
        let(:datetime_start2) { Time.zone.now - 1800.hours } # 1600 hours in the past
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/reports/orders_and_fulfillment_spec.rb:117:30: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
        let(:datetime_end) { Time.zone.now - 1400.hours } # 1400 hours in the past
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/reports/packing_report_spec.rb:13:26: C: [Corrected] Style/RedundantParentheses: Don't use parentheses around a method call.
  let!(:open_datetime) { (1.month.ago).strftime("%Y-%m-%d 00:00") }
                         ^^^^^^^^^^^^^
spec/system/admin/reports/packing_report_spec.rb:13:27: C: [Corrected] Rails/DurationArithmetic: Do not add or subtract duration.
  let!(:open_datetime) { (Time.zone.now - 1.month).strftime("%Y-%m-%d 00:00") }
                          ^^^^^^^^^^^^^^^^^^^^^^^

1481 files inspected, 28 offenses detected, 28 offenses corrected
2023-08-01 22:50:21 +09:00
Neal Chambers
a263110799 Safely autocorrect Rails/DotSeparatedKeys
Inspecting 1481 files
........................................................................C................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

app/controllers/api/v1/base_controller.rb:72:66: C: [Corrected] Rails/DotSeparatedKeys: Use the dot-separated keys instead of specifying the :scope option.
        message = I18n.t(:missing_parameter, param: error.param, scope: :api)
                                                                 ^^^^^^^^^^^
app/controllers/api/v1/base_controller.rb:79:84: C: [Corrected] Rails/DotSeparatedKeys: Use the dot-separated keys instead of specifying the :scope option.
        message = I18n.t(:unpermitted_parameters, params: error.params.join(", "), scope: :api)
                                                                                   ^^^^^^^^^^^

1481 files inspected, 2 offenses detected, 2 offenses corrected
2023-08-01 22:50:21 +09:00
Neal Chambers
44cf2faa1e Safely autocorrect Rails/ActiveRecordCallbacksOrder
Inspecting 1481 files
...........................................................................................................................................................................................................................................................C..C.CC........................................................................C...C..........C..C..................CC........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

app/models/customer.rb:32:3: C: [Corrected] Rails/ActiveRecordCallbacksOrder: before_validation is supposed to appear before before_destroy.
  before_validation :downcase_email
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/customer.rb:33:3: C: [Corrected] Rails/ActiveRecordCallbacksOrder: before_validation is supposed to appear before before_destroy.
  before_validation :empty_code
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/customer.rb:34:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/models/customer.rb:49:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/models/customer.rb:49:3: C: [Corrected] Rails/ActiveRecordCallbacksOrder: before_create is supposed to appear before before_destroy.
  before_create :associate_user
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/enterprise.rb:129:3: C: [Corrected] Rails/ActiveRecordCallbacksOrder: after_create is supposed to appear before after_touch.
  after_create :set_default_contact
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/enterprise.rb:130:3: C: [Corrected] Rails/ActiveRecordCallbacksOrder: after_create is supposed to appear before after_touch.
  after_create :relate_to_owners_enterprises
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/enterprise.rb:133:3: C: [Corrected] Rails/ActiveRecordCallbacksOrder: after_rollback is supposed to appear before after_touch.
  after_rollback :restore_permalink
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/enterprise.rb:134:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/models/enterprise_group.rb:18:3: C: [Corrected] Rails/ActiveRecordCallbacksOrder: after_save is supposed to appear before after_find.
  after_save :unset_undefined_address_fields
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/enterprise_group.rb:18:3: C: [Corrected] Rails/ActiveRecordCallbacksOrder: before_validation is supposed to appear before after_save.
  before_validation :sanitize_permalink
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/enterprise_group.rb:19:3: C: [Corrected] Rails/ActiveRecordCallbacksOrder: before_validation is supposed to appear before after_find.
  before_validation :sanitize_permalink
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/enterprise_group.rb:23:3: C: [Corrected] Rails/ActiveRecordCallbacksOrder: before_validation is supposed to appear before after_save.
  before_validation :sanitize_permalink
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/enterprise_relationship.rb:15:3: C: [Corrected] Rails/ActiveRecordCallbacksOrder: before_destroy is supposed to appear before after_save.
  before_destroy :revoke_all_child_variant_overrides
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/enterprise_relationship.rb:16:3: C: [Corrected] Rails/ActiveRecordCallbacksOrder: before_destroy is supposed to appear before after_save.
  before_destroy :destroy_related_exchanges
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/order.rb:108:5: C: [Corrected] Rails/ActiveRecordCallbacksOrder: before_save is supposed to appear before before_create.
    before_save :update_shipping_fees!, if: :complete?
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/order.rb:109:5: C: [Corrected] Rails/ActiveRecordCallbacksOrder: before_save is supposed to appear before before_create.
    before_save :update_payment_fees!, if: :complete?
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/payment.rb:30:5: C: [Corrected] Rails/ActiveRecordCallbacksOrder: after_initialize is supposed to appear before before_create.
    after_initialize :build_source
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/payment.rb:32:5: C: [Corrected] Rails/ActiveRecordCallbacksOrder: after_initialize is supposed to appear before after_create.
    after_initialize :build_source
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/payment.rb:33:5: C: [Corrected] Rails/ActiveRecordCallbacksOrder: after_create is supposed to appear before after_save.
    after_create :invalidate_old_payments
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/payment.rb:34:5: C: [Corrected] Rails/ActiveRecordCallbacksOrder: after_initialize is supposed to appear before after_save.
    after_initialize :build_source
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/payment.rb:35:5: C: [Corrected] Rails/ActiveRecordCallbacksOrder: after_create is supposed to appear before after_save.
    after_create :invalidate_old_payments
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/payment.rb:36:5: C: [Corrected] Rails/ActiveRecordCallbacksOrder: after_initialize is supposed to appear before after_save.
    after_initialize :build_source
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/payment.rb:46:5: C: [Corrected] Rails/ActiveRecordCallbacksOrder: after_initialize is supposed to appear before after_create.
    after_initialize :build_source
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/payment.rb:47:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/models/spree/product.rb:87:5: C: [Corrected] Rails/ActiveRecordCallbacksOrder: after_create is supposed to appear before after_save.
    after_create :ensure_standard_variant
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/return_authorization.rb:12:5: C: [Corrected] Rails/ActiveRecordCallbacksOrder: before_save is supposed to appear before before_create.
    before_save :force_positive_amount
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/user.rb:49:5: C: [Corrected] Rails/ActiveRecordCallbacksOrder: after_create is supposed to appear before before_destroy.
    after_create :associate_customers, :associate_orders
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/user.rb:50:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/models/spree/variant.rb:88:5: C: [Corrected] Rails/ActiveRecordCallbacksOrder: after_create is supposed to appear before after_save.
    after_create :create_stock_items
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/variant.rb:89:5: C: [Corrected] Rails/ActiveRecordCallbacksOrder: after_create is supposed to appear before after_save.
    after_create :set_position
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/variant.rb:90:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/models/spree/variant.rb:91:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/models/spree/variant.rb:91:5: C: [Corrected] Rails/ActiveRecordCallbacksOrder: around_destroy is supposed to appear before after_save.
    around_destroy :destruction
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/variant.rb:92:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.

1481 files inspected, 35 offenses detected, 35 offenses corrected
2023-08-01 22:50:21 +09:00
Neal Chambers
a1560263a1 Safely autocorrect Rails/ActionOrder
Inspecting 1481 files
.........................................C.................C.........................................................CC........C..........C.C.........C..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

app/controllers/admin/resource_controller.rb:39:5: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 0.
    def update
    ^^^^^^^^^^
app/controllers/admin/resource_controller.rb:39:5: C: [Corrected] Rails/ActionOrder: Action create should appear before update.
    def create ...
    ^^^^^^^^^^
app/controllers/admin/resource_controller.rb:51:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/controllers/admin/resource_controller.rb:52:5: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 2.
    def update_positions
    ^^^^^^^^^^^^^^^^^^^^
app/controllers/api/v0/orders_controller.rb:13:7: C: [Corrected] Rails/ActionOrder: Action index should appear before show.
      def index ...
      ^^^^^^^^^
app/controllers/api/v0/orders_controller.rb:23:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 0.
      def show
      ^^^^^^^^
app/controllers/api/v0/orders_controller.rb:28:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/controllers/api/v0/orders_controller.rb:29:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 2.
      def update
      ^^^^^^^^^^
app/controllers/spree/admin/images_controller.rb:26:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 0.
      def create
      ^^^^^^^^^^
app/controllers/spree/admin/images_controller.rb:37:7: C: [Corrected] Rails/ActionOrder: Action edit should appear before create.
      def edit ...
      ^^^^^^^^
app/controllers/spree/admin/images_controller.rb:40:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/controllers/spree/admin/images_controller.rb:41:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 2.
      def update
      ^^^^^^^^^^
app/controllers/spree/admin/invoices_controller.rb:19:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 0.
      def create
      ^^^^^^^^^^
app/controllers/spree/admin/invoices_controller.rb:43:7: C: [Corrected] Rails/ActionOrder: Action show should appear before create.
      def show ...
      ^^^^^^^^
app/controllers/spree/admin/invoices_controller.rb:49:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/controllers/spree/admin/invoices_controller.rb:50:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 2.
      def poll
      ^^^^^^^^
app/controllers/spree/admin/products_controller.rb:23:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 0.
      def new
      ^^^^^^^
app/controllers/spree/admin/products_controller.rb:23:7: C: [Corrected] Rails/ActionOrder: Action show should appear before new.
      def show ...
      ^^^^^^^^
app/controllers/spree/admin/products_controller.rb:24:7: C: [Corrected] Rails/ActionOrder: Action index should appear before show.
      def index ...
      ^^^^^^^^^
app/controllers/spree/admin/products_controller.rb:27:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/controllers/spree/admin/products_controller.rb:27:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 0.
      def create
      ^^^^^^^^^^
app/controllers/spree/admin/products_controller.rb:28:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/controllers/spree/admin/products_controller.rb:28:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 0.
      def new
      ^^^^^^^
app/controllers/spree/admin/products_controller.rb:28:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 2.
      def index
      ^^^^^^^^^
app/controllers/spree/admin/products_controller.rb:28:7: C: [Corrected] Rails/ActionOrder: Action index should appear before new.
      def index ...
      ^^^^^^^^^
app/controllers/spree/admin/products_controller.rb:29:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 2.
      def new
      ^^^^^^^
app/controllers/spree/admin/products_controller.rb:32:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/controllers/spree/admin/products_controller.rb:32:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 0.
      def create
      ^^^^^^^^^^
app/controllers/spree/admin/products_controller.rb:33:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 2.
      def edit
      ^^^^^^^^
app/controllers/spree/admin/products_controller.rb:36:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 0.
      def create
      ^^^^^^^^^^
app/controllers/spree/admin/products_controller.rb:38:7: C: [Corrected] Rails/ActionOrder: Action show should appear before create.
      def show ...
      ^^^^^^^^
app/controllers/spree/admin/products_controller.rb:42:7: C: [Corrected] Rails/ActionOrder: Action index should appear before create.
      def index ...
      ^^^^^^^^^
app/controllers/spree/admin/products_controller.rb:43:7: C: [Corrected] Rails/ActionOrder: Action index should appear before create.
      def index ...
      ^^^^^^^^^
app/controllers/spree/admin/products_controller.rb:43:7: C: [Corrected] Rails/ActionOrder: Action index should appear before show.
      def index ...
      ^^^^^^^^^
app/controllers/spree/admin/products_controller.rb:47:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/controllers/spree/admin/products_controller.rb:48:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 2.
      def edit
      ^^^^^^^^
app/controllers/spree/admin/products_controller.rb:48:7: C: [Corrected] Rails/ActionOrder: Action edit should appear before create.
      def edit ...
      ^^^^^^^^
app/controllers/spree/admin/products_controller.rb:51:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/controllers/spree/admin/products_controller.rb:52:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 2.
      def update
      ^^^^^^^^^^
app/controllers/spree/admin/taxons_controller.rb:13:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 0.
      def create
      ^^^^^^^^^^
app/controllers/spree/admin/taxons_controller.rb:29:7: C: [Corrected] Rails/ActionOrder: Action edit should appear before create.
      def edit ...
      ^^^^^^^^
app/controllers/spree/admin/taxons_controller.rb:34:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/controllers/spree/admin/taxons_controller.rb:35:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 2.
      def update
      ^^^^^^^^^^
app/controllers/spree/admin/variants_controller.rb:17:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 0.
      def edit
      ^^^^^^^^
app/controllers/spree/admin/variants_controller.rb:18:7: C: [Corrected] Rails/ActionOrder: Action new should appear before edit.
      def new ...
      ^^^^^^^
app/controllers/spree/admin/variants_controller.rb:21:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/controllers/spree/admin/variants_controller.rb:21:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 0.
      def update
      ^^^^^^^^^^
app/controllers/spree/admin/variants_controller.rb:22:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 2.
      def create
      ^^^^^^^^^^
app/controllers/spree/admin/variants_controller.rb:31:7: C: [Corrected] Rails/ActionOrder: Action new should appear before update.
      def new ...
      ^^^^^^^
app/controllers/spree/admin/variants_controller.rb:34:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/controllers/spree/admin/variants_controller.rb:35:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 2.
      def create
      ^^^^^^^^^^
app/controllers/spree/admin/variants_controller.rb:35:7: C: [Corrected] Rails/ActionOrder: Action create should appear before update.
      def create ...
      ^^^^^^^^^^
app/controllers/spree/admin/variants_controller.rb:42:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 0.
      def update
      ^^^^^^^^^^
app/controllers/spree/admin/variants_controller.rb:55:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/controllers/spree/admin/variants_controller.rb:56:7: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 2.
      def search
      ^^^^^^^^^^
app/controllers/user_confirmations_controller.rb:14:3: C: [Corrected] Rails/ActionOrder: Action show should appear before new.
  def show ...
  ^^^^^^^^
app/controllers/user_confirmations_controller.rb:15:3: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 0.
  def new
  ^^^^^^^
app/controllers/user_confirmations_controller.rb:19:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/controllers/user_confirmations_controller.rb:20:3: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 0.
  def create
  ^^^^^^^^^^
app/controllers/user_confirmations_controller.rb:21:3: C: [Corrected] Layout/EmptyLineBetweenDefs: Expected 1 empty line between method definitions; found 2.
  def create
  ^^^^^^^^^^
app/controllers/user_confirmations_controller.rb:37:3: C: [Corrected] Rails/ActionOrder: Action show should appear before create.
  def show ...
  ^^^^^^^^
app/controllers/user_confirmations_controller.rb:42:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
app/controllers/user_confirmations_controller.rb:43:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.

1481 files inspected, 63 offenses detected, 63 offenses corrected
2023-08-01 22:50:21 +09:00
Neal Chambers
e49c9e9061 Regenerate Rubocop's TODO file 2023-08-01 22:50:21 +09:00
Matt-Yorkley
885bc46d88 Update tax_category in product v3 table 2023-08-01 11:49:04 +01:00
David Cook
f7a137049f Merge pull request #11296 from dacook/hide-git-errors
Prevent git errors from showing in command output
2023-08-01 12:16:53 +10:00
Matt-Yorkley
91fc4b51b4 Rescue ImageMagick errors 2023-07-31 17:21:49 +01:00
Mohamed ABDELLANI
7d38a7b381 remove order number next to Tax Invoice 2023-07-31 17:01:36 +01:00
Mohamed ABDELLANI
760b17042b fix existing tests 2023-07-31 16:31:24 +01:00
Mohamed ABDELLANI
0ce8fae7c9 replace invoice_number method with delegate 2023-07-31 16:31:24 +01:00
Mohamed ABDELLANI
8abb9d2ecf add invoice number to alternative invoices 2023-07-31 16:31:24 +01:00
Mohamed ABDELLANI
e66cd5aaa3 add order number & invoice number to invoices 2023-07-31 16:31:24 +01:00
dependabot[bot]
8dcaba695e chore(deps-dev): bump rubocop from 1.55.0 to 1.55.1
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.55.0 to 1.55.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.55.0...v1.55.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-07-31 09:50:50 +00:00
dependabot[bot]
c885b42df1 chore(deps): bump @floating-ui/dom from 1.4.5 to 1.5.1
Bumps [@floating-ui/dom](https://github.com/floating-ui/floating-ui/tree/HEAD/packages/dom) from 1.4.5 to 1.5.1.
- [Release notes](https://github.com/floating-ui/floating-ui/releases)
- [Commits](https://github.com/floating-ui/floating-ui/commits/@floating-ui/dom@1.5.1/packages/dom)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-31 09:44:08 +00:00
Gaetan Craig-Riou
85adb9f345 Fix rubocop warning 2023-07-31 15:19:04 +10:00
Gaetan Craig-Riou
2857930263 Fix voucher adjustment request spec
Error messages have been updated to be more user friendly. This spec
was missed somehow.
2023-07-31 14:06:36 +10:00
Gaetan Craig-Riou
089d2b9c84 Clear any existing payment and payment fees when adding a voucher
If a user come back to checkout step 2 from step 3, the order
will have payment and possibly payment fee existing. This can
interfere with voucher calculation, so we clear them.
The user can then select a payment method again if needed
2023-07-31 12:05:52 +10:00
Maikel
c8ad6d7d1c Merge pull request #11300 from macanudo527/fix_rubocop_layout_3
Fix rubocop layout 4
2023-07-31 11:26:53 +10:00
Maikel
aa92aac5a9 Style FrozenStringLiteralComment
Co-authored-by: jibees <jb.bellet@gmail.com>
2023-07-31 11:19:10 +10:00
Matt-Yorkley
64b29d40a8 Migrate data for tax_category_id from products to variants 2023-07-31 09:23:40 +10:00
Matt-Yorkley
e2094665c5 Update enterprise fee report tax_category fetching 2023-07-31 09:23:20 +10:00
Matt-Yorkley
07774c4572 Update tax category specs 2023-07-31 09:23:20 +10:00
Matt-Yorkley
d1209dd49b Update order_with_taxes factory 2023-07-31 09:23:20 +10:00
Matt-Yorkley
b593e356b0 Update product factories 2023-07-31 09:23:20 +10:00
Matt-Yorkley
a84f9ebd2e Allow passing tax_category to new variant when creating a new product 2023-07-31 09:23:20 +10:00
Matt-Yorkley
0df121bcc8 Move tax_category validations test 2023-07-31 09:23:20 +10:00
Matt-Yorkley
b2a7a931f3 Update tax_category tests 2023-07-31 09:23:20 +10:00
Matt-Yorkley
4cb291290b Update product factory 2023-07-31 09:23:20 +10:00
Matt-Yorkley
5a48721af4 Update serializers, views, and JS for bulk products edit 2023-07-31 09:23:20 +10:00
Matt-Yorkley
363bbded43 Update permitted attributes 2023-07-31 09:23:20 +10:00
Matt-Yorkley
a52516bcbf Move tax_category dropdown in edit pages 2023-07-31 09:23:20 +10:00
Matt-Yorkley
b12c130e02 Add tax_category column to variants table 2023-07-31 09:23:20 +10:00
Matt-Yorkley
4934d09a4c Update delegation and method chaining between product and tax_category 2023-07-31 09:23:20 +10:00
Matt-Yorkley
d33e780411 Move tax_category association from product to variant 2023-07-31 09:23:19 +10:00
Neal Chambers
60cd84d565 Safely autocorrect Naming/BlockForwarding
Inspecting 1480 files
...................................................................................................................................................................C.......C..........C...............................................................................................................................................................................................................C...........................................................................................................C.........C...............................................................................................................................................................................................................................................................C........................................CC...C............................................................................................................................................................................................................................................................................................................................C.....................................................................................................................................................................................................C..............C.........C..CC.......C.....................................................................................................C...............

Offenses:

app/helpers/application_helper.rb:41:32: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
  def ng_form_for(name, *args, &block)
                               ^^^^^^
app/helpers/application_helper.rb:44:75: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
    form_for(name, *(args << options.merge(builder: AngularFormBuilder)), &block)
                                                                          ^^^^^^
app/helpers/application_helper.rb:49:37: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
  def method_missing(method, *args, &block)
                                    ^^^^^^
app/helpers/link_helper.rb:4:57: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
  def link_to_service(baseurl, name, html_options = {}, &block)
                                                        ^^^^^^
app/helpers/link_helper.rb:8:51: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
    link_to ext_url(baseurl, name), html_options, &block
                                                  ^^^^^^
app/helpers/spree/admin/base_helper.rb:6:56: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
      def field_container(model, method, options = {}, &block)
                                                       ^^^^^^
app/helpers/spree/admin/base_helper.rb:13:29: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
                    capture(&block),
                            ^^^^^^
app/reflexes/application_reflex.rb:29:19: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
  def with_locale(&block)
                  ^^^^^^
app/reflexes/application_reflex.rb:30:43: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
    I18n.with_locale(current_user.locale, &block)
                                          ^^^^^^
app/services/cache_service.rb:8:43: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
  def self.cache(cache_key, options = {}, &block)
                                          ^^^^^^
app/services/cache_service.rb:9:48: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
    Rails.cache.fetch cache_key.to_s, options, &block
                                               ^^^^^^
app/services/cache_service.rb:14:58: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
  def self.cached_data_by_class(cache_key, cached_class, &block)
                                                         ^^^^^^
app/services/cache_service.rb:16:23: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
                      &block
                      ^^^^^^
app/services/cache_service.rb:25:34: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
  def self.home_stats(statistic, &block)
                                 ^^^^^^
app/services/cache_service.rb:28:47: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
                      race_condition_ttl: 10, &block)
                                              ^^^^^^
app/services/current_order_locker.rb:12:31: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
  def self.around(controller, &block)
                              ^^^^^^
app/services/current_order_locker.rb:13:55: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
    lock_order_and_variants(controller.current_order, &block)
                                                      ^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:392:28: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
        def chain_to_scope(&block)
                           ^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:393:41: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
          @scope = @scope.instance_eval(&block)
                                        ^^^^^^
lib/spree/core/controller_helpers/respond_with.rb:7:34: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
    def respond_with(*resources, &block)
                                 ^^^^^^
lib/spree/core/controller_helpers/respond_with.rb:13:64: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
      return unless (collector = retrieve_collector_from_mimes(&block))
                                                               ^^^^^^
lib/spree/core/delegate_belongs_to.rb:80:39: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
    def class_def(name, method = nil, &blk)
                                      ^^^^
lib/spree/core/delegate_belongs_to.rb:81:54: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
      class_eval { method.nil? ? define_method(name, &blk) : define_method(name, method) }
                                                     ^^^^
lib/spree/core/environment_extension.rb:22:31: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
      def create_method(name, &block)
                              ^^^^^^
lib/spree/core/environment_extension.rb:23:51: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
        self.class.__send__(:define_method, name, &block)
                                                  ^^^^^^
spec/models/enterprise_caching_spec.rb:144:13: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
  def later(&block)
            ^^^^^^
spec/models/enterprise_caching_spec.rb:145:36: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
    Timecop.travel(1.day.from_now, &block)
                                   ^^^^^^
spec/support/embedded_pages_helper.rb:5:26: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
    def on_embedded_page(&block)
                         ^^^^^^
spec/support/embedded_pages_helper.rb:6:28: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
      within_frame :frame, &block
                           ^^^^^^
spec/support/preferences_helper.rb:11:31: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
  def reset_spree_preferences(&config_block)
                              ^^^^^^^^^^^^^
spec/support/preferences_helper.rb:16:33: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
    configure_spree_preferences(&config_block) if block_given?
                                ^^^^^^^^^^^^^
spec/support/request/shop_workflow.rb:87:37: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
  def within_variant(variant = nil, &block)
                                    ^^^^^^
spec/support/request/shop_workflow.rb:90:22: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
    within(selector, &block)
                     ^^^^^^
spec/support/request/ui_component_helper.rb:4:23: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
  def browse_as_small(&block)
                      ^^^^^^
spec/support/request/ui_component_helper.rb:5:39: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
    browse_with_window_size(640, 480, &block)
                                      ^^^^^^
spec/support/request/ui_component_helper.rb:8:24: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
  def browse_as_medium(&block)
                       ^^^^^^
spec/support/request/ui_component_helper.rb:9:40: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
    browse_with_window_size(1024, 768, &block)
                                       ^^^^^^
spec/support/request/web_helper.rb:52:23: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
  def within_row(num, &block)
                      ^^^^^^
spec/support/request/web_helper.rb:53:54: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
    within("table.index tbody tr:nth-child(#{num})", &block)
                                                     ^^^^^^
spec/swagger_helper.rb:77:19: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
  def param(args, &block)
                  ^^^^^^
spec/swagger_helper.rb:78:45: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
    public_send(:let, args) { instance_eval(&block) }
                                            ^^^^^^
spec/system/support/capybara_setup.rb:20:27: C: [Corrected] Naming/BlockForwarding: Use anonymous block forwarding.
  def using_session(name, &block)
                          ^^^^^^

1480 files inspected, 42 offenses detected, 42 offenses corrected
2023-07-30 21:29:19 +09:00
Neal Chambers
ae8a5b7f93 Safely autocorrect Lint/UnusedMethodArgument
Inspecting 1480 files
........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................W...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

lib/reporting/queries/query_interface.rb:18:30: W: [Corrected] Lint/UnusedMethodArgument: Unused method argument - default. If it's necessary, use _ or _default as an argument name to indicate that it won't be used. If it's unnecessary, remove it.
      def sum_grouped(field, default = 0)
                             ^^^^^^^
lib/reporting/queries/query_interface.rb:22:26: W: [Corrected] Lint/UnusedMethodArgument: Unused method argument - default. If it's necessary, use _ or _default as an argument name to indicate that it won't be used. If it's unnecessary, remove it.
      def sum_new(field, default = 0)
                         ^^^^^^^

1480 files inspected, 2 offenses detected, 2 offenses corrected
2023-07-30 21:29:19 +09:00
Neal Chambers
2a76b1972f Safely autocorrect Lint/SafeNavigationChain
Inspecting 1480 files
........................................................................................................................................................................................................................................................................................................................................W............................W..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

app/models/spree/line_item.rb:283:55: W: [Corrected] Lint/SafeNavigationChain: Do not chain ordinary method call after safe navigation operator.
        self.final_weight_volume = variant&.unit_value * quantity
                                                      ^^^^^^^^^^^
app/models/spree/line_item.rb:283:57: C: [Corrected] Layout/SpaceAroundMethodCallOperator: Avoid using spaces around a method call operator.
        self.final_weight_volume = variant&.unit_value&. * quantity
                                                        ^
app/models/spree/stock/availability_validator.rb:31:77: W: [Corrected] Lint/SafeNavigationChain: Do not chain ordinary method call after safe navigation operator.
        return line_item.order.shipments.first if line_item.order&.shipments.any?
                                                                            ^^^^^

1480 files inspected, 3 offenses detected, 3 offenses corrected
2023-07-30 21:29:19 +09:00
Neal Chambers
e7d53753e4 Safely autocorrect Lint/RedundantCopDisableDirective
Inspecting 1480 files
..............W.........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

app/components/product_component.rb:23:51: W: [Corrected] Lint/RedundantCopDisableDirective: Unnecessary disabling of Metrics/MethodLength.
  # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
                                                  ^^^^^^^^^^^^^^^^^^^^
app/components/product_component.rb:50:50: W: [Corrected] Lint/RedundantCopEnableDirective: Unnecessary enabling of Metrics/MethodLength.
  # rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength
                                                 ^^^^^^^^^^^^^^^^^^^^

1480 files inspected, 2 offenses detected, 2 offenses corrected
2023-07-30 21:29:19 +09:00
Neal Chambers
e9f448fad9 Safely autocorrect Lint/AmbiguousOperatorPrecedence
Inspecting 1480 files
...................................................................................................................................................................................................................................W..........................W........................................................W................W..............W................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

app/models/calculator/flexi_rate.rb:38:7: W: [Corrected] Lint/AmbiguousOperatorPrecedence: Wrap expressions with varying precedence with parentheses to avoid ambiguity.
      count * preferred_additional_item.to_f + preferred_first_item.to_f
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/enterprise.rb:362:12: W: [Corrected] Lint/AmbiguousOperatorPrecedence: Wrap expressions with varying precedence with parentheses to avoid ambiguity.
    cat << "sells_" + sells
           ^^^^^^^^^^^^^^^^
app/models/enterprise.rb:496:21: W: [Corrected] Lint/AmbiguousOperatorPrecedence: Wrap expressions with varying precedence with parentheses to avoid ambiguity.
    phone_number && "https://wa.me/" + phone_number.tr('+ ', '')
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/ability.rb:27:33: W: [Corrected] Lint/AmbiguousOperatorPrecedence: Wrap expressions with varying precedence with parentheses to avoid ambiguity.
          order.user == user || order.token && token == order.token
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/ability.rb:30:33: W: [Corrected] Lint/AmbiguousOperatorPrecedence: Wrap expressions with varying precedence with parentheses to avoid ambiguity.
          order.user == user || order.token && token == order.token
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/spree/line_item.rb:205:16: W: [Corrected] Lint/AmbiguousOperatorPrecedence: Wrap expressions with varying precedence with parentheses to avoid ambiguity.
      (price + fees / quantity).round(2)
               ^^^^^^^^^^^^^^^
app/models/spree/preferences/store.rb:28:11: W: [Corrected] Lint/AmbiguousOperatorPrecedence: Wrap expressions with varying precedence with parentheses to avoid ambiguity.
          should_persist? && Spree::Preference.where(key: key).exists?
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1480 files inspected, 7 offenses detected, 7 offenses corrected
2023-07-30 21:29:19 +09:00
bouaik
addbbc4006 fix margin in guest checkout 2023-07-29 07:52:55 -04:00
filipefurtad0
0bcde2dbda Update all locales with the latest Transifex translations 2023-07-28 16:33:49 +01:00
Filipe
5d624ef4be Merge pull request #11278 from mkllnk/swagger-fix
Fix swagger-api integration after last update
2023-07-28 16:27:32 +01:00
Filipe
1ddbb1c4e1 Merge pull request #11294 from Matt-Yorkley/connect-src
Update CSP configuration for Safari
2023-07-28 16:16:02 +01:00
Cillian O'Ruanaidh
8039c0106a Set firstname correctly in spec/system/admin/orders_spec.rb 2023-07-28 15:04:47 +01:00
Cillian O'Ruanaidh
276b94de5b Sort orders by last name, then first name i.e. the same way bulk order management works 2023-07-28 14:20:29 +01:00
Filipe
a975e2bd93 Merge pull request #11247 from jibees/9123-inconsistent-default-visibility-setting-for-newly-created-enterprises
Admin, Enterprise creation : set visibility to "Hidden" by default
2023-07-28 12:15:32 +01:00
Filipe
ef947f8749 Merge pull request #11282 from jibees/11025-white-label-trix-quotes-code-and-links-cant-be-identified-in-the-editor
White label: Customize rendering inside the trix-editor, to match the shopfront rendering
2023-07-28 11:23:50 +01:00
Filipe
21690670f5 Merge pull request #11292 from jibees/11108-dashboard-supplier-profile-inconsistent-indentation-on-deployed-version
Admin: improve platform version displaying on admin homepage
2023-07-28 11:01:07 +01:00
Gaetan Craig-Riou
33ef8def08 Update order total after removing a voucher
We need to do this to make sure when display the payment method
again.
Plus spec
2023-07-28 14:52:25 +10:00
Gaetan Craig-Riou
f35001dacc Update voucher adjustment and order total when adding a voucher
This is needed so we can check if payment is needed and display
no payment required when no payment needed
2023-07-28 14:27:27 +10:00
David Cook
ef62fb885d Check if record actually saved
I'm not sure if it will ever make a difference, but I think this makes more sense.
2023-07-28 14:11:45 +10:00
David Cook
be1a72743a Pending spec: vouchers should not require payment 2023-07-28 14:11:31 +10:00
David Cook
895f534afa Remove unnecessary extra page load 2023-07-28 14:11:19 +10:00
David Cook
febe6501c0 Prevent git errors from showing in command output
This would be a very rare case, but one time the git command failed, printing out an obscure "fatal" message to stderr which caused confusion.
2023-07-28 12:07:52 +10:00
Maikel
774bb7a607 Merge pull request #11238 from filipefurtad0/legal_invoices_spec
Adds coverage to Invoices (system specs)
2023-07-28 08:41:01 +10:00
filipefurtad0
98f29dcd9b Adds coverage on invoices section/table 2023-07-27 17:27:41 +01:00
Matt-Yorkley
dd9b28787c Update CSP configuration for Safari
Apparently some versions of Safari have issues with Websockets if the CSP doesn't explicitly define the `connect_src` in a certain way (including specifying the host). This issue is fixed in later versions of Safari and doesn't affect other browsers, for which the `default_src` with `:self` is sufficient.
2023-07-27 16:20:42 +01:00
filipefurtad0
35dfdc8bdc Adds coverage on Invoice tab
which should be visible as a function of the order state

Corrects cancelled case
2023-07-27 15:47:40 +01:00
Jean-Baptiste Bellet
8b4de3ddc7 Add version into its own .row .columns with centered text 2023-07-27 15:41:54 +02:00
jibees
55fbab4c0d Merge pull request #11287 from openfoodfoundation/dependabot/bundler/rexml-3.2.6
chore(deps): bump rexml from 3.2.5 to 3.2.6
2023-07-27 12:00:28 +02:00
Jean-Baptiste Bellet
a179c006fc Default design for ul and ol into the custom tab
`ul` and `old` default design already been reset, reactivate default design only for `.custom-tab`
2023-07-27 11:53:47 +02:00
Jean-Baptiste Bellet
4485490b0b Customize rendering inside the trix-editor, to match the shopfront rendering 2023-07-27 11:53:47 +02:00
jibees
b3949965fc Merge pull request #11288 from openfoodfoundation/dependabot/bundler/knapsack_pro-5.3.4
chore(deps-dev): bump knapsack_pro from 5.3.3 to 5.3.4
2023-07-27 11:34:37 +02:00
dependabot[bot]
79d0728fdd chore(deps-dev): bump knapsack_pro from 5.3.3 to 5.3.4
Bumps [knapsack_pro](https://github.com/KnapsackPro/knapsack_pro-ruby) from 5.3.3 to 5.3.4.
- [Changelog](https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v5.3.3...v5.3.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-27 09:25:02 +00:00
dependabot[bot]
4e9dae6817 chore(deps): bump rexml from 3.2.5 to 3.2.6
Bumps [rexml](https://github.com/ruby/rexml) from 3.2.5 to 3.2.6.
- [Release notes](https://github.com/ruby/rexml/releases)
- [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md)
- [Commits](https://github.com/ruby/rexml/compare/v3.2.5...v3.2.6)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-27 09:21:38 +00:00
jibees
96418dcde6 Merge pull request #11284 from mkllnk/caching-spec
Compile JS before testing caching
2023-07-27 09:41:22 +02:00
Maikel Linke
b9ebcc9b1b Remove version number from DFC API URLs
While it's quite common to version APIs it's not possible with current
DFC tools. The architecture also uses URLs as identifiers for objects
like products. Having the id of an object change just because the format
of its description changes doesn't make sense. The DFC may solve this by
adding a version number in a different way.

By removing the version from our API URL, all object ids (URIs) should
be stable from now on.
2023-07-27 15:38:36 +10:00
Maikel Linke
4872855471 Update DFC context to newest version
The new DFC Connector is based on the new DFC context which changed all
URLs of all data types.

There's also a better way to access semantic properties now.
2023-07-27 15:38:36 +10:00
dependabot[bot]
34fbcb0e02 chore(deps): bump datafoodconsortium-connector
Bumps datafoodconsortium-connector from 1.0.0.pre.alpha.6 to 1.0.0.pre.alpha.8.

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-27 15:38:36 +10:00
Maikel Linke
3b5b9ec54d Avoid network request to DFC context on export
This protects us from the DFC website going down or the DFC updating
the context with breaking changes. We are in control of updating the
context now (opt-in to newer versions).
2023-07-27 15:38:36 +10:00
David Cook
fdb80fe87c Merge pull request #11283 from macanudo527/fix_rubocop_layout_2
Fix rubocop layout 3
2023-07-27 10:29:29 +10:00
Neal Chambers
e923defd55 Safely autocorrect Layout/TrailingWhitespace
Inspecting 1479 files
...................................................................................................................................................C..C.......................................................................................................C.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.....C..................C.............................................................................................C...................................................................C.......................................................................................................................................................................C....................................................C.............C...........CC.........C......C.CC.C....................C........................................................

Offenses:

app/controllers/spree/users_controller.rb:36:37: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
            partial("layouts/alert",
                                    ^
app/controllers/spree/users_controller.rb:51:35: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          partial("layouts/alert",
                                  ^
app/controllers/user_confirmations_controller.rb:27:33: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
        partial("layouts/alert",
                                ^
app/models/enterprise.rb:117:24: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
  validates :instagram,
                       ^
spec/controllers/spree/credit_cards_controller_spec.rb:250:64: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
                  create(:stored_credit_card, user_id: user.id,
                                                               ^
spec/controllers/user_confirmations_controller_spec.rb:45:44: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
        session[:confirmation_return_url] =
                                           ^
spec/factories/order_factory.rb:40:67: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
            order.payments << build(:payment, amount: order.total,
                                                                  ^
spec/lib/reports/packing/packing_report_spec.rb:59:40: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
        build(:line_item_with_shipment,
                                       ^
spec/lib/reports/packing/packing_report_spec.rb:63:40: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
        build(:line_item_with_shipment,
                                       ^
spec/models/enterprise_spec.rb:521:67: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
        expect(Enterprise.supplying_variant_in([p1.variants.first,
                                                                  ^
spec/models/enterprise_spec.rb:906:77: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
      create(:enterprise_relationship, parent: distributor, child: supplier,
                                                                            ^
spec/services/products_renderer_spec.rb:22:73: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
      create(:product, name: "banana bread", primary_taxon_id: cakes.id,
                                                                        ^
spec/services/products_renderer_spec.rb:88:88: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          product_apples.product_properties.create!({ property_id: property_organic.id,
                                                                                       ^
spec/services/products_renderer_spec.rb:90:87: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          products_renderer = ProductsRenderer.new(distributor, order_cycle, customer,
                                                                                      ^
spec/services/products_renderer_spec.rb:97:90: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          fruits_supplier.producer_properties.create!({ property_id: property_organic.id,
                                                                                         ^
spec/services/products_renderer_spec.rb:99:87: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          products_renderer = ProductsRenderer.new(distributor, order_cycle, customer,
                                                                                      ^
spec/services/products_renderer_spec.rb:109:93: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          product_apples.product_properties.create!({ property_id: property_conventional.id,
                                                                                            ^
spec/services/products_renderer_spec.rb:111:94: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          product_banana_bread.product_properties.create!({ property_id: property_organic.id,
                                                                                             ^
spec/services/products_renderer_spec.rb:113:90: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          product_cherries.product_properties.create!({ property_id: property_organic.id,
                                                                                         ^
spec/services/products_renderer_spec.rb:115:91: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          product_doughnuts.product_properties.create!({ property_id: property_organic.id,
                                                                                          ^
spec/services/products_renderer_spec.rb:117:87: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          products_renderer = ProductsRenderer.new(distributor, order_cycle, customer,
                                                                                      ^
spec/support/request/stripe_stubs.rb:17:81: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
  def stub_payment_intent_get_request(response: {}, stripe_account_header: true,
                                                                                ^
spec/support/request/stripe_stubs.rb:172:6: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
    {
     ^
spec/support/request/stripe_stubs.rb:175:24: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
        object: "list",
                       ^
spec/support/request/stripe_stubs.rb:176:25: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
        has_more: false,
                        ^
spec/system/admin/bulk_order_management_spec.rb:792:99: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
      it "displays only line items whose orders meet the date restriction criteria, when changed",
                                                                                                  ^
spec/system/admin/bulk_order_management_spec.rb:1071:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
spec/system/admin/bulk_order_management_spec.rb:1121:82: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
      shared_examples "display only group by information for selected variant" do
                                                                                 ^^^^^^^^^^
spec/system/admin/bulk_order_management_spec.rb:1143:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
spec/system/admin/bulk_order_management_spec.rb:1166:12: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
        end
           ^
spec/system/admin/customers_spec.rb:18:98: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
        create(:customer, first_name: 'John', last_name: 'Doe', enterprise: managed_distributor1,
                                                                                                 ^
spec/system/admin/enterprise_fees_spec.rb:102:37: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
      select 'Inherit From Product',
                                    ^
spec/system/admin/enterprise_fees_spec.rb:128:38: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
      select 'Weight (per kg or lb)',
                                     ^
spec/system/admin/enterprise_fees_spec.rb:132:37: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
      select 'Flat Rate (per item)',
                                    ^
spec/system/admin/enterprise_fees_spec.rb:153:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
spec/system/admin/enterprise_fees_spec.rb:153:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
spec/system/admin/enterprise_fees_spec.rb:157:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
spec/system/admin/enterprise_fees_spec.rb:159:38: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
      select 'Flat Rate (per order)',
                                     ^
spec/system/admin/enterprise_fees_spec.rb:222:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
spec/system/admin/flatpickr_spec.rb:22:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
spec/system/admin/flatpickr_spec.rb:27:32: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
      find("#admin-menu").click
                               ^^^^^^^
spec/system/admin/flatpickr_spec.rb:32:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
spec/system/admin/flatpickr_spec.rb:34:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
spec/system/admin/flatpickr_spec.rb:41:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
spec/system/admin/order_cycles/complex_editing_spec.rb:74:33: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
    expect(page).to have_select(
                                ^
spec/system/admin/order_cycles/complex_editing_spec.rb:110:33: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
    expect(page).to have_select(
                                ^
spec/system/admin/order_cycles/list_spec.rb:147:46: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          expect(find('input.datetimepicker',
                                             ^
spec/system/admin/order_cycles/list_spec.rb:160:46: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          expect(find('input.datetimepicker',
                                             ^
spec/system/admin/order_cycles/list_spec.rb:188:46: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          expect(find('input.datetimepicker',
                                             ^
spec/system/admin/order_cycles/simple_spec.rb:447:43: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
        expect(page).not_to have_selector(
                                          ^
spec/system/admin/order_spec.rb:92:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
spec/system/admin/order_spec.rb:207:30: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          within(".modal") do
                             ^
spec/system/admin/order_spec.rb:235:21: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
      login_as_admin
                    ^^
spec/system/admin/order_spec.rb:240:16: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
      before do
               ^
spec/system/admin/order_spec.rb:247:62: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
    context "when using the cancel option in the dropdown" do
                                                             ^^
spec/system/admin/order_spec.rb:248:16: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
      before do
               ^
spec/system/admin/order_spec.rb:299:53: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
        expect(page).to have_content "Are you sure?"
                                                    ^^^^^^^^
spec/system/admin/order_spec.rb:327:36: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
        find("a.delete-item").click
                                   ^
spec/system/admin/order_spec.rb:401:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
spec/system/admin/order_spec.rb:405:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
spec/system/admin/order_spec.rb:598:59: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          expect(page).to have_link "Resend Confirmation",
                                                          ^
spec/system/admin/order_spec.rb:617:52: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          expect(page).to have_link "Cancel Order",
                                                   ^
spec/system/admin/order_spec.rb:633:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
spec/system/admin/order_spec.rb:635:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
spec/system/admin/order_spec.rb:635:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
spec/system/admin/order_spec.rb:674:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
spec/system/admin/order_spec.rb:735:35: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          within "#order-total" do
                                  ^
spec/system/admin/order_spec.rb:762:39: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
              within "#order-total" do
                                      ^
spec/system/admin/order_spec.rb:778:41: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
                within "#order-total" do
                                        ^
spec/system/admin/order_spec.rb:780:20: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
                end
                   ^^
spec/system/admin/order_spec.rb:796:39: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
              within "#order-total" do
                                      ^
spec/system/admin/order_spec.rb:807:88: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
                # Since the order is completed, the price is not supposed to be updated
                                                                                       ^
spec/system/admin/order_spec.rb:813:41: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
                within "#order-total" do
                                        ^
spec/system/admin/order_spec.rb:815:20: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
                end
                   ^^
spec/system/admin/order_spec.rb:924:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
spec/system/admin/order_spec.rb:959:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
spec/system/admin/order_spec.rb:981:16: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
      before do
               ^^
spec/system/admin/order_spec.rb:992:8: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
    end
       ^^
spec/system/admin/order_spec.rb:1002:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
spec/system/admin/shipping_methods_spec.rb:50:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
spec/system/admin/shipping_methods_spec.rb:92:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.

1479 files inspected, 81 offenses detected, 81 offenses corrected
2023-07-27 09:58:33 +10:00
Neal Chambers
e0206a0be6 Safely autocorrect Layout/TrailingEmptyLines
Inspecting 1479 files
..C....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

Rakefile:10:1: C: [Corrected] Layout/TrailingEmptyLines: 1 trailing blank lines detected.

1479 files inspected, 1 offense detected, 1 offense corrected
2023-07-27 09:58:33 +10:00
Neal Chambers
2dbaa7f89d Safely autocorrect Layout/MultilineMethodCallIndentation
Inspecting 1479 files
............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.......CC......................C..................................................

Offenses:

spec/controllers/api/v0/orders_controller_spec.rb:150:13: C: [Corrected] Layout/MultilineMethodCallIndentation: Use 2 (not 0) spaces for indenting an expression spanning multiple lines.
            .map{ |o| o["id"] }
            ^^^^
spec/system/admin/order_cycles/complex_editing_spec.rb:30:9: C: [Corrected] Layout/MultilineMethodCallIndentation: Use 2 (not 4) spaces for indenting an expression spanning multiple lines.
        .to eq(oc.orders_open_at.strftime("%Y-%m-%d %H:%M"))
        ^^^
spec/system/admin/order_cycles/complex_editing_spec.rb:32:9: C: [Corrected] Layout/MultilineMethodCallIndentation: Use 2 (not 4) spaces for indenting an expression spanning multiple lines.
        .to eq(oc.orders_close_at.strftime("%Y-%m-%d %H:%M"))
        ^^^
spec/system/admin/overview_spec.rb:16:62: C: [Corrected] Layout/MultilineMethodCallIndentation: Use 2 (not 55) spaces for indenting an expression spanning multiple lines.
                                                             .and_return @enterprise_user
                                                             ^^^^^^^^^^^
spec/system/admin/payment_method_spec.rb:62:22: C: [Corrected] Layout/MultilineMethodCallIndentation: Use 2 (not 13) spaces for indenting an expression spanning multiple lines.
                     .to_return(body: JSON.generate(stripe_account_mock))
                     ^^^^^^^^^^
spec/system/admin/variant_overrides_spec.rb:214:64: C: [Corrected] Layout/MultilineMethodCallIndentation: Use 2 (not 51) spaces for indenting an expression spanning multiple lines.
                                                               .and_return(build(:user))
                                                               ^^^^^^^^^^^

1479 files inspected, 6 offenses detected, 6 offenses corrected
2023-07-27 09:58:33 +10:00
Neal Chambers
164385ad13 Safely autocorrect Layout/MultilineMethodCallBraceLayout
Inspecting 1479 files
...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.....C.....................................................................

Offenses:

spec/system/admin/orders_spec.rb:485:80: C: [Corrected] Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.
                 "#listing_orders tbody tr td:first-child input[type=checkbox]")
                                                                               ^
spec/system/admin/orders_spec.rb:486:1: C: [Corrected] Layout/ClosingParenthesisIndentation: Indent ) to column 15 (not 0)
)).to be_checked
^
spec/system/admin/orders_spec.rb:486:15: C: [Corrected] Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the same line as the last argument when opening brace is on the same line as the first argument.
              ).to be_checked
              ^
spec/system/admin/orders_spec.rb:493:80: C: [Corrected] Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.
                 "#listing_orders tbody tr td:first-child input[type=checkbox]")
                                                                               ^
spec/system/admin/orders_spec.rb:494:1: C: [Corrected] Layout/ClosingParenthesisIndentation: Indent ) to column 15 (not 0)
)).to_not be_checked
^
spec/system/admin/orders_spec.rb:494:15: C: [Corrected] Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the same line as the last argument when opening brace is on the same line as the first argument.
              ).to_not be_checked
              ^
spec/system/admin/products_spec.rb:346:54: C: [Corrected] Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.
                                   product.id, filter)))
                                                     ^
spec/system/admin/products_spec.rb:347:1: C: [Corrected] Layout/ClosingParenthesisIndentation: Indent ) to column 33 (not 0)
)))
^
spec/system/admin/products_spec.rb:352:54: C: [Corrected] Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.
                                   product.id, filter)))
                                                     ^
spec/system/admin/products_spec.rb:354:1: C: [Corrected] Layout/ClosingParenthesisIndentation: Indent ) to column 33 (not 0)
)))
^

1479 files inspected, 10 offenses detected, 10 offenses corrected
2023-07-27 09:58:33 +10:00
Neal Chambers
a97e208881 Safely autocorrect Layout/MultilineBlockLayout
Inspecting 1479 files
....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

engines/order_management/app/services/order_management/subscriptions/validator.rb:101:9: C: [Corrected] Layout/IndentationWidth: Use 2 (not 12) spaces for indentation.
                    sli.quantity > 0 && !sli.marked_for_destruction?
        ^^^^^^^^^^^^
engines/order_management/app/services/order_management/subscriptions/validator.rb:101:11: C: [Corrected] Layout/MultilineBlockLayout: Block argument expression is not on the same line as the block start.
          |sli| sli.quantity > 0 && !sli.marked_for_destruction?
          ^^^^^

1479 files inspected, 2 offenses detected, 2 offenses corrected
2023-07-27 09:58:05 +10:00
Maikel Linke
f7d5217ef6 Compile JS before testing caching
That avoids flakiness.
2023-07-27 09:40:08 +10:00
Neal Chambers
ffda639629 Regenerate Rubocop's TODO file 2023-07-27 08:35:27 +09:00
Maikel
f9589b8b23 Merge pull request #11280 from filipefurtad0/fix_flaky_caching_spec
Comments out flaky caching example
2023-07-27 08:50:06 +10:00
Maikel
5e94c038dc Merge pull request #11227 from filipefurtad0/update_several_enterprise_fees
Updates spec to cover #11150 (regression spec)
2023-07-27 08:45:27 +10:00
Maikel
16d28ab797 Merge pull request #11277 from mkllnk/greek
Add greek locale
2023-07-27 08:38:51 +10:00
filipefurtad0
5ed9583048 Rubocop fixes - not seen locally
Not sure why these were triggered remotly, but not locally - even after making sure I'm up-to-date with master?
2023-07-26 18:35:12 +01:00
filipefurtad0
f7301b72aa Adds test case for updating multiple fees
Adds values, updates and asserts these are saved correctly
2023-07-26 18:35:09 +01:00
Jean-Baptiste Bellet
1a7e99143b Update mobile variant size for white label logo to fit the same ratio
Default size is 217*44. On mobile, we used to use 75*26, but with a different image.

With the white label, using the same image, we should have the same ratio between default and mobile ; that's why I've updated the width of the variant to 128.
2023-07-26 14:43:06 +02:00
filipefurtad0
83f1266b8a Comments out flaky example
Sets example to xit

pending is not suitable for flaky specs, as we'll get a red build anyway, each time the spec passes; commenting out should be the right approach till we fix this one
2023-07-26 12:05:06 +01:00
jibees
f5564a5947 Merge pull request #11279 from openfoodfoundation/dependabot/bundler/rubocop-1.55.0
chore(deps-dev): bump rubocop from 1.54.2 to 1.55.0
2023-07-26 12:56:01 +02:00
filipefurtad0
d4d8941117 Reverts #11019
As discussed here (https://github.com/openfoodfoundation/openfoodnetwork/issues/11010#issuecomment-1594153860), reset_spree_preferences already does Rails.cache.clear
2023-07-26 11:49:41 +01:00
dependabot[bot]
45edda9bf6 chore(deps-dev): bump rubocop from 1.54.2 to 1.55.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.54.2 to 1.55.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.54.2...v1.55.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-07-26 08:43:15 +00:00
jibees
ad7ec1e6d0 Merge pull request #11271 from openfoodfoundation/dependabot/bundler/aws-sdk-s3-1.132.0
chore(deps): bump aws-sdk-s3 from 1.131.0 to 1.132.0
2023-07-26 10:41:38 +02:00
jibees
b9871933e3 Merge pull request #11272 from openfoodfoundation/dependabot/bundler/view_component-3.5.0
chore(deps): bump view_component from 3.4.0 to 3.5.0
2023-07-26 10:40:55 +02:00
Maikel Linke
627e689757 Fix swagger-api integration after last update
See also:

* https://github.com/rswag/rswag/pull/668
2023-07-26 15:52:48 +10:00
Maikel Linke
cea44c1a78 Add greek locale 2023-07-26 14:45:35 +10:00
jibees
a832562d1f Merge pull request #11198 from dacook/admin_v3-table-tweaks
🚧 Products v3: table and menu tweaks
2023-07-25 16:00:24 +02:00
David Cook
8ef73906db Show products_v3 in the submenu
It's not translated, but that doesn't matter, it's just a shortcut while we're developing it.
2023-07-25 15:31:57 +02:00
David Cook
439c0a8e18 Remove unnecessary match_path options
Spree::Tab already knows when to highlight these, based on the controller name. It even handles sub-paths like '/admin/products/garlic/edit'.
2023-07-25 15:31:57 +02:00
David Cook
ea93800ee6 [table] Tax category: display None instead of blank 2023-07-25 15:31:57 +02:00
David Cook
51189a3138 [table] Hide properties for variant row
These were a duplicate of the product.
2023-07-25 15:31:57 +02:00
jibees
605cb730f7 Merge pull request #11163 from jibees/productsV3-searching-filtering-pagination
🚧 Products v3: viewing, searching,  filtering & pagination
2023-07-25 15:22:42 +02:00
Jean-Baptiste Bellet
352cf2ff71 Import typography.scss for admin_v3
And do not apply `a` style to `.button` element.

ie.
```
a:not(.button)
```
2023-07-25 14:29:00 +02:00
dependabot[bot]
e816629038 chore(deps): bump view_component from 3.4.0 to 3.5.0
Bumps [view_component](https://github.com/viewcomponent/view_component) from 3.4.0 to 3.5.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/v3.4.0...v3.5.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-25 10:10:33 +00:00
dependabot[bot]
789fde3c89 chore(deps): bump aws-sdk-s3 from 1.131.0 to 1.132.0
Bumps [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby) from 1.131.0 to 1.132.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-07-25 10:03:30 +00:00
filipefurtad0
04f83fbcce Finally, update system test for an end-to-end testing 2023-07-25 10:57:27 +02:00
Jean-Baptiste Bellet
d22566aa50 Set visible to only_through_links on enterprise creation 2023-07-25 10:57:27 +02:00
Jean-Baptiste Bellet
5a0d4d2a93 Set visible to only_through_links on enterprise registration 2023-07-25 10:57:26 +02:00
Jean-Baptiste Bellet
7aed068bb7 Enterprises.visible attribute is set to only_through_links by default
+ update enterprise_factory.rb to create "public" enterprise through specs via its factory
2023-07-25 10:57:26 +02:00
Jean-Baptiste Bellet
2a81a9acfb Add ability for non super-admin user to see products_v3 page 2023-07-25 09:20:25 +02:00
jibees
6f83d5b316 Merge pull request #11264 from openfoodfoundation/dependabot/bundler/knapsack_pro-5.3.3
chore(deps-dev): bump knapsack_pro from 5.3.2 to 5.3.3
2023-07-24 15:19:57 +02:00
jibees
af086253de Merge pull request #11265 from openfoodfoundation/dependabot/npm_and_yarn/jasmine-core-5.1.0
chore(deps-dev): bump jasmine-core from 5.0.1 to 5.1.0
2023-07-24 15:11:45 +02:00
Filipe
8ff877b865 Merge pull request #11258 from openfoodfoundation/dependabot/bundler/aws-sdk-s3-1.131.0
chore(deps): bump aws-sdk-s3 from 1.126.0 to 1.131.0
2023-07-24 13:30:42 +01:00
Filipe
1e2fb077cd Merge pull request #11261 from macanudo527/fix_rubocop_layout_1
Fix Rubocop Layout violations - 2
2023-07-24 13:05:46 +01:00
dependabot[bot]
f5c326f1b0 chore(deps-dev): bump jasmine-core from 5.0.1 to 5.1.0
Bumps [jasmine-core](https://github.com/jasmine/jasmine) from 5.0.1 to 5.1.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/v5.0.1...v5.1.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-24 09:36:51 +00:00
dependabot[bot]
bf010d273a chore(deps-dev): bump knapsack_pro from 5.3.2 to 5.3.3
Bumps [knapsack_pro](https://github.com/KnapsackPro/knapsack_pro-ruby) from 5.3.2 to 5.3.3.
- [Changelog](https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v5.3.2...v5.3.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-24 09:17:36 +00:00
Maikel Linke
f36ca77f5f Ease reading with related spec values on one line 2023-07-24 13:31:09 +10:00
Maikel Linke
a677444a97 Fix specs with missign parenthesis 2023-07-24 13:23:54 +10:00
Neal Chambers
bede52bdae Safely autocorrect Layout/LineLength
Inspecting 1478 files
.......C............................C..............................................................................................................C.......................................................................................................C............................................................................C................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.................C......................................C...................................................................................................................C...........................................................C........................C...C.....C..C..C..........C..................C...............C.....................C...................................................................................C......................................................C........C..C...........C....................C.CC....C....................................C......C..........................

Offenses:

app/components/confirm_modal_component.rb:4:88: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
  def initialize(id:, confirm_actions: nil, reflex: nil, controller: nil, message: nil,
                                                                                       ^
app/components/confirm_modal_component.rb:4:101: C: [Corrected] Layout/LineLength: Line is too long. [110/100]
  def initialize(id:, confirm_actions: nil, reflex: nil, controller: nil, message: nil, confirm_reflexes: nil)
                                                                                                    ^^^^^^^^^^
app/components/confirm_modal_component.rb:5:1: C: [Corrected] Layout/ParameterAlignment: Align the parameters of a method definition if they span more than one line.
confirm_reflexes: nil)
^^^^^^^^^^^^^^^^^^^^^
app/controllers/admin/product_import_controller.rb:142:43: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
      redirect_to '/admin/product_import',
                                          ^
app/controllers/admin/product_import_controller.rb:142:101: C: [Corrected] Layout/LineLength: Line is too long. [104/100]
      redirect_to '/admin/product_import', notice: I18n.t(:product_import_no_data_in_spreadsheet_notice)
                                                                                                    ^^^^
app/controllers/admin/product_import_controller.rb:143:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
notice: I18n.t(:product_import_no_data_in_spreadsheet_notice)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/controllers/spree/users_controller.rb:53:101: C: Layout/LineLength: Line is too long. [107/100]
                            message: t('devise.user_registrations.spree_user.signed_up_but_unconfirmed') })
                                                                                                    ^^^^^^^
app/models/customer.rb:43:101: C: [Corrected] Layout/LineLength: Line is too long. [113/100]
  scope :managed_by, ->(user) { user&.persisted? ? where(user: user).or(of(Enterprise.managed_by(user))) : none }
                                                                                                    ^^^^^^^^^^^^^
app/models/customer.rb:44:1: C: [Corrected] Layout/IndentationWidth: Use 2 (not 1) spaces for indentation.
 user&.persisted? ? where(user: user).or(of(Enterprise.managed_by(user))) : none
^
app/models/customer.rb:44:3: C: [Corrected] Layout/IndentationWidth: Use 2 (not -19) spaces for indentation.
  user&.persisted? ? where(user: user).or(of(Enterprise.managed_by(user))) : none
  ^^^^^^^^^^^^^^^^^^^
app/models/customer.rb:44:82: C: [Corrected] Layout/BlockEndNewline: Expression at 44, 82 should be on its own line.
 user&.persisted? ? where(user: user).or(of(Enterprise.managed_by(user))) : none }
                                                                                 ^
app/models/customer.rb:44:101: C: Layout/LineLength: Line is too long. [102/100]
                       user&.persisted? ? where(user: user).or(of(Enterprise.managed_by(user))) : none
                                                                                                    ^^
app/models/customer.rb:45:1: C: [Corrected] Layout/BlockAlignment: } at 45, 0 is not aligned with ->(user) { at 43, 21 or scope :managed_by, ->(user) { at 43, 2.
}
^
app/models/spree/line_item.rb:53:101: C: Layout/LineLength: Line is too long. [110/100]
    attr_accessor :skip_stock_check, :target_shipment # Allows manual skipping of Stock::AvailabilityValidator
                                                                                                    ^^^^^^^^^^
spec/controllers/admin/order_cycles_controller_spec.rb:38:101: C: Layout/LineLength: Line is too long. [108/100]
            it "loads order cycles that closed within the past month, and orders without a close_at date" do
                                                                                                    ^^^^^^^^
spec/controllers/admin/order_cycles_controller_spec.rb:48:101: C: Layout/LineLength: Line is too long. [111/100]
            it "loads order cycles that closed after the specified date, and orders without a close_at date" do
                                                                                                    ^^^^^^^^^^^
spec/controllers/admin/order_cycles_controller_spec.rb:100:101: C: Layout/LineLength: Line is too long. [125/100]
              expect(flash[:error]).to eq "You don't have permission to create an order cycle coordinated by that enterprise"
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^
spec/controllers/admin/order_cycles_controller_spec.rb:125:101: C: Layout/LineLength: Line is too long. [101/100]
            order_cycle.exchanges.create! sender: distributor, receiver: distributor, incoming: true,
                                                                                                    ^
spec/controllers/admin/order_cycles_controller_spec.rb:127:101: C: Layout/LineLength: Line is too long. [102/100]
            order_cycle.exchanges.create! sender: distributor, receiver: distributor, incoming: false,
                                                                                                    ^^
spec/controllers/admin/order_cycles_controller_spec.rb:284:101: C: Layout/LineLength: Line is too long. [101/100]
            merge(order_cycle: { preferred_product_selection_from_coordinator_inventory_only: true })
                                                                                                    ^
spec/controllers/admin/order_cycles_controller_spec.rb:311:101: C: Layout/LineLength: Line is too long. [104/100]
        create(:exchange, order_cycle: order_cycle, sender: coordinator, receiver: hub, incoming: false,
                                                                                                    ^^^^
spec/controllers/admin/order_cycles_controller_spec.rb:374:101: C: Layout/LineLength: Line is too long. [102/100]
          expect(json_response['errors']).to eq 'Hm, something went wrong. No order cycle data found.'
                                                                                                    ^^
spec/controllers/admin/order_cycles_controller_spec.rb:460:101: C: Layout/LineLength: Line is too long. [176/100]
          expect(flash[:error]).to eq 'That order cycle has been selected by a customer and cannot be deleted. To prevent customers from accessing it, please close it instead.'
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/controllers/admin/order_cycles_controller_spec.rb:470:101: C: Layout/LineLength: Line is too long. [147/100]
          expect(flash[:error]).to eq 'That order cycle is linked to a schedule and cannot be deleted. Please unlink or delete the schedule first.'
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/controllers/api/v0/order_cycles_controller_spec.rb:16:101: C: [Corrected] Layout/LineLength: Line is too long. [106/100]
    let!(:product1) { create(:product, name: "Kangaroo", primary_taxon: taxon1, properties: [property1]) }
                                                                                                    ^^^^^^
spec/controllers/api/v0/order_cycles_controller_spec.rb:17:1: C: [Corrected] Layout/IndentationWidth: Use 2 (not 1) spaces for indentation.
 create(:product, name: "Kangaroo", primary_taxon: taxon1, properties: [property1])
^
spec/controllers/api/v0/order_cycles_controller_spec.rb:17:3: C: [Corrected] Layout/IndentationWidth: Use 2 (not -2) spaces for indentation.
  create(:product, name: "Kangaroo", primary_taxon: taxon1, properties: [property1])
  ^^
spec/controllers/api/v0/order_cycles_controller_spec.rb:17:85: C: [Corrected] Layout/BlockEndNewline: Expression at 17, 85 should be on its own line.
 create(:product, name: "Kangaroo", primary_taxon: taxon1, properties: [property1]) }
                                                                                    ^
spec/controllers/api/v0/order_cycles_controller_spec.rb:17:101: C: [Corrected] Layout/LineLength: Line is too long. [106/100]
    let!(:product2) { create(:product, name: "Parsnips", primary_taxon: taxon2, properties: [property2]) }
                                                                                                    ^^^^^^
spec/controllers/api/v0/order_cycles_controller_spec.rb:18:1: C: [Corrected] Layout/BlockAlignment: } at 18, 0 is not aligned with let!(:product1) { at 16, 4.
}
^
spec/controllers/api/v0/order_cycles_controller_spec.rb:19:85: C: [Corrected] Layout/BlockEndNewline: Expression at 19, 85 should be on its own line.
 create(:product, name: "Parsnips", primary_taxon: taxon2, properties: [property2]) }
                                                                                    ^
spec/controllers/api/v0/order_cycles_controller_spec.rb:20:1: C: [Corrected] Layout/IndentationWidth: Use 2 (not 1) spaces for indentation.
 create(:product, name: "Parsnips", primary_taxon: taxon2, properties: [property2])
^
spec/controllers/api/v0/order_cycles_controller_spec.rb:20:3: C: [Corrected] Layout/IndentationWidth: Use 2 (not -2) spaces for indentation.
  create(:product, name: "Parsnips", primary_taxon: taxon2, properties: [property2])
  ^^
spec/controllers/api/v0/order_cycles_controller_spec.rb:21:1: C: [Corrected] Layout/BlockAlignment: } at 21, 0 is not aligned with let!(:product2) { at 19, 4.
}
^
spec/controllers/spree/admin/orders_controller_spec.rb:232:101: C: [Corrected] Layout/LineLength: Line is too long. [117/100]
        let!(:order_cycle){ create(:simple_order_cycle, distributors: [distributor], variants: [line_item.variant]) }
                                                                                                    ^^^^^^^^^^^^^^^^^
spec/controllers/spree/admin/orders_controller_spec.rb:233:1: C: [Corrected] Layout/IndentationWidth: Use 2 (not 1) spaces for indentation.
 create(:simple_order_cycle, distributors: [distributor], variants: [line_item.variant])
^
spec/controllers/spree/admin/orders_controller_spec.rb:233:3: C: [Corrected] Layout/IndentationWidth: Use 2 (not -6) spaces for indentation.
  create(:simple_order_cycle, distributors: [distributor], variants: [line_item.variant])
  ^^^^^^
spec/controllers/spree/admin/orders_controller_spec.rb:233:90: C: [Corrected] Layout/BlockEndNewline: Expression at 233, 90 should be on its own line.
 create(:simple_order_cycle, distributors: [distributor], variants: [line_item.variant]) }
                                                                                         ^
spec/controllers/spree/admin/orders_controller_spec.rb:234:1: C: [Corrected] Layout/BlockAlignment: } at 234, 0 is not aligned with let!(:order_cycle){ at 232, 8.
}
^
spec/controllers/spree/admin/orders_controller_spec.rb:252:101: C: Layout/LineLength: Line is too long. [109/100]
            allow_any_instance_of(Spree::Order).to receive(:ensure_available_shipping_rates).and_return(true)
                                                                                                    ^^^^^^^^^
spec/lib/reports/customers_report_spec.rb:93:88: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
                create(:order_with_totals_and_distribution, :completed, distributor: d,
                                                                                       ^
spec/lib/reports/customers_report_spec.rb:93:101: C: [Corrected] Layout/LineLength: Line is too long. [125/100]
                create(:order_with_totals_and_distribution, :completed, distributor: d, bill_address: a, shipping_method: sm)
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^
spec/lib/reports/customers_report_spec.rb:94:1: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
bill_address: a, shipping_method: sm)
^^^^^^^^^^^^^^^
spec/lib/reports/customers_report_spec.rb:94:101: C: Layout/LineLength: Line is too long. [109/100]
                                                                        bill_address: a, shipping_method: sm)
                                                                                                    ^^^^^^^^^
spec/lib/reports/customers_report_spec.rb:96:101: C: [Corrected] Layout/LineLength: Line is too long. [125/100]
                create(:order_with_totals_and_distribution, :completed, distributor: d, bill_address: a, shipping_method: sm)
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^
spec/lib/reports/customers_report_spec.rb:97:88: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
                create(:order_with_totals_and_distribution, :completed, distributor: d,
                                                                                       ^
spec/lib/reports/customers_report_spec.rb:98:1: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
bill_address: a, shipping_method: sm)
^^^^^^^^^^^^^^^
spec/lib/reports/customers_report_spec.rb:98:101: C: Layout/LineLength: Line is too long. [109/100]
                                                                        bill_address: a, shipping_method: sm)
                                                                                                    ^^^^^^^^^
spec/lib/reports/customers_report_spec.rb:113:101: C: Layout/LineLength: Line is too long. [118/100]
                                                   [d.address.address1, d.address.address2, d.address.city].join(" "),
                                                                                                    ^^^^^^^^^^^^^^^^^^
spec/lib/reports/customers_report_spec.rb:120:101: C: [Corrected] Layout/LineLength: Line is too long. [129/100]
                  create(:order_with_totals_and_distribution, :completed, distributor: d2, bill_address: a, shipping_method: sm2)
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/lib/reports/customers_report_spec.rb:122:91: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
                  create(:order_with_totals_and_distribution, :completed, distributor: d2,
                                                                                          ^
spec/lib/reports/customers_report_spec.rb:123:1: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
bill_address: a, shipping_method: sm2)
^^^^^^^^^^^^^^^
spec/lib/reports/customers_report_spec.rb:123:101: C: Layout/LineLength: Line is too long. [112/100]
                                                                          bill_address: a, shipping_method: sm2)
                                                                                                    ^^^^^^^^^^^^
spec/lib/reports/customers_report_spec.rb:133:101: C: Layout/LineLength: Line is too long. [120/100]
                                                     [d.address.address1, d.address.address2, d.address.city].join(" "),
                                                                                                    ^^^^^^^^^^^^^^^^^^^^
spec/lib/reports/customers_report_spec.rb:139:101: C: Layout/LineLength: Line is too long. [123/100]
                                                     [d2.address.address1, d2.address.address2, d2.address.city].join(" "),
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^^
spec/lib/reports/customers_report_spec.rb:145:101: C: [Corrected] Layout/LineLength: Line is too long. [128/100]
                  create(:order_with_totals_and_distribution, :completed, distributor: d, bill_address: a, shipping_method: sm2)
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/lib/reports/customers_report_spec.rb:148:90: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
                  create(:order_with_totals_and_distribution, :completed, distributor: d,
                                                                                         ^
spec/lib/reports/customers_report_spec.rb:149:1: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
bill_address: a, shipping_method: sm2)
^^^^^^^^^^^^^^^
spec/lib/reports/customers_report_spec.rb:149:101: C: Layout/LineLength: Line is too long. [112/100]
                                                                          bill_address: a, shipping_method: sm2)
                                                                                                    ^^^^^^^^^^^^
spec/migrations/migrate_customer_names_spec.rb:16:101: C: Layout/LineLength: Line is too long. [122/100]
                             value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise1.id}")
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^
spec/migrations/migrate_customer_names_spec.rb:18:101: C: Layout/LineLength: Line is too long. [122/100]
                             value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise2.id}")
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^
spec/migrations/migrate_customer_names_spec.rb:20:101: C: Layout/LineLength: Line is too long. [122/100]
                             value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise4.id}")
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^
spec/models/enterprise_spec.rb:521:101: C: [Corrected] Layout/LineLength: Line is too long. [111/100]
        expect(Enterprise.supplying_variant_in([p1.variants.first, p2.variants.first])).to match_array [s1, s2]
                                                                                                    ^^^^^^^^^^^
spec/models/enterprise_spec.rb:522:1: C: [Corrected] Layout/ArrayAlignment: Align the elements of an array literal if they span more than one line.
p2.variants.first])).to match_array [s1, s2]
^^^^^^^^^^^^^^^^^
spec/models/order_cycle_spec.rb:207:101: C: Layout/LineLength: Line is too long. [118/100]
      expect(oc.variants).to match_array [p0.variants.first, p1.variants.first, p2.variants.first, p2_v, p1_v_visible,
                                                                                                    ^^^^^^^^^^^^^^^^^^
spec/models/order_cycle_spec.rb:220:101: C: Layout/LineLength: Line is too long. [111/100]
      expect(oc.distributed_variants).to match_array [p1.variants.first, p2.variants.first, p2_v, p1_v_visible,
                                                                                                    ^^^^^^^^^^^
spec/models/product_importer_spec.rb:782:101: C: Layout/LineLength: Line is too long. [101/100]
          csv << [" Oats ", "\nPorridge Oats\n", "\r#{enterprise2.name}\r", "\t#{enterprise.name}\t",
                                                                                                    ^
spec/models/spree/ability_spec.rb:340:69: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          [:admin, :index, :read, :edit, :update, :search, :destroy,
                                                                    ^
spec/models/spree/ability_spec.rb:340:101: C: [Corrected] Layout/LineLength: Line is too long. [101/100]
          [:admin, :index, :read, :edit, :update, :search, :destroy, :delete], for: p1.variants.first
                                                                                                    ^
spec/models/spree/ability_spec.rb:341:1: C: [Corrected] Layout/ArrayAlignment: Align the elements of an array literal if they span more than one line.
:delete], for: p1.variants.first
^^^^^^^
spec/models/spree/ability_spec.rb:350:101: C: [Corrected] Layout/LineLength: Line is too long. [108/100]
          [:admin, :index, :read, :edit, :update, :search, :destroy, :delete], for: p_related.variants.first
                                                                                                    ^^^^^^^^
spec/models/spree/ability_spec.rb:351:69: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          [:admin, :index, :read, :edit, :update, :search, :destroy,
                                                                    ^
spec/models/spree/ability_spec.rb:352:1: C: [Corrected] Layout/ArrayAlignment: Align the elements of an array literal if they span more than one line.
:delete], for: p_related.variants.first
^^^^^^^
spec/models/spree/ability_spec.rb:379:101: C: [Corrected] Layout/LineLength: Line is too long. [101/100]
          [:admin, :index, :read, :create, :edit, :search, :update, :destroy], for: p2.variants.first
                                                                                                    ^
spec/models/spree/ability_spec.rb:381:68: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          [:admin, :index, :read, :create, :edit, :search, :update,
                                                                   ^
spec/models/spree/ability_spec.rb:382:1: C: [Corrected] Layout/ArrayAlignment: Align the elements of an array literal if they span more than one line.
:destroy], for: p2.variants.first
^^^^^^^^
spec/models/spree/adjustment_spec.rb:339:101: C: Layout/LineLength: Line is too long. [106/100]
          create(:tax_rate, included_in_price: true, calculator: ::Calculator::DefaultTax.new, zone: zone,
                                                                                                    ^^^^^^
spec/models/spree/adjustment_spec.rb:367:101: C: Layout/LineLength: Line is too long. [101/100]
                                      calculator: ::Calculator::FlatRate.new(preferred_amount: 50.0))
                                                                                                    ^
spec/models/spree/adjustment_spec.rb:428:101: C: Layout/LineLength: Line is too long. [105/100]
        context "when enterprise fees inherit their tax_category from the product they are applied to" do
                                                                                                    ^^^^^
spec/models/spree/adjustment_spec.rb:443:101: C: Layout/LineLength: Line is too long. [101/100]
                                      calculator: ::Calculator::FlatRate.new(preferred_amount: 50.0))
                                                                                                    ^
spec/models/spree/line_item_spec.rb:208:101: C: Layout/LineLength: Line is too long. [107/100]
        expect(LineItem.from_order_cycle(oc_order.order_cycle).first.id).to eq oc_order.line_items.first.id
                                                                                                    ^^^^^^^
spec/models/spree/line_item_spec.rb:342:101: C: Layout/LineLength: Line is too long. [102/100]
                                                               Spree::Variant.find(variant.id).on_hand
                                                                                                    ^^
spec/models/spree/product_spec.rb:409:74: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          create(:simple_order_cycle, suppliers: [s], distributors: [d1],
                                                                         ^
spec/models/spree/product_spec.rb:409:101: C: [Corrected] Layout/LineLength: Line is too long. [104/100]
          create(:simple_order_cycle, suppliers: [s], distributors: [d1], variants: [p1.variants.first])
                                                                                                    ^^^^
spec/models/spree/product_spec.rb:410:1: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
variants: [p1.variants.first])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/models/spree/product_spec.rb:410:101: C: [Corrected] Layout/LineLength: Line is too long. [104/100]
          create(:simple_order_cycle, suppliers: [s], distributors: [d2], variants: [p2.variants.first])
                                                                                                    ^^^^
spec/models/spree/product_spec.rb:411:74: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          create(:simple_order_cycle, suppliers: [s], distributors: [d2],
                                                                         ^
spec/models/spree/product_spec.rb:412:1: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
variants: [p2.variants.first])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/models/spree/product_spec.rb:486:101: C: [Corrected] Layout/LineLength: Line is too long. [104/100]
          create(:simple_order_cycle, suppliers: [s], distributors: [d1], variants: [p1.variants.first])
                                                                                                    ^^^^
spec/models/spree/product_spec.rb:487:101: C: [Corrected] Layout/LineLength: Line is too long. [104/100]
          create(:simple_order_cycle, suppliers: [s], distributors: [d2], variants: [p2.variants.first])
                                                                                                    ^^^^
spec/models/spree/product_spec.rb:488:74: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          create(:simple_order_cycle, suppliers: [s], distributors: [d1],
                                                                         ^
spec/models/spree/product_spec.rb:489:1: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
variants: [p1.variants.first])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/models/spree/product_spec.rb:490:74: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          create(:simple_order_cycle, suppliers: [s], distributors: [d2],
                                                                         ^
spec/models/spree/product_spec.rb:491:1: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
variants: [p2.variants.first])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/models/spree/product_spec.rb:495:101: C: [Corrected] Layout/LineLength: Line is too long. [102/100]
          create(:simple_order_cycle, suppliers: [s], distributors: [d], variants: [p.variants.first])
                                                                                                    ^^
spec/models/spree/product_spec.rb:499:73: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
          create(:simple_order_cycle, suppliers: [s], distributors: [d],
                                                                        ^
spec/models/spree/product_spec.rb:500:1: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
variants: [p.variants.first])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/models/spree/variant_spec.rb:356:101: C: Layout/LineLength: Line is too long. [108/100]
            it "lists any variants that are not listed as visible=false only for the relevant enterprise" do
                                                                                                    ^^^^^^^^
spec/models/spree/variant_spec.rb:479:101: C: Layout/LineLength: Line is too long. [108/100]
      expect_any_instance_of(OpenFoodNetwork::EnterpriseFeeCalculator).to receive(:fees_for).with(variant) {
                                                                                                    ^^^^^^^^
spec/models/spree/variant_spec.rb:494:101: C: Layout/LineLength: Line is too long. [116/100]
      expect_any_instance_of(OpenFoodNetwork::EnterpriseFeeCalculator).to receive(:fees_by_type_for).with(variant) {
                                                                                                    ^^^^^^^^^^^^^^^^
spec/models/spree/variant_spec.rb:704:101: C: Layout/LineLength: Line is too long. [115/100]
        expect_any_instance_of(VariantUnits::OptionValueNamer).to receive(:name).exactly(1).times.and_call_original
                                                                                                    ^^^^^^^^^^^^^^^
spec/requests/api/orders_spec.rb:167:88: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
              create(:order_with_line_items, line_items_count: 1, bill_address_id: nil,
                                                                                       ^
spec/requests/api/orders_spec.rb:167:101: C: [Corrected] Layout/LineLength: Line is too long. [109/100]
              create(:order_with_line_items, line_items_count: 1, bill_address_id: nil, ship_address_id: nil)
                                                                                                    ^^^^^^^^^
spec/requests/api/orders_spec.rb:168:1: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
ship_address_id: nil)
^^^^^^^^^^^^^^^^^^^^
spec/services/products_renderer_spec.rb:91:101: C: Layout/LineLength: Line is too long. [101/100]
                                                   { q: { with_properties: [property_organic.id] } })
                                                                                                    ^
spec/services/products_renderer_spec.rb:100:101: C: Layout/LineLength: Line is too long. [101/100]
                                                   { q: { with_properties: [property_organic.id] } })
                                                                                                    ^
spec/services/products_renderer_spec.rb:118:101: C: Layout/LineLength: Line is too long. [101/100]
                                                   { q: { with_properties: [property_organic.id] } })
                                                                                                    ^
spec/support/request/web_helper.rb:96:84: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
    tomselect_wrapper.find(:css, '.ts-dropdown.multi .ts-dropdown-content .option',
                                                                                   ^
spec/support/request/web_helper.rb:96:101: C: [Corrected] Layout/LineLength: Line is too long. [102/100]
    tomselect_wrapper.find(:css, '.ts-dropdown.multi .ts-dropdown-content .option', text: value).click
                                                                                                    ^^
spec/support/request/web_helper.rb:97:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
text: value).click
^^^^^^^^^^^
spec/system/admin/adjustments_spec.rb:29:101: C: [Corrected] Layout/LineLength: Line is too long. [197/100]
  let!(:tax_rate2) { create(:tax_rate, name: "TVA 20%", amount: 0.2, zone: default_tax_zone, included_in_price: true, tax_category: tax_category_included, calculator: Calculator::DefaultTax.new ) }
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/adjustments_spec.rb:30:1: C: [Corrected] Layout/IndentationWidth: Use 2 (not 1) spaces for indentation.
 create(:tax_rate, name: "TVA 20%", amount: 0.2, zone: default_tax_zone, included_in_price: true,
^
spec/system/admin/adjustments_spec.rb:30:3: C: [Corrected] Layout/IndentationWidth: Use 2 (not 0) spaces for indentation.
  create(:tax_rate, name: "TVA 20%", amount: 0.2, zone: default_tax_zone, included_in_price: true,

spec/system/admin/adjustments_spec.rb:30:98: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
 create(:tax_rate, name: "TVA 20%", amount: 0.2, zone: default_tax_zone, included_in_price: true,
                                                                                                 ^
spec/system/admin/adjustments_spec.rb:30:101: C: [Corrected] Layout/LineLength: Line is too long. [177/100]
 create(:tax_rate, name: "TVA 20%", amount: 0.2, zone: default_tax_zone, included_in_price: true, tax_category: tax_category_included, calculator: Calculator::DefaultTax.new ) }
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/adjustments_spec.rb:30:177: C: [Corrected] Layout/BlockEndNewline: Expression at 30, 177 should be on its own line.
 create(:tax_rate, name: "TVA 20%", amount: 0.2, zone: default_tax_zone, included_in_price: true, tax_category: tax_category_included, calculator: Calculator::DefaultTax.new ) }
                                                                                                                                                                                ^
spec/system/admin/adjustments_spec.rb:31:1: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
tax_category: tax_category_included, calculator: Calculator::DefaultTax.new )
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/adjustments_spec.rb:32:1: C: [Corrected] Layout/BlockAlignment: } at 32, 0 is not aligned with let!(:tax_rate2) { at 29, 2.
}
^
spec/system/admin/adjustments_spec.rb:41:101: C: Layout/LineLength: Line is too long. [134/100]
  shared_examples "when the enable_localized_number preference" do |adjustment_label, adjustment_amount, tax_category, tax, tax_total|
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/adjustments_spec.rb:67:101: C: [Corrected] Layout/LineLength: Line is too long. [117/100]
        it_behaves_like "when the enable_localized_number preference", "Discount", "-2", "TVA 20%", "$0.33", "$-1.67"
                                                                                                    ^^^^^^^^^^^^^^^^^
spec/system/admin/adjustments_spec.rb:68:100: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
        it_behaves_like "when the enable_localized_number preference", "Discount", "-2", "TVA 20%",
                                                                                                   ^
spec/system/admin/adjustments_spec.rb:69:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
"$0.33", "$-1.67"
^^^^^^^
spec/system/admin/adjustments_spec.rb:71:101: C: [Corrected] Layout/LineLength: Line is too long. [120/100]
        it_behaves_like "when the enable_localized_number preference", "Late fee", "100", "TVA 20%", "$-16.67", "$83.33"
                                                                                                    ^^^^^^^^^^^^^^^^^^^^
spec/system/admin/adjustments_spec.rb:73:90: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
        it_behaves_like "when the enable_localized_number preference", "Late fee", "100",
                                                                                         ^
spec/system/admin/adjustments_spec.rb:74:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
"TVA 20%", "$-16.67", "$83.33"
^^^^^^^^^
spec/system/admin/adjustments_spec.rb:77:101: C: [Corrected] Layout/LineLength: Line is too long. [113/100]
        it_behaves_like "when the enable_localized_number preference", "Discount", "-2", "GST", "$10.00", "$8.00"
                                                                                                    ^^^^^^^^^^^^^
spec/system/admin/adjustments_spec.rb:80:96: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
        it_behaves_like "when the enable_localized_number preference", "Discount", "-2", "GST",
                                                                                               ^
spec/system/admin/adjustments_spec.rb:81:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
"$10.00", "$8.00"
^^^^^^^^
spec/system/admin/adjustments_spec.rb:81:101: C: [Corrected] Layout/LineLength: Line is too long. [113/100]
        it_behaves_like "when the enable_localized_number preference", "Late fee", "110", "GST", "$10.00", "$120"
                                                                                                    ^^^^^^^^^^^^^
spec/system/admin/adjustments_spec.rb:85:97: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
        it_behaves_like "when the enable_localized_number preference", "Late fee", "110", "GST",
                                                                                                ^
spec/system/admin/adjustments_spec.rb:86:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
"$10.00", "$120"
^^^^^^^^
spec/system/admin/adjustments_spec.rb:93:101: C: [Corrected] Layout/LineLength: Line is too long. [117/100]
        it_behaves_like "when the enable_localized_number preference", "Discount", "-2", "TVA 20%", "$0.33", "$-1.67"
                                                                                                    ^^^^^^^^^^^^^^^^^
spec/system/admin/adjustments_spec.rb:97:101: C: [Corrected] Layout/LineLength: Line is too long. [120/100]
        it_behaves_like "when the enable_localized_number preference", "Late fee", "100", "TVA 20%", "$-16.67", "$83.33"
                                                                                                    ^^^^^^^^^^^^^^^^^^^^
spec/system/admin/adjustments_spec.rb:98:100: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
        it_behaves_like "when the enable_localized_number preference", "Discount", "-2", "TVA 20%",
                                                                                                   ^
spec/system/admin/adjustments_spec.rb:99:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
"$0.33", "$-1.67"
^^^^^^^
spec/system/admin/adjustments_spec.rb:103:90: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
        it_behaves_like "when the enable_localized_number preference", "Late fee", "100",
                                                                                         ^
spec/system/admin/adjustments_spec.rb:103:101: C: [Corrected] Layout/LineLength: Line is too long. [113/100]
        it_behaves_like "when the enable_localized_number preference", "Discount", "-2", "GST", "$10.00", "$8.00"
                                                                                                    ^^^^^^^^^^^^^
spec/system/admin/adjustments_spec.rb:104:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
"TVA 20%", "$-16.67", "$83.33"
^^^^^^^^^
spec/system/admin/adjustments_spec.rb:107:101: C: [Corrected] Layout/LineLength: Line is too long. [113/100]
        it_behaves_like "when the enable_localized_number preference", "Late fee", "110", "GST", "$10.00", "$120"
                                                                                                    ^^^^^^^^^^^^^
spec/system/admin/adjustments_spec.rb:110:96: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
        it_behaves_like "when the enable_localized_number preference", "Discount", "-2", "GST",
                                                                                               ^
spec/system/admin/adjustments_spec.rb:111:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
"$10.00", "$8.00"
^^^^^^^^
spec/system/admin/adjustments_spec.rb:115:97: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
        it_behaves_like "when the enable_localized_number preference", "Late fee", "110", "GST",
                                                                                                ^
spec/system/admin/adjustments_spec.rb:116:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
"$10.00", "$120"
^^^^^^^^
spec/system/admin/bulk_order_management_spec.rb:268:101: C: Layout/LineLength: Line is too long. [105/100]
                                      text: "#{o1.bill_address.last_name}, #{o1.bill_address.first_name}"
                                                                                                    ^^^^^
spec/system/admin/bulk_order_management_spec.rb:1036:101: C: Layout/LineLength: Line is too long. [147/100]
            expect(page).to have_content "This operation will result in one or more empty orders, which will be cancelled. Do you wish to proceed?"
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/bulk_order_management_spec.rb:1060:101: C: Layout/LineLength: Line is too long. [138/100]
          it "the user can confirm + wants to send email confirmation : line item is then deleted, order is canceled and email is sent" do
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/bulk_order_management_spec.rb:1072:101: C: Layout/LineLength: Line is too long. [134/100]
          it "the user can confirm + uncheck the restock option: line item is then deleted and order is canceled without retocking" do
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/customers_spec.rb:40:101: C: Layout/LineLength: Line is too long. [126/100]
                                                     managed_distributor2.name], without_options: [unmanaged_distributor.name]
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_cycles/simple_spec.rb:346:101: C: Layout/LineLength: Line is too long. [101/100]
                                           with_options: [schedule_of_other_managed_distributor.name]
                                                                                                    ^
spec/system/admin/order_cycles/simple_spec.rb:623:101: C: Layout/LineLength: Line is too long. [121/100]
                                 value: Time.zone.local(2040, 10, 17, 0o6, 0o0, 0o0).strftime("%F %T %z"), visible: false
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_cycles/simple_spec.rb:625:101: C: Layout/LineLength: Line is too long. [120/100]
                                 value: Time.zone.local(2040, 10, 24, 17, 0o0, 0o0).strftime("%F %T %z"), visible: false
                                                                                                    ^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_cycles/simple_spec.rb:733:101: C: Layout/LineLength: Line is too long. [121/100]
                                 value: Time.zone.local(2040, 10, 17, 0o6, 0o0, 0o0).strftime("%F %T %z"), visible: false
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_cycles/simple_spec.rb:735:101: C: Layout/LineLength: Line is too long. [120/100]
                                 value: Time.zone.local(2040, 10, 24, 17, 0o0, 0o0).strftime("%F %T %z"), visible: false
                                                                                                    ^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_spec.rb:598:101: C: [Corrected] Layout/LineLength: Line is too long. [101/100]
          expect(page).to have_link "Resend Confirmation", href: spree.resend_admin_order_path(order)
                                                                                                    ^
spec/system/admin/order_spec.rb:599:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
href: spree.resend_admin_order_path(order)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_spec.rb:616:101: C: [Corrected] Layout/LineLength: Line is too long. [105/100]
          expect(page).to have_link "Cancel Order", href: spree.fire_admin_order_path(order, e: 'cancel')
                                                                                                    ^^^^^
spec/system/admin/order_spec.rb:618:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
href: spree.fire_admin_order_path(order, e: 'cancel')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/orders_spec.rb:259:101: C: Layout/LineLength: Line is too long. [109/100]
                                       distributor: distributor2, bill_address_id: nil, ship_address_id: nil)
                                                                                                    ^^^^^^^^^
spec/system/admin/product_import_spec.rb:573:101: C: Layout/LineLength: Line is too long. [106/100]
      expect(page).to have_content "line 4: Cabbage - On_hand incorrect value - On_demand incorrect value"
                                                                                                    ^^^^^^
spec/system/admin/product_import_spec.rb:574:101: C: Layout/LineLength: Line is too long. [108/100]
      expect(page).to have_content "line 5: Aubergine - On_hand incorrect value - On_demand incorrect value"
                                                                                                    ^^^^^^^^
spec/system/admin/product_import_spec.rb:583:101: C: Layout/LineLength: Line is too long. [102/100]
        csv << ["name", "producer", "category", "on_hand", "price", "on_demand", "units", "unit_type",
                                                                                                    ^^
spec/system/admin/product_import_spec.rb:585:101: C: Layout/LineLength: Line is too long. [106/100]
        csv << ["Beans", "User Enterprise", "Vegetables", "invalid", "3.50", "1", "0.5", "g", "Small Bag",
                                                                                                    ^^^^^^
spec/system/admin/product_import_spec.rb:587:101: C: Layout/LineLength: Line is too long. [103/100]
        csv << ["Potatoes", "User Enterprise", "Vegetables", "6", "6", "invalid", "5", "kg", "Big Bag",
                                                                                                    ^^^
spec/system/admin/product_import_spec.rb:589:101: C: Layout/LineLength: Line is too long. [106/100]
        csv << ["Cabbage", "User Enterprise", "Vegetables", "invalid", "1.5", "invalid", "1", "kg", "Bag",
                                                                                                    ^^^^^^
spec/system/admin/product_import_spec.rb:591:101: C: Layout/LineLength: Line is too long. [102/100]
        csv << ["Aubergine", "User Enterprise", "Vegetables", nil, "1.5", "invalid", "1", "kg", "Bag",
                                                                                                    ^^
spec/system/admin/product_import_spec.rb:607:101: C: Layout/LineLength: Line is too long. [114/100]
      expect(page).to have_content "line 4: Cabbage ( Bag ) - On_hand incorrect value - On_demand incorrect value"
                                                                                                    ^^^^^^^^^^^^^^
spec/system/admin/product_import_spec.rb:608:101: C: Layout/LineLength: Line is too long. [116/100]
      expect(page).to have_content "line 5: Aubergine ( Bag ) - On_hand incorrect value - On_demand incorrect value"
                                                                                                    ^^^^^^^^^^^^^^^^
spec/system/admin/product_import_spec.rb:617:101: C: Layout/LineLength: Line is too long. [102/100]
        csv << ["name", "producer", "category", "on_hand", "price", "on_demand", "units", "unit_type",
                                                                                                    ^^
spec/system/admin/product_import_spec.rb:619:101: C: Layout/LineLength: Line is too long. [101/100]
        csv << ["Beans", "User Enterprise", "Vegetables", "-1", "3.50", "1", "500", "g", "Small Bag",
                                                                                                    ^
spec/system/admin/product_import_spec.rb:641:101: C: Layout/LineLength: Line is too long. [114/100]
      expect(page).to have_content "line 4: Cabbage ( Bag ) - On_hand incorrect value - On_demand incorrect value"
                                                                                                    ^^^^^^^^^^^^^^
spec/system/admin/product_import_spec.rb:642:101: C: Layout/LineLength: Line is too long. [116/100]
      expect(page).to have_content "line 5: Aubergine ( Bag ) - On_hand incorrect value - On_demand incorrect value"
                                                                                                    ^^^^^^^^^^^^^^^^
spec/system/consumer/shopping/cart_spec.rb:147:101: C: Layout/LineLength: Line is too long. [101/100]
                                                                     preferred_unit_from_list: "kg"),
                                                                                                    ^
spec/system/consumer/shopping/products_spec.rb:98:101: C: Layout/LineLength: Line is too long. [113/100]
                                                        "<script>alert('Dangerous!');</script>", truncate: false)
                                                                                                    ^^^^^^^^^^^^^

1478 files inspected, 173 offenses detected, 106 offenses corrected
2023-07-24 09:14:13 +09:00
Neal Chambers
e546a6b583 Safely autocorrect Layout/LineContinuationSpacing
Inspecting 1478 files
...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.....................C............................................................................

Offenses:

spec/system/admin/enterprise_fees_spec.rb:52:46: C: [Corrected] Layout/LineContinuationSpacing: Use one space in front of backslash.
    fill_in "#{prefix}_calculator_attributes"\
                                             ^
spec/system/admin/enterprise_fees_spec.rb:57:58: C: [Corrected] Layout/LineContinuationSpacing: Use one space in front of backslash.
    expect(page).to have_selector("##{prefix}_calculator"\
                                                         ^
spec/system/admin/enterprise_fees_spec.rb:142:43: C: [Corrected] Layout/LineContinuationSpacing: Use one space in front of backslash.
        "#{prefix}_calculator_attributes_"\
                                          ^
spec/system/admin/order_spec.rb:646:84: C: [Corrected] Layout/LineContinuationSpacing: Use one space in front of backslash.
            accept_alert "An invoice for this order will be sent to the customer. "\
                                                                                   ^

1478 files inspected, 4 offenses detected, 4 offenses corrected
2023-07-24 09:14:13 +09:00
Neal Chambers
948b287fd6 Safely autocorrect Layout/LeadingCommentSpace
Inspecting 1478 files
............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.........................................................................................

Offenses:

spec/system/admin/enterprises_spec.rb:204:5: C: [Corrected] Layout/LeadingCommentSpace: Missing space after #.
    #using "find" as fields outside of the screen and are not visible
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1478 files inspected, 1 offense detected, 1 offense corrected
2023-07-24 09:14:13 +09:00
Neal Chambers
9155614501 Safely autocorrect Layout/IndentationConsistency
Inspecting 1478 files
.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.C.......C......................................................................

Offenses:

spec/system/admin/order_cycles/complex_updating_specific_time_spec.rb:84:7: C: [Corrected] Layout/IndentationConsistency: Inconsistent indentation detected.
      "#order_cycle_incoming_exchange_1_variants_#{initial_variants.last.id}"
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_cycles/simple_spec.rb:784:9: C: [Corrected] Layout/IndentationConsistency: Inconsistent indentation detected.
        "order_cycle_selected_distributor_payment_method_ids_#{distributor_payment_method_id}"
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_cycles/simple_spec.rb:791:9: C: [Corrected] Layout/IndentationConsistency: Inconsistent indentation detected.
        "order_cycle_selected_distributor_shipping_method_ids_#{distributor_shipping_method_id}"
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/product_import_spec.rb:818:15: C: [Corrected] Layout/IndentationConsistency: Inconsistent indentation detected.
              I18n.t("admin.product_import.product_headings.#{heading}").upcase
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1478 files inspected, 4 offenses detected, 4 offenses corrected
2023-07-24 09:14:13 +09:00
Neal Chambers
dce02160d4 Safely autocorrect Layout/HashAlignment
Inspecting 1478 files
...................................................................................................................................................C.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C......................................................................................................................................................................................................................................................C......................CC....................C......................................................

Offenses:

app/controllers/spree/users_controller.rb:53:19: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
                  message: t('devise.user_registrations.spree_user.signed_up_but_unconfirmed') })
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/controllers/spree/users_controller.rb:53:101: C: Layout/LineLength: Line is too long. [107/100]
                            message: t('devise.user_registrations.spree_user.signed_up_but_unconfirmed') })
                                                                                                    ^^^^^^^
spec/models/enterprise_spec.rb:906:1: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
permissions: [permission])
^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/customers_spec.rb:19:1: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
code: nil, created_manually: true)
^^^^^^^^^
spec/system/admin/order_spec.rb:708:1: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
distributors: [distributor1])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/orders_spec.rb:45:4: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
   distributors: [distributor4, distributor5])
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/orders_spec.rb:249:9: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
        line_items_count: 0)
        ^^^^^^^^^^^^^^^^^^^
spec/system/admin/orders_spec.rb:254:9: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
        line_items_count: 1)
        ^^^^^^^^^^^^^^^^^^^
spec/system/admin/orders_spec.rb:259:9: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
        distributor: distributor2, bill_address_id: nil, ship_address_id: nil)
        ^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/orders_spec.rb:259:101: C: Layout/LineLength: Line is too long. [109/100]
                                       distributor: distributor2, bill_address_id: nil, ship_address_id: nil)
                                                                                                    ^^^^^^^^^
spec/system/admin/tag_rules_spec.rb:145:37: C: [Corrected] Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
                                    count: 4
                                    ^^^^^^^^

1478 files inspected, 11 offenses detected, 9 offenses corrected
2023-07-24 09:14:13 +09:00
Filipe
8bd25f9711 Merge pull request #11251 from jibees/11207-update-all-products-report-to-include-stock
Admin, Products & Inventory reports: add `on_hand` and `on_demand?` columns by default ; mark `Inventory (on hand)` report as deprecated
2023-07-21 17:07:00 +01:00
Filipe
0d0beda887 Merge pull request #11084 from abdellani/update_invoice_status_automatically
set invoice status automatically after creation
2023-07-21 16:21:05 +01:00
jibees
5142efc86e Merge pull request #11257 from openfoodfoundation/dependabot/bundler/knapsack_pro-5.3.2
chore(deps-dev): bump knapsack_pro from 5.3.1 to 5.3.2
2023-07-21 14:36:46 +02:00
Cillian O'Ruanaidh
0c0b85f4c4 Validate voucher code doesn't contain new line characters 2023-07-21 12:32:36 +01:00
Cillian O'Ruanaidh
0d0df82522 Validate voucher code length doesn't exceed the database column length i.e. 255 characters 2023-07-21 12:32:36 +01:00
Cillian O'Ruanaidh
5d66c8a578 Strip leading and trailing whitespace from voucher codes before validation 2023-07-21 12:32:36 +01:00
Cillian O'Ruanaidh
535ca954de Voucher codes should only be a single line so use a text field instead of a textarea 2023-07-21 12:12:36 +01:00
dependabot[bot]
df633f7855 chore(deps): bump aws-sdk-s3 from 1.126.0 to 1.131.0
Bumps [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby) from 1.126.0 to 1.131.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-07-21 09:17:05 +00:00
dependabot[bot]
44551766c5 chore(deps-dev): bump knapsack_pro from 5.3.1 to 5.3.2
Bumps [knapsack_pro](https://github.com/KnapsackPro/knapsack_pro-ruby) from 5.3.1 to 5.3.2.
- [Changelog](https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v5.3.1...v5.3.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-21 09:15:41 +00:00
jibees
6ddb3cd644 Merge pull request #11252 from filipefurtad0/invoices_missing_translations
Adds missing key
2023-07-21 10:42:35 +02:00
Jean-Baptiste Bellet
a094a89c09 Mark "Inventory (on hand)" report as deprecated
Co-Authored-By: Maikel <maikel@email.org.au>, @dacook
2023-07-21 09:27:07 +02:00
Jean-Baptiste Bellet
28fe479f53 Unhide on_demand & on_hand columns by default
+ update specs as well
2023-07-21 09:27:07 +02:00
David Cook
b464e51ba4 Merge pull request #11246 from mkllnk/engine-ruby-version
Add Ruby version to engines for Rubocop
2023-07-21 15:03:01 +10:00
Gaetan Craig-Riou
f9afc0ba96 Fix rubocop warning 2023-07-21 14:51:40 +10:00
Gaetan Craig-Riou
196b674bf1 Add system spec to test filtering by product 2023-07-21 14:51:40 +10:00
Gaetan Craig-Riou
2fff77b2ee Report, add filtering by product for line items 2023-07-21 14:51:40 +10:00
Gaetan Craig-Riou
ec78de7cea Add product dropdown on Order and Fulfillment reports
It includes loading the selected product to populate the dropdown
when needed.
2023-07-21 14:51:40 +10:00
Gaetan Craig-Riou
b4a3aaab19 Add select variant stimulus controller
This is similar to variantAutocomplete directive used on the
new order page. It doesn't have all the same feature, but it's a
start
2023-07-21 14:51:40 +10:00
Maikel Linke
54f39668ba Remove unused, outdated dependency declarations
The Gemfile of the main app is used.
2023-07-21 14:13:27 +10:00
Maikel Linke
a01aa8849c Add Ruby version to engines for Rubocop
> This ensures that RuboCop is using the same Ruby version as the gem.

https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Gemspec/RequiredRubyVersion
2023-07-21 14:13:26 +10:00
Maikel
022225581f Merge pull request #11249 from openfoodfoundation/dependabot/bundler/bugsnag-6.26.0
chore(deps): bump bugsnag from 6.25.2 to 6.26.0
2023-07-21 09:58:56 +10:00
Maikel
5c8939fb69 Merge pull request #11248 from openfoodfoundation/dependabot/bundler/knapsack_pro-5.3.1
chore(deps-dev): bump knapsack_pro from 5.3.0 to 5.3.1
2023-07-21 09:58:07 +10:00
Maikel
9ba9519622 Merge pull request #11241 from dacook/rubocop-layout-1
Fix Rubocop Layout violations - 1
2023-07-21 09:57:12 +10:00
filipefurtad0
4b64b9085c Adds missing keys 2023-07-20 19:18:27 +01:00
Filipe
6199d2c957 Merge pull request #11218 from openfoodfoundation/dependabot/bundler/stripe-8.6.0
chore(deps): bump stripe from 8.5.0 to 8.6.0
2023-07-20 12:56:42 +01:00
dependabot[bot]
a0cc07dc35 chore(deps): bump bugsnag from 6.25.2 to 6.26.0
Bumps [bugsnag](https://github.com/bugsnag/bugsnag-ruby) from 6.25.2 to 6.26.0.
- [Release notes](https://github.com/bugsnag/bugsnag-ruby/releases)
- [Changelog](https://github.com/bugsnag/bugsnag-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bugsnag/bugsnag-ruby/commits)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-20 09:41:23 +00:00
dependabot[bot]
afd854d32a chore(deps-dev): bump knapsack_pro from 5.3.0 to 5.3.1
Bumps [knapsack_pro](https://github.com/KnapsackPro/knapsack_pro-ruby) from 5.3.0 to 5.3.1.
- [Changelog](https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v5.3.0...v5.3.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-20 09:39:40 +00:00
David Cook
c112fad4b2 Update all locales with the latest Transifex translations 2023-07-20 14:11:16 +10:00
David Cook
19ee2b50c2 Safely autocorrect Layout/FirstHashElementIndentation
Inspecting 1478 files
...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C..................................................................................................................................................................................

Offenses:

spec/services/products_renderer_spec.rb:73:11: C: [Corrected] Layout/FirstHashElementIndentation: Use 2 spaces for indentation in a hash, relative to the first position after the preceding left parenthesis.
          "#{[:name, :meta_keywords, :variants_display_as, ...
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/services/products_renderer_spec.rb:76:9: C: [Corrected] Layout/FirstHashElementIndentation: Indent the right brace the same as the first position after the preceding left parenthesis.
        } })
        ^

1478 files inspected, 2 offenses detected, 2 offenses corrected
2023-07-20 14:05:16 +10:00
David Cook
aa124511de Safely autocorrect Layout/FirstArgumentIndentation
Inspecting 1478 files
..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C...........................................................................

Offenses:

spec/system/admin/orders_spec.rb:485:11: C: [Corrected] Layout/FirstArgumentIndentation: Indent the first argument one step more than page.find(.
          "#listing_orders tbody tr td:first-child input[type=checkbox]")
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/orders_spec.rb:493:11: C: [Corrected] Layout/FirstArgumentIndentation: Indent the first argument one step more than page.find(.
          "#listing_orders tbody tr td:first-child input[type=checkbox]")
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1478 files inspected, 2 offenses detected, 2 offenses corrected
2023-07-20 14:03:31 +10:00
David Cook
6859200339 Safely autocorrect Layout/ExtraSpacing
Inspecting 1478 files
................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.......................................................................................................................................................................................................................C......................................................................................................................................................................................................C......................

Offenses:

spec/lib/open_food_network/property_merge_spec.rb:22:57: C: [Corrected] Layout/ExtraSpacing: Unnecessary spacing detected.
      let(:product_property) { create(:product_property,  property: property) }
                                                        ^
spec/services/cart_service_spec.rb:276:58: C: [Corrected] Layout/ExtraSpacing: Unnecessary spacing detected.
        cart_service.instance_variable_set :@order_cycle,  double(:order_cycle)
                                                         ^
spec/system/consumer/shops_spec.rb:78:46: C: [Corrected] Layout/ExtraSpacing: Unnecessary spacing detected.
      expect(page).to have_no_selector 'hub',   text: d2.name
                                             ^^

1478 files inspected, 3 offenses detected, 3 offenses corrected
2023-07-20 14:01:44 +10:00
David Cook
bc330b69a5 Safely autocorrect Layout/EmptyLinesAroundBlockBody
Inspecting 1478 files
......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C...............................................................................

Offenses:

spec/system/admin/order_cycles/list_spec.rb:191:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body end.

1478 files inspected, 1 offense detected, 1 offense corrected
2023-07-20 13:59:53 +10:00
David Cook
6fa9165cc2 Safely autocorrect Layout/EmptyLines
Inspecting 1478 files
..............................................................................................................................................................................................................................................................................................................................................C.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

app/models/spree/payment.rb:100:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.

1478 files inspected, 1 offense detected, 1 offense corrected
2023-07-20 13:58:00 +10:00
David Cook
159a0d391c Safely autocorrect Layout/ClosingParenthesisIndentation
Inspecting 1478 files
..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C...........................................................................

Offenses:

spec/system/admin/orders_spec.rb:486:9: C: [Corrected] Layout/ClosingParenthesisIndentation: Align ) with (.
        ).to be_checked
        ^
spec/system/admin/orders_spec.rb:494:9: C: [Corrected] Layout/ClosingParenthesisIndentation: Align ) with (.
        ).to_not be_checked
        ^

1478 files inspected, 2 offenses detected, 2 offenses corrected
2023-07-20 13:56:13 +10:00
David Cook
0030343897 Safely autocorrect Layout/BlockEndNewline
Inspecting 1478 files
......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C...................................................................................................................................................................................................................................................................................................................................................................................C...........................................................................

Offenses:

spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:127:1: C: [Corrected] Layout/IndentationWidth: Use 2 (not 10) spaces for indentation.
          create(:enterprise_fee, fee_type: 'packing', amount: 7.89, name: "Packing")
^^^^^^^^^^
spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:127:3: C: [Corrected] Layout/IndentationWidth: Use 2 (not -6) spaces for indentation.
  create(:enterprise_fee, fee_type: 'packing', amount: 7.89, name: "Packing")
  ^^^^^^
spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:127:87: C: [Corrected] Layout/BlockEndNewline: Expression at 127, 87 should be on its own line.
          create(:enterprise_fee, fee_type: 'packing', amount: 7.89, name: "Packing") }
                                                                                      ^
spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:128:1: C: [Corrected] Layout/BlockAlignment: } at 128, 0 is not aligned with let!(:ef_packing) { at 126, 8.
}
^
spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:129:91: C: [Corrected] Layout/BlockEndNewline: Expression at 129, 91 should be on its own line.
          create(:enterprise_fee, fee_type: 'transport', amount: 0.12, name: "Transport") }
                                                                                          ^
spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:130:1: C: [Corrected] Layout/IndentationWidth: Use 2 (not 10) spaces for indentation.
          create(:enterprise_fee, fee_type: 'transport', amount: 0.12, name: "Transport")
^^^^^^^^^^
spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:130:3: C: [Corrected] Layout/IndentationWidth: Use 2 (not -6) spaces for indentation.
  create(:enterprise_fee, fee_type: 'transport', amount: 0.12, name: "Transport")
  ^^^^^^
spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:131:1: C: [Corrected] Layout/BlockAlignment: } at 131, 0 is not aligned with let!(:ef_transport) { at 129, 8.
}
^
spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:131:95: C: [Corrected] Layout/BlockEndNewline: Expression at 131, 95 should be on its own line.
          create(:enterprise_fee, fee_type: 'fundraising', amount: 3.45, name: "Fundraising") }
                                                                                              ^
spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:133:1: C: [Corrected] Layout/IndentationWidth: Use 2 (not 10) spaces for indentation.
          create(:enterprise_fee, fee_type: 'fundraising', amount: 3.45, name: "Fundraising")
^^^^^^^^^^
spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:133:3: C: [Corrected] Layout/IndentationWidth: Use 2 (not -6) spaces for indentation.
  create(:enterprise_fee, fee_type: 'fundraising', amount: 3.45, name: "Fundraising")
  ^^^^^^
spec/lib/open_food_network/enterprise_fee_calculator_spec.rb:134:1: C: [Corrected] Layout/BlockAlignment: } at 134, 0 is not aligned with let!(:ef_fundraising) { at 132, 8.
}
^
spec/system/admin/orders_spec.rb:44:1: C: [Corrected] Layout/IndentationWidth: Use 2 (not 1) spaces for indentation.
 create(:shipping_method_with, :pickup, name: "delivery",
^
spec/system/admin/orders_spec.rb:44:3: C: [Corrected] Layout/IndentationWidth: Use 2 (not 0) spaces for indentation.
  create(:shipping_method_with, :pickup, name: "delivery",

spec/system/admin/orders_spec.rb:45:45: C: [Corrected] Layout/BlockEndNewline: Expression at 45, 45 should be on its own line.
distributors: [distributor4, distributor5]) }
                                            ^
spec/system/admin/orders_spec.rb:46:1: C: [Corrected] Layout/BlockAlignment: } at 46, 0 is not aligned with let!(:shipping_method2) { at 43, 2.
}
^

1478 files inspected, 16 offenses detected, 16 offenses corrected
2023-07-20 13:54:30 +10:00
David Cook
7cbe1d94ad Safely autocorrect Layout/BlockAlignment
Inspecting 1478 files
...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C..................................................................................................................................................................................

Offenses:

spec/services/products_renderer_spec.rb:28:7: C: [Corrected] Layout/BlockAlignment: } at 28, 6 is not aligned with let!(:product_cherries) { at 25, 4.
      }
      ^

1478 files inspected, 1 offense detected, 1 offense corrected
2023-07-20 13:52:44 +10:00
David Cook
5a3a4a041f Safely autocorrect Layout/ArrayAlignment
Inspecting 1478 files
..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C......................CC.........................................C.................................

Offenses:

spec/system/admin/customers_spec.rb:40:13: C: [Corrected] Layout/ArrayAlignment: Align the elements of an array literal if they span more than one line.
            managed_distributor2.name], without_options: [unmanaged_distributor.name]
            ^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/customers_spec.rb:40:101: C: Layout/LineLength: Line is too long. [126/100]
                                                     managed_distributor2.name], without_options: [unmanaged_distributor.name]
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_spec.rb:742:1: C: [Corrected] Layout/ArrayAlignment: Align the elements of an array literal if they span more than one line.
different_shipping_method_for_distributor1]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/orders_spec.rb:48:33: C: [Corrected] Layout/ArrayAlignment: Align the elements of an array literal if they span more than one line.
                                distributor3, distributor4],
                                ^^^^^^^^^^^^
spec/system/consumer/shopping/cart_spec.rb:21:37: C: [Corrected] Layout/ArrayAlignment: Align the elements of an array literal if they span more than one line.
                                    product_with_fee.variants.first])
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1478 files inspected, 5 offenses detected, 4 offenses corrected
2023-07-20 13:50:55 +10:00
David Cook
bcfa70af4e Safely autocorrect Layout/ArgumentAlignment
Inspecting 1478 files
...................................................................................................................................................C..C.......................................................................................................C........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C..........................................C................................................................................................................................................................................................C..................................................................C............C..................CC............................................C......C..........................

Offenses:

app/controllers/spree/users_controller.rb:37:15: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
              locals: { type: "alert", message: t('devise.failure.already_registered') })
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/controllers/spree/users_controller.rb:52:13: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
            locals: { type: "success", ...
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
app/controllers/user_confirmations_controller.rb:28:11: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
          locals: { type: "success", message: t("devise.confirmations.send_instructions") })
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/enterprise.rb:54:5: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
    inverse_of: :distributor, foreign_key: :distributor_id
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/enterprise.rb:56:5: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
    inverse_of: :distributor, foreign_key: :distributor_id
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/enterprise.rb:118:5: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
    format: { ...
    ^^^^^^^^^
spec/lib/reports/packing/packing_report_spec.rb:60:11: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
          product: create(:simple_product, name: "visible", supplier: supplier1))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/lib/reports/packing/packing_report_spec.rb:64:11: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
          product: create(:simple_product, name: "not visible", supplier: supplier2))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/migrations/migrate_customer_names_spec.rb:16:7: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
      value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise1.id}")
      ^^^^^^^^^^^^^^^^^^^^^
spec/migrations/migrate_customer_names_spec.rb:16:101: C: Layout/LineLength: Line is too long. [122/100]
                             value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise1.id}")
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^
spec/migrations/migrate_customer_names_spec.rb:18:7: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
      value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise2.id}")
      ^^^^^^^^^^^^^^^^^^^^^
spec/migrations/migrate_customer_names_spec.rb:18:101: C: Layout/LineLength: Line is too long. [122/100]
                             value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise2.id}")
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^
spec/migrations/migrate_customer_names_spec.rb:20:7: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
      value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise4.id}")
      ^^^^^^^^^^^^^^^^^^^^^
spec/migrations/migrate_customer_names_spec.rb:20:101: C: Layout/LineLength: Line is too long. [122/100]
                             value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise4.id}")
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^
spec/services/products_renderer_spec.rb:91:13: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
            { q: { with_properties: [property_organic.id] } })
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/services/products_renderer_spec.rb:91:101: C: Layout/LineLength: Line is too long. [101/100]
                                                   { q: { with_properties: [property_organic.id] } })
                                                                                                    ^
spec/services/products_renderer_spec.rb:100:13: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
            { q: { with_properties: [property_organic.id] } })
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/services/products_renderer_spec.rb:100:101: C: Layout/LineLength: Line is too long. [101/100]
                                                   { q: { with_properties: [property_organic.id] } })
                                                                                                    ^
spec/services/products_renderer_spec.rb:118:13: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
            { q: { with_properties: [property_organic.id] } })
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/services/products_renderer_spec.rb:118:101: C: Layout/LineLength: Line is too long. [101/100]
                                                   { q: { with_properties: [property_organic.id] } })
                                                                                                    ^
spec/system/admin/bulk_order_management_spec.rb:268:11: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
          text: "#{o1.bill_address.last_name}, #{o1.bill_address.first_name}"
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/bulk_order_management_spec.rb:793:9: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
        retry: 3 do
        ^^^^^^^^
spec/system/admin/enterprise_fees_spec.rb:103:9: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
        from: "#{prefix}_tax_category_id"
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/enterprise_fees_spec.rb:129:9: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
        from: "#{prefix}_calculator_type"
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/enterprise_fees_spec.rb:133:9: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
        from: "#{prefix}_calculator_type"
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/enterprise_fees_spec.rb:160:9: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
        from: "#{prefix}_calculator_type"
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/enterprise_fees_spec.rb:221:13: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
            selected: 'Second Distributor'
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/enterprise_fees_spec.rb:232:43: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
                                          'Flat Rate (per order)', message, 0
                                          ^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_cycles/list_spec.rb:148:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
match: :first).value).to start_with oc_open_at.strftime("%Y-%m-%d %H:%M")
^^^^^^^^^^^^^
spec/system/admin/order_cycles/list_spec.rb:161:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
match: :first).value).to eq oc_open_at.strftime("%Y-%m-13 %H:%M")
^^^^^^^^^^^^^
spec/system/admin/order_cycles/list_spec.rb:189:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
match: :first).value).to eq test_value.to_datetime.strftime("%Y-%m-%d %H:%M")
^^^^^^^^^^^^^
spec/system/admin/order_cycles/simple_spec.rb:346:13: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
            with_options: [schedule_of_other_managed_distributor.name]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_cycles/simple_spec.rb:346:101: C: Layout/LineLength: Line is too long. [101/100]
                                           with_options: [schedule_of_other_managed_distributor.name]
                                                                                                    ^
spec/system/admin/order_cycles/simple_spec.rb:623:9: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
        value: Time.zone.local(2040, 10, 17, 0o6, 0o0, 0o0).strftime("%F %T %z"), visible: false
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_cycles/simple_spec.rb:623:101: C: Layout/LineLength: Line is too long. [121/100]
                                 value: Time.zone.local(2040, 10, 17, 0o6, 0o0, 0o0).strftime("%F %T %z"), visible: false
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_cycles/simple_spec.rb:625:9: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
        value: Time.zone.local(2040, 10, 24, 17, 0o0, 0o0).strftime("%F %T %z"), visible: false
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_cycles/simple_spec.rb:625:101: C: Layout/LineLength: Line is too long. [120/100]
                                 value: Time.zone.local(2040, 10, 24, 17, 0o0, 0o0).strftime("%F %T %z"), visible: false
                                                                                                    ^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_cycles/simple_spec.rb:733:9: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
        value: Time.zone.local(2040, 10, 17, 0o6, 0o0, 0o0).strftime("%F %T %z"), visible: false
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_cycles/simple_spec.rb:733:101: C: Layout/LineLength: Line is too long. [121/100]
                                 value: Time.zone.local(2040, 10, 17, 0o6, 0o0, 0o0).strftime("%F %T %z"), visible: false
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_cycles/simple_spec.rb:735:9: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
        value: Time.zone.local(2040, 10, 24, 17, 0o0, 0o0).strftime("%F %T %z"), visible: false
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/admin/order_cycles/simple_spec.rb:735:101: C: Layout/LineLength: Line is too long. [120/100]
                                 value: Time.zone.local(2040, 10, 24, 17, 0o0, 0o0).strftime("%F %T %z"), visible: false
                                                                                                    ^^^^^^^^^^^^^^^^^^^^
spec/system/consumer/shopping/cart_spec.rb:147:35: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
                                  preferred_unit_from_list: "kg"),
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/consumer/shopping/cart_spec.rb:147:101: C: Layout/LineLength: Line is too long. [101/100]
                                                                     preferred_unit_from_list: "kg"),
                                                                                                    ^
spec/system/consumer/shopping/products_spec.rb:98:11: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
          "<script>alert('Dangerous!');</script>", truncate: false)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/system/consumer/shopping/products_spec.rb:98:101: C: Layout/LineLength: Line is too long. [113/100]
                                                        "<script>alert('Dangerous!');</script>", truncate: false)
                                                                                                    ^^^^^^^^^^^^^

1478 files inspected, 45 offenses detected, 32 offenses corrected
2023-07-20 13:48:51 +10:00
David Cook
bb728d97fd Regenerate Rubocop's TODO file 2023-07-20 13:46:52 +10:00
Maikel
fd05f41349 Merge pull request #11236 from filipefurtad0/BO_out_of_stock_warning
Adds assertion on the Out of Stock message
2023-07-20 10:19:41 +10:00
David Cook
cdffeea5cb Merge pull request #10966 from macanudo527/fix_linelength_bundle3
Fix Layout/LineLength - Bundle 3
2023-07-20 10:04:24 +10:00
Maikel
f82222d97c Merge pull request #11239 from filipefurtad0/missing_translation_on_invoices_tab
Fixes missing translation on Invoices tab
2023-07-20 08:42:36 +10:00
filipefurtad0
8f8e28f816 Fixes missing translation on Invoices tab
Adds invoices to en.yml, fixing #11237
2023-07-19 18:11:45 +01:00
filipefurtad0
537e225c84 Adds assertion on the Out of Stock message 2023-07-19 16:28:06 +01:00
Jean-Baptiste Bellet
1750575f8c Need to update tab before updating panel since we retrieve panel from tab 2023-07-19 16:28:10 +02:00
Jean-Baptiste Bellet
695f76d3b6 Update format to be solve prettier warnings 2023-07-19 16:28:03 +02:00
Jean-Baptiste Bellet
0065ece6a6 Show vouchers panel only if enterprise sells products (own or any) 2023-07-19 16:02:16 +02:00
jibees
49a192eacc Merge pull request #11231 from openfoodfoundation/dependabot/bundler/mini_portile2-2.8.4
chore(deps): bump mini_portile2 from 2.8.2 to 2.8.4
2023-07-19 15:13:50 +02:00
jibees
821e5226fa Merge pull request #11232 from openfoodfoundation/dependabot/bundler/knapsack_pro-5.3.0
chore(deps-dev): bump knapsack_pro from 5.2.0 to 5.3.0
2023-07-19 15:11:27 +02:00
Jean-Baptiste Bellet
5d4ef5b52c To test the search by category, we need to use set primary_taxon attr 2023-07-19 14:58:40 +02:00
Jean-Baptiste Bellet
bada2ef4a7 Remove useless spec (will be tested right after) 2023-07-19 14:58:40 +02:00
Jean-Baptiste Bellet
62eaf4a1a9 This spec is not flaky anymore 2023-07-19 14:58:40 +02:00
Jean-Baptiste Bellet
55cad3659f Simplify products creation 2023-07-19 14:58:40 +02:00
Jean-Baptiste Bellet
6f6de00919 Better naming of argument to not override existing variable... 2023-07-19 14:58:40 +02:00
Jean-Baptiste Bellet
3fab9714f5 Use a constant as the search_key 2023-07-19 14:58:40 +02:00
Jean-Baptiste Bellet
79421f2265 Expect to found the product 2023-07-19 14:58:40 +02:00
Jean-Baptiste Bellet
2697a637a9 Use the OpenFoodNetwork::Permissions helper
To retrieve only primary producers
2023-07-19 14:58:40 +02:00
jibees
3245f7ff99 Update app/reflexes/products_reflex.rb
Co-authored-by: David Cook <david@redcliffs.net>
2023-07-19 14:58:40 +02:00
Jean-Baptiste Bellet
b42dfb574b Delete already imported (and modified) file 2023-07-19 14:58:40 +02:00
Jean-Baptiste Bellet
90c6398197 Simplify and call methods directly via before_reflex 2023-07-19 14:58:40 +02:00
Jean-Baptiste Bellet
b3bdba3a9b Better use merge! instead of q = q.merge 2023-07-19 14:58:40 +02:00
Jean-Baptiste Bellet
755a1842c2 Simplify to save execution time 2023-07-19 14:58:40 +02:00
Jean-Baptiste Bellet
037589ecda Add columns translation 2023-07-19 14:58:40 +02:00
Jean-Baptiste Bellet
dec779a357 available_on column has been deleted
https://github.com/openfoodfoundation/openfoodnetwork/pull/11136
2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
fac02c794c Search through more attributes than only name
Copy/paste from `app/assets/javascripts/darkswarm/controllers/products_controller.js.coffee`
2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
010f19cb83 Create a medium height button, and adjust #sort row 2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
c378ad1d88 Add "no results found" container 2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
5a8a187f54 Add clear search button and action 2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
904c7bfacf Buttons design
Remove already defined `$border-radius`

Defined `app/webpacker/css/admin/globals/variables.scss`

Adjust height
2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
7b56cbf3d4 Add labels to selectors, and adjust css
+ Adjusting filter elements with flex-grow properties
2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
333dc11fc1 Manage form params vs. URL params. And replace state with params.
"One needs to understand what the source of the params in a reflex is. And there are two sources:

the closest form
the url of the currently displayed page"

Source: https://github.com/stimulusreflex/stimulus_reflex/issues/290#issuecomment-683334963
2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
bfe1884ab5 Can filter by categories 2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
ef1702188f Extract filters from 'no products found' logic
We still want to display filters if no products found
2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
f58cf2d3b2 Can filter by producer
Not sur the request nor the `producers` in the reflex should be like this. This is a proof of concept, and should probably be reviewed

Fix linter issues
2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
ddfc60c85e Don't use events, but call the loading controller itself 2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
762b777995 Design of the search button 2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
51e139b6f1 Create first spec for the new products page
Modify comment, and contextualize search (inside search term)

Extract creation of products outside a before block
2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
38d0af8ec0 Simplify: don't need to pass through the js controller
Use the reflex itself

+ Don't need to create a method that will be called only in the connect

+ Simply code by adding only two lifecycle methods

Actually it seems that all reflex related to products controller should show/hide loading
2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
9d52f0b20a Loading spinner should be above content (filters, sort, ...) 2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
643897abb2 Add search functionnality 2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
c786f300ca Have a tiny url state management by using replace_state of cable_ready 2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
0fd4d892d9 This is now unused: through the js controller only at startup 2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
3da6e02192 Call pagination via perPage param: no state to manage, use param 2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
61d1f30e04 Rename productsV3 to products: avoid upper|lower case issues
This is causing some issues, misunderstandings around case.

Therefore, directly use the Reflex, and lifecycle methods `beforeFetch` and `afterFetch` are called, even if we use the Reflex (and not the js controller methods). This is pretty handy.

+ adds some id to pagination element (https://docs.stimulusreflex.com/guide/reflexes.html#declaring-a-reflex-in-html-with-data-attributes)

Global documentation: https://docs.stimulusreflex.com/guide/reflexes.html
2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
574adb88d2 Add a per page component
This is still a WIP.
2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
0b83dc088d Separation of concerns: use a loading controller
Two different events can be used: `show-loading` and `hide-loading`.

I'm not 100% sure this is the right way to go, but let's try!
2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
5aebbe4102 use beforeFetch and afterFetch lifecycle methods
+ Move outside `Admin` module the reflex

Therefore, this reflex should be _equivalent_ to its javascript controller: `ProductsV3` (relation is made through names)

Remove unwanted line

Actually call StimulusJS controller instead of calling the reflex itself

In order to have this "showLoading", "hideLoading" behavior.

It seems to be possible to directly use the Reflex itself (use `data-reflex` instead of `data-action`) but I can't make it work: the `stimulus-controller:after` event is never broadcasted/catched (but `stimulus-controller:before` yes...)

Documentation:
https://docs.stimulusreflex.com/guide/reflexes.html#understanding-stimulusreflex-controllers
https://docs.stimulusreflex.com/guide/lifecycle.html#generic-life-cycle-methods

Maybe @dacook if you want to have a look...
2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
3b61508652 Be more specific to only apply to the first container, ie. the root one
+ Override default position (relative) in order to have loading above
2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
47f21cb59e Add pagination with pagy
For `admin_style_v3` use `<` and `>` for next and previous link

instead of `next` and `previous` string

Extract a mixin for a default box-shadow

Maybe this needs to be redefined. Let's see how next things goes.

When a table is followed by a pagination, remove its margin-bottom + border

Finally, design the pagination component

Add sorting/pagination module, on top of table

We use `cablea_ready.replace`, so need to add `#products-content` id

Use a `pagy` partial with reflex action, instead of the legacy one

- revert the legacy one to its previous state
 - in reflex, fetch product with page attribute, 1 by default

Move `pagy` into `admin/shared/v3/` to be reusable

+ use fontawesome icons for next and previous page

Remove useless line
2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
69cff85577 Change color to EFF1F2 2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
9b92c25879 Add a section for specific rules for both admin-menu and sub-menu
+ change height for border bottom on selected/hovered menu
2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
9762819aa8 Use the right color 2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
1f3d41972f Add same padding than #admin-menu,#sub-menu li a in order to align
content (header, navigation, content) on both left and right
2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
2892301336 Factorize menu and submenu into same definition
as they are the same, expect the font-size
2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
24c045a09c Reduce padding 2023-07-19 14:58:39 +02:00
Jean-Baptiste Bellet
a8088ae231 Create a pseudo element to add a line under the menu item
- Increase top menu underline height to 3px
 - reduce underline width to same width of label
2023-07-19 14:58:39 +02:00
Konrad
d99ac35824 Merge pull request #11105 from jibees/11098-summary-step-order-details-line-break-on-currency-symbol-and-lettering
Checkout summary: avoid carriage return on price
2023-07-19 13:00:08 +02:00
Filipe
91e2e447c0 Merge pull request #11175 from jibees/11171-checkout-step-3-delivery-details-are-showing-bill-address-instead-of-delivery-address
Checkout, Summary step: Display the ship/delivery address (instead of the billing one)
2023-07-19 11:36:19 +01:00
Filipe
843bcaa500 Merge pull request #11184 from rioug/11183-fix-delete-voucher-tax-excl-price
[vouchers] fix delete voucher when tax excluded from price
2023-07-19 11:24:25 +01:00
dependabot[bot]
314c02a92b chore(deps-dev): bump knapsack_pro from 5.2.0 to 5.3.0
Bumps [knapsack_pro](https://github.com/KnapsackPro/knapsack_pro-ruby) from 5.2.0 to 5.3.0.
- [Changelog](https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v5.2.0...v5.3.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-07-19 09:31:24 +00:00
dependabot[bot]
6c323c82d5 chore(deps): bump mini_portile2 from 2.8.2 to 2.8.4
Bumps [mini_portile2](https://github.com/flavorjones/mini_portile) from 2.8.2 to 2.8.4.
- [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.2...v2.8.4)

---
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-07-19 09:27:32 +00:00
Jean-Baptiste Bellet
731fb3c0b3 Update cable_ready and stimulus_reflex as well
In order to reflect the one used in package.json
2023-07-19 09:05:31 +02:00
dependabot[bot]
385f3964ad chore(deps): bump stimulus_reflex from 3.5.0-rc2 to 3.5.0-rc3
Bumps [stimulus_reflex](https://github.com/stimulusreflex/stimulus_reflex) from 3.5.0-rc2 to 3.5.0-rc3.
- [Release notes](https://github.com/stimulusreflex/stimulus_reflex/releases)
- [Changelog](https://github.com/stimulusreflex/stimulus_reflex/blob/main/CHANGELOG.md)
- [Commits](https://github.com/stimulusreflex/stimulus_reflex/commits)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-19 09:05:31 +02:00
jibees
8475a31ebb Merge pull request #11228 from openfoodfoundation/dependabot/npm_and_yarn/word-wrap-1.2.4
chore(deps): bump word-wrap from 1.2.3 to 1.2.4
2023-07-19 08:51:34 +02:00
dependabot[bot]
dd7e6d1a19 chore(deps): bump word-wrap from 1.2.3 to 1.2.4
Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4.
- [Release notes](https://github.com/jonschlinkert/word-wrap/releases)
- [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4)

---
updated-dependencies:
- dependency-name: word-wrap
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-19 02:14:43 +00:00
Neal Chambers
c1095c3616 Update .rubocop_todo.yml 2023-07-19 08:43:36 +09:00
Neal Chambers
728926cc9a Fix Layout/LineLength 2023-07-19 08:39:26 +09:00
Filipe
40db81f056 Merge pull request #11150 from macanudo527/fix_admin_class_size
Fix Metrics/ClassSize
2023-07-18 19:10:03 +01:00
Filipe
15282f9738 Merge pull request #11115 from abdellani/fix-enterprise-users-should-have-access-to-invoices
authorize enterprise users to access invoices page
2023-07-18 16:42:00 +01:00
jibees
11b2d911d2 Merge pull request #11217 from openfoodfoundation/dependabot/bundler/rubocop-1.54.2
chore(deps-dev): bump rubocop from 1.54.1 to 1.54.2
2023-07-18 17:31:17 +02:00
jibees
bbdeb0c9ab Merge pull request #11213 from openfoodfoundation/dependabot/bundler/rswag-specs-2.10.1
chore(deps-dev): bump rswag-specs from 2.9.0 to 2.10.1
2023-07-18 17:29:37 +02:00
jibees
4e29fcba64 Merge pull request #11210 from openfoodfoundation/dependabot/npm_and_yarn/floating-ui/dom-1.4.5
chore(deps): bump @floating-ui/dom from 1.4.4 to 1.4.5
2023-07-18 17:14:41 +02:00
dependabot[bot]
a975b78816 chore(deps-dev): bump rubocop from 1.54.1 to 1.54.2
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.54.1 to 1.54.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.54.1...v1.54.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-07-18 15:08:00 +00:00
dependabot[bot]
02b1c6dd2d chore(deps-dev): bump rswag-specs from 2.9.0 to 2.10.1
Bumps [rswag-specs](https://github.com/rswag/rswag) from 2.9.0 to 2.10.1.
- [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.9.0...2.10.1)

---
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-07-18 15:07:21 +00:00
jibees
af365c6b79 Merge pull request #11215 from openfoodfoundation/dependabot/bundler/rswag-api-2.10.1
chore(deps): bump rswag-api from 2.9.0 to 2.10.1
2023-07-18 17:06:07 +02:00
jibees
f054b74c7d Merge pull request #11216 from openfoodfoundation/dependabot/bundler/rswag-ui-2.10.1
chore(deps): bump rswag-ui from 2.9.0 to 2.10.1
2023-07-18 17:05:15 +02:00
Filipe
adc5692bc5 Merge pull request #11182 from filipefurtad0/profile_change_spec
Adds spec for profile change
2023-07-18 16:02:39 +01:00
jibees
1d03f7a009 Merge pull request #11224 from openfoodfoundation/dependabot/bundler/knapsack_pro-5.2.0
chore(deps-dev): bump knapsack_pro from 5.1.2 to 5.2.0
2023-07-18 16:30:45 +02:00
dependabot[bot]
74f8f9dd52 chore(deps): bump rswag-api from 2.9.0 to 2.10.1
Bumps [rswag-api](https://github.com/rswag/rswag) from 2.9.0 to 2.10.1.
- [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.9.0...2.10.1)

---
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-07-18 14:28:58 +00:00
dependabot[bot]
dae690ae5c chore(deps): bump rswag-ui from 2.9.0 to 2.10.1
Bumps [rswag-ui](https://github.com/rswag/rswag) from 2.9.0 to 2.10.1.
- [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.9.0...2.10.1)

---
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-07-18 14:28:55 +00:00
dependabot[bot]
53b1188a43 chore(deps): bump @floating-ui/dom from 1.4.4 to 1.4.5
Bumps [@floating-ui/dom](https://github.com/floating-ui/floating-ui/tree/HEAD/packages/dom) from 1.4.4 to 1.4.5.
- [Release notes](https://github.com/floating-ui/floating-ui/releases)
- [Commits](https://github.com/floating-ui/floating-ui/commits/@floating-ui/dom@1.4.5/packages/dom)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-18 14:28:47 +00:00
dependabot[bot]
6c02e1c05d chore(deps-dev): bump knapsack_pro from 5.1.2 to 5.2.0
Bumps [knapsack_pro](https://github.com/KnapsackPro/knapsack_pro-ruby) from 5.1.2 to 5.2.0.
- [Changelog](https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v5.1.2...v5.2.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-18 09:18:55 +00:00
Gaetan Craig-Riou
a5b2bc6293 Per review, Refactor VoucherAdjustmentsService
Change #calculate to #update and clean up internal code
2023-07-18 15:16:21 +10:00
Gaetan Craig-Riou
a584f9aaec Refactor VoucherAdjustmentsService
It's more inline with existing coding style
2023-07-18 14:39:01 +10:00
David Cook
46b27b2d9d Number release steps
There are three distinct parts to the process, so I thought it worth giving them an identifying number.
2023-07-18 09:34:28 +10:00
Neal Chambers
8fc0a20249 Add Additional Test for Model Creation 2023-07-18 08:17:34 +09:00
Neal Chambers
ba862bc4b7 Add tests for Enterprise Fees Bulk Update 2023-07-18 08:17:34 +09:00
Neal Chambers
186d7a2f54 Move and Rename BulkUpdateForm 2023-07-18 08:17:34 +09:00
David Cook
9b16c1171f Remove redundant returns
The return value of active record validations doesn't actually do anything. A record is 'valid?' if @errors is empty.
2023-07-18 08:17:34 +09:00
Neal Chambers
521af70959 Add Strong Params to Enterprise Fees Form 2023-07-18 08:17:34 +09:00
Neal Chambers
9e17b80ea9 Update .rubocop_todo.yml 2023-07-18 08:17:34 +09:00
Neal Chambers
fb1ae855c2 Fix Metrics/ClassLength 2023-07-18 08:17:34 +09:00
filipefurtad0
e14bc5e642 Adds comments on producer_profile_only attribute
Fixing typo
2023-07-17 15:06:02 +01:00
filipefurtad0
16477cad51 Adds spec for profile change (2)
via enterprises path
2023-07-17 15:06:02 +01:00
filipefurtad0
e0be25f927 Adds spec for profile change
via admin path
2023-07-17 15:06:02 +01:00
Jean-Baptiste Bellet
1cf647e04b Avoid line-break by wrapping into nowrap element 2023-07-17 14:00:48 +02:00
Jean-Baptiste Bellet
776b9adc72 Display shipping address in summary step, instead of the billing one
+ update specs accordingly
2023-07-17 09:37:05 +02:00
Jean-Baptiste Bellet
f177258444 Randomize also city and zipcode for randomized address 2023-07-17 09:33:29 +02:00
filipefurtad0
bfb2fc528e Update all locales with the latest Transifex translations 2023-07-14 17:37:22 +01:00
dependabot[bot]
654601f4b2 chore(deps): bump stripe from 8.5.0 to 8.6.0
Bumps [stripe](https://github.com/stripe/stripe-ruby) from 8.5.0 to 8.6.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.5.0...v8.6.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-07-14 09:09:19 +00:00
Gaetan Craig-Riou
0e0850ef49 Add specs to cover re calculation
It is important that the calculated voucher adjustments don't change
if they are recalculated and it is equally important that they are
updated if the order has changed
2023-07-14 14:47:39 +10:00
Gaetan Craig-Riou
5a59396a41 Remove call to VoucherAdjustmentService when creating a voucher
Voucher will be automatically applied when the order transition to
the confirmation step. No need to do the work twice.
2023-07-14 14:47:39 +10:00
Gaetan Craig-Riou
3d9542fec2 Per review, rename amount to adjustment_amount
It was confusing as I was re assigning a variable given as a parameter
2023-07-14 14:47:39 +10:00
Gaetan Craig-Riou
41271192e1 Per review, Makes quantity change more explicit 2023-07-14 14:47:39 +10:00
Gaetan Craig-Riou
751056ba39 As per review comment, spell out voucher code when entering a voucher
Plus, update other related spec to be consistent
2023-07-14 14:47:39 +10:00
Gaetan Craig-Riou
789ce39ff4 Fixing Rubocop errors 2023-07-14 14:47:39 +10:00
Gaetan Craig-Riou
a8062e951a Add a scenario to make sure voucher adjustment a recalculated
This is specificly for voucher with a tax component, but it will
also become relevant for percentage based voucher.
2023-07-14 14:47:03 +10:00
Gaetan Craig-Riou
edabc56b5c Add voucher calculation after updating an order
This is to make sure the voucher are recalculated when a customer
update the order content from the `/cart` page. This is tested
with system test
2023-07-14 14:47:03 +10:00
Gaetan Craig-Riou
ca7dcb82b8 Apply voucher after transitionning to the confirmation step
Testing that VoucherAdjustmentsService.calculate has been called after a
transition doens't work, skipping test for now.
2023-07-14 14:47:03 +10:00
Gaetan Craig-Riou
366cca7984 Prevent voucher adjustment from bein updated when update is called 2023-07-14 14:47:03 +10:00
Gaetan Craig-Riou
87790b29ae Fix VoucherAdjustmentsService.calculate so we can call it mutiple time
It now uses `order.pre_discount_total` to make any calculation, that
means you can call it multiple time and you will still get the same
adjustment amount, included_tax and tax adjustment when needed. This
is assuming nothing changed on the order.
2023-07-14 14:47:03 +10:00
Gaetan Craig-Riou
60c0c54eb2 Update create_adjustment to create with an amount of 0
Amount calculation is handled by VoucherAdjustmentService.calculate
2023-07-14 14:47:03 +10:00
Matt-Yorkley
04bbea53e1 Move voucher processing out of checkout controller 2023-07-14 14:46:16 +10:00
Gaetan Craig-Riou
dc711bde78 Fix voucher adjustment delete
When using a voucher with tax not incluced in price, we need to delete
both the voucher adjustment and the tax adjustment
2023-07-14 13:37:45 +10:00
Konrad
bddc10626b Merge pull request #11148 from cillian/fix-duplicate-rows-in-customer-addresses-report
Don't return duplicate rows in the customer addresses report
2023-07-13 20:32:01 +02:00
Filipe
9e0aa1854f Merge pull request #11159 from abdellani/remove-split-checkout-from-feature_toggle
Remove split checkout from feature toggle
2023-07-13 17:20:18 +01:00
Filipe
308ce9263d Merge pull request #11170 from jibees/11160-bulk-actions-function-not-working-on-safari-mac-browser
Admin, Orders: Make bulk actions dropdown re-enabled for Safari browser
2023-07-13 17:17:18 +01:00
Filipe
2f8a056bee Merge pull request #11187 from jibees/10975-white-label-remember-custom-tab-activation-after-error-message
Admin, White Label: check the custom tab checkbox if any errors on custom tab (ie. title is blank)
2023-07-13 16:43:18 +01:00
Filipe
60c75097d3 Merge pull request #11145 from mkllnk/dfc-create-response
DFC API return SuppliedProduct after creation
2023-07-13 16:15:22 +01:00
Filipe
448d5ea017 Merge pull request #11135 from Matt-Yorkley/vouchers
Vouchers part 2
2023-07-13 12:50:32 +01:00
jibees
9f86218a83 Merge pull request #11202 from openfoodfoundation/dependabot/bundler/view_component-3.4.0
chore(deps): bump view_component from 3.3.0 to 3.4.0
2023-07-12 16:00:48 +02:00
dependabot[bot]
e03ffa0405 chore(deps): bump view_component from 3.3.0 to 3.4.0
Bumps [view_component](https://github.com/viewcomponent/view_component) from 3.3.0 to 3.4.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/v3.3.0...v3.4.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-12 09:25:11 +00:00
jibees
f22b8db462 Merge pull request #11191 from openfoodfoundation/dependabot/npm_and_yarn/semver-5.7.2
chore(deps): bump semver from 5.7.1 to 5.7.2
2023-07-11 17:38:28 +02:00
dependabot[bot]
90ad6ce19d chore(deps): bump semver from 5.7.1 to 5.7.2
Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2.
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md)
- [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-11 09:43:07 +00:00
Matt-Yorkley
4884a8c368 Merge pull request #11179 from openfoodfoundation/dependabot/npm_and_yarn/cable_ready-5.0.1
chore(deps): bump cable_ready from 5.0.0 to 5.0.1
2023-07-11 10:42:37 +01:00
David Cook
d03b88cf83 Rename variables
To make it clear they are arrays
2023-07-11 10:48:52 +02:00
Jean-Baptiste Bellet
0fdf7876a6 Instanciate instance variable + use spread operator to be more concise
and efficient ;)
2023-07-11 10:48:52 +02:00
Jean-Baptiste Bellet
4bcba86fc8 Avoid error when testing through jest about removing event listenner
Avoid:
```
  TypeError: Cannot read properties of null (reading 'removeEventListener')
        at extended.disconnect (/home/runner/work/openfoodnetwork/openfoodnetwork/app/webpacker/controllers/dropdown_controller.js:32:14)
        at Context.disconnect (/home/runner/work/openfoodnetwork/openfoodnetwork/node_modules/stimulus/dist/stimulus.umd.js:1441:25)
```
2023-07-11 10:48:52 +02:00
Jean-Baptiste Bellet
6143f4ce6f Use dropdown controller to manager actions dropdown in orders page 2023-07-11 10:48:52 +02:00
Jean-Baptiste Bellet
7084c53f38 Do not display menu is the dropdown is 'disabled'
ie. classList contains `disabled`
2023-07-11 10:48:52 +02:00
Jean-Baptiste Bellet
02aea989be Add on_click_outside behavior on dropdown_controller
"It's a Surprise Tool That Will Help Us Later"
2023-07-11 10:48:52 +02:00
Jean-Baptiste Bellet
d78af187e0 Allow dropdown controller to toggle more than one class
"It's a Surprise Tool That Will Help Us Later"
2023-07-11 10:48:51 +02:00
Mohamed ABDELLANI
4b003aa08b replace status:status with cancelled:boolean on invoice model 2023-07-11 09:15:25 +01:00
David Cook
bb1d053825 Merge pull request #11162 from dacook/DropSpreePromotionTables
Drop unused Spree Promotion Tables
2023-07-11 10:16:45 +10:00
Jean-Baptiste Bellet
a8b9d9d8af Check the custom tab checkbox if any errors (ie. title is blank) 2023-07-10 16:31:33 +02:00
Gaetan Craig-Riou
9f1b4f56c0 Merge pull request #11181 from openfoodfoundation/dependabot/npm_and_yarn/tough-cookie-4.1.3
chore(deps): bump tough-cookie from 4.0.0 to 4.1.3
2023-07-10 12:03:02 +10:00
David Cook
b6d10df332 DropSpreePromotionTables 2023-07-10 10:51:44 +10:00
dependabot[bot]
c299f891e0 chore(deps): bump tough-cookie from 4.0.0 to 4.1.3
Bumps [tough-cookie](https://github.com/salesforce/tough-cookie) from 4.0.0 to 4.1.3.
- [Release notes](https://github.com/salesforce/tough-cookie/releases)
- [Changelog](https://github.com/salesforce/tough-cookie/blob/master/CHANGELOG.md)
- [Commits](https://github.com/salesforce/tough-cookie/compare/v4.0.0...v4.1.3)

---
updated-dependencies:
- dependency-name: tough-cookie
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-09 11:11:55 +00:00
dependabot[bot]
2310c665c3 chore(deps): bump cable_ready from 5.0.0 to 5.0.1
Bumps [cable_ready](https://github.com/stimulusreflex/cable_ready) from 5.0.0 to 5.0.1.
- [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/compare/v5.0.0...v5.0.1)

---
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-07-07 09:35:52 +00:00
David Cook
17da66b72a Update contents of variable directly
Also, it makes the line shorter, allowing us to use one-line if syntax :)
2023-07-07 14:22:36 +10:00
Mohamed ABDELLANI
f68064480a authorize distributor manager to generate invoices 2023-07-06 17:36:13 +01:00
Maikel Linke
11a4cd8613 Protect invoicing against unauthorized use
This could be optimised for performance but this was the simplest way
and we can work on it if performance becomes a problem.
2023-07-06 17:36:13 +01:00
Maikel Linke
15c30246a5 Allow to see only invoices of managed enterprises 2023-07-06 17:36:13 +01:00
Maikel Linke
46410b5be2 Test the right invoices controller
I was wondering why the spec didn't work and then I noticed that it was
testing the wrong controller and passing the wrong parameter.
2023-07-06 17:36:13 +01:00
Maikel Linke
85002d3804 Spec bug allowing any enterprise to view invoices 2023-07-06 17:36:13 +01:00
Maikel Linke
145696aa7f Create only used test data
The `params` and the user are created before the request. But, for
example, the enterprise user doesn't need creating when testing
permissions of the normal user.
2023-07-06 17:36:13 +01:00
Mohamed ABDELLANI
3a9a023dea authorize enterprise users to access invoices page 2023-07-06 17:36:13 +01:00
Matt-Yorkley
652beac73f Drop valid? check from zero_priced_order? method 2023-07-05 15:31:05 +01:00
Mohamed ABDELLANI
17b71b0f8d remove split checkout context from customer spec
We don't need to enable split checkout, as this is default and unique mode.
2023-07-05 14:54:07 +01:00
Mohamed ABDELLANI
a89451e667 remove splitcheckout from feature toggle list 2023-07-05 14:53:40 +01:00
David Cook
7e0042ea1d Apply code suggestion
Co-authored-by: Gaetan Craig-Riou <gaetan.riou@gmail.com>

Co-authored-by: Gaetan Craig-Riou <40413322+rioug@users.noreply.github.com>
2023-07-05 11:27:03 +10:00
Cillian O'Ruanaidh
a80ff6097a Improve formatting in spec/lib/reports/customers_report_spec.rb 2023-07-04 18:27:57 +01:00
Matt-Yorkley
671dfc7082 Don't flush errors when checking zero priced order validity 2023-07-04 14:42:31 +01:00
Matt-Yorkley
66a546027f Add test coverage for handling zero priced orders 2023-07-04 13:13:05 +01:00
Gaetan Craig-Riou
74073946e6 Move VoucherAdjustmentsController to request specs 2023-07-04 13:13:05 +01:00
Matt-Yorkley
55cc57cf87 Use pre_discount_total when comparing to voucher amount 2023-07-04 13:13:05 +01:00
Matt-Yorkley
ad6d0c1c73 Add nil safety in reports for zero priced orders with no payment method 2023-07-04 13:13:05 +01:00
Matt-Yorkley
2aa3f8eb89 Fix flaky test 2023-07-04 13:13:05 +01:00
Matt-Yorkley
f7912a2240 Fix CSS/layout issues 2023-07-04 13:13:05 +01:00
Matt-Yorkley
672400192f Update use of params 2023-07-04 13:13:05 +01:00
Matt-Yorkley
37a4c73a12 Fix rubocop complaint 2023-07-04 13:13:05 +01:00
Matt-Yorkley
9b45b71696 Improve feature toggling 2023-07-04 13:13:05 +01:00
Matt-Yorkley
2f0f3e0820 Re-enable voucher test 2023-07-04 13:13:05 +01:00
Matt-Yorkley
28795effc3 Clarify named vouchers in UI 2023-07-04 13:13:05 +01:00
Matt-Yorkley
de97e69e7d Show/hide payment methods if voucher changes order total to zero 2023-07-04 13:13:05 +01:00
Matt-Yorkley
55bce9f1b2 Remove @voucher_adjustment instance variable 2023-07-04 13:13:05 +01:00
Matt-Yorkley
7a0b83076b Move loading of saved cards out of checkout concern 2023-07-04 13:13:05 +01:00
Matt-Yorkley
1cd38c957d Introduce "zero priced orders" in admin order payments UI and helper 2023-07-04 13:13:05 +01:00
Matt-Yorkley
bd29a9acde Introduce "zero priced orders" to checkout UI and order state flow 2023-07-04 13:13:05 +01:00
Matt-Yorkley
a65b3b8b60 Extract voucher tests to separate controller spec 2023-07-04 13:13:05 +01:00
Matt-Yorkley
d7950617ec Drop superfluous method 2023-07-04 13:13:05 +01:00
Matt-Yorkley
47b5a3fb1d Don't apply tax calculations if there's no tax 2023-07-04 13:13:05 +01:00
Matt-Yorkley
9e5061fc31 Move voucher processing out of checkout controller 2023-07-04 13:13:05 +01:00
Matt-Yorkley
91004588f6 Add separate voucher form 2023-07-03 11:03:05 +01:00
Matt-Yorkley
3f83da9928 Move voucher section out of main checkout form 2023-07-03 11:03:05 +01:00
Matt-Yorkley
e04a3f6b4d Move form definition down into each checkout step 2023-07-03 11:03:05 +01:00
Matt-Yorkley
75e6ccd580 Simplify voucher controller 2023-07-03 11:03:05 +01:00
Matt-Yorkley
3d44f4bc98 Introduce "zero priced order" concept with no required payment
This applies to cases where an order contains items with zero price or where applied vouchers have reduced the order's total to zero.
2023-07-03 11:03:05 +01:00
Maikel Linke
4a562d0e7f Add workaround for updated DFC v1.8 URLs
Once the DFC Connector was updated we can all use the new URLs. But for
now we have the old ones and add some compatibility to the old ones.
2023-07-03 16:05:18 +10:00
Maikel Linke
fc46dbacdc Spec DFC Connector import behaviour around context
The DFC updated the URLs in their context, basically changing the ids of
all data types. I'll add a hacky workaround in the next commit.
2023-07-03 16:05:18 +10:00
Maikel Linke
9183c8acdd Deal with bad SuppliedProduct data 2023-07-03 14:17:18 +10:00
Maikel Linke
18bcc179ef Clarify request body required to create product
We have to work around an Rswag limitation here. But I think that this
version is clearer on the spec.
2023-07-03 14:17:18 +10:00
Maikel Linke
d5c41980d6 Document example for updating SuppliedProduct 2023-07-03 13:44:57 +10:00
Maikel Linke
7dc6cb151d Include DFC context in spec example
The DFC Prototype does include the context while the output of the DFC
Connector refers to the URL of the published context. While that's more
efficient, it's also brittle because the context is updated from time to
time. That happened three days ago and working with the newly published
context breaks our integration until we get an updated version of the
DFC Connector containing the new URLs for datatypes.
2023-07-03 13:27:24 +10:00
Maikel Linke
7b9e4f6914 Move test files to own directory 2023-07-03 13:25:55 +10:00
Maikel Linke
811740c361 Correct OFN session cookie name
And improve the documentation in general.
2023-07-03 13:25:55 +10:00
Maikel Linke
7a51995aeb Respond with SuppliedProduct data when creating 2023-07-03 12:37:23 +10:00
Maikel Linke
5a4efdbce3 Separate DFC API swagger config
This allows us to run the specs separately to generate the
documentation. It's more efficient this way and the separate swagger doc
file is easier to read.

The engine-specific swagger helper also allows us to simplify the spec
files.

Added an exception to our styleguide because it's intended and useful to
have a complete (lengthy) description of the API in one block.
2023-07-03 12:37:23 +10:00
Cillian O'Ruanaidh
bf44284237 Don't return duplicate rows in the customer addresses report 2023-06-30 17:10:44 +01:00
616 changed files with 14840 additions and 6198 deletions

8
.env
View File

@@ -52,6 +52,8 @@ SMTP_PASSWORD="f00d"
# see="https://developers.google.com/maps/documentation/javascript/get-api-key
# GOOGLE_MAPS_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# see https://developers.google.com/maps/documentation/javascript/localization#Region
# GOOGLE_MAPS_REGION="XX"
# Stripe details for instance account
# Find these under 'Developers' -> 'API keys' in your Stripe account dashboard.
@@ -61,3 +63,9 @@ SMTP_PASSWORD="f00d"
# STRIPE_INSTANCE_PUBLISHABLE_KEY="pk_test_xxxx" # This can be a test key or a live key
# STRIPE_CLIENT_ID="ca_xxxx" # This can be a development ID or a production ID
# STRIPE_ENDPOINT_SECRET="whsec_xxxx"
# New relic settings
# see: https://one.eu.newrelic.com/admin-portal/, Administration > API keys to get the license key
# NEW_RELIC_AGENT_ENABLED=true
# NEW_RELIC_APP_NAME="Open Food Network"
# NEW_RELIC_LICENSE_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

View File

@@ -7,21 +7,31 @@ assignees: ''
---
## Preparation on Thursday
## 1. Preparation on Thursday
- [ ] Merge pull requests in the [Ready To Go] column
- [ ] Include translations: `tx pull --force`
- [ ] Include translations
<details><summary>Command line instructions:</summary>
<pre>
git checkout master
git pull upstream master
tx pull --force
git commit -a -m "Update all locales with the latest Transifex translations"
git push upstream master</pre>
</details>
- [ ] Create a tag: `git push upstream HEAD:refs/tags/vX.Y.Z`
- [ ] [Draft new release]. Look at previous [releases] for inspiration.
- Select new release tag
- _Generate release notes_ and arrange into categories as required.
- [ ] Notify [#instance-managers] of user-facing changes.
## Testing
## 2. Testing
- [ ] [Find build] of the release commit and copy it below.
- [ ] Move this issue to Test Ready.
- [ ] Notify `@testers` in [#testing].
- [ ] Test build: <!-- paste build link here, e.g. https://semaphore...builds/1234 -->
- [ ] Test build: [Deploy to Staging] with release tag.
## Finish on Tuesday
## 3. Finish on Tuesday
- [ ] Publish and notify [#global-community] (this is automatically posted with a plugin)
- [ ] Deploy the new release to all managed instances.
@@ -29,7 +39,7 @@ assignees: ''
<pre>
cd ofn-install
git pull
ansible-playbook --limit all-prod --extra-vars "git_version=vx.y.z" playbooks/deploy.yml
ansible-playbook --limit all-prod --extra-vars "git_version=vX.Y.Z" playbooks/deploy.yml
</pre>
</details>
- [ ] Notify [#instance-managers]:
@@ -44,5 +54,5 @@ The full process is described at https://github.com/openfoodfoundation/openfoodn
[releases]: https://github.com/openfoodfoundation/openfoodnetwork/releases
[#instance-managers]: https://app.slack.com/client/T02G54U79/CG7NJ966B
[#testing]: https://openfoodnetwork.slack.com/app_redirect?channel=C02TZ6X00
[Find build]: https://semaphoreci.com/openfoodfoundation/openfoodnetwork-2/branches/master
[Deploy to Staging]: https://github.com/openfoodfoundation/openfoodnetwork/actions/workflows/stage.yml
[#global-community]: https://app.slack.com/client/T02G54U79/C59ADD8F2

11
.github/release.yml vendored Normal file
View File

@@ -0,0 +1,11 @@
changelog:
categories:
- title: "User-facing changes 👀" # Other categories will need to be manually arrange for now.
labels:
- '*'
exclude:
labels:
- dependencies
- title: Dependencies 📦
labels:
- dependencies

View File

@@ -13,6 +13,10 @@ on:
- staging.openfoodnetwork.org.uk
- staging.openfoodnetwork.org.au
- staging.coopcircuits.fr
commit_ref:
description: "Commit Reference"
type: string
required: false
jobs:
deploy_pr:
@@ -59,4 +63,4 @@ jobs:
- name: Deploy to Staging
if: success()
run: |
ssh ofn-deploy@${{ inputs.server }} -o LogLevel=ERROR "$GITHUB_REF_NAME $GITHUB_SHA"
ssh ofn-deploy@${{ inputs.server }} -o LogLevel=ERROR "$GITHUB_REF_NAME ${{ inputs.commit_ref || github.sha }}"

View File

@@ -13,7 +13,8 @@ postcss.config.js
# SCSS
# Enabled: most of admin
/app/webpacker/css/admin/globals/
/app/webpacker/css/admin/globals/mixins.scss
/app/webpacker/css/admin/globals/variables.scss
/app/webpacker/css/admin/shared/
/app/webpacker/css/admin_v3/globals/variables.scss
/app/webpacker/css/darkswarm/

View File

@@ -25,6 +25,7 @@ Metrics/BlockLength:
AllowedMethods: [
"class_eval",
"collection",
"configure",
"context",
"delete",
"describe",
@@ -52,6 +53,13 @@ Rails/ApplicationRecord:
# Migrations should not contain application code:
- "db/migrate/*.rb"
# Allow many-to-many associations without explicit model.
# - It avoids the additional code of a model class.
# - It simplifies the declaration of the association.
# - Rails may know that there are no callbacks associated.
Rails/HasAndBelongsToMany:
Enabled: false
Rails/SkipsModelValidations:
AllowedMethods:
- "touch"
@@ -92,6 +100,8 @@ Naming/VariableNumber:
AllowedIdentifiers:
- street_address_1
- street_address_2
AllowedPatterns:
- _v[\d]+
Bundler/DuplicatedGem:
Enabled: false

View File

@@ -1,318 +1,18 @@
# This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400 --no-auto-gen-timestamp`
# using RuboCop version 1.52.1.
# using RuboCop version 1.56.0.
# 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
# Configuration parameters: Severity, Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Exclude:
- 'engines/catalog/catalog.gemspec'
- 'engines/dfc_provider/dfc_provider.gemspec'
- 'engines/order_management/order_management.gemspec'
- 'engines/web/web.gemspec'
# Offense count: 31
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: with_first_argument, with_fixed_indentation
Layout/ArgumentAlignment:
Exclude:
- 'app/controllers/spree/users_controller.rb'
- 'app/controllers/user_confirmations_controller.rb'
- 'app/models/enterprise.rb'
- 'spec/lib/reports/packing/packing_report_spec.rb'
- 'spec/migrations/migrate_customer_names_spec.rb'
- 'spec/services/products_renderer_spec.rb'
- 'spec/system/admin/bulk_order_management_spec.rb'
- 'spec/system/admin/enterprise_fees_spec.rb'
- 'spec/system/admin/order_cycles/list_spec.rb'
- 'spec/system/admin/order_cycles/simple_spec.rb'
- 'spec/system/consumer/shopping/cart_spec.rb'
- 'spec/system/consumer/shopping/products_spec.rb'
# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: with_first_element, with_fixed_indentation
Layout/ArrayAlignment:
Exclude:
- 'spec/system/admin/customers_spec.rb'
- 'spec/system/admin/order_spec.rb'
- 'spec/system/admin/orders_spec.rb'
- 'spec/system/consumer/shopping/cart_spec.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleAlignWith.
# SupportedStylesAlignWith: either, start_of_block, start_of_line
Layout/BlockAlignment:
Exclude:
- 'spec/services/products_renderer_spec.rb'
# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
Layout/BlockEndNewline:
Exclude:
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
- 'spec/system/admin/orders_spec.rb'
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Layout/ClosingParenthesisIndentation:
Exclude:
- 'spec/system/admin/orders_spec.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Layout/EmptyLines:
Exclude:
- 'app/models/spree/payment.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, no_empty_lines
Layout/EmptyLinesAroundBlockBody:
Exclude:
- 'spec/system/admin/order_cycles/list_spec.rb'
# 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'
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_braces
Layout/FirstHashElementIndentation:
Exclude:
- 'spec/services/products_renderer_spec.rb'
# Offense count: 10
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
# SupportedHashRocketStyles: key, separator, table
# SupportedColonStyles: key, separator, table
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/HashAlignment:
Exclude:
- 'app/controllers/spree/users_controller.rb'
- 'spec/migrations/migrate_customer_names_spec.rb'
- 'spec/models/enterprise_spec.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: 4
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: normal, indented_internal_methods
Layout/IndentationConsistency:
Exclude:
- 'spec/system/admin/order_cycles/complex_updating_specific_time_spec.rb'
- 'spec/system/admin/order_cycles/simple_spec.rb'
- 'spec/system/admin/product_import_spec.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Width, AllowedPatterns.
Layout/IndentationWidth:
Exclude:
- 'spec/services/products_renderer_spec.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment.
Layout/LeadingCommentSpace:
Exclude:
- 'spec/system/admin/enterprises_spec.rb'
# Offense count: 105
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: space, no_space
Layout/LineContinuationSpacing:
Exclude:
- '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_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: 13
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: aligned, indented
Layout/LineEndStringConcatenationIndentation:
Exclude:
- '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: 213
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Layout/LineLength:
Exclude:
- 'app/components/confirm_modal_component.rb'
- 'app/controllers/admin/product_import_controller.rb'
- 'app/models/customer.rb'
- 'app/models/spree/line_item.rb'
- 'spec/controllers/admin/order_cycles_controller_spec.rb'
- 'spec/controllers/api/v0/order_cycles_controller_spec.rb'
- 'spec/controllers/spree/admin/orders_controller_spec.rb'
- 'spec/lib/reports/customers_report_spec.rb'
- 'spec/models/enterprise_spec.rb'
- 'spec/models/order_cycle_spec.rb'
- 'spec/models/product_importer_spec.rb'
- 'spec/models/spree/ability_spec.rb'
- 'spec/models/spree/adjustment_spec.rb'
- 'spec/models/spree/line_item_spec.rb'
- 'spec/models/spree/product_spec.rb'
- 'spec/models/spree/tax_rate_spec.rb'
- 'spec/models/spree/user_spec.rb'
- 'spec/models/spree/variant_spec.rb'
- 'spec/models/tag_rule/filter_order_cycles_spec.rb'
- 'spec/models/tag_rule/filter_payment_methods_spec.rb'
- 'spec/models/tag_rule/filter_products_spec.rb'
- 'spec/models/tag_rule/filter_shipping_methods_spec.rb'
- 'spec/models/variant_override_spec.rb'
- 'spec/requests/api/orders_spec.rb'
- 'spec/requests/checkout/failed_checkout_spec.rb'
- 'spec/serializers/api/admin/exchange_serializer_spec.rb'
- 'spec/serializers/api/admin/order_cycle_serializer_spec.rb'
- 'spec/services/address_geocoder_spec.rb'
- 'spec/services/cart_service_spec.rb'
- 'spec/services/checkout/post_checkout_actions_spec.rb'
- 'spec/services/content_sanitizer_spec.rb'
- 'spec/services/embedded_page_service_spec.rb'
- 'spec/services/exchange_products_renderer_spec.rb'
- 'spec/services/order_cycle_distributed_variants_spec.rb'
- 'spec/services/order_syncer_spec.rb'
- 'spec/services/paypal_items_builder_spec.rb'
- 'spec/services/permissions/order_spec.rb'
- 'spec/services/permitted_attributes/order_cycle_spec.rb'
- 'spec/services/product_tag_rules_filterer_spec.rb'
- 'spec/services/products_renderer_spec.rb'
- 'spec/support/cancan_helper.rb'
- 'spec/support/features/datepicker_helper.rb'
- 'spec/support/matchers/select2_matchers.rb'
- 'spec/support/request/web_helper.rb'
- 'spec/system/admin/adjustments_spec.rb'
- 'spec/system/admin/bulk_order_management_spec.rb'
- 'spec/system/admin/bulk_product_update_spec.rb'
- 'spec/system/admin/order_spec.rb'
- 'spec/system/admin/product_import_spec.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Layout/MultilineBlockLayout:
Exclude:
- 'engines/order_management/app/services/order_management/subscriptions/validator.rb'
# Offense count: 6
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: symmetrical, new_line, same_line
Layout/MultilineMethodCallBraceLayout:
Exclude:
- 'spec/system/admin/orders_spec.rb'
- 'spec/system/admin/products_spec.rb'
# Offense count: 6
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: aligned, indented, indented_relative_to_receiver
Layout/MultilineMethodCallIndentation:
Exclude:
- 'spec/controllers/api/v0/orders_controller_spec.rb'
- 'spec/system/admin/order_cycles/complex_editing_spec.rb'
- 'spec/system/admin/overview_spec.rb'
- 'spec/system/admin/payment_method_spec.rb'
- 'spec/system/admin/variant_overrides_spec.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: final_newline, final_blank_line
Layout/TrailingEmptyLines:
Exclude:
- 'Rakefile'
# Offense count: 76
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowInHeredoc.
Layout/TrailingWhitespace:
Exclude:
- 'app/controllers/spree/users_controller.rb'
- 'app/controllers/user_confirmations_controller.rb'
- 'app/models/enterprise.rb'
- 'spec/controllers/spree/credit_cards_controller_spec.rb'
- 'spec/controllers/user_confirmations_controller_spec.rb'
- 'spec/factories/order_factory.rb'
- 'spec/lib/reports/packing/packing_report_spec.rb'
- 'spec/models/enterprise_spec.rb'
- 'spec/services/products_renderer_spec.rb'
- 'spec/support/request/stripe_stubs.rb'
- 'spec/system/admin/bulk_order_management_spec.rb'
- 'spec/system/admin/customers_spec.rb'
- 'spec/system/admin/enterprise_fees_spec.rb'
- 'spec/system/admin/flatpickr_spec.rb'
- 'spec/system/admin/order_cycles/complex_editing_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/product_import_spec.rb'
- 'spec/system/admin/shipping_methods_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'
- 'spec/system/admin/tag_rules_spec.rb'
# Offense count: 17
# Configuration parameters: AllowedMethods.
@@ -353,7 +53,7 @@ Lint/DuplicateRequire:
Exclude:
- 'spec/lib/open_food_network/scope_variants_to_search_spec.rb'
# Offense count: 19
# Offense count: 18
# Configuration parameters: AllowComments, AllowEmptyLambdas.
Lint/EmptyBlock:
Exclude:
@@ -421,36 +121,12 @@ Lint/RedundantSafeNavigation:
Exclude:
- 'app/models/spree/payment.rb'
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowedMethods.
# AllowedMethods: present?, blank?, presence, try, try!, in?
Lint/SafeNavigationChain:
Exclude:
- 'app/models/spree/line_item.rb'
- 'app/models/spree/stock/availability_validator.rb'
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
Lint/UnusedMethodArgument:
Exclude:
- 'lib/reporting/queries/query_interface.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Lint/UselessMethodDefinition:
Exclude:
- 'app/models/spree/gateway.rb'
# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: CheckForMethodsWithNoSideEffects.
Lint/Void:
Exclude:
- 'spec/system/admin/order_cycles/complex_updating_specific_time_spec.rb'
- 'spec/system/admin/order_cycles/simple_spec.rb'
# Offense count: 26
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
Metrics/AbcSize:
@@ -477,7 +153,7 @@ Metrics/AbcSize:
- 'lib/tasks/enterprises.rake'
- 'spec/services/order_checkout_restart_spec.rb'
# Offense count: 48
# Offense count: 46
# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns.
# AllowedMethods: refine
Metrics/BlockLength:
@@ -488,7 +164,6 @@ Metrics/BlockLength:
- 'app/models/spree/shipment.rb'
- 'lib/spree/core/controller_helpers/common.rb'
- 'lib/tasks/data.rake'
- 'spec/base_spec_helper.rb'
- 'spec/factories.rb'
- 'spec/factories/address_factory.rb'
- 'spec/factories/enterprise_factory.rb'
@@ -507,11 +182,9 @@ Metrics/BlockLength:
- 'spec/support/cancan_helper.rb'
- 'spec/support/matchers/select2_matchers.rb'
- 'spec/support/matchers/table_matchers.rb'
- 'spec/swagger_helper.rb'
- 'spec/system/consumer/shopping/checkout_spec.rb'
- 'spec/system/consumer/shopping/checkout_stripe_spec.rb'
- 'spec/system/consumer/shopping/variant_overrides_spec.rb'
- 'spec/system/consumer/split_checkout_tax_not_incl_spec.rb'
# Offense count: 1
# Configuration parameters: CountBlocks, Max.
@@ -519,22 +192,17 @@ Metrics/BlockNesting:
Exclude:
- 'app/models/spree/payment/processing.rb'
# Offense count: 49
# Offense count: 45
# Configuration parameters: CountComments, Max, CountAsOne.
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'
- 'app/controllers/api/v0/products_controller.rb'
- 'app/controllers/application_controller.rb'
- 'app/controllers/payment_gateways/paypal_controller.rb'
- 'app/controllers/split_checkout_controller.rb'
- 'app/controllers/spree/admin/orders_controller.rb'
- 'app/controllers/spree/admin/payment_methods_controller.rb'
- 'app/controllers/spree/admin/payments_controller.rb'
@@ -555,15 +223,16 @@ Metrics/ClassLength:
- 'app/models/spree/payment.rb'
- 'app/models/spree/product.rb'
- 'app/models/spree/shipment.rb'
- 'app/models/spree/shipping_method.rb'
- 'app/models/spree/user.rb'
- 'app/models/spree/variant.rb'
- 'app/models/spree/zone.rb'
- 'app/reflexes/products_reflex.rb'
- 'app/serializers/api/cached_enterprise_serializer.rb'
- 'app/serializers/api/enterprise_shopfront_serializer.rb'
- 'app/services/cart_service.rb'
- 'app/services/order_cycle_form.rb'
- 'app/services/order_syncer.rb'
- 'app/services/sets/product_set.rb'
- 'engines/order_management/app/services/order_management/order/updater.rb'
- 'lib/open_food_network/enterprise_fee_calculator.rb'
- 'lib/open_food_network/order_cycle_form_applicator.rb'
@@ -711,31 +380,6 @@ Naming/AccessorMethodName:
- 'spec/support/request/shop_workflow.rb'
- 'spec/support/request/web_helper.rb'
# Offense count: 42
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, BlockForwardingName.
# SupportedStyles: anonymous, explicit
Naming/BlockForwarding:
Exclude:
- 'app/helpers/application_helper.rb'
- 'app/helpers/link_helper.rb'
- 'app/helpers/spree/admin/base_helper.rb'
- 'app/reflexes/application_reflex.rb'
- 'app/services/cache_service.rb'
- 'app/services/current_order_locker.rb'
- 'lib/reporting/reports/enterprise_fee_summary/scope.rb'
- 'lib/spree/core/controller_helpers/respond_with.rb'
- 'lib/spree/core/delegate_belongs_to.rb'
- 'lib/spree/core/environment_extension.rb'
- 'spec/models/enterprise_caching_spec.rb'
- 'spec/support/embedded_pages_helper.rb'
- 'spec/support/preferences_helper.rb'
- 'spec/support/request/shop_workflow.rb'
- 'spec/support/request/ui_component_helper.rb'
- 'spec/support/request/web_helper.rb'
- 'spec/swagger_helper.rb'
- 'spec/system/support/capybara_setup.rb'
# Offense count: 1
# Configuration parameters: ForbiddenDelimiters.
# ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$))
@@ -776,39 +420,6 @@ 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: 12
# 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/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
@@ -816,86 +427,6 @@ Rails/ActiveRecordOverride:
Exclude:
- 'app/models/spree/product.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/ApplicationController:
Exclude:
- 'engines/dfc_provider/app/controllers/dfc_provider/base_controller.rb'
# Offense count: 5
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: NilOrEmpty, NotPresent, UnlessPresent.
Rails/Blank:
Exclude:
- 'app/models/spree/order_contents.rb'
- 'app/services/content_sanitizer.rb'
- '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
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: slashes, arguments
Rails/FilePath:
Exclude:
- 'app/models/product_import/product_importer.rb'
- 'lib/tasks/karma.rake'
- 'spec/base_spec_helper.rb'
- 'spec/models/content_configuration_spec.rb'
- 'spec/support/downloads_helper.rb'
# Offense count: 8
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/HasAndBelongsToMany:
Exclude:
- 'app/models/enterprise.rb'
- 'app/models/enterprise_group.rb'
- 'app/models/order_cycle.rb'
- 'app/models/spree/role.rb'
- 'app/models/spree/shipping_method.rb'
- 'app/models/spree/user.rb'
- 'app/models/spree/zone.rb'
# Offense count: 47
# Configuration parameters: Include.
# Include: app/models/**/*.rb
@@ -936,14 +467,6 @@ Rails/HelperInstanceVariable:
- 'app/helpers/spree/admin/orders_helper.rb'
- 'app/helpers/spree/orders_helper.rb'
# 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
@@ -959,12 +482,6 @@ Rails/I18nLocaleTexts:
Exclude:
- 'app/controllers/admin/stripe_accounts_controller.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/IgnoredColumnsAssignment:
Exclude:
- 'app/models/spree/variant.rb'
# Offense count: 22
# Configuration parameters: IgnoreScopes, Include.
# Include: app/models/**/*.rb
@@ -984,7 +501,7 @@ Rails/InverseOf:
- 'app/models/spree/variant.rb'
- 'app/models/subscription_line_item.rb'
# Offense count: 38
# Offense count: 35
# Configuration parameters: Include.
# Include: app/controllers/**/*.rb, app/mailers/**/*.rb
Rails/LexicallyScopedActionFilter:
@@ -1065,28 +582,24 @@ Rails/PluckInWhere:
Exclude:
- 'app/models/spree/variant.rb'
# Offense count: 30
# Offense count: 22
# 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/spree/variant.rb'
- 'app/models/subscription_line_item.rb'
- 'app/models/tag_rule.rb'
- 'app/models/variant_override.rb'
@@ -1117,30 +630,14 @@ Rails/ResponseParsedBody:
- 'spec/controllers/spree/credit_cards_controller_spec.rb'
- 'spec/controllers/user_registrations_controller_spec.rb'
# Offense count: 4
# Offense count: 3
# 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
@@ -1157,16 +654,6 @@ Rails/SquishedSQLHeredocs:
- '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: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
@@ -1200,7 +687,7 @@ Rails/UnknownEnv:
Exclude:
- 'app/models/spree/app_configuration.rb'
# Offense count: 55
# Offense count: 56
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/WhereEquals:
Exclude:
@@ -1249,28 +736,6 @@ Rails/WhereExists:
- '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:
@@ -1289,12 +754,6 @@ Style/ArrayIntersect:
- 'lib/open_food_network/tag_rule_applicator.rb'
- 'spec/support/matchers/select2_matchers.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/BlockComments:
Exclude:
- 'spec/system/admin/tag_rules_spec.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowOnConstant, AllowOnSelfClass.
@@ -1337,20 +796,6 @@ 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:
@@ -1411,16 +856,8 @@ Style/GuardClause:
- 'spec/support/request/shop_workflow.rb'
- 'spec/system/support/precompile_assets.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: braces, no_braces
Style/HashAsLastArrayItem:
Exclude:
- 'app/components/products_table_component.rb'
# Offense count: 12
# This cop supports safe autocorrection (--autocorrect).
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowSplatArgument.
Style/HashConversion:
Exclude:
@@ -1441,7 +878,7 @@ Style/HashLikeCase:
Exclude:
- 'app/models/enterprise.rb'
# Offense count: 1778
# Offense count: 1784
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
@@ -1450,8 +887,6 @@ Style/HashSyntax:
Exclude:
- 'app/components/confirm_modal_component.rb'
- 'app/components/help_modal_component.rb'
- 'app/components/products_table_component.rb'
- 'app/components/selector_with_filter_component.rb'
- 'app/controllers/admin/customers_controller.rb'
- 'app/controllers/admin/enterprise_fees_controller.rb'
- 'app/controllers/admin/enterprise_groups_controller.rb'
@@ -1593,7 +1028,6 @@ Style/HashSyntax:
- 'lib/tasks/sample_data/user_factory.rb'
- 'lib/tasks/subscriptions/debug.rake'
- 'lib/tasks/subscriptions/test.rake'
- 'spec/components/product_component_spec.rb'
- 'spec/constraints/feature_toggle_constraint_spec.rb'
- 'spec/controllers/admin/bulk_line_items_controller_spec.rb'
- 'spec/controllers/admin/customers_controller_spec.rb'
@@ -1649,7 +1083,6 @@ Style/HashSyntax:
- 'spec/helpers/spree/base_helper_spec.rb'
- 'spec/jobs/report_job_spec.rb'
- 'spec/jobs/subscription_confirm_job_spec.rb'
- 'spec/jobs/subscription_placement_job_spec.rb'
- 'spec/jobs/webhook_delivery_job_spec.rb'
- 'spec/lib/open_food_network/address_finder_spec.rb'
- 'spec/lib/open_food_network/enterprise_fee_applicator_spec.rb'
@@ -1693,12 +1126,10 @@ Style/HashSyntax:
- 'spec/models/concerns/order_shipment_spec.rb'
- 'spec/models/concerns/product_stock_spec.rb'
- 'spec/models/customer_spec.rb'
- 'spec/models/enterprise_caching_spec.rb'
- 'spec/models/enterprise_fee_spec.rb'
- 'spec/models/enterprise_relationship_spec.rb'
- 'spec/models/enterprise_spec.rb'
- 'spec/models/exchange_spec.rb'
- 'spec/models/invoice_spec.rb'
- 'spec/models/order_cycle_spec.rb'
- 'spec/models/product_import/entry_validator_spec.rb'
- 'spec/models/product_import/inventory_reset_strategy_spec.rb'
@@ -1708,7 +1139,6 @@ Style/HashSyntax:
- 'spec/models/spree/address_spec.rb'
- 'spec/models/spree/adjustment_spec.rb'
- 'spec/models/spree/calculator_spec.rb'
- 'spec/models/spree/classification_spec.rb'
- 'spec/models/spree/credit_card_spec.rb'
- 'spec/models/spree/gateway/stripe_sca_spec.rb'
- 'spec/models/spree/inventory_unit_spec.rb'
@@ -1738,7 +1168,6 @@ Style/HashSyntax:
- 'spec/queries/customers_with_balance_spec.rb'
- 'spec/queries/outstanding_balance_spec.rb'
- 'spec/queries/payments_requiring_action_spec.rb'
- 'spec/requests/admin/vouchers_controller_spec.rb'
- 'spec/requests/api/v1/customers_spec.rb'
- 'spec/requests/checkout/failed_checkout_spec.rb'
- 'spec/requests/checkout/paypal_spec.rb'
@@ -1815,7 +1244,6 @@ Style/HashSyntax:
- 'spec/system/admin/subscriptions_spec.rb'
- 'spec/system/admin/tag_rules_spec.rb'
- 'spec/system/admin/variant_overrides_spec.rb'
- 'spec/system/admin/variants_spec.rb'
- 'spec/system/admin/vouchers_spec.rb'
- 'spec/system/consumer/account/cards_spec.rb'
- 'spec/system/consumer/account/developer_settings_spec.rb'
@@ -1886,7 +1314,7 @@ Style/NestedModifier:
- 'spec/system/admin/payments_stripe_spec.rb'
- 'spec/system/admin/reports_spec.rb'
# Offense count: 36
# Offense count: 38
Style/OpenStructUse:
Exclude:
- 'app/helpers/injection_helper.rb'
@@ -1952,14 +1380,13 @@ Style/RedundantArgument:
- 'engines/dfc_provider/app/services/authorization_control.rb'
- 'spec/support/query_counter.rb'
# Offense count: 14
# Offense count: 13
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantConstantBase:
Exclude:
- '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'
@@ -1980,11 +1407,30 @@ Style/RedundantInitialize:
Exclude:
- 'spec/models/spree/gateway_spec.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantRegexpEscape:
# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/RedundantInterpolation:
Exclude:
- 'app/models/spree/order.rb'
- 'lib/tasks/karma.rake'
- 'spec/base_spec_helper.rb'
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantRegexpArgument:
Exclude:
- 'app/models/spree/shipping_method.rb'
- 'lib/spree/i18n.rb'
# Offense count: 5
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn:
Exclude:
- 'app/models/product_import/entry_validator.rb'
- 'app/models/spree/stock/availability_validator.rb'
- 'lib/reporting/reports/enterprise_fee_summary/summarizer.rb'
- 'lib/stripe/authorize_response_patcher.rb'
- 'lib/tasks/data.rake'
# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
@@ -1994,10 +1440,18 @@ Style/RedundantStringEscape:
- 'spec/controllers/spree/admin/shipping_methods_controller_spec.rb'
- 'spec/system/admin/enterprise_fees_spec.rb'
# Offense count: 205
# Offense count: 19
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowedMethods, AllowedPatterns.
Style/ReturnNilInPredicateMethodDefinition:
Exclude:
- 'app/models/order_cycle.rb'
- 'app/serializers/api/admin/customer_serializer.rb'
- 'engines/order_management/app/services/order_management/subscriptions/validator.rb'
# Offense count: 204
Style/Send:
Exclude:
- 'app/controllers/split_checkout_controller.rb'
- 'spec/controllers/admin/subscriptions_controller_spec.rb'
- 'spec/controllers/payment_gateways/paypal_controller_spec.rb'
- 'spec/controllers/spree/admin/base_controller_spec.rb'

View File

@@ -103,8 +103,8 @@ gem 'redis', '>= 4.0', require: ['redis', 'redis/connection/hiredis']
gem 'sidekiq'
gem 'sidekiq-scheduler'
gem "cable_ready", "5.0.0.rc2"
gem "stimulus_reflex", "3.5.0.rc2"
gem "cable_ready", "5.0.1"
gem "stimulus_reflex", "3.5.0.rc3"
gem 'combine_pdf'
gem 'wicked_pdf'
@@ -138,6 +138,8 @@ gem 'mini_portile2', '~> 2.8'
gem "faraday"
gem "private_address_check"
gem 'newrelic_rpm'
group :production, :staging do
gem 'sd_notify' # For better Systemd process management. Used by Puma.
end
@@ -157,6 +159,7 @@ group :test, :development do
gem 'rspec-retry', require: false
gem 'rswag-specs'
gem 'shoulda-matchers'
gem 'stimulus_reflex_testing'
gem 'timecop'
end

View File

@@ -26,9 +26,6 @@ PATH
remote: engines/dfc_provider
specs:
dfc_provider (0.0.1)
active_model_serializers (~> 0.8.4)
jwt (~> 2.2)
rspec (~> 3.9)
PATH
remote: engines/order_management
@@ -44,49 +41,49 @@ GEM
remote: https://rubygems.org/
specs:
Ascii85 (1.1.0)
actioncable (7.0.6)
actionpack (= 7.0.6)
activesupport (= 7.0.6)
actioncable (7.0.7.2)
actionpack (= 7.0.7.2)
activesupport (= 7.0.7.2)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (7.0.6)
actionpack (= 7.0.6)
activejob (= 7.0.6)
activerecord (= 7.0.6)
activestorage (= 7.0.6)
activesupport (= 7.0.6)
actionmailbox (7.0.7.2)
actionpack (= 7.0.7.2)
activejob (= 7.0.7.2)
activerecord (= 7.0.7.2)
activestorage (= 7.0.7.2)
activesupport (= 7.0.7.2)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.0.6)
actionpack (= 7.0.6)
actionview (= 7.0.6)
activejob (= 7.0.6)
activesupport (= 7.0.6)
actionmailer (7.0.7.2)
actionpack (= 7.0.7.2)
actionview (= 7.0.7.2)
activejob (= 7.0.7.2)
activesupport (= 7.0.7.2)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (7.0.6)
actionview (= 7.0.6)
activesupport (= 7.0.6)
actionpack (7.0.7.2)
actionview (= 7.0.7.2)
activesupport (= 7.0.7.2)
rack (~> 2.0, >= 2.2.4)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actionpack-action_caching (1.2.2)
actionpack (>= 4.0.0)
actiontext (7.0.6)
actionpack (= 7.0.6)
activerecord (= 7.0.6)
activestorage (= 7.0.6)
activesupport (= 7.0.6)
actiontext (7.0.7.2)
actionpack (= 7.0.7.2)
activerecord (= 7.0.7.2)
activestorage (= 7.0.7.2)
activesupport (= 7.0.7.2)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.0.6)
activesupport (= 7.0.6)
actionview (7.0.7.2)
activesupport (= 7.0.7.2)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
@@ -98,20 +95,20 @@ GEM
activemodel (>= 5.2.0)
activestorage (>= 5.2.0)
activesupport (>= 5.2.0)
activejob (7.0.6)
activesupport (= 7.0.6)
activejob (7.0.7.2)
activesupport (= 7.0.7.2)
globalid (>= 0.3.6)
activemerchant (1.123.0)
activesupport (>= 4.2)
builder (>= 2.1.2, < 4.0.0)
i18n (>= 0.6.9)
nokogiri (~> 1.4)
activemodel (7.0.6)
activesupport (= 7.0.6)
activerecord (7.0.6)
activemodel (= 7.0.6)
activesupport (= 7.0.6)
activerecord-import (1.4.1)
activemodel (7.0.7.2)
activesupport (= 7.0.7.2)
activerecord (7.0.7.2)
activemodel (= 7.0.7.2)
activesupport (= 7.0.7.2)
activerecord-import (1.5.0)
activerecord (>= 4.2)
activerecord-postgresql-adapter (0.0.1)
pg
@@ -121,14 +118,14 @@ GEM
multi_json (~> 1.11, >= 1.11.2)
rack (>= 2.0.8, < 3)
railties (>= 5.2.4.1)
activestorage (7.0.6)
actionpack (= 7.0.6)
activejob (= 7.0.6)
activerecord (= 7.0.6)
activesupport (= 7.0.6)
activestorage (7.0.7.2)
actionpack (= 7.0.7.2)
activejob (= 7.0.7.2)
activerecord (= 7.0.7.2)
activesupport (= 7.0.7.2)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (7.0.6)
activesupport (7.0.7.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
@@ -157,34 +154,35 @@ GEM
awesome_nested_set (3.5.0)
activerecord (>= 4.0.0, < 7.1)
aws-eventstream (1.2.0)
aws-partitions (1.780.0)
aws-sdk-core (3.175.0)
aws-partitions (1.809.0)
aws-sdk-core (3.181.0)
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.67.0)
aws-sdk-core (~> 3, >= 3.174.0)
aws-sdk-kms (1.71.0)
aws-sdk-core (~> 3, >= 3.177.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.126.0)
aws-sdk-core (~> 3, >= 3.174.0)
aws-sdk-s3 (1.133.0)
aws-sdk-core (~> 3, >= 3.181.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.4)
aws-sigv4 (1.5.2)
aws-sigv4 (~> 1.6)
aws-sigv4 (1.6.0)
aws-eventstream (~> 1, >= 1.0.2)
base64 (0.1.1)
bcrypt (3.1.18)
bigdecimal (3.0.2)
bindata (2.4.15)
bindex (0.8.1)
bootsnap (1.16.0)
msgpack (~> 1.2)
bugsnag (6.25.2)
bugsnag (6.26.0)
concurrent-ruby (~> 1.0)
builder (3.2.4)
bullet (7.0.7)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.11)
cable_ready (5.0.0.rc2)
cable_ready (5.0.1)
actionpack (>= 5.2)
actionview (>= 5.2)
activesupport (>= 5.2)
@@ -234,8 +232,8 @@ 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)
datafoodconsortium-connector (1.0.0.pre.alpha.8)
virtual_assembly-semantizer (~> 1.0, >= 1.0.5)
date (3.3.3)
debug (1.8.0)
irb (>= 1.5.0)
@@ -355,20 +353,20 @@ GEM
jquery-ui-rails (4.2.1)
railties (>= 3.2.16)
json (2.6.3)
json-canonicalization (0.3.1)
json-canonicalization (0.3.2)
json-jwt (1.16.3)
activesupport (>= 4.2)
aes_key_wrap
bindata
faraday (~> 2.0)
faraday-follow_redirects
json-ld (3.2.3)
json-ld (3.2.5)
htmlentities (~> 4.3)
json-canonicalization (~> 0.3)
json-canonicalization (~> 0.3, >= 0.3.2)
link_header (~> 0.0, >= 0.0.8)
multi_json (~> 1.15)
rack (~> 2.2)
rdf (~> 3.2, >= 3.2.9)
rack (>= 2.2, < 4)
rdf (~> 3.2, >= 3.2.10)
json-schema (3.0.0)
addressable (>= 2.8)
json_spec (1.1.5)
@@ -377,7 +375,7 @@ GEM
jsonapi-serializer (2.2.0)
activesupport (>= 4.2)
jwt (2.7.1)
knapsack_pro (5.1.2)
knapsack_pro (5.4.1)
rake
language_server-protocol (3.17.0.3)
launchy (2.5.0)
@@ -399,16 +397,16 @@ GEM
marcel (1.0.2)
matrix (0.4.2)
method_source (1.0.0)
mime-types (3.4.1)
mime-types (3.5.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2021.0225)
mime-types-data (3.2023.0808)
mimemagic (0.4.3)
nokogiri (~> 1)
rake
mini_magick (4.11.0)
mini_mime (1.1.2)
mini_portile2 (2.8.2)
minitest (5.18.1)
mini_mime (1.1.5)
mini_portile2 (2.8.4)
minitest (5.19.0)
monetize (1.12.0)
money (~> 6.12)
money (6.16.0)
@@ -416,7 +414,7 @@ GEM
msgpack (1.7.1)
multi_json (1.15.0)
multi_xml (0.6.0)
net-imap (0.3.6)
net-imap (0.3.7)
date
net-protocol
net-pop (0.1.2)
@@ -425,8 +423,9 @@ GEM
timeout
net-smtp (0.3.3)
net-protocol
newrelic_rpm (9.4.2)
nio4r (2.5.9)
nokogiri (1.15.3)
nokogiri (1.15.4)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
oauth2 (1.4.11)
@@ -484,15 +483,15 @@ GEM
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (5.0.1)
puma (6.3.0)
public_suffix (5.0.3)
puma (6.3.1)
nio4r (~> 2.0)
query_count (1.1.1)
activerecord (>= 4.2)
railties (>= 4.2)
raabro (1.4.0)
racc (1.7.1)
rack (2.2.7)
rack (2.2.8)
rack-mini-profiler (2.3.4)
rack (>= 1.2.0)
rack-oauth2 (1.21.3)
@@ -509,25 +508,25 @@ GEM
rack-test (2.1.0)
rack (>= 1.3)
rack-timeout (0.6.3)
rails (7.0.6)
actioncable (= 7.0.6)
actionmailbox (= 7.0.6)
actionmailer (= 7.0.6)
actionpack (= 7.0.6)
actiontext (= 7.0.6)
actionview (= 7.0.6)
activejob (= 7.0.6)
activemodel (= 7.0.6)
activerecord (= 7.0.6)
activestorage (= 7.0.6)
activesupport (= 7.0.6)
rails (7.0.7.2)
actioncable (= 7.0.7.2)
actionmailbox (= 7.0.7.2)
actionmailer (= 7.0.7.2)
actionpack (= 7.0.7.2)
actiontext (= 7.0.7.2)
actionview (= 7.0.7.2)
activejob (= 7.0.7.2)
activemodel (= 7.0.7.2)
activerecord (= 7.0.7.2)
activestorage (= 7.0.7.2)
activesupport (= 7.0.7.2)
bundler (>= 1.15.0)
railties (= 7.0.6)
railties (= 7.0.7.2)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
activesupport (>= 5.0.1.rc1)
rails-dom-testing (2.1.1)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
@@ -539,13 +538,13 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
rails-i18n (7.0.7)
rails-i18n (7.0.8)
i18n (>= 0.7, < 2)
railties (>= 6.0.0, < 8)
rails_safe_tasks (1.0.0)
railties (7.0.6)
actionpack (= 7.0.6)
activesupport (= 7.0.6)
railties (7.0.7.2)
actionpack (= 7.0.7.2)
activesupport (= 7.0.7.2)
method_source
rake (>= 12.2)
thor (~> 1.0)
@@ -559,7 +558,7 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rdf (3.2.9)
rdf (3.2.11)
link_header (~> 0.0, >= 0.0.8)
redcarpet (3.6.0)
redis (4.8.1)
@@ -573,7 +572,7 @@ GEM
responders (3.1.0)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.2.5)
rexml (3.2.6)
roadie (5.0.1)
css_parser (~> 1.4)
nokogiri (~> 1.8)
@@ -608,18 +607,19 @@ GEM
rspec-support (~> 3.12)
rspec-retry (0.6.2)
rspec-core (> 3.3)
rspec-support (3.12.0)
rswag-api (2.9.0)
rspec-support (3.12.1)
rswag-api (2.10.1)
railties (>= 3.1, < 7.1)
rswag-specs (2.9.0)
rswag-specs (2.10.1)
activesupport (>= 3.1, < 7.1)
json-schema (>= 2.2, < 4.0)
railties (>= 3.1, < 7.1)
rspec-core (>= 2.14)
rswag-ui (2.9.0)
rswag-ui (2.10.1)
actionpack (>= 3.1, < 7.1)
railties (>= 3.1, < 7.1)
rubocop (1.54.1)
rubocop (1.56.1)
base64 (~> 0.1.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
@@ -627,7 +627,7 @@ GEM
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.0, < 2.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
@@ -695,18 +695,20 @@ GEM
state_machines-activerecord (0.9.0)
activerecord (>= 6.0)
state_machines-activemodel (>= 0.9.0)
stimulus_reflex (3.5.0.rc2)
stimulus_reflex (3.5.0.rc3)
actioncable (>= 5.2, < 8)
actionpack (>= 5.2, < 8)
actionview (>= 5.2, < 8)
activesupport (>= 5.2, < 8)
cable_ready (>= 5.0.0.rc2)
cable_ready (~> 5.0)
nokogiri (~> 1.0)
rack (>= 2, < 4)
railties (>= 5.2, < 8)
redis (>= 4.0, < 6.0)
stimulus_reflex_testing (0.3.0)
stimulus_reflex (>= 3.3.0)
stringex (2.8.6)
stripe (8.5.0)
stripe (9.0.0)
swd (1.3.0)
activesupport (>= 3)
attr_required (>= 0.0.5)
@@ -715,7 +717,7 @@ GEM
thor (1.2.2)
thread-local (1.1.0)
tilt (2.1.0)
timecop (0.9.6)
timecop (0.9.8)
timeout (0.4.0)
ttfunk (1.7.0)
tzinfo (2.0.6)
@@ -732,7 +734,7 @@ GEM
activemodel (>= 3.0.0)
public_suffix
vcr (6.2.0)
view_component (3.3.0)
view_component (3.5.0)
activesupport (>= 5.2.0, < 8.0)
concurrent-ruby (~> 1.0)
method_source (~> 1.0)
@@ -740,7 +742,7 @@ GEM
rails (>= 5.2, < 8.0)
stimulus_reflex (>= 3.5.0.pre2)
view_component (>= 2.28.0)
virtual_assembly-semantizer (1.0.4)
virtual_assembly-semantizer (1.0.5)
json-ld (~> 3.2, >= 3.2.3)
warden (1.2.9)
rack (>= 2.0.9)
@@ -762,7 +764,7 @@ GEM
railties (>= 5.2)
semantic_range (>= 2.3.0)
webrick (1.7.0)
websocket-driver (0.7.5)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
whenever (1.0.0)
@@ -773,7 +775,7 @@ GEM
xml-simple (1.1.8)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.8)
zeitwerk (2.6.11)
PLATFORMS
ruby
@@ -799,7 +801,7 @@ DEPENDENCIES
bootsnap
bugsnag
bullet
cable_ready (= 5.0.0.rc2)
cable_ready (= 5.0.1)
cancancan (~> 1.15.0)
capybara
catalog!
@@ -850,6 +852,7 @@ DEPENDENCIES
mimemagic (> 0.3.5)
mini_portile2 (~> 2.8)
monetize (~> 1.11)
newrelic_rpm
oauth2 (~> 1.4.7)
omniauth-rails_csrf_protection
omniauth_openid_connect
@@ -897,7 +900,8 @@ DEPENDENCIES
spring
spring-commands-rspec
state_machines-activerecord
stimulus_reflex (= 3.5.0.rc2)
stimulus_reflex (= 3.5.0.rc3)
stimulus_reflex_testing
stringex (~> 2.8.5)
stripe
timecop

View File

@@ -7,4 +7,3 @@
require_relative 'config/application'
Openfoodnetwork::Application.load_tasks

View File

@@ -135,6 +135,7 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout
display_name: null
on_hand: null
price: null
tax_category_id: null
DisplayProperties.setShowVariants product.id, true
@@ -346,9 +347,6 @@ filterSubmitProducts = (productsToFilter) ->
if product.hasOwnProperty("category_id")
filteredProduct.primary_taxon_id = product.category_id
hasUpdatableProperty = true
if product.hasOwnProperty("tax_category_id")
filteredProduct.tax_category_id = product.tax_category_id
hasUpdatableProperty = true
if product.hasOwnProperty("inherits_properties")
filteredProduct.inherits_properties = product.inherits_properties
hasUpdatableProperty = true
@@ -389,6 +387,9 @@ filterSubmitVariant = (variant) ->
if variant.hasOwnProperty("display_name")
filteredVariant.display_name = variant.display_name
hasUpdatableProperty = true
if variant.hasOwnProperty("tax_category_id")
filteredVariant.tax_category_id = variant.tax_category_id
hasUpdatableProperty = true
if variant.hasOwnProperty("display_as")
filteredVariant.display_as = variant.display_as
hasUpdatableProperty = true

View File

@@ -11,14 +11,8 @@ angular.module("admin.indexUtils").directive "objForUpdate", (switchClass, pendi
pendingChanges.remove(scope.object().id, scope.attr)
scope.clear()
else
change =
object: scope.object()
type: scope.type
attr: scope.attr
value: if value? then value else ""
scope: scope
scope.pending()
pendingChanges.add(scope.object().id, scope.attr, change)
addPendingChange(scope.attr, value ? "")
scope.reset = (value) ->
scope.savedValue = value
@@ -34,3 +28,33 @@ angular.module("admin.indexUtils").directive "objForUpdate", (switchClass, pendi
scope.clear = ->
switchClass( element, "", ["update-pending", "update-error", "update-success"], false )
# When a list of customer is filtered and we removed the "filtered value" from a customer, we
# want to make sure the customer is updated. IE. filtering by tag, and removing said tag.
# Deleting the "filtered value" from a customer will remove the customer entry, thus
# removing "objForUpdate" directive from the active scope. That means $watch won't pick up
# the attribute changed.
# To ensure the customer is still updated, we check on the $destroy event to see if
# the attribute has changed, if so we queue up the change.
scope.$on '$destroy', (value) ->
# No update
return if scope.object()[scope.attr] is scope.savedValue
# For some reason the code attribute is removed from the object when cleared, so we add
# an emptyvalue so it gets updated properly
if scope.attr is "code" and scope.object()[scope.attr] is undefined
scope.object()["code"] = ""
# Queuing up change
addPendingChange(scope.attr, scope.object()[scope.attr])
# private
addPendingChange = (attr, value) ->
change =
object: scope.object()
type: scope.type
attr: attr
value: value
scope: scope
pendingChanges.add(scope.object().id, attr, change)

View File

@@ -9,10 +9,9 @@ angular.module('Darkswarm').controller "RegistrationFormCtrl", ($scope, Registra
$scope.create = (form) ->
if ($scope.valid(form))
$scope.disableButton()
EnterpriseRegistrationService.create().then(() ->
EnterpriseRegistrationService.create($scope.enableButton).then(() ->
$scope.enableButton()
)
end
$scope.update = (nextStep, form) ->
EnterpriseRegistrationService.update(nextStep) if $scope.valid(form)

View File

@@ -1,7 +1,8 @@
# frozen_string_literal: true
class ConfirmModalComponent < ModalComponent
def initialize(id:, confirm_actions: nil, reflex: nil, controller: nil, message: nil, confirm_reflexes: nil)
def initialize(id:, confirm_actions: nil, reflex: nil, controller: nil, message: nil,
confirm_reflexes: nil)
super(id: id, close_button: true)
@confirm_actions = confirm_actions
@reflex = reflex

View File

@@ -1,15 +0,0 @@
# frozen_string_literal: true
class PaginationComponent < ViewComponentReflex::Component
def initialize(pagy:, data:)
super
@count = pagy.count
@page = pagy.page
@per_page = pagy.items
@pages = pagy.pages
@next = pagy.next
@prev = pagy.prev
@data = data
@series = pagy.series
end
end

View File

@@ -1,16 +0,0 @@
= component_controller do
%nav{"aria-label": "pagination"}
.pagination
.pagination-prev{data: @prev.nil? ? nil : @data, "data-page": @prev, class: "#{'inactive' if @prev.nil?}"}
= I18n.t "components.pagination.previous"
.pagination-pages
- @series.each do |page|
- if page == :gap
.pagination-gap
- else
.pagination-page{data: @data, "data-page": page, class: "#{'active' if page.to_i == @page}"}
= page
.pagination-next{data: @next.nil? ? nil : @data, "data-page": @next, class: "#{'inactive' if @next.nil?}"}
= I18n.t "components.pagination.next"

View File

@@ -1,69 +0,0 @@
nav {
.pagination {
display: flex;
justify-content: space-between;
align-items: flex-start;
font-size: 14px;
.pagination-prev, .pagination-next {
cursor: pointer;
&:after, &:before {
font-size: 2em;
position: relative;
top: 3px;
}
&.inactive {
cursor: default;
color: $disabled-dark;
}
}
.pagination-prev {
margin-left: 10px;
&:before {
content: "";
margin-left: 10px;
margin-right: 10px;
}
}
.pagination-next {
margin-right: 10px;
&:after {
content: "";
margin-left: 10px;
margin-right: 10px;
}
}
.pagination-pages {
display: flex;
align-items: flex-end;
.pagination-gap, .pagination-page {
padding: 0 0.5rem;
margin-left: 10px;
margin-right: 10px;
}
.pagination-gap {
color: $disabled-dark;
}
.pagination-page {
color: $color-4;
cursor: pointer;
&.active {
border-top: 3px solid $spree-blue;
color: $spree-blue;
cursor: default;
}
}
}
}
}

View File

@@ -1,57 +0,0 @@
# frozen_string_literal: true
class ProductComponent < ViewComponentReflex::Component
DATETIME_FORMAT = '%F %T'
def initialize(product:, columns:)
super
@product = product
@image = @product.image if product.image.present?
@columns = columns.map do |c|
{
id: c[:value],
value: column_value(c[:value])
}
end
end
# This must be define when using ProductComponent.with_collection()
def collection_key
@product.id
end
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
def column_value(column)
case column
when 'name'
@product.name
when 'price'
@product.price
when 'unit'
"#{@product.variants.first.unit_value} #{@product.variant_unit}"
when 'producer'
@product.supplier.name
when 'category'
@product.taxons.map(&:name).join(', ')
when 'sku'
@product.sku
when 'on_hand'
@product.on_hand || 0
when 'on_demand'
@product.on_demand
when 'tax_category'
@product.tax_category.name
when 'inherits_properties'
@product.inherits_properties
when 'import_date'
format_date(@product.import_date)
end
end
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength
private
def format_date(date)
date&.strftime(DATETIME_FORMAT) || ''
end
end

View File

@@ -1,6 +0,0 @@
%tr
- @columns.each do |column|
%td.products_column{class: column[:id]}
- if column[:id] == "name" && @image&.attachment.present?
= image_tag @image.url(:mini)
= column[:value]

View File

@@ -1,179 +0,0 @@
# frozen_string_literal: true
class ProductsTableComponent < ViewComponentReflex::Component
include Pagy::Backend
SORTABLE_COLUMNS = ['name', 'import_date'].freeze
SELECTABLE_COLUMNS = [
{ label: I18n.t("admin.products_page.columns_selector.price"), value: "price" },
{ label: I18n.t("admin.products_page.columns_selector.unit"), value: "unit" },
{ label: I18n.t("admin.products_page.columns_selector.producer"), value: "producer" },
{ label: I18n.t("admin.products_page.columns_selector.category"), value: "category" },
{ label: I18n.t("admin.products_page.columns_selector.sku"), value: "sku" },
{ label: I18n.t("admin.products_page.columns_selector.on_hand"), value: "on_hand" },
{ label: I18n.t("admin.products_page.columns_selector.on_demand"), value: "on_demand" },
{ label: I18n.t("admin.products_page.columns_selector.tax_category"), value: "tax_category" },
{
label: I18n.t("admin.products_page.columns_selector.inherits_properties"),
value: "inherits_properties"
},
{ label: I18n.t("admin.products_page.columns_selector.import_date"), value: "import_date" }
].sort do |a, b|
a[:label] <=> b[:label]
end.freeze
PER_PAGE_VALUE = [10, 25, 50, 100].freeze
PER_PAGE = PER_PAGE_VALUE.map { |value| { label: value, value: value } }
NAME_COLUMN = {
label: I18n.t("admin.products_page.columns.name"), value: "name", sortable: true
}.freeze
def initialize(user:)
super
@user = user
@selectable_columns = SELECTABLE_COLUMNS
@columns_selected = ['unit', 'price', 'on_hand', 'category', 'import_date']
@per_page = PER_PAGE
@per_page_selected = [10]
@categories = [{ label: "All", value: "all" }] +
Spree::Taxon.order(:name)
.map { |taxon| { label: taxon.name, value: taxon.id.to_s } }
@categories_selected = ["all"]
@producers = [{ label: "All", value: "all" }] +
OpenFoodNetwork::Permissions.new(@user)
.managed_product_enterprises.is_primary_producer.by_name
.map { |producer| { label: producer.name, value: producer.id.to_s } }
@producers_selected = ["all"]
@page = 1
@sort = { column: "name", direction: "asc" }
@search_term = ""
end
# any change on a "reflex_data_attributes" (defined in the template) will trigger a re render
def before_render
fetch_products
refresh_columns
end
# Element refers to the component the data is set on
def search_term
# Element is SearchInputComponent
@search_term = element.dataset['value']
end
def toggle_column
# Element is SelectorComponent
column = element.dataset['value']
@columns_selected = if @columns_selected.include?(column)
@columns_selected - [column]
else
@columns_selected + [column]
end
end
def click_sort
# Element is TableHeaderComponent
@sort = {
column: element.dataset['sort-value'],
direction: element.dataset['sort-direction'] == "asc" ? "desc" : "asc"
}
end
def toggle_per_page
# Element is SelectorComponent
selected = element.dataset['value'].to_i
@per_page_selected = [selected] if PER_PAGE_VALUE.include?(selected)
end
def toggle_category
# Element is SelectorWithFilterComponent
category_clicked = element.dataset['value']
@categories_selected = toggle_selector_with_filter(category_clicked, @categories_selected)
end
def toggle_producer
# Element is SelectorWithFilterComponent
producer_clicked = element.dataset['value']
@producers_selected = toggle_selector_with_filter(producer_clicked, @producers_selected)
end
def change_page
# Element is PaginationComponent
page = element.dataset['page'].to_i
@page = page if page > 0
end
private
def refresh_columns
@columns = @columns_selected.map do |column|
{
label: I18n.t("admin.products_page.columns.#{column}"),
value: column,
sortable: SORTABLE_COLUMNS.include?(column)
}
end.sort! { |a, b| a[:label] <=> b[:label] }
@columns.unshift(NAME_COLUMN)
end
def toggle_selector_with_filter(clicked, selected)
selected = if selected.include?(clicked)
selected - [clicked]
else
selected + [clicked]
end
if clicked == "all" || selected.empty?
selected = ["all"]
elsif selected.include?("all") && selected.length > 1
selected -= ["all"]
end
selected
end
def fetch_products
product_query = OpenFoodNetwork::Permissions.new(@user).editable_products.merge(product_scope)
@products = product_query.ransack(ransack_query).result
@pagy, @products = pagy(@products, items: @per_page_selected.first, page: @page)
end
def product_scope
scope = if @user.has_spree_role?("admin") || @user.enterprises.present?
Spree::Product
else
Spree::Product.active
end
scope.includes(product_query_includes)
end
def ransack_query
query = { s: "#{@sort[:column]} #{@sort[:direction]}" }
query = if @producers_selected.include?("all")
query.merge({ supplier_id_eq: "" })
else
query.merge({ supplier_id_in: @producers_selected })
end
query = query.merge({ name_cont: @search_term }) if @search_term.present?
if @categories_selected.include?("all")
query.merge({ primary_taxon_id_eq: "" })
else
query.merge({ primary_taxon_id_in: @categories_selected })
end
end
def product_query_includes
[
:image,
variants: [
:default_price,
:stock_locations,
:stock_items,
:variant_overrides
]
]
end
end

View File

@@ -1,21 +0,0 @@
= component_controller(class: "products-table") do
.products-table-form
.products-table-form_filter_results
= render(SearchInputComponent.new(value: @search_term, data: reflex_data_attributes(:search_term)))
.products-table-form_categories_selector
= render(SelectorWithFilterComponent.new(title: t("admin.products_page.filters.categories.title"), selected: @categories_selected, items: @categories, data: reflex_data_attributes(:toggle_category), selected_items_i18n_key: "admin.products_page.filters.categories.selected_categories"))
.products-table-form_producers_selector
= render(SelectorWithFilterComponent.new(title: t("admin.products_page.filters.producers.title"), selected: @producers_selected, items: @producers, data: reflex_data_attributes(:toggle_producer), selected_items_i18n_key: "admin.products_page.filters.producers.selected_producers"))
.products-table-form_per-page_selector
= render(SelectorComponent.new(title: t('admin.products_page.filters.per_page', count: @per_page_selected[0]), selected: @per_page_selected, items: @per_page, data: reflex_data_attributes(:toggle_per_page)))
.products-table-form_columns_selector
= render(SelectorComponent.new(title: t("admin.products_page.filters.columns"), selected: @columns_selected, items: @selectable_columns, data: reflex_data_attributes(:toggle_column)))
.products-table_table
%table
= render(TableHeaderComponent.new(columns: @columns, sort: @sort, data: reflex_data_attributes(:click_sort)))
%tbody
= render(ProductComponent.with_collection(@products, columns: @columns))
.products-table-form_pagination
= render(PaginationComponent.new(pagy: @pagy, data: reflex_data_attributes(:change_page)))

View File

@@ -1,47 +0,0 @@
.products-table {
.products-table-form {
display: grid;
grid-template-columns: repeat( auto-fit, minmax(250px, 1fr) );
grid-gap: 10px;
margin-bottom: 10px;
}
.products-table_table {
box-shadow: 0 10px 10px -1px rgb(0 0 0 / 10%);
}
.products-table-form_pagination {
position: relative;
top: -15px;
nav, .pagination {
margin-top: 0;
padding-top: 0;
}
}
}
.products-table.loading {
.products-table-form_pagination, .products-table_table {
position: relative;
&:before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.5);
}
}
.products-table_table {
&:before {
background-position: center;
background-repeat: no-repeat;
background-size: 50px 50px;
background-image: url("../images/spinning-circles.svg");
}
}
}

View File

@@ -1,9 +0,0 @@
# frozen_string_literal: true
class SearchInputComponent < ViewComponentReflex::Component
def initialize(value: nil, data: {})
super
@value = value
@data = data
end
end

View File

@@ -1,5 +0,0 @@
= component_controller do
%div.search-input
%input{type: 'text', placeholder: t("components.search_input.placeholder"), id: 'search_query', data: {action: 'debounced:input->search-input#search'}, value: @value}
.search-button{data: @data}
%i.fa.fa-search

View File

@@ -1,23 +0,0 @@
.search-input {
border: 1px solid $disabled-light;
height: 3em;
display: flex;
line-height: 3em;
align-items: center;
input {
border: none;
height: 3em;
width: 100%;
box-sizing: border-box;
padding-right: 5px;
}
.search-button {
padding-right: 10px;
padding-left: 5px;
cursor: pointer;
color: $color-4;
}
}

View File

@@ -1,17 +0,0 @@
# frozen_string_literal: true
class SelectorComponent < ViewComponentReflex::Component
def initialize(title:, selected:, items:, data: {})
super
@title = title
@items = items.map do |item|
{
label: item[:label],
value: item[:value],
selected: selected.include?(item[:value])
}
end
@selected = selected
@data = data
end
end

View File

@@ -1,11 +0,0 @@
= component_controller do
.selector.selector-close
.selector-main{ data: { action: "click->selector#toggle" } }
.selector-main-title
= @title
.selector-arrow
.selector-wrapper
.selector-items
- @items.each do |item|
.selector-item{ class: ("selected" if item[:selected]), data: @data, "data-value": item[:value] }
= item[:label]

View File

@@ -1,86 +0,0 @@
.selector {
position: relative;
.selector-main {
border: 1px solid $disabled-light;
height: 3em;
position: relative;
cursor: pointer;
.selector-main-title {
line-height: 3em;
padding-left: 10px;
padding-right: 10px;
}
.selector-arrow {
position: absolute;
right: 0px;
height: 3em;
width: 1.5em;
top: -1px;
&:after {
content: "";
position: absolute;
top: 50%;
right: 5px;
margin-top: -5px;
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 5px solid $disabled-light;
}
}
}
.selector-wrapper {
position: absolute;
left: 0px;
right: 0px;
z-index: 1;
background-color: white;
margin-top: -1px;
border: 1px solid $disabled-light;
.selector-items {
overflow-y: auto;
min-height: 6em;
.selector-item {
padding-left: 10px;
padding-right: 10px;
border-bottom: 1px solid $disabled-light;
position: relative;
height: 3em;
line-height: 3em;
&:hover {
background-color: #eee;
cursor: pointer;
}
&:last-child {
border-bottom: none;
}
&.selected {
&:after {
content: "";
display: inline-block;
position: absolute;
right: 10px;
}
}
}
}
}
&.selector-close {
.selector-wrapper {
display: none;
}
}
}

View File

@@ -1,11 +0,0 @@
# frozen_string_literal: true
class SelectorWithFilterComponent < SelectorComponent
def initialize(title:, selected:, items:, data: {},
selected_items_i18n_key: 'components.selector_with_filter.selected_items')
super(title: title, selected: selected, items: items, data: data)
@selected_items = items.select { |item| @selected.include?(item[:value]) }
@selected_items_i18n_key = selected_items_i18n_key
@items = items
end
end

View File

@@ -1,22 +0,0 @@
= component_controller do
.super-selector.selector.selector-close
.selector-main{ data: { action: "click->selector-with-filter#toggle" } }
.super-selector-label
= @title
.super-selector-selected-items
- case @selected_items.length
- when 1, 2
- @selected_items.each do |item|
.super-selector-selected-item
= item[:label]
- else
.super-selector-selected-item
= t(@selected_items_i18n_key, count: @selected_items.length)
.selector-arrow
.selector-wrapper
.super-selector-search
%input{type: "text", placeholder: t("components.selector_with_filter.search_placeholder"), data: { action: "debounced:input->selector-with-filter#filter" } }
.selector-items
- @items.each do |item|
.selector-item{ class: ("selected" if item[:selected]), data: @data.merge({ "selector-with-filter-target": "items" }), "data-value": item[:value] }
= item[:label]

View File

@@ -1,51 +0,0 @@
.super-selector {
position: relative;
.selector-main {
.super-selector-label {
padding-left: 5px;
padding-right: 5px;
margin-left: 10px;
position: absolute;
top: -1em;
background-color: white;
}
}
.super-selector-selected-items {
margin-left: 5px;
margin-right: 2em;
margin-top: 7px;
display: flex;
.super-selector-selected-item {
border: 1px solid $pale-blue;
background-color: $spree-light-blue;
border-radius: 20px;
height: 2em;
padding-left: 10px;
padding-right: 10px;
display: inline-block;
margin-right: 5px;
padding-top: 2px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
.selector-wrapper {
.super-selector-search {
border-bottom: 1px solid $disabled-light;
padding: 10px 5px;
input {
border: 1px solid $disabled-light;
box-sizing: border-box;
border-radius: 4px;
width: 100%;
}
}
}
}

View File

@@ -1,10 +0,0 @@
# frozen_string_literal: true
class TableHeaderComponent < ViewComponentReflex::Component
def initialize(columns:, sort:, data: {})
super
@columns = columns
@sort = sort
@data = data
end
end

View File

@@ -1,7 +0,0 @@
= component_controller do
%thead.table-header
%tr
- @columns.each do |column|
%th{class: (column[:sortable] ? "th-sortable " : "" ) + (@sort[:column] == column[:value] ? " th-sorted-#{@sort[:direction]}" : ""), data: (@data if column[:sortable] == true), "data-sort-value": column[:value], "data-sort-direction": @sort[:direction]}
= column[:label]

View File

@@ -1,23 +0,0 @@
thead.table-header {
th {
&.th-sortable {
cursor: pointer;
}
&.th-sorted-asc, &.th-sorted-desc {
&:after {
display: inline-block;
padding-left: 10px;
}
}
&.th-sorted-asc {
&:after {
content: "";
}
}
&.th-sorted-desc {
&:after {
content: "";
}
}
}
}

View File

@@ -6,8 +6,6 @@ module Admin
class EnterpriseFeesController < Admin::ResourceController
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?
@@ -36,7 +34,8 @@ module Admin
end
def bulk_update
@enterprise_fee_set = Sets::EnterpriseFeeSet.new(enterprise_fee_bulk_params)
# Forms has strong parameters, so we don't need to validate them in controller
@enterprise_fee_set = EnterpriseFeesBulkUpdate.new(params)
if @enterprise_fee_set.save
redirect_to redirect_path, notice: I18n.t(:enterprise_fees_update_notice)
@@ -89,47 +88,5 @@ module Admin
main_app.admin_enterprise_fees_path
end
def enterprise_fee_bulk_params
params.require(:sets_enterprise_fee_set).permit(
collection_attributes: [
:id, :enterprise_id, :fee_type, :name, :tax_category_id,
:inherits_tax_category, :calculator_type,
{ calculator_attributes: PermittedAttributes::Calculator.attributes }
]
)
end
def check_enterprise_fee_input
enterprise_fee_bulk_params['collection_attributes'].each do |_, fee_row|
enterprise_fees = fee_row['calculator_attributes']&.slice(
:preferred_flat_percent, :preferred_amount,
:preferred_first_item, :preferred_additional_item,
:preferred_minimal_amount, :preferred_normal_amount,
:preferred_discount_amount, :preferred_per_unit
)
next unless enterprise_fees
enterprise_fees.each do |_, enterprise_amount|
unless enterprise_amount.nil? || Float(enterprise_amount, exception: false)
flash[:error] = I18n.t(:calculator_preferred_value_error)
return redirect_to redirect_path
end
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

@@ -92,7 +92,7 @@ module Admin
return render :welcome, layout: "spree/layouts/bare_admin"
end
attributes = { sells: register_params[:sells], visible: true }
attributes = { sells: register_params[:sells], visible: "only_through_links" }
if @enterprise.update(attributes)
flash[:success] = I18n.t(:enterprise_register_success_notice, enterprise: @enterprise.name)

View File

@@ -139,7 +139,8 @@ module Admin
end
def raise_invalid_file_path
redirect_to '/admin/product_import', notice: I18n.t(:product_import_no_data_in_spreadsheet_notice)
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$}

View File

@@ -1,7 +0,0 @@
# frozen_string_literal: true
module Admin
class ProductsController < Spree::Admin::BaseController
def index; end
end
end

View File

@@ -13,7 +13,7 @@ module Admin
if @proxy_order.cancel
render_as_json @proxy_order
else
render json: { errors: [t('admin.proxy_orders.cancel.could_not_cancel_the_order')] },
render json: { errors: [t('.could_not_cancel_the_order')] },
status: :unprocessable_entity
end
end
@@ -22,7 +22,7 @@ module Admin
if @proxy_order.resume
render_as_json @proxy_order
else
render json: { errors: [t('admin.proxy_orders.resume.could_not_resume_the_order')] },
render json: { errors: [t('.could_not_resume_the_order')] },
status: :unprocessable_entity
end
end

View File

@@ -55,6 +55,15 @@ module Admin
@report_title = report_title
@rendering_options = rendering_options
@data = Reporting::FrontendData.new(spree_current_user)
variant_id_in = params[:variant_id_in]&.compact_blank
load_selected_variant if variant_id_in.present?
end
# Orders and Fulfillment Reports include a per product filter, load any selected product
def load_selected_variant
variant = Spree::Variant.find(params[:variant_id_in][0])
@variant_serialized = Api::Admin::VariantSerializer.new(variant)
end
def render_data?

View File

@@ -24,9 +24,10 @@ module Admin
end
end
def update
if @object.update(permitted_resource_params)
flash[:success] = flash_message_for(@object, :successfully_updated)
def create
@object.attributes = permitted_resource_params
if @object.save
flash[:success] = flash_message_for(@object, :successfully_created)
respond_with(@object) do |format|
format.html { redirect_to location_after_save }
format.js { render layout: false }
@@ -36,10 +37,9 @@ module Admin
end
end
def create
@object.attributes = permitted_resource_params
if @object.save
flash[:success] = flash_message_for(@object, :successfully_created)
def update
if @object.update(permitted_resource_params)
flash[:success] = flash_message_for(@object, :successfully_updated)
respond_with(@object) do |format|
format.html { redirect_to location_after_save }
format.js { render layout: false }

View File

@@ -8,15 +8,13 @@ module Admin
include PaperTrailLogging
before_action :adapt_params, only: [:update]
before_action :editable_order_cycle_ids_for_create, only: [:create]
before_action :editable_order_cycle_ids_for_update, only: [:update]
before_action :check_dependent_subscriptions, only: [:destroy]
after_action :sync_subscriptions_for_update, only: :update
respond_to :json
respond_override create: { json: {
OVERRIDE_RESPONSE = { json: {
success: lambda {
render_as_json @schedule,
editable_schedule_ids: permissions.editable_schedules.pluck(:id)
@@ -25,17 +23,10 @@ module Admin
render json: { errors: @schedule.errors.full_messages },
status: :unprocessable_entity
}
} }
respond_override update: { json: {
success: lambda {
render_as_json @schedule,
editable_schedule_ids: permissions.editable_schedules.pluck(:id)
},
failure: lambda {
render json: { errors: @schedule.errors.full_messages },
status: :unprocessable_entity
}
} }
} }.freeze
respond_override create: OVERRIDE_RESPONSE
respond_override update: OVERRIDE_RESPONSE
def index
respond_to do |format|
@@ -50,22 +41,23 @@ module Admin
end
def create
return respond_with(@schedule) if params[:order_cycle_ids].blank?
@schedule.attributes = permitted_resource_params
if @schedule.save
@schedule.order_cycle_ids = params[:order_cycle_ids]
@schedule.save!
sync_subscriptions_for_create
@schedule_form = ScheduleForm.new(params, spree_current_user, @schedule)
if @schedule_form.save
flash[:success] = flash_message_for(@schedule, :successfully_created)
@existing_order_cycle_ids = []
sync_subscriptions_for_create
end
respond_with(@schedule)
end
def update
@existing_order_cycle_ids = @schedule.order_cycle_ids
@object = ScheduleForm.new(params, spree_current_user, @schedule)
super
end
private
def collection
@@ -96,37 +88,6 @@ module Admin
params[:schedule][:order_cycle_ids] = params[:order_cycle_ids]
end
def editable_order_cycle_ids_for_create
return unless params[:order_cycle_ids]
@existing_order_cycle_ids = []
result = editable_order_cycles(params[:order_cycle_ids])
params[:order_cycle_ids] = result
end
def editable_order_cycle_ids_for_update
return unless params[:schedule][:order_cycle_ids]
@existing_order_cycle_ids = @schedule.order_cycle_ids
result = editable_order_cycles(params[:schedule][:order_cycle_ids])
params[:schedule][:order_cycle_ids] = result
@schedule.order_cycle_ids = result
end
def editable_order_cycles(requested)
permitted = OrderCycle
.where(id: params[:order_cycle_ids] | @existing_order_cycle_ids)
.merge(OrderCycle.managed_by(spree_current_user))
.pluck(:id)
result = @existing_order_cycle_ids
result |= (requested & permitted) # add any requested & permitted ids
# remove any existing and permitted ids that were not specifically requested
result -= ((result & permitted) - requested)
result
end
def check_dependent_subscriptions
return if Subscription.where(schedule_id: @schedule).empty?
@@ -140,14 +101,14 @@ module Admin
@permissions = OpenFoodNetwork::Permissions.new(spree_current_user)
end
def sync_subscriptions_for_update
return unless params[:schedule][:order_cycle_ids] && @object.errors.blank?
def sync_subscriptions_for_create
return unless params[:order_cycle_ids]
sync_subscriptions
end
def sync_subscriptions_for_create
return unless params[:order_cycle_ids]
def sync_subscriptions_for_update
return unless params[:schedule][:order_cycle_ids] && @schedule.errors.blank?
sync_subscriptions
end
@@ -155,6 +116,7 @@ module Admin
def sync_subscriptions
removed_ids = @existing_order_cycle_ids - @schedule.order_cycle_ids
new_ids = @schedule.order_cycle_ids - @existing_order_cycle_ids
return unless removed_ids.any? || new_ids.any?
subscriptions = Subscription.where(schedule_id: @schedule)

View File

@@ -9,22 +9,28 @@ module Admin
end
def create
voucher_params = permitted_resource_params.merge(enterprise: @enterprise)
@voucher = Voucher.create(voucher_params)
@voucher = Voucher.new(
permitted_resource_params.merge(enterprise: @enterprise)
)
if @voucher.save
redirect_to(
"#{edit_admin_enterprise_path(@enterprise)}#vouchers_panel",
flash: { success: flash_message_for(@voucher, :successfully_created) }
)
flash[:success] = I18n.t(:successfully_created, resource: "Voucher")
redirect_to edit_admin_enterprise_path(@enterprise, anchor: :vouchers_panel)
else
flash[:error] = @voucher.errors.full_messages.to_sentence
render :new
render_error
end
rescue ActiveRecord::SubclassNotFound
@voucher.errors.add(:type)
render_error
end
private
def render_error
flash[:error] = @voucher.errors.full_messages.to_sentence
render :new
end
def load_enterprise
@enterprise = OpenFoodNetwork::Permissions
.new(spree_current_user)
@@ -33,7 +39,7 @@ module Admin
end
def permitted_resource_params
params.require(:voucher).permit(:code, :amount)
params.require(:voucher).permit(:code, :amount, :type)
end
end
end

View File

@@ -74,7 +74,7 @@ module Api
end
def override_visible
enterprise_params[:visible] = false
enterprise_params[:visible] = "only_through_links"
end
def enterprise_params

View File

@@ -5,11 +5,6 @@ module Api
class OrdersController < Api::V0::BaseController
include PaginationData
def show
authorize! :read, order
render json: order, serializer: Api::OrderDetailedSerializer, current_order: order
end
def index
authorize! :admin, Spree::Order
@@ -26,6 +21,11 @@ module Api
}
end
def show
authorize! :read, order
render json: order, serializer: Api::OrderDetailedSerializer, current_order: order
end
def update
authorize! :admin, order

View File

@@ -13,7 +13,7 @@ module Api
skip_authorization_check only: [:show, :bulk_products, :overridable]
def show
@product = find_product(params[:id])
@product = product_finder.find_product
render json: @product, serializer: Api::Admin::ProductSerializer
end
@@ -30,7 +30,7 @@ module Api
def update
authorize! :update, Spree::Product
@product = find_product(params[:id])
@product = product_finder.find_product
if @product.update(product_params)
render json: @product, serializer: Api::Admin::ProductSerializer, status: :ok
else
@@ -40,36 +40,20 @@ module Api
def destroy
authorize! :delete, Spree::Product
@product = find_product(params[:id])
@product = product_finder.find_product
authorize! :delete, @product
@product.destroy
render json: @product, serializer: Api::Admin::ProductSerializer, status: :no_content
end
def bulk_products
product_query = OpenFoodNetwork::Permissions.
new(current_api_user).
editable_products.
merge(product_scope)
if params[:import_date].present?
product_query = product_query.
imported_on(params[:import_date]).
group_by_products_id
end
@products = product_query.
ransack(query_params_with_defaults).
result
@products = product_finder.bulk_products
render_paged_products @products
end
def overridable
producer_ids = OpenFoodNetwork::Permissions.new(current_api_user).
variant_override_producers.by_name.select('enterprises.id')
@products = paged_products_for_producers producer_ids
@products = product_finder.paged_products_for_producers
render_paged_products @products, ::Api::Admin::ProductSimpleSerializer
end
@@ -78,7 +62,7 @@ module Api
#
def clone
authorize! :create, Spree::Product
original_product = find_product(params[:product_id])
original_product = product_finder.find_product_to_be_cloned
authorize! :update, original_product
@product = original_product.duplicate
@@ -88,37 +72,8 @@ module Api
private
def find_product(id)
product_scope.find(id)
end
def product_scope
if current_api_user.has_spree_role?("admin") || current_api_user.enterprises.present?
scope = Spree::Product
if params[:show_deleted]
scope = scope.with_deleted
end
else
scope = Spree::Product.active
end
scope.includes(product_query_includes)
end
def product_query_includes
[
image: { attachment_attachment: :blob },
variants: [:default_price, :stock_locations, :stock_items, :variant_overrides]
]
end
def paged_products_for_producers(producer_ids)
Spree::Product.where(nil).
merge(product_scope).
includes(variants: [:product, :default_price, :stock_items]).
where(supplier_id: producer_ids).
by_producer.by_name.
ransack(params[:q]).result
def product_finder
ProductScopeQuery.new(current_api_user, params)
end
def render_paged_products(products, product_serializer = ::Api::Admin::ProductSerializer)
@@ -135,10 +90,6 @@ module Api
}
end
def query_params_with_defaults
(params[:q] || {}).reverse_merge(s: 'created_at desc')
end
def product_params
@product_params ||=
params.permit(product: PermittedAttributes::Product.attributes)[:product].to_h

View File

@@ -69,14 +69,14 @@ module Api
end
def missing_parameter(error)
message = I18n.t(:missing_parameter, param: error.param, scope: :api)
message = I18n.t('api.missing_parameter', param: error.param)
render status: :unprocessable_entity,
json: json_api_error(message)
end
def unpermitted_parameters(error)
message = I18n.t(:unpermitted_parameters, params: error.params.join(", "), scope: :api)
message = I18n.t('api.unpermitted_parameters', params: error.params.join(", "))
render status: :unprocessable_entity,
json: json_api_error(message)

View File

@@ -14,7 +14,7 @@ module CheckoutCallbacks
prepend_before_action :require_order_cycle
prepend_before_action :require_distributor_chosen
before_action :load_order, :associate_user, :load_saved_addresses, :load_saved_credit_cards
before_action :load_order, :associate_user, :load_saved_addresses
before_action :load_shipping_methods, if: -> { params[:step] == "details" }
before_action :ensure_order_not_completed
@@ -30,8 +30,6 @@ 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
@@ -43,11 +41,6 @@ module CheckoutCallbacks
@order.ship_address ||= finder.ship_address
end
def load_saved_credit_cards
@saved_credit_cards = spree_current_user&.credit_cards&.with_payment_profile.to_a
@selected_card = nil
end
def load_shipping_methods
@shipping_methods = available_shipping_methods.sort { |a, b| a.name.casecmp(b.name) }
end

View File

@@ -0,0 +1,47 @@
# frozen_string_literal: true
module CheckoutSteps
extend ActiveSupport::Concern
private
def summary_step?
params[:step] == "summary"
end
def payment_step?
params[:step] == "payment"
end
def redirect_to_step_based_on_order
case @order.state
when "cart", "address", "delivery"
redirect_to checkout_step_path(:details)
when "payment"
redirect_to checkout_step_path(:payment)
when "confirmation"
redirect_to checkout_step_path(:summary)
else
redirect_to order_path(@order, order_token: @order.token)
end
end
def redirect_to_step
case params[:step]
when "details"
return redirect_to checkout_step_path(:payment)
when "payment"
return redirect_to checkout_step_path(:summary)
end
redirect_to_step_based_on_order
end
def check_step
case @order.state
when "cart", "address", "delivery"
redirect_to checkout_step_path(:details) unless params[:step] == "details"
when "payment"
redirect_to checkout_step_path(:payment) if params[:step] == "summary"
end
end
end

View File

@@ -16,7 +16,7 @@ module RequestTimeouts
respond_to do |type|
type.html {
render status: :gateway_timeout,
file: Rails.root.join("public/500.html"),
file: Rails.public_path.join('500.html'),
formats: [:html],
layout: nil
}

View File

@@ -9,7 +9,7 @@ class ErrorsController < ApplicationController
event.add_metadata(:request, request.env)
end
render status: :not_found
render status: :not_found, formats: :html
end
def internal_server_error

View File

@@ -8,6 +8,7 @@ class SplitCheckoutController < ::BaseController
include OrderStockCheck
include Spree::BaseHelper
include CheckoutCallbacks
include CheckoutSteps
include OrderCompletion
include CablecarResponses
include WhiteLabel
@@ -25,12 +26,12 @@ class SplitCheckoutController < ::BaseController
redirect_to_step_based_on_order unless params[:step]
check_step if params[:step]
flash_error_when_no_shipping_method_available if available_shipping_methods.none?
return if available_shipping_methods.any?
flash[:error] = I18n.t('split_checkout.errors.no_shipping_methods_available')
end
def update
return process_voucher if params[:apply_voucher].present?
if confirm_order || update_order
return if performed?
@@ -50,85 +51,13 @@ class SplitCheckoutController < ::BaseController
private
def render_error
flash.now[:error] ||= I18n.t(
'split_checkout.errors.saving_failed',
messages: order_error_messages
)
flash.now[:error] ||= I18n.t('split_checkout.errors.saving_failed')
render status: :unprocessable_entity, cable_ready: cable_car.
replace("#checkout", partial("split_checkout/checkout")).
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?
# Reorder errors to make sure the most important ones are shown first
# and finally, return the error messages to sentence
reorder_errors.map(&:full_message).to_sentence
end
def no_ship_address_needed?
@order.errors[:shipping_method].present? || params[:ship_address_same_as_billing] == "1"
end
def remove_ship_address_errors
@order.errors.delete("ship_address.firstname")
@order.errors.delete("ship_address.address1")
@order.errors.delete("ship_address.city")
@order.errors.delete("ship_address.phone")
@order.errors.delete("ship_address.lastname")
@order.errors.delete("ship_address.zipcode")
end
def reorder_errors
@order.errors.sort_by do |e|
case e.attribute
when /email/i then 0
when /phone/i then 1
when /bill_address/i then 2 + bill_address_error_order(e)
else 20
end
end
end
def bill_address_error_order(error)
case error.attribute
when /firstname/i then 0
when /lastname/i then 1
when /address1/i then 2
when /city/i then 3
when /zipcode/i then 4
else 5
end
end
def flash_error_when_no_shipping_method_available
flash[:error] = I18n.t('split_checkout.errors.no_shipping_methods_available')
end
def check_payments_adjustments
@order.payments.each(&:ensure_correct_adjustment)
end
@@ -139,7 +68,7 @@ class SplitCheckoutController < ::BaseController
def confirm_order
return unless summary_step? && @order.confirmation?
return unless validate_summary! && @order.errors.empty?
return unless validate_current_step
@order.customer.touch :terms_and_conditions_accepted_at
@@ -165,82 +94,15 @@ class SplitCheckoutController < ::BaseController
def update_order
return if params[:confirm_order] || @order.errors.any?
# If we have "pick up" shipping method (require_ship_address is set to false), use the
# distributor address as shipping address
use_shipping_address_from_distributor if shipping_method_ship_address_not_required?
@order.select_shipping_method(params[:shipping_method_id])
@order.update(order_params)
@order.update_totals_and_states
validate_current_step!
@order.errors.empty?
validate_current_step
end
def use_shipping_address_from_distributor
@order.ship_address = @order.address_from_distributor
# Add the missing data
bill_address = params[:order][:bill_address_attributes]
@order.ship_address.firstname = bill_address[:firstname]
@order.ship_address.lastname = bill_address[:lastname]
@order.ship_address.phone = bill_address[:phone]
# Remove shipping address from parameter so we don't override the address we just set
params[:order].delete(:ship_address_attributes)
end
def shipping_method_ship_address_not_required?
selected_shipping_method = available_shipping_methods&.select do |sm|
sm.id.to_s == params[:shipping_method_id]
end
return false if selected_shipping_method.empty?
selected_shipping_method.first.require_ship_address == false
end
def process_voucher
if add_voucher
VoucherAdjustmentsService.calculate(@order)
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)
unless 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"
def validate_current_step
Checkout::Validation.new(@order, params).call && @order.errors.empty?
end
def advance_order_state
@@ -249,63 +111,7 @@ class SplitCheckoutController < ::BaseController
OrderWorkflow.new(@order).advance_checkout(raw_params.slice(:shipping_method_id))
end
def validate_current_step!
step = ([params[:step]] & ["details", "payment", "summary"]).first
send("validate_#{step}!")
end
def validate_details!
return true if params[:shipping_method_id].present?
@order.errors.add :shipping_method, I18n.t('split_checkout.errors.select_a_shipping_method')
end
def validate_payment!
return true if params.dig(:order, :payments_attributes, 0, :payment_method_id).present?
@order.errors.add :payment_method, I18n.t('split_checkout.errors.select_a_payment_method')
end
def validate_summary!
return true if params[:accept_terms]
return true unless TermsOfService.required?(@order.distributor)
@order.errors.add(:terms_and_conditions, t("split_checkout.errors.terms_not_accepted"))
end
def order_params
@order_params ||= Checkout::Params.new(@order, params, spree_current_user).call
end
def redirect_to_step_based_on_order
case @order.state
when "cart", "address", "delivery"
redirect_to checkout_step_path(:details)
when "payment"
redirect_to checkout_step_path(:payment)
when "confirmation"
redirect_to checkout_step_path(:summary)
else
redirect_to order_path(@order, order_token: @order.token)
end
end
def redirect_to_step
case params[:step]
when "details"
return redirect_to checkout_step_path(:payment)
when "payment"
return redirect_to checkout_step_path(:summary)
end
redirect_to_step_based_on_order
end
def check_step
case @order.state
when "cart", "address", "delivery"
redirect_to checkout_step_path(:details) unless params[:step] == "details"
when "payment"
redirect_to checkout_step_path(:payment) if params[:step] == "summary"
end
end
end

View File

@@ -20,6 +20,10 @@ module Spree
render layout: !request.xhr?
end
def edit
@url_filters = ::ProductFilters.new.extract(request.query_parameters)
end
def create
@url_filters = ::ProductFilters.new.extract(request.query_parameters)
set_viewable
@@ -34,10 +38,6 @@ module Spree
end
end
def edit
@url_filters = ::ProductFilters.new.extract(request.query_parameters)
end
def update
@url_filters = ::ProductFilters.new.extract(request.query_parameters)
set_viewable

View File

@@ -4,58 +4,30 @@ module Spree
module Admin
class InvoicesController < Spree::Admin::BaseController
respond_to :json
authorize_resource class: false
def index
@order = Spree::Order.find_by(number: params[:order_id])
end
def create
invoice_service = BulkInvoiceService.new
invoice_service.start_pdf_job(params[:order_ids])
render json: invoice_service.id, status: :ok
end
def generate
@order = Order.find_by(number: params[:order_id])
@comparator = OrderInvoiceComparator.new(@order)
if @comparator.can_generate_new_invoice?
@order.invoices.create!(
date: Time.zone.today,
number: @order.invoices.count + 1,
data: invoice_data
)
elsif @comparator.can_update_latest_invoice?
@order.invoices.last.update!(
date: Time.zone.today,
data: invoice_data
)
end
redirect_back(fallback_location: spree.admin_dashboard_path)
authorize! :invoice, @order
end
def show
invoice_id = params[:id]
invoice_pdf = BulkInvoiceService.new.filepath(invoice_id)
invoice_pdf = filepath(invoice_id)
send_file(invoice_pdf, type: 'application/pdf', disposition: :inline)
end
def poll
invoice_id = params[:invoice_id]
if BulkInvoiceService.new.invoice_created? invoice_id
render json: { created: true }, status: :ok
else
render json: { created: false }, status: :unprocessable_entity
end
def generate
@order = Order.find_by(number: params[:order_id])
authorize! :invoice, @order
OrderInvoiceGenerator.new(@order).generate_or_update_latest_invoice
redirect_back(fallback_location: spree.admin_dashboard_path)
end
protected
private
def invoice_data
@invoice_data ||= InvoiceDataGenerator.new(@order).generate
def filepath(invoice_id)
"tmp/invoices/#{invoice_id}.pdf"
end
end
end

View File

@@ -16,8 +16,22 @@ module Spree
before_action :load_spree_api_key, only: [:index, :variant_overrides]
before_action :strip_new_properties, only: [:create, :update]
def index
@current_user = spree_current_user
@show_latest_import = params[:latest_import] || false
end
def show
session[:return_to] ||= request.referer
redirect_to( action: :edit )
end
def new
@object.shipping_category = DefaultShippingCategory.find_or_create
@object.shipping_category_id = DefaultShippingCategory.find_or_create.id
end
def edit
@url_filters = ::ProductFilters.new.extract(request.query_parameters)
end
def create
@@ -35,20 +49,6 @@ module Spree
end
end
def show
session[:return_to] ||= request.referer
redirect_to( action: :edit )
end
def index
@current_user = spree_current_user
@show_latest_import = params[:latest_import] || false
end
def edit
@url_filters = ::ProductFilters.new.extract(request.query_parameters)
end
def update
@url_filters = ::ProductFilters.new.extract(request.query_parameters)
@@ -180,7 +180,7 @@ module Spree
select('DISTINCT spree_variants.import_date').
joins(:product).
where('spree_products.supplier_id IN (?)', editable_enterprises.collect(&:id)).
where('spree_variants.import_date IS NOT NULL').
where.not(spree_variants: { import_date: nil }).
where(spree_variants: { deleted_at: nil }).
order('spree_variants.import_date DESC')
end

View File

@@ -5,6 +5,12 @@ module Spree
class TaxonsController < Spree::Admin::BaseController
respond_to :html, :json, :js
def edit
@taxonomy = Taxonomy.find(params[:taxonomy_id])
@taxon = @taxonomy.taxons.find(params[:id])
@permalink_part = @taxon.permalink.split("/").last
end
def create
@taxonomy = Taxonomy.find(params[:taxonomy_id])
@taxon = @taxonomy.taxons.build(params[:taxon])
@@ -26,12 +32,6 @@ module Spree
end
end
def edit
@taxonomy = Taxonomy.find(params[:taxonomy_id])
@taxon = @taxonomy.taxons.find(params[:id])
@permalink_part = @taxon.permalink.split("/").last
end
def update
@taxonomy = Taxonomy.find(params[:taxonomy_id])
@taxon = @taxonomy.taxons.find(params[:id])

View File

@@ -28,7 +28,7 @@ module Spree
if @user.save
if roles
@user.spree_roles = roles.reject(&:blank?).collect{ |r| Spree::Role.find(r) }
@user.spree_roles = roles.compact_blank.collect{ |r| Spree::Role.find(r) }
end
flash.now[:success] = Spree.t(:created_successfully)
@@ -45,7 +45,7 @@ module Spree
if @user.update(user_params)
if roles
@user.spree_roles = roles.reject(&:blank?).collect{ |r| Spree::Role.find(r) }
@user.spree_roles = roles.compact_blank.collect{ |r| Spree::Role.find(r) }
end
flash.now[:success] = update_message

View File

@@ -7,29 +7,19 @@ module Spree
class VariantsController < ::Admin::ResourceController
belongs_to 'spree/product'
before_action :load_data, only: [:new, :edit]
def index
@url_filters = ::ProductFilters.new.extract(request.query_parameters)
end
def edit
@url_filters = ::ProductFilters.new.extract(request.query_parameters)
end
def update
@url_filters = ::ProductFilters.new.extract(request.query_parameters)
if @object.update(permitted_resource_params)
flash[:success] = flash_message_for(@object, :successfully_updated)
redirect_to spree.admin_product_variants_url(params[:product_id], @url_filters)
else
redirect_to spree.edit_admin_product_variant_url(params[:product_id],
@object,
@url_filters)
end
end
def new
@url_filters = ::ProductFilters.new.extract(request.query_parameters)
@object.shipping_category ||= DefaultShippingCategory.find_or_create
end
def edit
@url_filters = ::ProductFilters.new.extract(request.query_parameters)
end
def create
@@ -53,6 +43,19 @@ module Spree
@object.on_hand = on_hand.to_i if on_hand.present?
end
def update
@url_filters = ::ProductFilters.new.extract(request.query_parameters)
if @object.update(permitted_resource_params)
flash[:success] = flash_message_for(@object, :successfully_updated)
redirect_to spree.admin_product_variants_url(params[:product_id], @url_filters)
else
redirect_to spree.edit_admin_product_variant_url(params[:product_id],
@object,
@url_filters)
end
end
def search
scoper = OpenFoodNetwork::ScopeVariantsForSearch.new(variant_search_params)
@variants = scoper.search
@@ -107,6 +110,13 @@ module Spree
:include_out_of_stock
).to_h.with_indifferent_access
end
private
def load_data
@tax_categories = TaxCategory.order(:name)
@shipping_categories = ShippingCategory.order(:name)
end
end
end
end

View File

@@ -69,6 +69,10 @@ module Spree
if @order.contents.update_cart(order_params)
@order.recreate_all_fees! # Enterprise fees on line items and on the order itself
# Re apply the voucher
VoucherAdjustmentsService.new(@order).update
@order.update_totals_and_states
if @order.complete?
@order.update_payment_fees!
@order.create_tax_charge!

View File

@@ -33,8 +33,8 @@ module Spree
render status: :ok, cable_ready: cable_car.
inner_html(
"#login-feedback",
partial("layouts/alert",
locals: { type: "alert", message: t('devise.failure.already_registered') })
partial("layouts/alert",
locals: { type: "alert", message: t('devise.failure.already_registered') })
).
dispatch_event(name: "login:modal:open")
else
@@ -48,9 +48,11 @@ module Spree
if @user.save
render cable_ready: cable_car.inner_html(
"#signup-feedback",
partial("layouts/alert",
locals: { type: "success",
message: t('devise.user_registrations.spree_user.signed_up_but_unconfirmed') })
partial("layouts/alert",
locals: {
type: "success",
message: t('devise.user_registrations.spree_user.signed_up_but_unconfirmed')
})
)
else
render status: :unprocessable_entity, cable_ready: cable_car.morph(

View File

@@ -5,6 +5,13 @@ class UserConfirmationsController < DeviseController
include Spree::Core::ControllerHelpers::Auth
include CablecarResponses
# GET /resource/confirmation?confirmation_token=abcdef
def show
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource) }
end
# GET /resource/confirmation/new
def new
build_resource({})
@@ -24,8 +31,8 @@ class UserConfirmationsController < DeviseController
else
render cable_ready: cable_car.inner_html(
"##{params[:tab] || 'forgot'}-feedback",
partial("layouts/alert",
locals: { type: "success", message: t("devise.confirmations.send_instructions") })
partial("layouts/alert",
locals: { type: "success", message: t("devise.confirmations.send_instructions") })
)
return
end
@@ -33,13 +40,6 @@ class UserConfirmationsController < DeviseController
respond_with_navigational(resource){ redirect_to login_path }
end
# GET /resource/confirmation?confirmation_token=abcdef
def show
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource) }
end
protected
def set_return_url

View File

@@ -1,32 +1,91 @@
# frozen_string_literal: true
class VoucherAdjustmentsController < BaseController
include CablecarResponses
before_action :set_order
def create
if add_voucher
update_payment_section
elsif @order.errors.present?
render_error
end
end
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) }
# An order can have more than one adjustment linked to one voucher
adjustment = @order.voucher_adjustments.find_by(id: params[:id])
if adjustment.present?
@order.voucher_adjustments.where(originator_id: adjustment.originator_id)&.destroy_all
end
# Update order to make sure we display the appropriate payment method
@order.update_totals_and_states
update_payment_section
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(
def set_order
@order = current_order
end
def add_voucher
if voucher_params[:voucher_code].blank?
@order.errors.add(:voucher_code, I18n.t('split_checkout.errors.voucher_not_found'))
return false
end
voucher = Voucher.find_by(code: voucher_params[:voucher_code], enterprise: @order.distributor)
if voucher.nil?
@order.errors.add(:voucher_code, I18n.t('split_checkout.errors.voucher_not_found'))
return false
end
adjustment = voucher.create_adjustment(voucher.code, @order)
unless adjustment.persisted?
@order.errors.add(:voucher_code, I18n.t('split_checkout.errors.add_voucher_error'))
adjustment.errors.each { |error| @order.errors.import(error) }
return false
end
clear_payments
VoucherAdjustmentsService.new(@order).update
@order.update_totals_and_states
true
end
def update_payment_section
render cable_ready: cable_car.replace(
selector: "#checkout-payment-methods",
html: render_to_string(partial: "split_checkout/payment", locals: { step: "payment" })
)
end
def render_error
flash.now[:error] = @order.errors.full_messages.to_sentence
render status: :unprocessable_entity, cable_ready: cable_car.
replace("#flashes", partial("shared/flashes", locals: { flashes: flash })).
replace(
"#voucher-section",
partial(
"split_checkout/voucher_section",
locals: { order: @order, voucher_adjustment: @order.voucher_adjustments.first }
)
)
)
end
def voucher_params
params.require(:order).permit(:voucher_code)
end
# Clear payments and payment fees, to not affect voucher adjustment calculation
def clear_payments
@order.payments.incomplete.destroy_all
end
end

View File

@@ -0,0 +1,74 @@
# frozen_string_literal: true
class EnterpriseFeesBulkUpdate
include ActiveModel::Model
attr_reader :errors
validate :check_enterprise_fee_input
validate :check_calculators_compatibility_with_taxes
def initialize(params)
@errors = ActiveModel::Errors.new self
@params = params
end
def save
return false unless valid?
@enterprise_fee_set = Sets::EnterpriseFeeSet.new(enterprise_fee_bulk_params)
unless @enterprise_fee_set.save
@enterprise_fee_set.errors.each do |error|
@errors.add(error.attribute, error.type)
end
return false
end
true
end
private
def check_enterprise_fee_input
enterprise_fee_bulk_params['collection_attributes'].each do |_, fee_row|
enterprise_fees = fee_row['calculator_attributes']&.slice(
:preferred_flat_percent, :preferred_amount,
:preferred_first_item, :preferred_additional_item,
:preferred_minimal_amount, :preferred_normal_amount,
:preferred_discount_amount, :preferred_per_unit
)
next unless enterprise_fees
enterprise_fees.each do |_, enterprise_amount|
unless enterprise_amount.nil? || Float(enterprise_amount, exception: false)
@errors.add(:base, I18n.t(:calculator_preferred_value_error))
end
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'])
@errors.add(
:base,
I18n.t(
'activerecord.errors.models.enterprise_fee.inherit_tax_requires_per_item_calculator'
)
)
end
end
def enterprise_fee_bulk_params
@params.require(:sets_enterprise_fee_set).permit(
collection_attributes: [
:id, :enterprise_id, :fee_type, :name, :tax_category_id,
:inherits_tax_category, :calculator_type,
{ calculator_attributes: PermittedAttributes::Calculator.attributes }
]
)
end
end

View File

@@ -0,0 +1,78 @@
# frozen_string_literal: true
class ScheduleForm
include ActiveModel::Model
attr_reader :errors, :flash_success
def initialize(params, user, schedule = nil)
@errors = ActiveModel::Errors.new self
# Not strong
@params = params
@current_user = user
@schedule = schedule
end
def save
editable_order_cycle_ids_for_create
return false if @params[:order_cycle_ids].blank?
@schedule.attributes = permitted_resource_params
if @schedule.save
@schedule.order_cycle_ids = @params[:order_cycle_ids]
@schedule.save!
end
true
end
def update(_params)
editable_order_cycle_ids_for_update
false unless @schedule.update(permitted_resource_params)
end
def order_cycle_ids
@schedule.order_cycle_ids
end
private
def editable_order_cycle_ids_for_create
return unless @params[:order_cycle_ids]
@existing_order_cycle_ids = []
result = editable_order_cycles(@params[:order_cycle_ids])
@params[:order_cycle_ids] = result
end
def editable_order_cycle_ids_for_update
return unless @params[:schedule][:order_cycle_ids]
@existing_order_cycle_ids = @schedule.order_cycle_ids
result = editable_order_cycles(@params[:schedule][:order_cycle_ids])
@params[:schedule][:order_cycle_ids] = result
@schedule.order_cycle_ids = result
end
def editable_order_cycles(requested)
permitted = OrderCycle
.where(id: @params[:order_cycle_ids] | @existing_order_cycle_ids)
.merge(OrderCycle.managed_by(@current_user))
.pluck(:id)
result = @existing_order_cycle_ids
result |= (requested & permitted) # add any requested & permitted ids
# remove any existing and permitted ids that were not specifically requested
result -= ((result & permitted) - requested)
result
end
def permitted_resource_params
@params.require(:schedule).permit(:id, :name, order_cycle_ids: [])
end
end

View File

@@ -42,7 +42,7 @@ module Admin
{ name: 'shipping_methods', icon_class: "icon-truck", show: show_shipping_methods },
{ name: 'payment_methods', icon_class: "icon-money", show: show_payment_methods },
{ name: 'enterprise_fees', icon_class: "icon-tasks", show: show_enterprise_fees },
{ name: 'vouchers', icon_class: "icon-ticket", show: true },
{ name: 'vouchers', icon_class: "icon-ticket", show: is_shop },
{ name: 'enterprise_permissions', icon_class: "icon-plug", show: true,
href: admin_enterprise_relationships_path },
{ name: 'inventory_settings', icon_class: "icon-list-ol", show: is_shop },

View File

@@ -38,15 +38,15 @@ module ApplicationHelper
end.join("\n").html_safe
end
def ng_form_for(name, *args, &block)
def ng_form_for(name, *args, &)
options = args.extract_options!
form_for(name, *(args << options.merge(builder: AngularFormBuilder)), &block)
form_for(name, *(args << options.merge(builder: AngularFormBuilder)), &)
end
# Pass URL helper calls on to spree where applicable so that we don't need to use
# spree.foo_path in any view rendered from non-spree-namespaced controllers.
def method_missing(method, *args, &block)
def method_missing(method, *args, &)
if method.to_s.end_with?('_path', '_url') && spree.respond_to?(method)
spree.public_send(method, *args)
else

View File

@@ -120,6 +120,8 @@ module CheckoutHelper
end
def payment_or_shipping_price(method, order)
return unless method
price = method.compute_amount(order)
if price.zero?
t('checkout_method_free')

View File

@@ -6,7 +6,7 @@ module DiscourseHelper
end
def discourse_url
ENV['DISCOURSE_URL']
ENV.fetch('DISCOURSE_URL', nil)
end
def discourse_login_url

View File

@@ -1,11 +1,11 @@
# frozen_string_literal: true
module LinkHelper
def link_to_service(baseurl, name, html_options = {}, &block)
def link_to_service(baseurl, name, html_options = {}, &)
return if name.blank?
html_options = html_options.merge target: '_blank'
link_to ext_url(baseurl, name), html_options, &block
link_to(ext_url(baseurl, name), html_options, &)
end
def ext_url(prefix, url)

View File

@@ -3,14 +3,14 @@
module Spree
module Admin
module BaseHelper
def field_container(model, method, options = {}, &block)
def field_container(model, method, options = {}, &)
css_classes = options[:class].to_a
css_classes << 'field'
if error_message_on(model, method).present?
css_classes << 'withError'
end
content_tag(:div,
capture(&block),
capture(&),
class: css_classes.join(' '),
id: "#{model}_#{method}_field")
end

View File

@@ -5,11 +5,13 @@ module Spree
def payment_method(payment)
# hack to allow us to retrieve the name of a "deleted" payment method
id = payment.payment_method_id
return if id.nil?
Spree::PaymentMethod.find_with_destroyed(id)
end
def payment_method_name(payment)
payment_method(payment).name
payment_method(payment)&.name
end
end
end

View File

@@ -5,13 +5,9 @@ class BulkInvoiceJob < ApplicationJob
delegate :render, to: ActionController::Base
def perform(order_ids, filepath, options = {})
pdf = CombinePDF.new
sorted_orders(order_ids).each do |order|
invoice = renderer.render_to_string(order)
pdf << CombinePDF.parse(invoice)
end
orders = sorted_orders(order_ids)
orders.filter!(&:invoiceable?) if OpenFoodNetwork::FeatureToggle.enabled?(:invoices)
orders.each(&method(:generate_invoice))
ensure_directory_exists filepath
@@ -32,6 +28,17 @@ class BulkInvoiceJob < ApplicationJob
@renderer ||= InvoiceRenderer.new
end
def generate_invoice(order)
renderer_data = if OpenFoodNetwork::FeatureToggle.enabled?(:invoices)
OrderInvoiceGenerator.new(order).generate_or_update_latest_invoice
order.invoices.first.presenter
else
order
end
invoice = renderer.render_to_string(renderer_data)
pdf << CombinePDF.parse(invoice)
end
def broadcast(filepath, channel)
file_id = filepath.split("/").last.split(".").first
@@ -47,4 +54,8 @@ class BulkInvoiceJob < ApplicationJob
def ensure_directory_exists(filepath)
FileUtils.mkdir_p(File.dirname(filepath))
end
def pdf
@pdf ||= CombinePDF.new
end
end

View File

@@ -48,7 +48,14 @@ module Spree
def invoice_email(order_or_order_id)
@order = find_order(order_or_order_id)
pdf = InvoiceRenderer.new.render_to_string(@order)
renderer_data = if OpenFoodNetwork::FeatureToggle.enabled?(:invoices)
OrderInvoiceGenerator.new(@order).generate_or_update_latest_invoice
@order.invoices.first.presenter
else
@order
end
pdf = InvoiceRenderer.new.render_to_string(renderer_data)
attach_file("invoice-#{@order.number}.pdf", pdf)
I18n.with_locale valid_locale(@order.user) do

View File

@@ -1,8 +1,6 @@
# frozen_string_literal: true
class AdjustmentMetadata < ApplicationRecord
self.belongs_to_required_by_default = true
belongs_to :adjustment, class_name: 'Spree::Adjustment'
belongs_to :enterprise
end

View File

@@ -45,7 +45,7 @@ module Calculator
def line_items_total(order)
matched_line_items = order.line_items.select do |line_item|
line_item.product.tax_category == rate.tax_category
line_item.variant.tax_category == rate.tax_category
end
matched_line_items.sum(&:total)
@@ -70,7 +70,7 @@ module Calculator
def applicable_rate?(applicator, line_item)
fee = applicator.enterprise_fee
(!fee.inherits_tax_category && fee.tax_category == rate.tax_category) ||
(fee.inherits_tax_category && line_item.product.tax_category == rate.tax_category)
(fee.inherits_tax_category && line_item.variant.tax_category == rate.tax_category)
end
# Finds relevant fees for whole order,

View File

@@ -35,7 +35,7 @@ module Calculator
private
def compute_for(count)
count * preferred_additional_item.to_f + preferred_first_item.to_f
(count * preferred_additional_item.to_f) + preferred_first_item.to_f
end
end
end

View File

@@ -5,8 +5,6 @@ require 'open_food_network/column_preference_defaults'
class ColumnPreference < ApplicationRecord
extend OpenFoodNetwork::ColumnPreferenceDefaults
self.belongs_to_required_by_default = true
# Non-persisted attributes that only have one
# setting (ie. the default) for a given column
attr_accessor :name

View File

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

View File

@@ -34,7 +34,7 @@ module PermalinkGenerator
if id.nil?
scope_with_deleted
else
scope_with_deleted.where('id != ?', id)
scope_with_deleted.where.not(id:)
end
end

View File

@@ -71,7 +71,7 @@ class ContentConfiguration < Spree::Preferences::Configuration
preference :footer_pinterest_url, :string, default: ""
preference :footer_email, :string, default: "hello@openfoodnetwork.org"
preference :community_forum_url, :string, default: "http://community.openfoodnetwork.org"
preference :footer_links_md, :text, default: <<-EOS.strip_heredoc
preference :footer_links_md, :text, default: <<~EOS
[Newsletter sign-up](/)
[News](/)

View File

@@ -1,8 +1,6 @@
# frozen_string_literal: true
class CoordinatorFee < ApplicationRecord
self.belongs_to_required_by_default = true
belongs_to :order_cycle
belongs_to :enterprise_fee
end

View File

@@ -1,7 +1,7 @@
# frozen_string_literal: false
class CustomTab < ApplicationRecord
belongs_to :enterprise, optional: false
belongs_to :enterprise
validates :title, presence: true, length: { maximum: 20 }
end

View File

@@ -10,8 +10,6 @@
class Customer < ApplicationRecord
include SetUnusedAddressFields
self.belongs_to_required_by_default = true
acts_as_taggable
searchable_attributes :first_name, :last_name, :email, :code
@@ -19,6 +17,9 @@ class Customer < ApplicationRecord
belongs_to :enterprise
belongs_to :user, class_name: "Spree::User", optional: true
has_many :orders, class_name: "Spree::Order"
before_validation :downcase_email
before_validation :empty_code
before_create :associate_user
before_destroy :update_orders_and_delete_canceled_subscriptions
belongs_to :bill_address, class_name: "Spree::Address", optional: true
@@ -29,9 +30,6 @@ class Customer < ApplicationRecord
alias_attribute :shipping_address, :ship_address
accepts_nested_attributes_for :ship_address
before_validation :downcase_email
before_validation :empty_code
validates :code, uniqueness: { scope: :enterprise_id, allow_nil: true }
validates :email, presence: true, 'valid_email_2/email': true,
uniqueness: {
@@ -40,12 +38,12 @@ class Customer < ApplicationRecord
}
scope :of, ->(enterprise) { where(enterprise_id: enterprise) }
scope :managed_by, ->(user) { user&.persisted? ? where(user: user).or(of(Enterprise.managed_by(user))) : none }
scope :managed_by, ->(user) {
user&.persisted? ? where(user: user).or(of(Enterprise.managed_by(user))) : none
}
scope :created_manually, -> { where(created_manually: true) }
scope :visible, -> { where(id: Spree::Order.complete.select(:customer_id)).or(created_manually) }
before_create :associate_user
attr_accessor :gateway_recurring_payment_client_secret, :gateway_shop_id
def full_name

View File

@@ -2,7 +2,6 @@
class DistributorPaymentMethod < ApplicationRecord
self.table_name = "distributors_payment_methods"
self.belongs_to_required_by_default = true
belongs_to :payment_method, class_name: "Spree::PaymentMethod", touch: true
belongs_to :distributor, class_name: "Enterprise", touch: true

View File

@@ -2,7 +2,6 @@
class DistributorShippingMethod < ApplicationRecord
self.table_name = "distributors_shipping_methods"
self.belongs_to_required_by_default = true
belongs_to :shipping_method, class_name: "Spree::ShippingMethod", touch: true
belongs_to :distributor, class_name: "Enterprise", touch: true

View File

@@ -44,16 +44,16 @@ class Enterprise < ApplicationRecord
dependent: :destroy
has_many :distributed_orders, class_name: 'Spree::Order', foreign_key: 'distributor_id'
belongs_to :address, class_name: 'Spree::Address'
belongs_to :business_address, class_name: 'Spree::Address', dependent: :destroy
belongs_to :business_address, optional: true, class_name: 'Spree::Address', dependent: :destroy
has_many :enterprise_fees
has_many :enterprise_roles, dependent: :destroy
has_many :users, through: :enterprise_roles
belongs_to :owner, class_name: 'Spree::User',
inverse_of: :owned_enterprises
has_many :distributor_payment_methods,
inverse_of: :distributor, foreign_key: :distributor_id
inverse_of: :distributor, foreign_key: :distributor_id
has_many :distributor_shipping_methods,
inverse_of: :distributor, foreign_key: :distributor_id
inverse_of: :distributor, foreign_key: :distributor_id
has_many :payment_methods, through: :distributor_payment_methods
has_many :shipping_methods, through: :distributor_shipping_methods
has_many :customers
@@ -91,7 +91,7 @@ class Enterprise < ApplicationRecord
end
has_one_attached :white_label_logo, service: image_service do |attachment|
attachment.variant :default, resize_to_fill: [217, 44]
attachment.variant :mobile, resize_to_fill: [75, 26]
attachment.variant :mobile, resize_to_fill: [128, 26]
end
validates :logo,
@@ -108,29 +108,27 @@ class Enterprise < ApplicationRecord
validates :name, presence: true
validate :name_is_unique
validates :sells, presence: true, inclusion: { in: SELLS }
validates :address, presence: true, associated: true
validates :owner, presence: true
validates :address, associated: true
validates :permalink, uniqueness: true, presence: true
validate :shopfront_taxons
validate :shopfront_producers
validate :enforce_ownership_limit, if: lambda { owner_id_changed? && !owner_id.nil? }
validates :instagram,
format: {
with: VALID_INSTAGRAM_REGEX,
message: Spree.t('errors.messages.invalid_instagram_url')
}, allow_blank: true
validates :instagram,
format: {
with: VALID_INSTAGRAM_REGEX,
message: Spree.t('errors.messages.invalid_instagram_url')
}, allow_blank: true
validate :validate_white_label_logo_link
before_validation :initialize_permalink, if: lambda { permalink.nil? }
before_validation :set_unused_address_fields
after_validation :ensure_owner_is_manager, if: lambda { owner_id_changed? && !owner_id.nil? }
after_touch :touch_distributors
after_create :set_default_contact
after_create :relate_to_owners_enterprises
after_create_commit :send_welcome_email
after_rollback :restore_permalink
after_touch :touch_distributors
after_create_commit :send_welcome_email
scope :by_name, -> { order('name') }
scope :visible, -> { where(visible: "public") }
@@ -151,13 +149,13 @@ class Enterprise < ApplicationRecord
select('DISTINCT enterprises.id')
if ready_enterprises.any?
where("enterprises.id NOT IN (?)", ready_enterprises)
where.not(enterprises: { id: ready_enterprises })
else
where(nil)
end
}
scope :is_primary_producer, -> { where("enterprises.is_primary_producer IS TRUE") }
scope :is_distributor, -> { where('sells != ?', 'none') }
scope :is_distributor, -> { where.not(sells: 'none') }
scope :is_hub, -> { where(sells: 'any') }
scope :supplying_variant_in, lambda { |variants|
joins(supplied_products: :variants).
@@ -359,7 +357,7 @@ class Enterprise < ApplicationRecord
def category
# Make this crazy logic human readable so we can argue about it sanely.
cat = is_primary_producer ? "producer_" : "non_producer_"
cat << "sells_" + sells
cat << ("sells_" + sells)
# Map backend cases to front end cases.
case cat
@@ -454,14 +452,14 @@ class Enterprise < ApplicationRecord
uri = URI(white_label_logo_link)
self.white_label_logo_link = "http://#{white_label_logo_link}" if uri.scheme.nil?
rescue URI::InvalidURIError
errors.add(:white_label_logo_link, I18n.t(:invalid_url))
errors.add(:white_label_logo_link, I18n.t(:invalid_url, url: white_label_logo_link))
end
def image_url_for(image, name)
return unless image.variable?
image_variant_url_for(image.variant(name))
rescue ActiveStorage::Error => e
rescue ActiveStorage::Error, MiniMagick::Error, ActionView::Template::Error => e
Bugsnag.notify "Enterprise ##{id} #{image.try(:name)} error: #{e.message}"
Rails.logger.error(e.message)
@@ -478,7 +476,7 @@ class Enterprise < ApplicationRecord
def name_is_unique
dups = Enterprise.where(name: name)
dups = dups.where('id != ?', id) unless new_record?
dups = dups.where.not(id: id) unless new_record?
errors.add :name, I18n.t(:enterprise_name_error, email: dups.first.owner.email) if dups.any?
end
@@ -493,7 +491,7 @@ class Enterprise < ApplicationRecord
end
def correct_whatsapp_url(phone_number)
phone_number && "https://wa.me/" + phone_number.tr('+ ', '')
phone_number && ("https://wa.me/" + phone_number.tr('+ ', ''))
end
def correct_instagram_url(url)
@@ -533,7 +531,7 @@ class Enterprise < ApplicationRecord
# - it grants permissions to all pre-existing hubs
# - all producers grant permission to it
enterprises = owner.owned_enterprises.where('enterprises.id != ?', self)
enterprises = owner.owned_enterprises.where.not(enterprises: { id: self })
# We grant permissions to all pre-existing hubs
hub_permissions = [:add_to_order_cycle]
@@ -582,7 +580,7 @@ class Enterprise < ApplicationRecord
# We avoid an infinite loop and don't need to touch the whole distributor tree.
def touch_distributors
Enterprise.distributing_products(supplied_products.select(:id)).
where('enterprises.id != ?', id).
where.not(enterprises: { id: id }).
update_all(updated_at: Time.zone.now)
end
end

View File

@@ -6,7 +6,7 @@ class EnterpriseFee < ApplicationRecord
acts_as_paranoid
belongs_to :enterprise
belongs_to :tax_category, class_name: 'Spree::TaxCategory'
belongs_to :tax_category, optional: true, class_name: 'Spree::TaxCategory'
has_many :coordinator_fees, dependent: :destroy
has_many :order_cycles, through: :coordinator_fees
@@ -37,7 +37,7 @@ class EnterpriseFee < ApplicationRecord
}
scope :per_item, lambda {
joins(:calculator).where('spree_calculators.type NOT IN (?)', PER_ORDER_CALCULATORS)
joins(:calculator).where.not(spree_calculators: { type: PER_ORDER_CALCULATORS })
}
scope :per_order, lambda {
joins(:calculator).where('spree_calculators.type IN (?)', PER_ORDER_CALCULATORS)

View File

@@ -8,19 +8,19 @@ class EnterpriseGroup < ApplicationRecord
acts_as_list
has_and_belongs_to_many :enterprises, join_table: 'enterprise_groups_enterprises'
belongs_to :owner, class_name: 'Spree::User', inverse_of: :owned_groups
belongs_to :owner, class_name: 'Spree::User', inverse_of: :owned_groups, optional: true
belongs_to :address, class_name: 'Spree::Address'
accepts_nested_attributes_for :address
validates :address, presence: true, associated: true
validates :address, associated: true
before_validation :set_undefined_address_fields
before_validation :set_unused_address_fields
after_find :unset_undefined_address_fields
before_validation :sanitize_permalink
after_save :unset_undefined_address_fields
after_find :unset_undefined_address_fields
validates :name, presence: true
validates :description, presence: true
before_validation :sanitize_permalink
validates :permalink, uniqueness: true, presence: true
delegate :phone, :address1, :address2, :city, :zipcode, :state, :country, to: :address
@@ -46,10 +46,14 @@ class EnterpriseGroup < ApplicationRecord
}
def set_unused_address_fields
return if address.blank?
address.firstname = address.lastname = address.company = I18n.t(:unused)
end
def set_undefined_address_fields
return if address.blank?
address.phone.present? || address.phone = I18n.t(:undefined)
address.address1.present? || address.address1 = I18n.t(:undefined)
address.city.present? || address.city = I18n.t(:undefined)

View File

@@ -5,15 +5,14 @@ class EnterpriseRelationship < ApplicationRecord
belongs_to :child, class_name: 'Enterprise', touch: true
has_many :permissions, class_name: 'EnterpriseRelationshipPermission', dependent: :destroy
validates :parent, :child, presence: true
validates :child_id, uniqueness: {
scope: :parent_id,
message: I18n.t('validation_msg_relationship_already_established')
}
after_save :update_permissions_of_child_variant_overrides
before_destroy :revoke_all_child_variant_overrides
before_destroy :destroy_related_exchanges
after_save :update_permissions_of_child_variant_overrides
scope :with_enterprises, -> {
joins("
@@ -76,7 +75,7 @@ class EnterpriseRelationship < ApplicationRecord
if perms.nil?
permissions.destroy_all
else
permissions.where('name NOT IN (?)', perms).destroy_all
permissions.where.not(name: perms).destroy_all
perms.map { |name| permissions.find_or_initialize_by name: name }
end
end

View File

@@ -4,7 +4,6 @@ class EnterpriseRole < ApplicationRecord
belongs_to :user, class_name: "Spree::User"
belongs_to :enterprise
validates :user, :enterprise, presence: true
validates :enterprise_id,
uniqueness: { scope: :user_id, message: I18n.t(:enterprise_role_uniqueness_error) }

View File

@@ -10,6 +10,8 @@
# shopfront (outgoing products). But the set of shown products can be smaller
# than all incoming products.
class Exchange < ApplicationRecord
self.belongs_to_required_by_default = false
acts_as_taggable
belongs_to :order_cycle
@@ -88,7 +90,6 @@ class Exchange < ApplicationRecord
exchange = dup
exchange.order_cycle = new_order_cycle
exchange.enterprise_fee_ids = enterprise_fee_ids
exchange.tag_ids = tag_ids
exchange.save!
clone_all_exchange_variants(exchange.id)
exchange

View File

@@ -1,6 +1,8 @@
# frozen_string_literal: true
class ExchangeFee < ApplicationRecord
self.belongs_to_required_by_default = false
belongs_to :exchange
belongs_to :enterprise_fee
end

View File

@@ -1,6 +1,8 @@
# frozen_string_literal: true
class ExchangeVariant < ApplicationRecord
self.belongs_to_required_by_default = false
belongs_to :exchange
belongs_to :variant, class_name: 'Spree::Variant'

View File

@@ -1,6 +1,8 @@
# frozen_string_literal: true
class InventoryItem < ApplicationRecord
self.belongs_to_required_by_default = false
belongs_to :enterprise
belongs_to :variant, class_name: "Spree::Variant"

View File

@@ -1,9 +1,17 @@
# frozen_string_literal: true
class Invoice < ApplicationRecord
self.belongs_to_required_by_default = false
belongs_to :order, class_name: 'Spree::Order'
serialize :data, Hash
before_validation :serialize_order
after_create :cancel_previous_invoices
default_scope { order(created_at: :desc) }
def self.latest
reorder(created_at: :desc).first
end
def presenter
@presenter ||= Invoice::DataPresenter.new(self)
@@ -14,4 +22,8 @@ class Invoice < ApplicationRecord
self.data = Invoice::OrderSerializer.new(order).serializable_hash
end
def cancel_previous_invoices
order.invoices.where.not(id:).update_all(cancelled: true)
end
end

View File

@@ -4,7 +4,8 @@ class Invoice
class DataPresenter
attr_reader :invoice
delegate :data, :date, to: :invoice
delegate :data, to: :invoice
delegate :number, :date, to: :invoice, prefix: true
FINALIZED_NON_SUCCESSFUL_STATES = %w(canceled returned).freeze
@@ -78,12 +79,12 @@ class Invoice
end.sort_by { |tax| tax[:rate_amount] }
end
def all_tax_adjustments
all_eligible_adjustments.select { |a| a.originator_type == 'Spree::TaxRate' }
def display_date
I18n.l(invoice_date.to_date, format: :long)
end
def invoice_date
date
def all_tax_adjustments
all_eligible_adjustments.select { |a| a.originator_type == 'Spree::TaxRate' }
end
def paid?

View File

@@ -24,6 +24,10 @@ class Invoice
render_address([address1, address2, city, zipcode, state&.name])
end
def blank?
@data.nil?
end
private
def render_address(address_parts)

View File

@@ -3,7 +3,8 @@
class Invoice
class DataPresenter
class Distributor < Invoice::DataPresenter::Base
attributes :name, :abn, :acn, :logo_url, :display_invoice_logo, :invoice_text, :email_address
attributes :name, :abn, :acn, :logo_url, :display_invoice_logo, :invoice_text, :email_address,
:phone
attributes_with_presenter :contact, :address, :business_address
def display_invoice_logo?

View File

@@ -3,6 +3,8 @@
require 'open_food_network/scope_variant_to_hub'
class OrderCycle < ApplicationRecord
self.belongs_to_required_by_default = false
searchable_attributes :orders_open_at, :orders_close_at, :coordinator_id
searchable_scopes :active, :inactive, :active_or_complete, :upcoming, :closed, :not_closed,
:dated, :undated, :soonest_opening, :soonest_closing, :most_recently_closed

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