Compare commits

...

346 Commits

Author SHA1 Message Date
Matt-Yorkley
74f27544f7 Merge pull request #7647 from andrewpbrett/default-country-codes
Use correct default country code
2021-05-25 11:21:34 +02:00
Matt-Yorkley
5868765087 Merge pull request #7673 from Matt-Yorkley/spree-config-caching
Fix clashing loggers
2021-05-25 11:09:33 +02:00
Maikel
545d64a2e5 Merge pull request #7682 from openfoodfoundation/dependabot/bundler/i18n-js-3.8.3
Bump i18n-js from 3.8.2 to 3.8.3
2021-05-25 14:48:19 +10:00
Matt-Yorkley
c69dee4c96 Merge pull request #7636 from psychoslave/tip/zeus
Remove all material related to Zeus
2021-05-25 00:10:01 +02:00
Andy Brett
b367001b95 Merge pull request #7641 from luisramos0/order_path
[Rails 6.1] Fix view specs
2021-05-24 14:41:32 -07:00
Andy Brett
120fc4ca42 Merge pull request #7605 from filipefurtad0/import_item_products
Products and Inventory import: Items units
2021-05-24 14:17:43 -07:00
Andy Brett
e4756a523a Merge pull request #7678 from mkllnk/schema
Update schema syntax with Rails 5.2
2021-05-24 13:22:18 -07:00
Andy Brett
46843a5efa Merge pull request #7662 from Matt-Yorkley/enterprise-rendering
Render enterprise rows as a collection
2021-05-24 09:37:58 -07:00
Matt-Yorkley
6377736f43 Allow :site_url to be picked up from ENV vars 2021-05-24 14:58:53 +01:00
dependabot[bot]
e90403dbbe Bump i18n-js from 3.8.2 to 3.8.3
Bumps [i18n-js](https://github.com/fnando/i18n-js) from 3.8.2 to 3.8.3.
- [Release notes](https://github.com/fnando/i18n-js/releases)
- [Changelog](https://github.com/fnando/i18n-js/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fnando/i18n-js/compare/v3.8.2...v3.8.3)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-24 05:49:51 +00:00
Matt-Yorkley
3dc3581e6b Ensure Mail configs are applied when the app starts
Previously we only set these part-way through deployment, so the values could be out of sync between our ENV vars and Spree::Config (which itself is a mix of both cached values and database-persisted values).
2021-05-23 23:05:16 +01:00
Matt-Yorkley
ff82f70e9a Remove custom logger object
This is handled already in Delayed::Command and Delayed::Worker
2021-05-23 23:05:16 +01:00
Andy Brett
560f462f7b Merge pull request #7679 from mkllnk/sample-data
Fix sample_data by filtering params for products
2021-05-22 10:37:30 -07:00
Pau Pérez Fabregat
23b2b5ba56 Merge pull request #7563 from filipefurtad0/import_products_fixture_path
Adds file and fixture path to test product import
2021-05-21 10:12:20 +02:00
Maikel Linke
11cb8cbbdc Fix sample_data by filtering params for products
We were passing too many parameters to the product creation. Rails 5.2
complained that products don't have a distributor. Filtering the
parameters helps.
2021-05-21 12:41:55 +10:00
Maikel Linke
41799b2663 Update schema syntax with Rails 5.2
The style seems to be different. This avoids a modified schema after
running rake db:migrate.
2021-05-21 11:50:34 +10:00
filipefurtad0
2f842bcbdd Adds file and fixture path to test product import
Adds file and fixture path to test product import

Reverts changes on context and it descriptions
2021-05-20 20:08:47 +01:00
Matt-Yorkley
336a8b5825 Merge pull request #7671 from Matt-Yorkley/licence
Add Spree copyright notice
2021-05-20 18:56:16 +02:00
Andy Brett
d2f54f5bd2 Merge pull request #7666 from mkllnk/codecov
Stop Codecov failing good pull requests
2021-05-20 09:18:34 -07:00
Pau Pérez Fabregat
8c81c14c8d Merge pull request #7580 from apricot12/Remove-LineItems-N+1
Removed N+1 queries while counting line_items
2021-05-20 11:42:14 +02:00
Matt-Yorkley
1f6d872fa5 Add Spree copyright notice 2021-05-20 10:25:48 +01:00
Jean-Baptiste Bellet
ae1b9b8dd5 Update all locales with the latest Transifex translations 2021-05-20 10:12:46 +02:00
Maikel
1e1706d371 Merge pull request #7280 from Matt-Yorkley/atomic
Remove atomic gem
2021-05-20 17:53:36 +10:00
Maikel Linke
5ccaa521cf Stop Codecov failing good pull requests
Something doesn't quite work with our Codecov setup. It somehow thinks
that the coverage is decreasing even though it's either not changing or
even increasing.

Until those problems are resolved, let's not mark pull requests as
failed so that we can rely on the pull's overall status report.
2021-05-20 14:18:43 +10:00
Maikel Linke
90bb9870ab Bump Codecov from 1.3.1 to 1.5.0 2021-05-20 14:17:36 +10:00
Andy Brett
70ac719725 Merge pull request #7649 from andrewpbrett/payments-when-out-of-stock
Check stock before doing anything related to admin payments
2021-05-19 14:45:38 -07:00
Andy Brett
08d540a761 Merge pull request #7648 from Matt-Yorkley/redis
Switch cache store from memcached to redis
2021-05-19 10:36:20 -07:00
Andy Brett
304a3804bc Merge pull request #7594 from luisramos0/update_attributes
[Rails 6.1] Replace AR's update_attributes! with update! (and rename order.update! and adjustment.update! in the process)
2021-05-19 10:34:12 -07:00
Luis Ramos
f7726e552a Adapt code coming from master to the new order api with update_order! 2021-05-19 10:09:42 -07:00
Luis Ramos
a1ac4e85ed Replace update_attributes with update 2021-05-19 09:54:25 -07:00
Luis Ramos
f8e5370b0b Replace update_attributes with update 2021-05-19 09:54:25 -07:00
Luis Ramos
fb560089b9 Replace usages of update_attributes! with usage of update! 2021-05-19 09:54:25 -07:00
Luis Ramos
341f6c9f62 Now that adjustment.update! has been renamed to adjustment.update_adjustment! we can use AR's update! on adjustment 2021-05-19 09:54:25 -07:00
Luis Ramos
b2e97fe1d2 Rename order.update! to order.update_order! and adjustment.update! to adjustment.update_adjustment! 2021-05-19 09:54:22 -07:00
Andy Brett
e73584fef7 remove setters from DefaultCountry service 2021-05-19 09:42:52 -07:00
Andy Brett
45ad4bbcf1 remove setting of Spree::Config country code 2021-05-19 09:33:02 -07:00
Matt-Yorkley
096847ea07 Merge pull request #7618 from openfoodfoundation/dependabot/npm_and_yarn/hosted-git-info-2.8.9
Bump hosted-git-info from 2.8.8 to 2.8.9
2021-05-19 13:51:01 +02:00
Pau Pérez Fabregat
faf6a37c9f Merge pull request #7631 from openfoodfoundation/dependabot/bundler/ddtrace-0.49.0
Bump ddtrace from 0.48.0 to 0.49.0
2021-05-19 12:32:52 +02:00
Pau Pérez Fabregat
d4ec1bda54 Merge pull request #7652 from openfoodfoundation/dependabot/bundler/webmock-3.13.0
Bump webmock from 3.12.2 to 3.13.0
2021-05-19 12:32:08 +02:00
Pau Pérez Fabregat
5560a99423 Merge pull request #7663 from openfoodfoundation/transifex
Transifex
2021-05-19 11:50:02 +02:00
Matt-Yorkley
0c4e191f3b Render enterprise rows as a collection
Note: this is a bit like an N+1 query, but for rendering. If there are 30 enterprises, the partial file would be loaded and parsed 30 times; but if we render it as a collection it'll load the partial once and substantially improve the performance.
2021-05-19 08:48:25 +01:00
Andy Brett
2bb38619ea Merge pull request #7656 from openfoodfoundation/dependabot/bundler/rubocop-1.15.0
Bump rubocop from 1.14.0 to 1.15.0
2021-05-18 13:36:56 -07:00
Andy Brett
4b352da402 Merge pull request #7630 from apricot12/persistent_flash_after_reload
Persistent flash after reload
2021-05-18 12:55:37 -07:00
Transifex-Openfoodnetwork
75243b8e6a Updating translations for config/locales/en_US.yml 2021-05-19 05:54:38 +10:00
Andy Brett
7df2915fbd add DefaultCountry service 2021-05-18 12:44:53 -07:00
Matt-Yorkley
6427a3846b Merge pull request #7651 from openfoodfoundation/dependabot/bundler/activerecord-import-1.1.0
Bump activerecord-import from 1.0.8 to 1.1.0
2021-05-18 20:06:21 +02:00
Andy Brett
5169ee91ea add comment for before_action 2021-05-18 10:42:19 -07:00
Andy Brett
5917accdd2 refactor using Extract Method 2021-05-18 10:38:35 -07:00
Matt-Yorkley
5dd24623f7 Merge pull request #7479 from Matt-Yorkley/payment-callbacks
Update Payment after_save callback
2021-05-18 16:19:29 +02:00
Matt-Yorkley
befb6f632f Merge pull request #7659 from openfoodfoundation/dependabot/bundler/nokogiri-1.11.4
Bump nokogiri from 1.11.3 to 1.11.4
2021-05-18 11:14:32 +02:00
dependabot[bot]
92e0f8349c Bump nokogiri from 1.11.3 to 1.11.4
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.11.3 to 1.11.4.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.11.3...v1.11.4)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-18 08:37:29 +00:00
dependabot[bot]
ffbba01c41 Bump rubocop from 1.14.0 to 1.15.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.14.0 to 1.15.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.14.0...v1.15.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-18 05:24:48 +00:00
Pau Pérez Fabregat
5f9679655c Merge pull request #7645 from Matt-Yorkley/stripe-payment-processing
Stripe payment processing
2021-05-17 16:17:21 +02:00
dependabot[bot]
6ded80d2c6 Bump webmock from 3.12.2 to 3.13.0
Bumps [webmock](https://github.com/bblimke/webmock) from 3.12.2 to 3.13.0.
- [Release notes](https://github.com/bblimke/webmock/releases)
- [Changelog](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bblimke/webmock/compare/v3.12.2...v3.13.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-17 05:51:55 +00:00
dependabot[bot]
eb3c33b091 Bump activerecord-import from 1.0.8 to 1.1.0
Bumps [activerecord-import](https://github.com/zdennis/activerecord-import) from 1.0.8 to 1.1.0.
- [Release notes](https://github.com/zdennis/activerecord-import/releases)
- [Changelog](https://github.com/zdennis/activerecord-import/blob/master/CHANGELOG.md)
- [Commits](https://github.com/zdennis/activerecord-import/compare/v1.0.8...v1.1.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-17 05:51:01 +00:00
Matt-Yorkley
794216713a Ensure payment is processed if order is in completed state 2021-05-16 23:03:07 +01:00
Matt-Yorkley
a2862e604c Find relevant payment that matches the payment intent, not the last payment 2021-05-16 23:00:31 +01:00
Matt-Yorkley
8429da3d2a Remove unused argument from ProcessPaymentIntent 2021-05-16 22:19:01 +01:00
Matt-Yorkley
381b0e78d5 Improve ProcessPaymentIntent specs 2021-05-16 20:14:14 +01:00
Matt-Yorkley
2e63cd8116 Add explanatory comment on payment processing flow 2021-05-16 20:11:45 +01:00
Matt-Yorkley
52e0d84238 Reload in-memory payment before checking it's new state
The state should have changed in the database if the payment was processed successfully, and the memoized version here will not know that without a reload.
2021-05-16 20:11:45 +01:00
Matt-Yorkley
5725535715 Fix payment state checking 2021-05-16 20:11:45 +01:00
Matt-Yorkley
05ed98aa0c Use :order_with_totals in ProcessPaymentIntent
If we just use the :order factory here, it has no line items and no total, which means when we try to push it into complete state, the #requires_payment? check fails because the order total is zero, which means the call to #process_payments is ignored
2021-05-16 20:11:45 +01:00
Matt-Yorkley
fd021d4778 Refactor payment intent status checking and return "ok" if the payment has already been processed successfully in a previous request
If the page is reloaded after the payment has already gone through, we can skip the processing and give a non-error response; the payment is already completed and Stripe's response confirms it was successful.
2021-05-16 20:11:45 +01:00
Matt-Yorkley
2b9f9fce86 Fix flash session memory-effect when showing errors after payment processing
We're not doing a redirect after setting this flash message, so we need to ensure it's discarded after the current page load.
2021-05-16 20:11:45 +01:00
Matt-Yorkley
81aac442f2 Improve conditional in raise_if_not_in_capture_state 2021-05-16 20:11:45 +01:00
Matt-Yorkley
16e3af9b49 Update OrderController spec 2021-05-16 20:11:45 +01:00
Matt-Yorkley
227bdd7d4c Update ProcessPaymentIntent spec 2021-05-16 12:55:48 +01:00
Matt-Yorkley
471a7903f6 Update PaymentIntentValidator spec 2021-05-16 12:19:04 +01:00
Matt-Yorkley
37177e7207 Add test coverage to StripeSCA spec 2021-05-16 12:19:04 +01:00
Matt-Yorkley
5805104d13 Tidy up controller and add explanatory comment 2021-05-16 12:19:04 +01:00
Matt-Yorkley
e686a4f627 Move raising of errors when payment intent state != "requires_capture" out of PaymentIntentValidator service
When we're fetching the payment intent via PaymentIntentValidator in StripeSCA#purhcase (to capture it), we want it to fail loudly if it's not in "requires_capture" state. We're now also re-using the same PaymentIntentValidator service to check if payment processing was *successful*, in which case we need it *not* to fail loudly if the state == "succeeded", eg != "requires_capture".
2021-05-16 12:19:04 +01:00
Andy Brett
c7f80d86a8 Merge pull request #7638 from Matt-Yorkley/dead-code-order-distribution
Delete dead code in OrdersController#update_distribution
2021-05-15 12:40:25 -07:00
Andy Brett
19187583e1 Merge pull request #7643 from openfoodfoundation/dependabot/bundler/test-prof-1.0.5
Bump test-prof from 1.0.3 to 1.0.5
2021-05-15 12:28:22 -07:00
Andy Brett
f2c3b096a0 Merge pull request #7566 from luisramos0/erb
[Rails 6.0] Fix problem in erb template by explicitly setting format to js
2021-05-15 10:45:01 -07:00
Andy Brett
816d752dc8 Merge pull request #7439 from openfoodfoundation/dependabot/bundler/jwt-2.2.3
Bump jwt from 2.2.2 to 2.2.3
2021-05-15 10:36:13 -07:00
Andy Brett
0a880a2bf3 flip conditional order for performance 2021-05-15 07:08:07 -07:00
Matt-Yorkley
d6b3b0a3d3 Ensure a basic level of fault-tolerance on Redis connections
The default for reconnect_attempts is 0, which is not helpful! 1 is generally considered to be enough.
2021-05-15 11:36:19 +01:00
Andy Brett
ca38948e21 check stock before doing anything related to admin payments 2021-05-14 17:42:37 -07:00
Andy Brett
fe67c01e57 guard against no database, but not against .connected?
Similar to b22ce43efe
2021-05-14 12:56:24 -07:00
Matt-Yorkley
37053239c0 Switch cache store from memcached to redis 2021-05-14 20:46:13 +01:00
dependabot[bot]
2bb5a4b11f Bump test-prof from 1.0.3 to 1.0.5
Bumps [test-prof](https://github.com/test-prof/test-prof) from 1.0.3 to 1.0.5.
- [Release notes](https://github.com/test-prof/test-prof/releases)
- [Changelog](https://github.com/test-prof/test-prof/blob/master/CHANGELOG.md)
- [Commits](https://github.com/test-prof/test-prof/compare/v1.0.3...v1.0.5)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-14 05:17:23 +00:00
Maikel Linke
cea3ee4ef9 Transifex updates 2021-05-14 10:06:31 +10:00
Luis Ramos
90db52e5f5 Fix route 2021-05-14 00:14:02 +01:00
Luis Ramos
b1896733ca Fix routes 2021-05-14 00:08:20 +01:00
Luis Ramos
a949422ac9 Adapt view spec stubs to rails 6 2021-05-13 23:28:35 +01:00
Luis Ramos
0243e5cbb8 Fix route in order view 2021-05-13 23:08:50 +01:00
Andy Brett
ebdbfe0027 Merge pull request #7639 from drummer83/patch-1
Remove Ruby version from WIKI
2021-05-13 13:26:34 -07:00
Konrad
b680697af6 Remove Ruby version
Let's remove the Ruby version from the text. It changes regularly and have the link where to find it right behind it.
2021-05-13 21:16:02 +02:00
Matt-Yorkley
2e248744c0 Merge pull request #7520 from Matt-Yorkley/shipment-controller
Shipment controller: test coverage and improvements
2021-05-13 20:26:51 +02:00
Matt-Yorkley
82a6befce7 Delete dead code in OrdersController#update_distribution
I can't see any evidence that these params ever get sent to this action...
2021-05-13 15:29:53 +01:00
Mathieu Lovato Stumpf Guntz
ccef65039a Remove all material related to Zeus 2021-05-13 12:21:58 +02:00
dependabot[bot]
e4a670da5a Bump ddtrace from 0.48.0 to 0.49.0
Bumps [ddtrace](https://github.com/DataDog/dd-trace-rb) from 0.48.0 to 0.49.0.
- [Release notes](https://github.com/DataDog/dd-trace-rb/releases)
- [Changelog](https://github.com/DataDog/dd-trace-rb/blob/master/CHANGELOG.md)
- [Commits](https://github.com/DataDog/dd-trace-rb/compare/v0.48.0...v0.49.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-13 05:24:45 +00:00
Nihal Mohammed
c930b2ee60 Fix persistet flash after /cart page reload 2021-05-13 05:57:25 +05:30
Matt-Yorkley
4932e1dcb5 Merge pull request #7628 from viktorsmari/remove-distributer-sample-data
Remove distributer from sample_data
2021-05-12 23:53:13 +02:00
Viktor Smari
536281ec80 Remove distributer from sample_data
Closes #7625
2021-05-12 23:01:08 +02:00
Nihal Mohammed
367cee593f Move eager loading line_items to controller 2021-05-13 01:12:13 +05:30
Matt-Yorkley
99cf23df26 Merge pull request #7530 from Matt-Yorkley/email-after-commit
Email after commit
2021-05-12 21:22:55 +02:00
Matt-Yorkley
f49d4592a0 Merge pull request #7506 from guidoDutra/5546-prevent-deleting-only-item-in-confirmed-order
prevent deleting only item in confirmed order
2021-05-12 21:10:09 +02:00
Pau Pérez Fabregat
7f27544acb Merge pull request #7612 from openfoodfoundation/dependabot/bundler/actionpack-action_caching-1.2.2
Bump actionpack-action_caching from 1.2.1 to 1.2.2
2021-05-12 16:24:25 +02:00
Pau Pérez Fabregat
2aac44d95e Merge pull request #7620 from openfoodfoundation/transifex
Transifex
2021-05-12 15:50:25 +02:00
Pau Pérez Fabregat
8f921b8b08 Merge pull request #7593 from viktorsmari/add-bullet-footer
Add bullet footer
2021-05-12 15:47:54 +02:00
Transifex-Openfoodnetwork
dfe485b079 Updating translations for config/locales/ru.yml 2021-05-12 17:49:31 +10:00
dependabot[bot]
ad9096b5a8 Bump hosted-git-info from 2.8.8 to 2.8.9
Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-11 23:49:14 +00:00
Matt-Yorkley
e60a513c88 Merge pull request #7571 from coopdevs/make-specs-accurate
Properly mock validator and extend tests
2021-05-11 22:24:01 +02:00
Pau Pérez Fabregat
1f8e731594 Merge pull request #7596 from openfoodfoundation/transifex
Transifex
2021-05-11 11:56:35 +02:00
dependabot[bot]
d69ef31bf9 Bump actionpack-action_caching from 1.2.1 to 1.2.2
Bumps [actionpack-action_caching](https://github.com/rails/actionpack-action_caching) from 1.2.1 to 1.2.2.
- [Release notes](https://github.com/rails/actionpack-action_caching/releases)
- [Changelog](https://github.com/rails/actionpack-action_caching/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rails/actionpack-action_caching/compare/v1.2.1...v1.2.2)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-11 05:05:32 +00:00
Andy Brett
9ae7c5efbc Merge pull request #7578 from psychoslave/master
Update things related to some package manager influencing setup process
2021-05-10 17:01:46 -07:00
Matt-Yorkley
902bbf7dc4 Merge pull request #7576 from Matt-Yorkley/bulk-line-items
Add test coverage to BulkLineItemsController actions
2021-05-11 01:47:17 +02:00
Andy Brett
d29ef0d7b1 Merge branch 'master' into make-specs-accurate 2021-05-10 16:10:33 -07:00
Andy Brett
d2a3d9049f Merge pull request #7588 from andrewpbrett/enterprise-permalink-spec
[Rails 6.0] Fix enterprise permalink spec
2021-05-10 15:30:45 -07:00
filipefurtad0
0cd6c53e0d Adds test-case on the inventory import for unit Items 2021-05-10 19:12:41 +01:00
filipefurtad0
5475b79cde Adds test-case on the product import unit Items 2021-05-10 19:07:05 +01:00
filipefurtad0
8e24c655b0 Adds verification of inventory import on inventory page 2021-05-10 19:01:41 +01:00
filipefurtad0
bb5452ad26 Adds verification of product import on products page 2021-05-10 18:57:47 +01:00
Matt-Yorkley
85b8e9b51f Merge pull request #7595 from openfoodfoundation/dependabot/bundler/factory_bot_rails-6.2.0
Bump factory_bot_rails from 6.1.0 to 6.2.0
2021-05-10 19:55:54 +02:00
Andy Brett
3239c893ba Merge pull request #7590 from viktorsmari/ransack-search-deprecation
Ransack.search is deprecated. Use .ransack instead
2021-05-10 08:43:09 -07:00
Andy Brett
17a0063b40 Merge pull request #7402 from filipefurtad0/products_spec_add_ons
Adds coverage for product deletion and cloning
2021-05-10 06:26:11 -07:00
Transifex-Openfoodnetwork
75dc7af0ed Updating translations for config/locales/en_GB.yml 2021-05-10 18:16:04 +10:00
dependabot[bot]
cb15e28cef Bump factory_bot_rails from 6.1.0 to 6.2.0
Bumps [factory_bot_rails](https://github.com/thoughtbot/factory_bot_rails) from 6.1.0 to 6.2.0.
- [Release notes](https://github.com/thoughtbot/factory_bot_rails/releases)
- [Changelog](https://github.com/thoughtbot/factory_bot_rails/blob/master/NEWS.md)
- [Commits](https://github.com/thoughtbot/factory_bot_rails/compare/v6.1.0...v6.2.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-10 05:55:18 +00:00
Andy Brett
cbefa5f882 Merge pull request #7589 from andrewpbrett/order-adjustments-spec
[Rails 6.0] Fix order adjustments spec
2021-05-09 10:38:19 -07:00
Andy Brett
231f01dad2 fix order adjustments spec 2021-05-09 10:09:22 -07:00
Viktor Smari
c14ccdc21c Add bullet footer
Left corner of the page will show the bullet warnings
2021-05-09 16:49:00 +02:00
Nihal Mohammed
fcf70c242e edit item_count method to shorthand for improved readability 2021-05-09 18:31:26 +05:30
Andy Brett
a0476be2c9 Merge pull request #7568 from andrewpbrett/stripe-mock-js
[Rails 6.0] Use raw to render stripe mock js file
2021-05-08 17:46:24 -07:00
Matt-Yorkley
24a5407c8f Merge pull request #7565 from luisramos0/rails6_success
[Rails 6.0] Replace be_success on test_response with status 200
2021-05-09 02:33:49 +02:00
Andy Brett
66da72ccc2 use raw to render stripe mock js 2021-05-08 17:29:38 -07:00
Viktor Smari
6a342ae368 Ransack.search is deprecated. Use .ransack instead
https://github.com/activerecord-hackery/ransack/pull/975
2021-05-09 01:05:37 +02:00
Andy Brett
dd851edbdc fix enterprise permalink spec 2021-05-08 14:21:45 -07:00
Andy Brett
2910cbf15c Merge pull request #7582 from openfoodfoundation/transifex
Transifex
2021-05-08 13:55:11 -07:00
Transifex-Openfoodnetwork
d24d7fce56 Updating translations for config/locales/de_DE.yml 2021-05-09 05:16:39 +10:00
Nihal Mohammed
e485a4a8ef Remove untested change to payments 2021-05-08 23:51:38 +05:30
Nihal Mohammed
026942dd72 Fix item_count to properly count quantity of every item 2021-05-08 23:45:41 +05:30
Nihal Mohammed
237ebd6ec4 Removed N+1 queries while counting line_items 2021-05-08 21:09:06 +05:30
Mathieu Lovato Stumpf Guntz
a4d6e69309 Replace nmp with yarn, remove newrelic 2021-05-07 21:10:55 +02:00
Mathieu Lovato Stumpf Guntz
29e04dd8c8 Merge branch 'master' of https://github.com/openfoodfoundation/openfoodnetwork 2021-05-07 16:00:08 +02:00
Mathieu Lovato Stumpf Guntz
5a8e271037 Update .node-version to last LTS and drop setup tests 2021-05-07 15:54:15 +02:00
Andy Brett
5a16954bf6 Merge pull request #7572 from openfoodfoundation/transifex
Transifex
2021-05-07 06:46:56 -07:00
Matt-Yorkley
43e41f4980 Add more explicit test coverage to BulkLineItemsController acitons
This spec includes taxes on line items, fees on the order and on line items, taxes on fees (inherited and non-inherited), shipping and payment fees and taxes on shipping. It checks all of these things are correctly updated after the order is changed via BOM.
2021-05-07 11:54:04 +01:00
Matt-Yorkley
39156ec988 Merge pull request #7574 from Matt-Yorkley/dfc-routes
Update DFC routes
2021-05-07 11:27:50 +02:00
Matt-Yorkley
c71d4bce6a Update DFC routes 2021-05-07 09:42:35 +01:00
Pau Pérez Fabregat
8d8abed529 Merge pull request #7496 from jibees/4957-flaky-specs
Uncomment flaky spec on variant_overrides_spec.rb
2021-05-07 10:29:36 +02:00
Transifex-Openfoodnetwork
55018260df Updating translations for config/locales/en_FR.yml 2021-05-07 17:53:34 +10:00
Transifex-Openfoodnetwork
cbdeef064a Updating translations for config/locales/fr.yml 2021-05-07 17:53:20 +10:00
Transifex-Openfoodnetwork
ac2c02a983 Updating translations for config/locales/es.yml 2021-05-07 16:40:26 +10:00
Transifex-Openfoodnetwork
c71a4918a0 Updating translations for config/locales/ca.yml 2021-05-07 16:40:03 +10:00
Pau Perez
fd5e0fd60f Properly mock validator and extend tests
Tests were passing but not due to the expected reason. While at it, we
extended the assertions to be more precise.
2021-05-07 08:35:54 +02:00
Andy Brett
dbd0d4a795 Merge pull request #7570 from openfoodfoundation/release/v3.6.10
Update all locales with the latest Transifex translations
2021-05-06 20:41:25 -07:00
Andy Brett
328381b732 Update all locales with the latest Transifex translations 2021-05-06 20:38:41 -07:00
Luis Ramos
de000228cf Fix problem in erb template by explicitly setting format to js while calling it 2021-05-06 23:52:16 +01:00
Luis Ramos
a2de86c23e Replace be_success on test_reponse with status 200
In rails 6 response.success? is not supported.
2021-05-06 23:51:30 +01:00
Andy Brett
415d86bff0 Merge pull request #7562 from coopdevs/fix-failed-sca-auth
Fix failed SCA authentication on subs. order payment not reflected in OFN
2021-05-06 15:25:16 -07:00
Andy Brett
8b9083d28f Merge pull request #7560 from openfoodfoundation/dependabot/bundler/rails-5.2.6
Bump rails from 5.2.5 to 5.2.6
2021-05-06 15:14:06 -07:00
dependabot[bot]
7f5dddffa0 Bump rails from 5.2.5 to 5.2.6
Bumps [rails](https://github.com/rails/rails) from 5.2.5 to 5.2.6.
- [Release notes](https://github.com/rails/rails/releases)
- [Commits](https://github.com/rails/rails/compare/v5.2.5...v5.2.6)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-06 17:35:58 +00:00
Andy Brett
cfa4bde965 Merge pull request #7559 from openfoodfoundation/dependabot/bundler/rubocop-rails-2.10.1
Bump rubocop-rails from 2.10.0 to 2.10.1
2021-05-06 10:34:20 -07:00
Andy Brett
9e6ede4072 Merge pull request #7561 from openfoodfoundation/dependabot/bundler/rubocop-1.14.0
Bump rubocop from 1.13.0 to 1.14.0
2021-05-06 10:33:40 -07:00
Pau Perez
9a63f38790 I18n-ize error messages. 2021-05-06 16:34:29 +02:00
Pau Perez
69b91ea136 Wait until the end to mark payment as processed
This gives us the opportunity to retry the operation in case the
processing fails.
2021-05-06 16:19:01 +02:00
Pau Perez
dea6a01e61 Handle SCA payments that can't complete 2021-05-06 16:19:01 +02:00
Pau Perez
2147584daf Validate intents against Stripe and display errors
Now the existing validation is redundant. It's Stripe's API who does
that now. It's up to them to decide what's a valid intent.
2021-05-06 16:19:01 +02:00
Pau Perez
b723ed4a98 Skip Stripe logic when no payment data is passed 2021-05-06 16:19:01 +02:00
dependabot[bot]
ccfe352d62 Bump rubocop from 1.13.0 to 1.14.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.13.0 to 1.14.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.13.0...v1.14.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-06 05:22:38 +00:00
dependabot[bot]
76fb157518 Bump rubocop-rails from 2.10.0 to 2.10.1
Bumps [rubocop-rails](https://github.com/rubocop/rubocop-rails) from 2.10.0 to 2.10.1.
- [Release notes](https://github.com/rubocop/rubocop-rails/releases)
- [Changelog](https://github.com/rubocop/rubocop-rails/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rails/compare/v2.10.0...v2.10.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-06 05:18:52 +00:00
Andy Brett
a7331efd67 Merge pull request #7477 from luisramos0/require_dependency
Remove require_dependency or use require
2021-05-05 13:24:19 -07:00
Pau Pérez Fabregat
b57755398c Merge pull request #7531 from openfoodfoundation/dependabot/bundler/daemons-1.4.0
Bump daemons from 1.3.1 to 1.4.0
2021-05-05 21:42:25 +02:00
dependabot[bot]
076081929f Bump daemons from 1.3.1 to 1.4.0
Bumps [daemons](https://github.com/thuehlinger/daemons) from 1.3.1 to 1.4.0.
- [Release notes](https://github.com/thuehlinger/daemons/releases)
- [Changelog](https://github.com/thuehlinger/daemons/blob/master/Releases)
- [Commits](https://github.com/thuehlinger/daemons/compare/v1.3.1...v1.4.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-05 18:07:37 +00:00
Andy Brett
4b183bb6c1 Merge pull request #7555 from openfoodfoundation/dependabot/bundler/rubocop-rails-2.10.0
Bump rubocop-rails from 2.9.1 to 2.10.0
2021-05-05 11:06:43 -07:00
Andy Brett
d2f3cdd6b9 Merge pull request #7546 from openfoodfoundation/dependabot/bundler/activerecord-session_store-2.0.0
Bump activerecord-session_store from 1.1.3 to 2.0.0
2021-05-05 11:06:10 -07:00
Andy Brett
baf3d4b2cd Merge pull request #6488 from openfoodfoundation/dependabot/bundler/pg-1.2.3
Bump pg from 0.21.0 to 1.2.3
2021-05-05 11:05:52 -07:00
Andy Brett
f8f3cb78e3 Merge pull request #7549 from openfoodfoundation/dependabot/bundler/roadie-rails-2.2.0
Bump roadie-rails from 1.3.0 to 2.2.0
2021-05-05 11:05:24 -07:00
dependabot[bot]
18373533e6 Bump roadie-rails from 1.3.0 to 2.2.0
Bumps [roadie-rails](https://github.com/Mange/roadie-rails) from 1.3.0 to 2.2.0.
- [Release notes](https://github.com/Mange/roadie-rails/releases)
- [Changelog](https://github.com/Mange/roadie-rails/blob/master/Changelog.md)
- [Commits](https://github.com/Mange/roadie-rails/compare/v1.3.0...v2.2.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-05 17:40:59 +00:00
dependabot[bot]
679ceaead7 Bump pg from 0.21.0 to 1.2.3
Bumps [pg](https://github.com/ged/ruby-pg) from 0.21.0 to 1.2.3.
- [Release notes](https://github.com/ged/ruby-pg/releases)
- [Changelog](https://github.com/ged/ruby-pg/blob/master/History.rdoc)
- [Commits](https://github.com/ged/ruby-pg/compare/v0.21.0...v1.2.3)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-05 17:40:49 +00:00
Pau Pérez Fabregat
64baebd791 Merge pull request #7545 from openfoodfoundation/dependabot/bundler/ransack-2.4.1
Bump ransack from 2.3.0 to 2.4.1
2021-05-05 19:39:42 +02:00
dependabot[bot]
31adbdbf7a Bump activerecord-session_store from 1.1.3 to 2.0.0
Bumps [activerecord-session_store](https://github.com/rails/activerecord-session_store) from 1.1.3 to 2.0.0.
- [Release notes](https://github.com/rails/activerecord-session_store/releases)
- [Commits](https://github.com/rails/activerecord-session_store/compare/v1.1.3...v2.0.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-05 17:15:11 +00:00
Pau Pérez Fabregat
819479f05c Merge pull request #7552 from luisramos0/rails525
Upgrade to rails 5.2.5 with "bundle update rails"
2021-05-05 19:14:04 +02:00
Pau Pérez Fabregat
324999494b Merge pull request #7523 from openfoodfoundation/transifex
Transifex
2021-05-05 18:31:30 +02:00
Andy Brett
82845e1cfc Merge pull request #7528 from Matt-Yorkley/has_many_through
Reorder has_many relationship with :through option
2021-05-05 08:08:15 -07:00
Andy Brett
3e714b1539 Merge pull request #7527 from Matt-Yorkley/dead-code-deleted
Remove #deleted? method from Product and Variant
2021-05-05 08:07:39 -07:00
Andy Brett
002420304d Merge pull request #7526 from Matt-Yorkley/dead-currency
Remove currency from OrderContents
2021-05-05 08:06:53 -07:00
dependabot[bot]
aa90c4f34f Bump rubocop-rails from 2.9.1 to 2.10.0
Bumps [rubocop-rails](https://github.com/rubocop/rubocop-rails) from 2.9.1 to 2.10.0.
- [Release notes](https://github.com/rubocop/rubocop-rails/releases)
- [Changelog](https://github.com/rubocop/rubocop-rails/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rails/compare/v2.9.1...v2.10.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-05 05:14:36 +00:00
Luis Ramos
63e2122593 Upgrade to rails 5.2.5 with a bundle update rails 2021-05-04 21:31:09 +01:00
Andy Brett
35671e2464 Merge pull request #7548 from openfoodfoundation/dependabot/bundler/rspec-rails-5.0.1
Bump rspec-rails from 4.1.2 to 5.0.1
2021-05-04 13:22:48 -07:00
Andy Brett
4b9418ebd6 Merge pull request #7547 from openfoodfoundation/dependabot/bundler/coffee-rails-5.0.0
Bump coffee-rails from 4.2.2 to 5.0.0
2021-05-04 13:02:50 -07:00
dependabot[bot]
ec8f42513b Bump rspec-rails from 4.1.2 to 5.0.1
Bumps [rspec-rails](https://github.com/rspec/rspec-rails) from 4.1.2 to 5.0.1.
- [Release notes](https://github.com/rspec/rspec-rails/releases)
- [Changelog](https://github.com/rspec/rspec-rails/blob/main/Changelog.md)
- [Commits](https://github.com/rspec/rspec-rails/compare/v4.1.2...v5.0.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-04 19:21:11 +00:00
dependabot[bot]
3ba439ec0d Bump coffee-rails from 4.2.2 to 5.0.0
Bumps [coffee-rails](https://github.com/rails/coffee-rails) from 4.2.2 to 5.0.0.
- [Release notes](https://github.com/rails/coffee-rails/releases)
- [Changelog](https://github.com/rails/coffee-rails/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rails/coffee-rails/compare/v4.2.2...v5.0.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-04 19:20:07 +00:00
dependabot[bot]
47e79a8d60 Bump ransack from 2.3.0 to 2.4.1
Bumps [ransack](https://github.com/activerecord-hackery/ransack) from 2.3.0 to 2.4.1.
- [Release notes](https://github.com/activerecord-hackery/ransack/releases)
- [Changelog](https://github.com/activerecord-hackery/ransack/blob/master/CHANGELOG.md)
- [Commits](https://github.com/activerecord-hackery/ransack/compare/v2.3.0...2.4.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-04 19:19:33 +00:00
Transifex-Openfoodnetwork
119fdd9e53 Updating translations for config/locales/en_CA.yml 2021-05-05 03:12:14 +10:00
Matt-Yorkley
00c4a28d22 Extract order-updating logic to Order::Updater 2021-05-04 16:40:10 +01:00
Matt-Yorkley
8e10f7af0e Update payments controller test setup
We need to use a completed order in the test setup here or it doesn't behave correctly. `order.completed_at` is nil, for example.
2021-05-04 16:40:10 +01:00
Matt-Yorkley
135a311c05 Update void payments
Backport from Spree 2.4 stable: 4121992398
2021-05-04 16:40:10 +01:00
Matt-Yorkley
13bb5aa8dd Update Payment after_save callback
Backport from Spree 2.4 stable: 4d652a77fd
2021-05-04 16:40:09 +01:00
Matt-Yorkley
2b1becfd47 Merge pull request #7185 from openfoodfoundation/rails-5-2
Rails 5.2 upgrade
2021-05-04 17:21:03 +02:00
Pau Perez
cb1e4caad8 Update all locales with the latest Transifex translations 2021-05-04 08:34:04 +02:00
Andy Brett
edc51d1155 Merge pull request #7532 from openfoodfoundation/dependabot/bundler/test-prof-1.0.3
Bump test-prof from 1.0.2 to 1.0.3
2021-05-03 11:31:50 -07:00
filipefurtad0
a476416dc4 Removes html tr tag; Clarifies it block 2021-05-03 17:03:34 +01:00
Transifex-Openfoodnetwork
55b1b860d1 Updating translations for config/locales/en_US.yml 2021-05-04 02:03:25 +10:00
Matt-Yorkley
e2a411c23c Add map helper to RegistrationController
Fixes 3 errors including:

Registration Terms of Service agreement if accepting Terms of Service is not required allows registration as normal
     Failure/Error: super

     ActionView::Template::Error:
       undefined method `using_google_maps?' for #<#<Class:0x00007fd4949c4558>:0x00007fd499dd0ae8>
     # ./app/helpers/application_helper.rb:20:in `method_missing'
     # ./app/views/registration/steps/_details.html.haml:60:in `_app_views_registration_steps__details_html_haml___1911121144363058234_70275472163280'
     # ./app/views/registration/index.html.haml:12:in `block in _app_views_registration_index_html_haml__993897347679518865_70275545598940'
     # ./app/views/registration/index.html.haml:11:in `each'
     # ./app/views/registration/index.html.haml:11:in `_app_views_registration_index_html_haml__993897347679518865_70275545598940'
     # ./lib/open_food_network/rack_request_blocker.rb:36:in `call'
     # ------------------
     # --- Caused by: ---
     # NoMethodError:
     #   undefined method `using_google_maps?' for #<#<Class:0x00007fd4949c4558>:0x00007fd499dd0ae8>
     #   ./app/helpers/application_helper.rb:20:in `method_missing'
2021-05-03 14:17:54 +01:00
Matt-Yorkley
aa013ef76a Update redirect_back syntax for Rails 5
Introduced in 5.0, the old syntax is removed in 5.2
2021-05-03 14:17:54 +01:00
Matt-Yorkley
a645b8c58f Re-apply previous 5.2 commit: Don't reload payments in after_save callback
This causes issues in master, but is needed in the 5.2 branch.
2021-05-03 14:17:54 +01:00
Matt-Yorkley
4888f1cd06 Stub OrderPaymentFinder to return correct object
OrderPaymentFinder was re-fetching the payment object from the database, so the subsequent line that stubs #authorize! on that payment was not being applied to the correct object.
2021-05-03 14:17:54 +01:00
Matt-Yorkley
31fc6201fc Include payment method helper in ApplicationController 2021-05-03 14:17:54 +01:00
Matt-Yorkley
ab65b01fcf Rename payments helper 2021-05-03 14:17:54 +01:00
Matt-Yorkley
1de68d091a Update guard clause in line item callbacks (take two)
The `changed?` method is more accurately replaced by `saved_changes.present?`

In some cases here (where the object had just been saved for the first time) the guard clause was still stopping execution unexpectedly.
2021-05-03 14:17:54 +01:00
Matt-Yorkley
ac53df37d9 Fix callback in LineItem
#changed? here was not working as before, and the code was never getting past this guard in various places where previously it did. This meant the callback was effectively disabled, and order.update! was not being called when it should be.
2021-05-03 14:17:54 +01:00
Luis Ramos
279c15c306 Adapt spec to rails 5.2 2021-05-03 14:17:54 +01:00
Luis Ramos
47a5809100 Fix rspec syntax 2021-05-03 14:17:54 +01:00
Andy Brett
705666ecd0 fix /spec/models/spree/credit_card_spec.rb:301 2021-05-03 14:17:54 +01:00
Luis Ramos
aaf4710694 Fix cart_service_spec to adapt to the actual usage of it from cart_controller, params are now sent inside a Parameters object, not as a hash 2021-05-03 14:17:54 +01:00
Luis Ramos
f5a7ff0f0a Switch from map, that does not exist in ActionController::Parameters, to each 2021-05-03 14:17:54 +01:00
Andy Brett
203dbb7a8b Revert "Switch from map, that does not exist in ActionController::Parameters, to each"
This reverts commit 69a15d4f04.
2021-05-03 14:17:54 +01:00
Andy Brett
ea5f9c6747 Revert "Fix cart_service_spec to adapt to the actual usage of it from cart_controller, params are now sent inside a Parameters object, not as a hash"
This reverts commit bb465b5715.
2021-05-03 14:17:54 +01:00
Andy Brett
d255ca22f5 use new attribute_changed method for taxons take 2 2021-05-03 14:17:54 +01:00
Andy Brett
be0eb5f5f9 ignore nil in payment report spec expectation 2021-05-03 14:17:54 +01:00
Andy Brett
52525dc437 Fix /spec/models/spree/product_spec.rb:118 2021-05-03 14:17:54 +01:00
Andy Brett
d381b2a544 Use saved_change_to prefix to check for changes 2021-05-03 14:17:54 +01:00
Luis Ramos
c08bc743d3 Replace usage of changed? with saved_change_to_ 2021-05-03 14:17:54 +01:00
Luis Ramos
c1402fe4f2 Upgrade state_machines 2021-05-03 14:17:54 +01:00
Matt-Yorkley
e9b6f89ae0 Update params syntax in engine controller specs 2021-05-03 14:17:54 +01:00
Matt-Yorkley
26688dda36 Add angular_form helper
Fixes:

Failure/Error: super

     ActionView::Template::Error:
       undefined method `ng_options_for_select' for #<#<Class:0x00007fbf8e43e310>:0x000055783fbebec0>
       Did you mean?  options_for_select
     # ./app/helpers/application_helper.rb:20:in `method_missing'
     # ./app/helpers/angular_form_builder.rb:26:in `ng_select'
     # ./app/views/admin/enterprise_fees/index.html.haml:34:in `block (2 levels) in _app_views_admin_enterprise_fees_index_html_haml__800455454875182851_46987476952700'
     # ./app/helpers/angular_form_builder.rb:6:in `ng_fields_for'
     # ./app/views/admin/enterprise_fees/index.html.haml:28:in `block in _app_views_admin_enterprise_fees_index_html_haml__800455454875182851_46987476952700'
     # ./app/helpers/application_helper.rb:11:in `ng_form_for'
     # ./app/views/admin/enterprise_fees/index.html.haml:4:in `_app_views_admin_enterprise_fees_index_html_haml__800455454875182851_46987476952700'
     # ./lib/open_food_network/rack_request_blocker.rb:36:in `call'
     # ------------------
     # --- Caused by: ---
     # NoMethodError:
     #   undefined method `ng_options_for_select' for #<#<Class:0x00007fbf8e43e310>:0x000055783fbebec0>
     #   Did you mean?  options_for_select
     #   ./app/helpers/application_helper.rb:20:in `method_missing'
2021-05-03 14:17:54 +01:00
Matt-Yorkley
b7aeceaf67 Add enterprise_fees helper
Fixes:

Failure/Error: super

     ActionView::Template::Error:
       undefined method `angular_id' for #<#<Class:0x00007f57c7126670>:0x00007f57c55754f8>
     # ./app/helpers/application_helper.rb:20:in `method_missing'
     # ./app/views/admin/enterprise_fees/index.html.haml:32:in `block (2 levels) in _app_views_admin_enterprise_fees_index_html_haml__3854507252304647884_70007474860840'
     # ./app/helpers/angular_form_builder.rb:6:in `ng_fields_for'
     # ./app/views/admin/enterprise_fees/index.html.haml:28:in `block in _app_views_admin_enterprise_fees_index_html_haml__3854507252304647884_70007474860840'
     # ./app/helpers/application_helper.rb:11:in `ng_form_for'
     # ./app/views/admin/enterprise_fees/index.html.haml:4:in `_app_views_admin_enterprise_fees_index_html_haml__3854507252304647884_70007474860840'
     # ./lib/open_food_network/rack_request_blocker.rb:36:in `call'
     # ------------------
     # --- Caused by: ---
     # NoMethodError:
     #   undefined method `angular_id' for #<#<Class:0x00007f57c7126670>:0x00007f57c55754f8>
     #   ./app/helpers/application_helper.rb:20:in `method_missing'
2021-05-03 14:17:54 +01:00
Matt-Yorkley
e6a3041f45 Add admin/enterprises helper
Fixes:

Failure/Error: super

     ActionView::Template::Error:
       undefined method `add_check_if_single' for #<#<Class:0x0000564501a3c838>:0x00007f446cdd68e8>
     # ./app/helpers/application_helper.rb:20:in `method_missing'
     # ./app/views/spree/admin/shared/_hubs_sidebar.html.haml:16:in `block in _app_views_spree_admin_shared__hubs_sidebar_html_haml___1973426344114200431_69965928779540'
     # ./app/views/spree/admin/shared/_hubs_sidebar.html.haml:11:in `each'
     # ./app/views/spree/admin/shared/_hubs_sidebar.html.haml:11:in `_app_views_spree_admin_shared__hubs_sidebar_html_haml___1973426344114200431_69965928779540'
     # ./app/views/spree/admin/payment_methods/edit.html.haml:15:in `block in _app_views_spree_admin_payment_methods_edit_html_haml__571217921761730685_69965930474120'
     # ./app/views/spree/admin/payment_methods/edit.html.haml:11:in `_app_views_spree_admin_payment_methods_edit_html_haml__571217921761730685_69965930474120'
     # ./app/controllers/admin/resource_controller.rb:23:in `block (2 levels) in edit'
     # ./lib/spree/core/controller_helpers/respond_with.rb:24:in `respond_with'
     # ./app/controllers/admin/resource_controller.rb:22:in `edit'
     # ./lib/open_food_network/rack_request_blocker.rb:36:in `call'
     # ------------------
     # --- Caused by: ---
     # NoMethodError:
     #   undefined method `add_check_if_single' for #<#<Class:0x0000564501a3c838>:0x00007f446cdd68e8>
     #   ./app/helpers/application_helper.rb:20:in `method_missing'
2021-05-03 14:17:54 +01:00
Matt-Yorkley
b0787e83b2 Add checkout helper
Fixes:

      Failure/Error: super

      ActionView::Template::Error:
        undefined method `checkout_adjustments_for' for #<#<Class:0x000055f4bd847a30>:0x000055f4bd845c30>
      # ./app/helpers/application_helper.rb:20:in `method_missing'
      # ./app/views/spree/admin/orders/_invoice_table.html.haml:26:in `_app_views_spree_admin_orders__invoice_table_html_haml___3617932924646213210_47254819384740'
      # ./app/views/spree/admin/orders/invoice.html.haml:67:in `_app_views_spree_admin_orders_invoice_html_haml__1476001169744481148_47254819971700'
      # ./app/services/invoice_renderer.rb:8:in `render_to_string'
      # ./app/controllers/spree/admin/orders_controller.rb:81:in `invoice'
      # ./spec/support/controller_requests_helper.rb:49:in `process_action_with_route'
      # ./spec/support/controller_requests_helper.rb:23:in `spree_get'
      # ./spec/controllers/spree/admin/orders/invoices_spec.rb:58:in `block (6 levels) in <top (required)>'
      # ------------------
      # --- Caused by: ---
      # NoMethodError:
      #   undefined method `checkout_adjustments_for' for #<#<Class:0x000055f4bd847a30>:0x000055f4bd845c30>
      #   ./app/helpers/application_helper.rb:20:in `method_missing'
2021-05-03 14:17:54 +01:00
Luis Ramos
1b4930de8f Fix mimemagic 036 yank issue 2021-05-03 14:17:54 +01:00
Matt-Yorkley
f874397115 Fix errors in PermittedAttributes::OrderCycle 2021-05-03 14:17:54 +01:00
Matt-Yorkley
5fc60f53ba Update mimemagic gem!
The package maintainer nuked this gem last night as part of a major licence change for the repo, and chaos ensued. It's a dependency for ActiveStorage which is now part of Rails. Versions *above* 0.3.5 are now available, and work. All versions below 0.3.6 have been removed without warning (currently used by ~576,971 repos on Github!) D:
2021-05-03 14:17:54 +01:00
Matt-Yorkley
943c00c924 WIP - Update loading of helpers in controllers
Rails has changed the way helpers are loaded. It's a bit weird. It was throwing lots of errors, and recommended using this setting, but now requires that all helpers are loaded explicitly. I'm not sure about this.
2021-05-03 14:17:54 +01:00
Matt-Yorkley
138f00876b Update Rails to 5.2 2021-05-03 14:17:54 +01:00
Transifex-Openfoodnetwork
b00dcecd52 Updating translations for config/locales/en_GB.yml 2021-05-03 18:16:39 +10:00
dependabot[bot]
d3b3ed3b9c Bump test-prof from 1.0.2 to 1.0.3
Bumps [test-prof](https://github.com/test-prof/test-prof) from 1.0.2 to 1.0.3.
- [Release notes](https://github.com/test-prof/test-prof/releases)
- [Changelog](https://github.com/test-prof/test-prof/blob/master/CHANGELOG.md)
- [Commits](https://github.com/test-prof/test-prof/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-03 05:47:40 +00:00
filipefurtad0
19768e1398 adds coverage for product deletion and cloning 2021-05-02 18:33:13 +01:00
Matt-Yorkley
7c2d77a3ee Fix assertion in ModelSet test
The mismatched use of hash attributes as strings and hash attributes as symbols here (attrs['name'] and attrs[:name]) meant that the conditional was not returning the expected results in the test.
2021-05-02 13:42:38 +01:00
Matt-Yorkley
2560757ea2 Change Enterprise after_create callback to after_create_commit
As a general rule, if you're triggering an email job as part of an after create/save callback, it should use after commit instead.

Why? The transaction can't finish until after the record is persisted (the data is committed) which includes the logic in all callbacks. So for example if the transaction fails after the email job has been placed it will be rolled back, but the email job will already be in the queue, and it'll be referencing a record that doesn't actually exist (due to the rollback).
2021-05-02 13:23:31 +01:00
Matt-Yorkley
9d23c0d9e2 Reorder has_many relationship with :through option
If it's using :through it should be defined after the relationship it's connected to
2021-05-01 16:20:36 +01:00
Matt-Yorkley
7948c5943d Remove #deleted? method from Product and Variant
This method is already supplied via the paranoia gem, there's no need to re-implement it here.
2021-05-01 12:54:33 +01:00
Matt-Yorkley
2eb17dbbd1 Remove currency from OrderContents
The currency argument here is not actually used anywhere. The related conditional logic is also not covered in any tests.
2021-05-01 11:10:51 +01:00
Transifex-Openfoodnetwork
0a9fc429ac Updating translations for config/locales/de_DE.yml 2021-05-01 08:32:50 +10:00
Andy Brett
8672969798 Merge pull request #7515 from openfoodfoundation/dependabot/bundler/devise-4.8.0
Bump devise from 4.7.3 to 4.8.0
2021-04-30 11:24:20 -07:00
Andy Brett
1be730fcfb Merge pull request #7512 from Matt-Yorkley/package-refactor
Package update
2021-04-30 08:51:51 -07:00
Transifex-Openfoodnetwork
7fd82540ce Updating translations for config/locales/en_IE.yml 2021-05-01 00:27:53 +10:00
Matt-Yorkley
e290c128bf Fix error in Api::ShipmentController#update with :unlock parameter
This is a generic issue caused by a clash between state machines trying to define (or failing to define) the #open method on adjustments as part of their state changes interface. This method is already defined in Object. For more details, see: bb42e33bf7/lib/state_machines/machine.rb (L323-L350)
2021-04-30 14:13:22 +01:00
Matt-Yorkley
95a73704a2 Add more test coverage to Api::ShipmentController#update 2021-04-30 14:09:32 +01:00
Matt-Yorkley
b843b871f6 Ensure order totals and payment/shipment states are correct when changing shipping method on a completed order.
This used to happen via an after_save callback in Shipment, which called `order.update!`. That has recently been removed. After changing a shipment's selected shipping rate (shipping method), we need to ensure the order's totals and states are updated. We don't need to update all of the order's adjustments though (see previous commit).

FYI Spree handled this issue like this: 24388485ed, but there are lots of things about that commit that are clearly awful, like: params handling in a model, duplication of Order::Updater logic across the codebase, the Shipment class having responsiblity for knowing which things need to be updated on the order, etc. The result is ultimately the same as what we're doing here though.
2021-04-30 12:57:01 +01:00
Matt-Yorkley
925676f136 Split Order::Updater#update into two methods
There are two distinct (and very important) operations happening here. The first is to update all adjustments (which can be *incredibly* expensive) and the second is to ensure the order's totals and shipping/payment states are correct. There are lots of places where we currently do both of these things where in fact we only need to do the latter (and skip the really expensive part).
2021-04-30 12:48:53 +01:00
Matt-Yorkley
d3f41f14c7 Add test coverage for Api::ShipmentsController#update 2021-04-30 12:45:49 +01:00
Matt-Yorkley
045ce73c83 Simplify shipment controller params 2021-04-30 12:20:47 +01:00
Matt-Yorkley
932d000c9d Improve shipping method factory
You can now specify an amount for the flat_rate option.
2021-04-30 12:19:43 +01:00
Matt-Yorkley
c7ce10f998 Handle order objects with no distributor 2021-04-30 11:12:41 +01:00
Matt-Yorkley
5b29243847 Delete unused method Stock::Package#currency 2021-04-30 11:10:20 +01:00
Matt-Yorkley
3897c3af68 Refactor Stock::Package#shipping_methods 2021-04-30 11:10:20 +01:00
Matt-Yorkley
c3c396eaea Add soft-deletion test coverage to Package#shipping_methods 2021-04-30 11:10:19 +01:00
Pau Perez
03b2e558b3 Update all locales with the latest Transifex translations 2021-04-30 11:58:13 +02:00
Pau Pérez Fabregat
fca4fde9a6 Merge pull request #7518 from openfoodfoundation/transifex
Transifex
2021-04-30 11:54:01 +02:00
Pau Pérez Fabregat
057bcddee9 Merge pull request #7478 from jibees/7458-get-products-on-order-cycle-change-events
Get the whole list of products on order cycle changes
2021-04-30 11:39:15 +02:00
Transifex-Openfoodnetwork
05b1e598e0 Updating translations for config/locales/es.yml 2021-04-30 19:37:16 +10:00
Transifex-Openfoodnetwork
0faee508b5 Updating translations for config/locales/ca.yml 2021-04-30 19:34:42 +10:00
Pau Pérez Fabregat
3aaa818d00 Merge pull request #7516 from openfoodfoundation/transifex
Transifex
2021-04-30 11:30:07 +02:00
Pau Pérez Fabregat
006cf45f2a Merge pull request #7514 from openfoodfoundation/dependabot/bundler/rack-mini-profiler-2.3.2
Bump rack-mini-profiler from 2.3.1 to 2.3.2
2021-04-30 11:29:28 +02:00
Transifex-Openfoodnetwork
afd17d6cf8 Updating translations for config/locales/ru.yml 2021-04-30 18:45:03 +10:00
Transifex-Openfoodnetwork
f6b6564048 Updating translations for config/locales/fr.yml 2021-04-30 17:48:22 +10:00
Transifex-Openfoodnetwork
9c49040fbb Updating translations for config/locales/en_FR.yml 2021-04-30 17:47:48 +10:00
Transifex-Openfoodnetwork
a8b3d10377 Updating translations for config/locales/fr.yml 2021-04-30 17:45:21 +10:00
dependabot[bot]
c1d246081e Bump devise from 4.7.3 to 4.8.0
Bumps [devise](https://github.com/plataformatec/devise) from 4.7.3 to 4.8.0.
- [Release notes](https://github.com/plataformatec/devise/releases)
- [Changelog](https://github.com/heartcombo/devise/blob/master/CHANGELOG.md)
- [Commits](https://github.com/plataformatec/devise/compare/v4.7.3...v4.8.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-30 05:20:39 +00:00
dependabot[bot]
cf6545e501 Bump rack-mini-profiler from 2.3.1 to 2.3.2
Bumps [rack-mini-profiler](https://github.com/MiniProfiler/rack-mini-profiler) from 2.3.1 to 2.3.2.
- [Release notes](https://github.com/MiniProfiler/rack-mini-profiler/releases)
- [Changelog](https://github.com/MiniProfiler/rack-mini-profiler/blob/master/CHANGELOG.md)
- [Commits](https://github.com/MiniProfiler/rack-mini-profiler/compare/v2.3.1...v2.3.2)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-30 05:17:41 +00:00
Andy Brett
f64d5a9f59 Merge pull request #7438 from jibees/7353-fix-OC-display-issue-text-on-two-lines
Change the position of order_cycle component into a shop front
2021-04-29 14:05:06 -07:00
Andy Brett
c069a23926 Merge pull request #7476 from cillian/admin-stripe-elements-width
Increase the width of Stripe Elements fields in admin so they don't overlap
2021-04-29 14:04:44 -07:00
Andy Brett
8ba139c6fb Merge pull request #6825 from julesemmac/6584-map-location-confirm
6584 map location confirm
2021-04-29 14:04:06 -07:00
Matt-Yorkley
0291a7c471 Merge pull request #7482 from Matt-Yorkley/updater-update
Updater update
2021-04-29 21:12:15 +02:00
Andy Brett
699f1c4f41 Merge pull request #7497 from andrewpbrett/fix-double-stripe-payments
Use capture! if payment is already authorized
2021-04-29 08:35:19 -07:00
Jean-Baptiste Bellet
5a3771fc42 Add special config to avoid a inconsistant LoadError
Error is
```
Failure/Error: @app.call(env)
     LoadError:
       Unable to autoload constant Api::V0::OrderCyclesController, expected /Users/jibees/dev/openfoodnetwork/app/controllers/api/v0/order_cycles_controller.rb to define it
```
2021-04-29 15:31:24 +02:00
Pau Pérez Fabregat
6c5db0f836 Merge pull request #7507 from Matt-Yorkley/shipment-state-update
Shipment callback state update
2021-04-29 12:01:55 +02:00
Matt-Yorkley
2f49d089ea Use Time.zone.now 2021-04-29 08:56:17 +01:00
Matt-Yorkley
290c1d0ebf Bring in shipment state updating from Spree 2.2 2021-04-28 21:43:28 +01:00
Matt-Yorkley
2fda550821 Add test for shipment state after ship action 2021-04-28 21:40:08 +01:00
Guido Oliveira
84285ff985 prevent deleting only item in confirmed order 2021-04-28 17:37:28 -03:00
Andy Brett
4f246da79f add feature spec 2021-04-28 11:25:43 -07:00
Andy Brett
73e5fd3f5b use method to clarify intent on payment intents 2021-04-28 10:43:06 -07:00
Andy Brett
4736013946 update spec 2021-04-28 10:43:06 -07:00
Pau Pérez Fabregat
6ee6e4ed04 Merge pull request #7472 from openfoodfoundation/transifex
Transifex
2021-04-28 19:36:43 +02:00
Pau Pérez Fabregat
ef9720aee7 Merge pull request #7461 from andrewpbrett/fix-blocked-bo-orders
Scope variant to take overrides into account in packer
2021-04-28 19:36:02 +02:00
Matt-Yorkley
4bd2fb8930 Merge pull request #7498 from openfoodfoundation/dependabot/bundler/view_component-2.31.1
Bump view_component from 2.31.0 to 2.31.1
2021-04-28 12:47:55 +02:00
dependabot[bot]
2494ba0def Bump view_component from 2.31.0 to 2.31.1
Bumps [view_component](https://github.com/github/view_component) from 2.31.0 to 2.31.1.
- [Release notes](https://github.com/github/view_component/releases)
- [Changelog](https://github.com/github/view_component/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/view_component/compare/v2.31.0...v2.31.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-28 05:28:59 +00:00
Andy Brett
9906afa1a6 use capture! if payment is already authorized 2021-04-27 17:59:03 -07:00
Matt-Yorkley
1d29e277f2 Merge pull request #7493 from Matt-Yorkley/order-states-bug-redux
Reload order before updating in Payment callback
2021-04-27 17:43:34 +02:00
Matt-Yorkley
c7e65185ee Regression test for new order with variant overrides 2021-04-27 07:44:41 -07:00
Matt-Yorkley
22f79fe540 Reload order before updating in Payment callback 2021-04-27 14:27:35 +01:00
Matt-Yorkley
a5a324fd6f Add failing spec for payment and shipment states bug
The order was being left in an unexpected condition here, it's states are not set and there seem to be some weird issues.
2021-04-27 14:27:35 +01:00
Matt-Yorkley
5934b100e9 Test payment and shipment states in checkout spec
If these aren't behaving correctly we need to know about it...
2021-04-27 14:27:35 +01:00
Jean-Baptiste Bellet
81385b63c7 Uncomment (not so) flaky spec 2021-04-27 15:27:16 +02:00
Matt-Yorkley
574d78403d Merge pull request #7433 from coopdevs/raise-on-failed-customer-creation
Notify Bugsnag if customer fails to be created
2021-04-27 12:42:39 +02:00
Matt-Yorkley
3c1889d719 Merge pull request #7490 from openfoodfoundation/dependabot/bundler/view_component-2.31.0
Bump view_component from 2.30.0 to 2.31.0
2021-04-27 12:08:29 +02:00
Jean-Baptiste Bellet
5085501f89 Add automated tests around pagination in product list for a shop
- with two order cycles and go from one to the other
2021-04-27 11:24:56 +02:00
Jean-Baptiste Bellet
07881ede2d Do not trigger loadMore method immediatly
- This avoid to request unwanted resources, ie. the next 10 products of a shop
2021-04-27 11:24:48 +02:00
Jean-Baptiste Bellet
cdbcbf4214 Reinitialize page params when changing order cycle 2021-04-27 11:24:48 +02:00
Jean-Baptiste Bellet
523b957ba7 Initialize activeTaxons and activeProperties
- so there is no unwanted changes (from `undefined` to `[]`) that  would trigger a loadProducts request
2021-04-27 11:24:48 +02:00
Jean-Baptiste Bellet
71466e643f Instanciate only one ProductsCtrl
- instead of 2: therefore, for each shop display, we only request products one time instead of two times.
2021-04-27 11:24:48 +02:00
Matt-Yorkley
cc85bf791a Merge pull request #7481 from openfoodfoundation/dependabot/bundler/codecov-0.5.2
Bump codecov from 0.5.1 to 0.5.2
2021-04-27 09:24:51 +02:00
dependabot[bot]
fa32aecebf Bump view_component from 2.30.0 to 2.31.0
Bumps [view_component](https://github.com/github/view_component) from 2.30.0 to 2.31.0.
- [Release notes](https://github.com/github/view_component/releases)
- [Changelog](https://github.com/github/view_component/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/view_component/compare/v2.30.0...v2.31.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-27 05:26:40 +00:00
Andy Brett
de02acad64 add feature spec 2021-04-26 15:42:36 -07:00
Matt-Yorkley
f52d03fbf4 Refactor Order::Updater#update so we don't call update_totals twice
Calling this method twice on every update is really expensive and not necessary.
2021-04-26 11:46:05 +01:00
Pau Perez
ee01b0162c Write if as a one-liner and avoid extra queries 2021-04-26 12:39:03 +02:00
Pau Perez
002dabb80c Improve spec 2021-04-26 10:15:13 +02:00
Pau Perez
451e05985f Fix spec 2021-04-26 10:15:13 +02:00
Pau Perez
679de40a41 Move specs to where they belong 2021-04-26 10:15:13 +02:00
Pau Perez
5845ace8e9 Don't persist models to test serializer
Serializers don't care whether or not the objects they go through are
persisted in DB. They just convert them.
2021-04-26 10:15:13 +02:00
Pau Perez
c65d82be01 Notify Bugsnag if customer fails to be created
This will hopefully let us see in Bugsnag when #6038 happens and so
we'll have all the diagnostics data. The fact that the `order.distributor`
is optional but mandatory to create the customer already gives us some
clue.
2021-04-26 10:15:12 +02:00
dependabot[bot]
69dd33383c Bump codecov from 0.5.1 to 0.5.2
Bumps [codecov](https://github.com/codecov/codecov-ruby) from 0.5.1 to 0.5.2.
- [Release notes](https://github.com/codecov/codecov-ruby/releases)
- [Changelog](https://github.com/codecov/codecov-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-ruby/compare/v0.5.1...v0.5.2)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-26 05:53:44 +00:00
Andy Brett
6153f1c1b4 Merge pull request #7471 from Matt-Yorkley/dead-scopes
Order scopes
2021-04-25 11:51:00 -07:00
Andy Brett
6f20a23d47 Merge pull request #7436 from coopdevs/remove-duplicate-method
Replace duplicate #unauthorized method with module inclusion
2021-04-25 11:26:12 -07:00
Luis Ramos
f357c3ff30 Remove require_dependency or use require
See here https://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#require-dependency
2021-04-23 19:20:25 +01:00
Cillian O'Ruanaidh
8cdc4bc3f4 Increase the width of Stripe Elements fields in admin so they don't overlap
The card number and expiry month/year fields were overlapping on the new payment form in the admin area.
2021-04-23 17:54:22 +01:00
Andy Brett
e42b0bb1ae Merge pull request #7469 from openfoodfoundation/dependabot/bundler/view_component-2.30.0
Bump view_component from 2.28.0 to 2.30.0
2021-04-23 09:48:57 -07:00
Andy Brett
5e21480ae0 add packer spec 2021-04-23 09:35:27 -07:00
Matt-Yorkley
0c08e3cb3a Merge pull request #7466 from openfoodfoundation/dependabot/npm_and_yarn/storybook/addon-docs-6.2.9
Bump @storybook/addon-docs from 6.2.7 to 6.2.9
2021-04-23 13:53:04 +02:00
dependabot[bot]
3c9b7db763 Bump @storybook/addon-docs from 6.2.7 to 6.2.9
Bumps [@storybook/addon-docs](https://github.com/storybookjs/storybook/tree/HEAD/addons/docs) from 6.2.7 to 6.2.9.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/v6.2.9/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.2.9/addons/docs)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-23 11:49:16 +00:00
Matt-Yorkley
d116d664f5 Merge pull request #7467 from openfoodfoundation/dependabot/npm_and_yarn/storybook/addon-controls-6.2.9
Bump @storybook/addon-controls from 6.2.7 to 6.2.9
2021-04-23 13:47:14 +02:00
dependabot[bot]
ff36cea0b0 Bump @storybook/addon-controls from 6.2.7 to 6.2.9
Bumps [@storybook/addon-controls](https://github.com/storybookjs/storybook/tree/HEAD/addons/controls) from 6.2.7 to 6.2.9.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/v6.2.9/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.2.9/addons/controls)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-23 11:30:47 +00:00
Matt-Yorkley
0c6f8e978e Merge pull request #7465 from openfoodfoundation/dependabot/npm_and_yarn/storybook/server-6.2.9
Bump @storybook/server from 6.2.7 to 6.2.9
2021-04-23 13:27:50 +02:00
Pau Perez
e5eb68dffc Replace duplicate method with module inclusion
No reason to risk diverging their implementations. They are exact
copies.

Likewise, there's no need to have to I18n keys with almost the same
content.
2021-04-23 12:03:11 +02:00
Transifex-Openfoodnetwork
35658e984b Updating translations for config/locales/en_IE.yml 2021-04-23 19:43:25 +10:00
Transifex-Openfoodnetwork
a019c73166 Updating translations for config/locales/en_IE.yml 2021-04-23 19:40:16 +10:00
Matt-Yorkley
4938285dd7 Move order query methods to chainable scopes 2021-04-23 10:29:48 +01:00
Matt-Yorkley
caee2eb3e9 Remove dead code in order
These aren't used anywhere
2021-04-23 10:23:40 +01:00
dependabot[bot]
54fd2c5f0f Bump view_component from 2.28.0 to 2.30.0
Bumps [view_component](https://github.com/github/view_component) from 2.28.0 to 2.30.0.
- [Release notes](https://github.com/github/view_component/releases)
- [Changelog](https://github.com/github/view_component/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/view_component/compare/v2.28.0...v2.30.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-23 08:18:44 +00:00
dependabot[bot]
8c76752045 Bump @storybook/server from 6.2.7 to 6.2.9
Bumps [@storybook/server](https://github.com/storybookjs/storybook/tree/HEAD/app/server) from 6.2.7 to 6.2.9.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/v6.2.9/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.2.9/app/server)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-23 06:06:24 +00:00
Cillian O'Ruanaidh
af3eb82343 Merge in upstream changes from julesemmac:6584-map-location-confirm and resolve conflicts 2021-04-22 22:34:02 +01:00
Cillian O'Ruanaidh
1e96f92df2 Fix the toggle address confirmed checkbox so the latitude/longitude gets set
Before when you checked and unchecked the checkbox it was toggling the :isConfirmed variable.
2021-04-22 22:16:47 +01:00
Cillian O'Ruanaidh
12704af143 Use after_action calls for geocoding instead of old update.after, create.after calls 2021-04-22 22:13:28 +01:00
Cillian O'Ruanaidh
42d002cee8 Increase the default geocoder timeout to prevent geocoding timeouts in development
The timeout default was 3 before, this changes it to 6. I presume these timeouts could happen in production too.
2021-04-22 22:10:36 +01:00
Cillian O'Ruanaidh
cd97f1a6ef Update angular-google-maps to 2.0.1 instead of 2.4.0 which was breaking /map page.
The master branch uses 2.0.0 but this PR went up to 2.4.0, however that caused the /map page to break and it was difficult to figure out why. We need to update to 2.0.1 because when you drag and drop the location icon during sign up there was an error which is fixed in 2.0.1. Maybe it would be good to upgrade to 2.4.0 at some point but this PR is already quite big.
2021-04-22 22:08:40 +01:00
Andy Brett
56cf43f1c1 scope variant to take overrides into account in packer 2021-04-22 11:45:12 -07:00
Cillian O'Ruanaidh
c41476423b Merge latest master into julesemmac/6584-map-location-confirm and resolve conflict in api/enterprises_controller.rb 2021-04-22 19:43:49 +01:00
Jean-Baptiste Bellet
5e712fa4c0 Add variable for the zIndex of the navigation header 2021-04-20 13:50:39 +02:00
Jean-Baptiste Bellet
6dbe91b199 Positions the order_cycle according to shop-tabs
- Move from `enterprises/shop.html.haml` to `shopping_shared/_tabs.html.haml` to handle its position correctly
 - Remove marginTop and height to order cycle component and display it relative to parent's bottom (ie. the columns in `tab-buttons`)
- Adjust z-index to display the entire component
2021-04-20 13:50:33 +02:00
dependabot[bot]
8b06a735ac Bump jwt from 2.2.2 to 2.2.3
Bumps [jwt](https://github.com/jwt/ruby-jwt) from 2.2.2 to 2.2.3.
- [Release notes](https://github.com/jwt/ruby-jwt/releases)
- [Changelog](https://github.com/jwt/ruby-jwt/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jwt/ruby-jwt/compare/v2.2.2...v2.2.3)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-20 05:21:34 +00:00
Maikel Linke
1b14755401 Reduce AbcSize for rubocop 2021-04-09 12:15:47 +10:00
Maikel Linke
ce516db20f Replace usage of Spree's action hooks with Rails
We don't need Spree's hooks any more and will remove them. Rails'
version is much simpler.
2021-04-09 12:04:31 +10:00
Cillian O'Ruanaidh
8a4e7d70a9 Pass in owner_id parameter correctly so admin/enterprises#create controller spec doesn't fail 2021-04-09 12:04:31 +10:00
Cillian O'Ruanaidh
a59a340fcd Extract location map from registration form into its own partial, also add missing new lines 2021-04-09 12:04:31 +10:00
Cillian O'Ruanaidh
16b90cfc2e Allow people to set enterprise latitude/longitude manually or automatically.
This for new changes to the enterprise registration/signup flow where a map will be displayed when people are filling in their address. On this map people can check the geocoder has geocoded their address correctly and if not they can manually adjust their latitude/longitude on the map.

But currently every time someone changes their address in the Admin > Enterprise > Address section the address would automatically be geocoded so this could overwrite the latitude/longitude that was set during sign up. To prevent the latitude/longitude from being overwritten this add's a checkbox which people need to explicity click if they want their address to be automatically geocoded, otherwise it will just use the manually configured latitude/longitude.

Note this new feature which allows people to select their location on a map during registration only works with Google maps so far. So if an instance is using Open Street Map this change also adds support for passing a :use_geocoder parameter to the Api::EnterprisesController during registration so that the address will be geocoded on the backend without the use of a map.
2021-04-09 12:03:12 +10:00
julesemmac
5e6ea31ad1 Improving user discover on ofn map
The context for this update is here: https://community.openfoodnetwork.org/t/improving-user-discovery-on-ofn-map/2013

Also with rebasing help from Maikel Linke <mkllnk@web.de>
2021-04-09 12:02:22 +10:00
Matt-Yorkley
153ec268b7 Remove RackRequestBlocker 2021-03-30 13:24:44 +01:00
Matt-Yorkley
92eaf5fbaa Remove atomic gem
Bundler says this when installing gems:
```
Post-install message from atomic:
This gem has been deprecated and merged into Concurrent Ruby (http://concurrent-ruby.com).
```
We already have concurrent-ruby 👍
2021-03-30 12:29:48 +01:00
Cillian O'Ruanaidh
31f737422c Pass in owner_id parameter correctly so admin/enterprises#create controller spec doesn't fail 2021-03-19 22:21:47 +00:00
Cillian O'Ruanaidh
4e1eefa877 Extract location map from registration form into its own partial, also add missing new lines 2021-03-19 21:43:29 +00:00
Cillian O'Ruanaidh
f20cea7e4f Allow people to set enterprise latitude/longitude manually or automatically.
This for new changes to the enterprise registration/signup flow where a map will be displayed when people are filling in their address. On this map people can check the geocoder has geocoded their address correctly and if not they can manually adjust their latitude/longitude on the map.

But currently every time someone changes their address in the Admin > Enterprise > Address section the address would automatically be geocoded so this could overwrite the latitude/longitude that was set during sign up. To prevent the latitude/longitude from being overwritten this add's a checkbox which people need to explicity click if they want their address to be automatically geocoded, otherwise it will just use the manually configured latitude/longitude.

Note this new feature which allows people to select their location on a map during registration only works with Google maps so far. So if an instance is using Open Street Map this change also adds support for passing a :use_geocoder parameter to the Api::EnterprisesController during registration so that the address will be geocoded on the backend without the use of a map.
2021-03-19 21:43:29 +00:00
julesemmac
971971803e Improving user discover on ofn map
The context for this update is here: https://community.openfoodnetwork.org/t/improving-user-discovery-on-ofn-map/2013

Also with rebasing help from Maikel Linke <mkllnk@web.de>
2021-03-19 21:43:29 +00:00
249 changed files with 3380 additions and 1990 deletions

5
.github/codecov.yml vendored Normal file
View File

@@ -0,0 +1,5 @@
coverage:
status:
project:
default:
informational: true

View File

@@ -322,4 +322,4 @@ jobs:
run: bundle exec rspec --profile --pattern "engines/*/spec/{,/*/**}/*_spec.rb,spec/features/admin/*/*_spec.rb,spec/lib/{,/*/**}/*_spec.rb"
- name: Codecov
uses: codecov/codecov-action@v1.3.1
uses: codecov/codecov-action@v1.5.0

View File

@@ -1 +1 @@
5.12.0
14.16.1

View File

@@ -931,7 +931,6 @@ Style/FrozenStringLiteralComment:
- 'app/helpers/spree/admin/base_helper.rb'
- 'app/helpers/spree/admin/general_settings_helper.rb'
- 'app/helpers/spree/admin/orders_helper.rb'
- 'app/helpers/spree/admin/payments_helper.rb'
- 'app/helpers/spree/admin/taxons_helper.rb'
- 'app/helpers/spree/admin/zones_helper.rb'
- 'app/helpers/spree/orders_helper.rb'

View File

@@ -6,7 +6,7 @@ This is a general guide to setting up an Open Food Network **development environ
The fastest way to make it work locally is to use Docker, you only need to setup git, see the [Docker setup guide](docker/README.md).
Otherwise, for a local setup you will need:
* Ruby 2.4.4 and bundler (check current Ruby version in [.ruby-version](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/.ruby-version) file)
* Ruby and bundler (check current Ruby version in [.ruby-version](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/.ruby-version) file)
* PostgreSQL database
* Chrome (for testing)
@@ -78,8 +78,6 @@ Note: If your OS is not explicitly supported in the setup guides then not all te
Note: The time zone on your machine should match the one defined in `config/application.yml`.
The project is configured to use [Zeus][zeus] to reduce the pre-test startup time while Rails loads. See the [Zeus GitHub page][zeus] for usage instructions.
Once [npm dependencies are installed][karma], AngularJS tests can be run with:
./script/karma run
@@ -119,7 +117,6 @@ If these commands succeed, you should be able to [continue the setup process](#g
[ubuntu]: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Development-Environment-Setup:-Ubuntu
[debian]: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Development-Environment-Setup:-Debian
[wiki]: https://github.com/openfoodfoundation/openfoodnetwork/wiki
[zeus]: https://github.com/burke/zeus
[rubocop]: https://rubocop.readthedocs.io/en/latest/
[karma]: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Karma
[slack-dev]: https://openfoodnetwork.slack.com/messages/C2GQ45KNU

19
Gemfile
View File

@@ -4,18 +4,18 @@ source 'https://rubygems.org'
ruby "2.5.8"
git_source(:github) { |repo_name| "https://github.com/#{repo_name}.git" }
gem 'rails', '~> 5.0.0'
gem 'rails', '~> 5.2'
gem 'activemerchant', '>= 1.78.0'
gem 'angular-rails-templates', '>= 0.3.0'
gem 'awesome_nested_set'
gem 'ransack', '2.3.0'
gem 'ransack', '2.4.1'
gem 'responders'
gem 'sass', '<= 4.7.1'
gem 'sass-rails', '< 6.0.0'
gem 'i18n'
gem 'i18n-js', '~> 3.8.2'
gem 'i18n-js', '~> 3.8.3'
gem 'rails-i18n'
gem 'rails_safe_tasks', '~> 1.0'
@@ -29,7 +29,7 @@ gem "order_management", path: "./engines/order_management"
gem 'web', path: './engines/web'
gem 'activerecord-postgresql-adapter'
gem 'pg', '~> 0.21.0'
gem 'pg', '~> 1.2.3'
gem 'acts_as_list', '1.0.4'
gem 'cancancan', '~> 1.15.0'
@@ -75,11 +75,15 @@ gem 'dalli'
gem 'figaro'
gem 'geocoder'
gem 'gmaps4rails'
gem 'mimemagic', '> 0.3.5'
gem 'paper_trail', '~> 10.3.1'
gem 'paperclip', '~> 3.4.1'
gem 'rack-rewrite'
gem 'rack-ssl', require: 'rack/ssl'
gem 'roadie-rails', '~> 1.3.0'
gem 'roadie-rails', '~> 2.2.0'
gem 'redis', '>= 4.0', require: ['redis', 'redis/connection/hiredis']
gem 'hiredis'
gem 'combine_pdf'
gem 'wicked_pdf'
@@ -92,7 +96,7 @@ gem 'whenever', require: false
gem 'test-unit', '~> 3.4'
gem 'coffee-rails', '~> 4.2.2'
gem 'coffee-rails', '~> 5.0.0'
gem 'compass-rails'
gem 'mini_racer', '0.4.0'
@@ -126,12 +130,11 @@ end
group :test, :development do
# Pretty printed test output
gem 'atomic'
gem 'awesome_print'
gem 'bullet'
gem 'capybara'
gem 'database_cleaner', require: false
gem "factory_bot_rails", '6.1.0', require: false
gem "factory_bot_rails", '6.2.0', require: false
gem 'fuubar', '~> 2.5.1'
gem 'json_spec', '~> 1.1.4'
gem 'knapsack'

View File

@@ -47,58 +47,62 @@ PATH
GEM
remote: https://rubygems.org/
specs:
actioncable (5.0.7.2)
actionpack (= 5.0.7.2)
nio4r (>= 1.2, < 3.0)
websocket-driver (~> 0.6.1)
actionmailer (5.0.7.2)
actionpack (= 5.0.7.2)
actionview (= 5.0.7.2)
activejob (= 5.0.7.2)
actioncable (5.2.6)
actionpack (= 5.2.6)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.6)
actionpack (= 5.2.6)
actionview (= 5.2.6)
activejob (= 5.2.6)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.0.7.2)
actionview (= 5.0.7.2)
activesupport (= 5.0.7.2)
rack (~> 2.0)
rack-test (~> 0.6.3)
actionpack (5.2.6)
actionview (= 5.2.6)
activesupport (= 5.2.6)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionpack-action_caching (1.2.1)
actionpack-action_caching (1.2.2)
actionpack (>= 4.0.0)
actionview (5.0.7.2)
activesupport (= 5.0.7.2)
actionview (5.2.6)
activesupport (= 5.2.6)
builder (~> 3.1)
erubis (~> 2.7.0)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
active_model_serializers (0.8.4)
activemodel (>= 3.0)
activejob (5.0.7.2)
activesupport (= 5.0.7.2)
activejob (5.2.6)
activesupport (= 5.2.6)
globalid (>= 0.3.6)
activemerchant (1.119.0)
activesupport (>= 4.2)
builder (>= 2.1.2, < 4.0.0)
i18n (>= 0.6.9)
nokogiri (~> 1.4)
activemodel (5.0.7.2)
activesupport (= 5.0.7.2)
activerecord (5.0.7.2)
activemodel (= 5.0.7.2)
activesupport (= 5.0.7.2)
arel (~> 7.0)
activerecord-import (1.0.8)
activemodel (5.2.6)
activesupport (= 5.2.6)
activerecord (5.2.6)
activemodel (= 5.2.6)
activesupport (= 5.2.6)
arel (>= 9.0)
activerecord-import (1.1.0)
activerecord (>= 3.2)
activerecord-postgresql-adapter (0.0.1)
pg
activerecord-session_store (1.1.3)
actionpack (>= 4.0)
activerecord (>= 4.0)
activerecord-session_store (2.0.0)
actionpack (>= 5.2.4.1)
activerecord (>= 5.2.4.1)
multi_json (~> 1.11, >= 1.11.2)
rack (>= 1.5.2, < 3)
railties (>= 4.0)
activesupport (5.0.7.2)
rack (>= 2.0.8, < 3)
railties (>= 5.2.4.1)
activestorage (5.2.6)
actionpack (= 5.2.6)
activerecord (= 5.2.6)
marcel (~> 1.0.0)
activesupport (5.2.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
@@ -118,9 +122,8 @@ GEM
railties (>= 3, < 7)
angularjs-file-upload-rails (2.4.1)
angularjs-rails (1.5.5)
arel (7.1.4)
arel (9.0.0)
ast (2.4.2)
atomic (1.1.101)
awesome_nested_set (3.4.0)
activerecord (>= 4.0.0, < 7.0)
awesome_print (1.9.2)
@@ -152,12 +155,12 @@ GEM
climate_control (0.2.0)
cocaine (0.5.8)
climate_control (>= 0.0.3, < 1.0)
codecov (0.5.1)
codecov (0.5.2)
simplecov (>= 0.15, < 0.22)
coderay (1.1.3)
coffee-rails (4.2.2)
coffee-rails (5.0.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0)
railties (>= 5.2.0)
coffee-script (2.4.1)
coffee-script-source
execjs
@@ -184,12 +187,12 @@ GEM
crack (0.4.5)
rexml
crass (1.0.6)
css_parser (1.7.1)
css_parser (1.9.0)
addressable
daemons (1.3.1)
daemons (1.4.0)
dalli (2.7.11)
database_cleaner (1.99.0)
ddtrace (0.48.0)
ddtrace (0.49.0)
ffi (~> 1.0)
msgpack
debugger-linecache (1.2.0)
@@ -203,7 +206,7 @@ GEM
delayed_job (> 2.0.3)
rack-protection (>= 1.5.5)
sinatra (>= 1.4.4)
devise (4.7.3)
devise (4.8.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
@@ -216,14 +219,13 @@ GEM
diff-lcs (1.4.4)
docile (1.3.5)
erubi (1.10.0)
erubis (2.7.0)
eventmachine (1.2.7)
excon (0.79.0)
execjs (2.7.0)
factory_bot (6.1.0)
factory_bot (6.2.0)
activesupport (>= 5.0.0)
factory_bot_rails (6.1.0)
factory_bot (~> 6.1.0)
factory_bot_rails (6.2.0)
factory_bot (~> 6.2.0)
railties (>= 5.0.0)
faraday (1.3.0)
faraday-net_http (~> 1.0)
@@ -282,9 +284,10 @@ GEM
tilt
hashdiff (1.0.1)
highline (2.0.3)
hiredis (0.6.3)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
i18n-js (3.8.2)
i18n-js (3.8.3)
i18n (>= 0.6.6)
immigrant (0.3.6)
activerecord (>= 3.0)
@@ -302,7 +305,7 @@ GEM
json_spec (1.1.5)
multi_json (~> 1.0)
rspec (>= 2.0, < 4.0)
jwt (2.2.2)
jwt (2.2.3)
kaminari (1.2.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.1)
@@ -323,17 +326,21 @@ GEM
letter_opener (1.7.0)
launchy (~> 2.2)
libv8-node (15.14.0.0)
loofah (2.9.0)
loofah (2.9.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (1.0.1)
method_source (1.0.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2020.1104)
mini_mime (1.0.3)
mini_portile2 (2.5.0)
mimemagic (0.4.3)
nokogiri (~> 1)
rake
mini_mime (1.1.0)
mini_portile2 (2.5.1)
mini_racer (0.4.0)
libv8-node (~> 15.14.0.0)
minitest (5.14.4)
@@ -347,8 +354,8 @@ GEM
multipart-post (2.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
nio4r (2.5.2)
nokogiri (1.11.2)
nio4r (2.5.7)
nokogiri (1.11.4)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
oauth2 (1.4.7)
@@ -370,16 +377,14 @@ GEM
parallel (1.20.1)
paranoia (2.4.3)
activerecord (>= 4.0, < 6.2)
parser (3.0.1.0)
parser (3.0.1.1)
ast (~> 2.4.1)
paypal-sdk-core (0.3.4)
multi_json (~> 1.0)
xml-simple
paypal-sdk-merchant (1.117.2)
paypal-sdk-core (~> 0.3.0)
pg (0.21.0)
polyamorous (2.3.0)
activerecord (>= 5.0)
pg (1.2.3)
power_assert (2.0.0)
pry (0.13.1)
coderay (~> 1.1)
@@ -390,26 +395,27 @@ GEM
public_suffix (4.0.6)
racc (1.5.2)
rack (2.2.3)
rack-mini-profiler (2.3.1)
rack-mini-profiler (2.3.2)
rack (>= 1.2.0)
rack-protection (2.1.0)
rack
rack-rewrite (1.5.1)
rack-ssl (1.4.1)
rack
rack-test (0.6.3)
rack (>= 1.0)
rails (5.0.7.2)
actioncable (= 5.0.7.2)
actionmailer (= 5.0.7.2)
actionpack (= 5.0.7.2)
actionview (= 5.0.7.2)
activejob (= 5.0.7.2)
activemodel (= 5.0.7.2)
activerecord (= 5.0.7.2)
activesupport (= 5.0.7.2)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.6)
actioncable (= 5.2.6)
actionmailer (= 5.2.6)
actionpack (= 5.2.6)
actionview (= 5.2.6)
activejob (= 5.2.6)
activemodel (= 5.2.6)
activerecord (= 5.2.6)
activestorage (= 5.2.6)
activesupport (= 5.2.6)
bundler (>= 1.3.0)
railties (= 5.0.7.2)
railties (= 5.2.6)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
@@ -424,25 +430,24 @@ GEM
i18n (>= 0.7, < 2)
railties (>= 5.0, < 6)
rails_safe_tasks (1.0.0)
railties (5.0.7.2)
actionpack (= 5.0.7.2)
activesupport (= 5.0.7.2)
railties (5.2.6)
actionpack (= 5.2.6)
activesupport (= 5.2.6)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
thor (>= 0.19.0, < 2.0)
rainbow (3.0.0)
raindrops (0.19.1)
rake (13.0.3)
ransack (2.3.0)
actionpack (>= 5.0)
activerecord (>= 5.0)
activesupport (>= 5.0)
ransack (2.4.1)
activerecord (>= 5.2.4)
activesupport (>= 5.2.4)
i18n
polyamorous (= 2.3.0)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
redcarpet (3.5.1)
redis (4.2.5)
regexp_parser (2.1.1)
request_store (1.5.0)
rack (>= 1.4)
@@ -450,12 +455,12 @@ GEM
actionpack (>= 5.0)
railties (>= 5.0)
rexml (3.2.5)
roadie (3.5.1)
roadie (4.0.0)
css_parser (~> 1.4)
nokogiri (~> 1.8)
roadie-rails (1.3.0)
railties (>= 3.0, < 5.3)
roadie (~> 3.1)
roadie-rails (2.2.0)
railties (>= 5.1, < 6.2)
roadie (>= 3.1, < 5.0)
roo (2.8.3)
nokogiri (~> 1)
rubyzip (>= 1.3.0, < 3.0.0)
@@ -471,10 +476,10 @@ GEM
rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-rails (4.1.2)
actionpack (>= 4.2)
activesupport (>= 4.2)
railties (>= 4.2)
rspec-rails (5.0.1)
actionpack (>= 5.2)
activesupport (>= 5.2)
railties (>= 5.2)
rspec-core (~> 3.10)
rspec-expectations (~> 3.10)
rspec-mocks (~> 3.10)
@@ -495,21 +500,21 @@ GEM
rswag-ui (2.4.0)
actionpack (>= 3.1, < 7.0)
railties (>= 3.1, < 7.0)
rubocop (1.13.0)
rubocop (1.15.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.2.0, < 2.0)
rubocop-ast (>= 1.5.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.4.1)
parser (>= 2.7.1.5)
rubocop-rails (2.9.1)
rubocop-ast (1.5.0)
parser (>= 3.0.1.1)
rubocop-rails (2.10.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 0.90.0, < 2.0)
rubocop (>= 1.7.0, < 2.0)
ruby-progressbar (1.11.0)
ruby-rc4 (0.1.5)
ruby2_keywords (0.0.2)
@@ -551,16 +556,16 @@ GEM
activesupport (>= 4.0)
sprockets (>= 3.0.0)
state_machines (0.5.0)
state_machines-activemodel (0.7.1)
activemodel (>= 4.1)
state_machines-activemodel (0.8.0)
activemodel (>= 5.1)
state_machines (>= 0.5.0)
state_machines-activerecord (0.6.0)
activerecord (>= 4.1)
state_machines-activemodel (>= 0.5.0)
state_machines-activerecord (0.8.0)
activerecord (>= 5.1)
state_machines-activemodel (>= 0.8.0)
stringex (2.8.5)
stripe (5.30.0)
temple (0.8.2)
test-prof (1.0.2)
test-prof (1.0.5)
test-unit (3.4.1)
power_assert
thor (0.20.3)
@@ -582,7 +587,7 @@ GEM
get_process_mem (~> 0)
unicorn (>= 4, < 7)
uniform_notifier (1.14.1)
view_component (2.28.0)
view_component (2.31.1)
activesupport (>= 5.0.0, < 7.0)
view_component_storybook (0.8.0)
view_component (>= 2.2)
@@ -592,11 +597,11 @@ GEM
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (>= 3.0, < 4.0)
webmock (3.12.2)
webmock (3.13.0)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
websocket-driver (0.6.5)
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
whenever (1.0.0)
@@ -625,7 +630,6 @@ DEPENDENCIES
angular_rails_csrf
angularjs-file-upload-rails (~> 2.4.1)
angularjs-rails (= 1.5.5)
atomic
awesome_nested_set
awesome_print
aws-sdk (= 1.67.0)
@@ -636,7 +640,7 @@ DEPENDENCIES
capybara
catalog!
codecov
coffee-rails (~> 4.2.2)
coffee-rails (~> 5.0.0)
combine_pdf
compass-rails
custom_error_message!
@@ -653,7 +657,7 @@ DEPENDENCIES
devise-token_authenticatable
dfc_provider!
eventmachine (>= 1.2.3)
factory_bot_rails (= 6.1.0)
factory_bot_rails (= 6.2.0)
ffaker
figaro
flipper
@@ -668,8 +672,9 @@ DEPENDENCIES
good_migrations
haml
highline (= 2.0.3)
hiredis
i18n
i18n-js (~> 3.8.2)
i18n-js (~> 3.8.3)
immigrant
jquery-migrate-rails
jquery-rails (= 4.4.0)
@@ -680,6 +685,7 @@ DEPENDENCIES
kaminari (~> 1.2.1)
knapsack
letter_opener (>= 1.4.1)
mimemagic (> 0.3.5)
mini_racer (= 0.4.0)
monetize (~> 1.11)
oauth2 (~> 1.4.7)
@@ -689,20 +695,21 @@ DEPENDENCIES
paperclip (~> 3.4.1)
paranoia (~> 2.4)
paypal-sdk-merchant (= 1.117.2)
pg (~> 0.21.0)
pg (~> 1.2.3)
pry
pry-byebug
rack-mini-profiler (< 3.0.0)
rack-rewrite
rack-ssl
rails (~> 5.0.0)
rails (~> 5.2)
rails-controller-testing
rails-i18n
rails_safe_tasks (~> 1.0)
ransack (= 2.3.0)
ransack (= 2.4.1)
redcarpet
redis (>= 4.0)
responders
roadie-rails (~> 1.3.0)
roadie-rails (~> 2.2.0)
roo (~> 2.8.3)
rspec-rails (>= 3.5.2)
rspec-retry

View File

@@ -11,8 +11,9 @@
#= require leaflet-1.6.0.js
#= require leaflet-providers.js
#= require lodash.underscore.js
# bluebird.js is a dependency of angular-google-maps.js 2.0.0
# bluebird.js and angular-simple-logger are dependencies of angular-google-maps.js 2.0.0
#= require bluebird.js
#= require angular-simple-logger.min.js
#= require angular-scroll.min.js
#= require angular-google-maps.min.js
#= require ../shared/mm-foundation-tpls-0.9.0-20180826174721.min.js

View File

@@ -3,7 +3,7 @@ Darkswarm.controller "EditBoughtOrderController", ($scope, $resource, $timeout,
$scope.removeEnabled = true
$scope.deleteLineItem = (id) ->
if Cart.has_one_line_item()
if Cart.isOnlyItemInOrder(id)
Messages.error(t 'orders_cannot_remove_the_final_item')
$scope.removeEnabled = false
$timeout (->

View File

@@ -11,6 +11,8 @@ Darkswarm.controller "ProductsCtrl", ($scope, $sce, $filter, $rootScope, Product
$scope.supplied_taxons = null
$scope.supplied_properties = null
$scope.showFilterSidebar = false
$scope.activeTaxons = []
$scope.activeProperties = []
# Update filters after initial load of shop tab
$timeout =>
@@ -20,6 +22,7 @@ Darkswarm.controller "ProductsCtrl", ($scope, $sce, $filter, $rootScope, Product
$rootScope.$on "orderCycleSelected", ->
$scope.update_filters()
$scope.clearAll()
$scope.page = 1
$scope.update_filters = ->
order_cycle_id = OrderCycle.order_cycle.order_cycle_id

View File

@@ -1,8 +1,10 @@
Darkswarm.controller "RegistrationCtrl", ($scope, RegistrationService, EnterpriseRegistrationService, availableCountries) ->
Darkswarm.controller "RegistrationCtrl", ($scope, RegistrationService, EnterpriseRegistrationService, availableCountries, GmapsGeo) ->
$scope.currentStep = RegistrationService.currentStep
$scope.enterprise = EnterpriseRegistrationService.enterprise
$scope.select = RegistrationService.select
$scope.geocodedAddress = ''
$scope.latLong = null
$scope.addressConfirmed = false
$scope.steps = ['details', 'contact', 'type', 'about', 'images', 'social']
# Filter countries without states since the form requires a state to be selected.
@@ -22,3 +24,26 @@ Darkswarm.controller "RegistrationCtrl", ($scope, RegistrationService, Enterpris
$scope.countryHasStates = ->
$scope.enterprise.country.states.length > 0
$scope.map = {center: {latitude: 0.000000, longitude: 0.000000 }, zoom: 1}
$scope.options = {scrollwheel: false}
$scope.locateAddress = () ->
{ address1, address2, city, state_id, zipcode } = $scope.enterprise.address
addressQuery = [address1, address2, city, state_id, zipcode].filter((value) => !!value).join(", ")
GmapsGeo.geocode addressQuery, (results, status) =>
$scope.geocodedAddress = results && results[0]?.formatted_address
location = results[0]?.geometry?.location
if location
$scope.$apply(() =>
$scope.latLong = {latitude: location.lat(), longitude: location.lng()}
$scope.map = {center: {latitude: location.lat(), longitude: location.lng()}, zoom: 16 }
)
$scope.toggleAddressConfirmed = ->
$scope.addressConfirmed = !$scope.addressConfirmed
if $scope.addressConfirmed
$scope.enterprise.address.latitude = $scope.latLong.latitude
$scope.enterprise.address.longitude = $scope.latLong.longitude
else
$scope.enterprise.address.latitude = null
$scope.enterprise.address.longitude = null

View File

@@ -115,8 +115,9 @@ Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http, $modal, $roo
@line_items = []
localStorageService.clearAll() # One day this will have to be moar GRANULAR
has_one_line_item: =>
@line_items_finalised.length == 1
isOnlyItemInOrder: (id) =>
deletedItem = @line_items_finalised.find((item) -> item.id == id)
@line_items_finalised.filter((item) -> item.order_id == deletedItem.order_id).length == 1
removeFinalisedLineItem: (id) =>
@line_items_finalised = @line_items_finalised.filter (item) ->

View File

@@ -21,6 +21,7 @@ Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService,
url: "/api/v0/enterprises"
data:
enterprise: @prepare()
use_geocoder: @useGeocoder()
params:
token: spreeApiKey
).success((data) =>
@@ -45,6 +46,7 @@ Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService,
url: "/api/v0/enterprises/#{@enterprise.id}"
data:
enterprise: @prepare()
use_geocoder: @useGeocoder()
params:
token: spreeApiKey
).success((data) ->
@@ -63,3 +65,7 @@ Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService,
enterprise.address_attributes = @enterprise.address if @enterprise.address?
enterprise.address_attributes.country_id = @enterprise.country.id if @enterprise.country?
enterprise
useGeocoder: =>
if @enterprise.address? && !@enterprise.address.latitude? && !@enterprise.address.longitude?
return "1"

View File

@@ -10,7 +10,7 @@ Darkswarm.service "GmapsGeo", ->
# console.log "Error: #{status}"
geocode: (address, callback) ->
geocoder = new google.maps.Geocoder()
geocoder.geocode {'address': address, 'region': "<%= Spree::Country.find_by(id: Spree::Config[:default_country_id]).iso %>"}, callback
geocoder.geocode {'address': address, 'region': "<%= DefaultCountry.code %>"}, callback
distanceBetween: (src, dst) ->
google.maps.geometry.spherical.computeDistanceBetween @toLatLng(src), @toLatLng(dst)
@@ -20,4 +20,4 @@ Darkswarm.service "GmapsGeo", ->
if locatable.lat?
locatable
else
new google.maps.LatLng locatable.latitude, locatable.longitude
new google.maps.LatLng locatable.latitude, locatable.longitude

View File

@@ -181,11 +181,10 @@ shop ordercycle {
}
}
shop navigation ordercycle {
margin-top: 3.4em;
shop .tab-buttons ordercycle {
padding: 1em;
height: 7.6em;
position: absolute;
bottom: 0;
right: 1em;
}

View File

@@ -1,6 +1,8 @@
@import "mixins";
@import 'typography';
$shop-navigation-zindex: 20;
section {
:not(shop) navigation {
box-shadow: $distributor-header-shadow;
@@ -11,7 +13,7 @@ section {
display: block;
background: $white;
position: relative;
z-index: 20;
z-index: $shop-navigation-zindex;
.details {
box-sizing: border-box;

View File

@@ -167,6 +167,26 @@
height: 166px;
}
}
.map-container--registration {
width: 100%;
height: 244px;
margin-bottom: 1em;
map, .angular-google-map-container, google-map, .angular-google-map {
display: block;
height: 220px;
width: 100%;
}
}
.center {
justify-content: center;
}
.button.primary {
border-radius: 0;
}
}
#registration-type {

View File

@@ -9,7 +9,7 @@
color: $dark-grey;
box-shadow: $distributor-header-shadow;
position: relative;
z-index: 10;
z-index: $shop-navigation-zindex + 1;
.columns {
display: flex;

View File

@@ -35,7 +35,7 @@ module Admin
if @line_item.update(line_item_params)
order.update_line_item_fees! @line_item
order.update_order_fees!
order.update!
order.update_order!
render body: nil, status: :no_content # No Content, does not trigger ng resource auto-update
else
render json: { errors: @line_item.errors }, status: :precondition_failed

View File

@@ -28,9 +28,7 @@ module Admin
def build_resource
enterprise_group = super
enterprise_group.address = Spree::Address.new
enterprise_group.address.country = Spree::Country.find_by(
id: Spree::Config[:default_country_id]
)
enterprise_group.address.country = DefaultCountry.country
enterprise_group
end

View File

@@ -4,6 +4,8 @@ require 'open_food_network/order_cycle_permissions'
module Admin
class EnterprisesController < Admin::ResourceController
include GeocodeEnterpriseAddress
# These need to run before #load_resource so that @object is initialised with sanitised values
prepend_before_action :override_owner, only: :create
prepend_before_action :override_sells, only: :create
@@ -22,6 +24,8 @@ module Admin
before_action :load_properties, only: [:edit, :update]
before_action :setup_property, only: [:edit]
after_action :geocode_address_if_use_geocoder, only: [:create, :update]
helper 'spree/products'
include OrderCyclesHelper
@@ -115,7 +119,7 @@ module Admin
def build_resource
enterprise = super
enterprise.address ||= Spree::Address.new
enterprise.address.country ||= Spree::Country.find_by(id: Spree::Config[:default_country_id])
enterprise.address.country ||= DefaultCountry.country
enterprise
end

View File

@@ -1,7 +1,7 @@
# frozen_string_literal: true
# Base controller for OFN's API
require_dependency 'spree/api/controller_setup'
require "spree/api/controller_setup"
require "spree/core/controller_helpers/ssl"
module Api

View File

@@ -3,6 +3,8 @@
module Api
module V0
class EnterprisesController < Api::V0::BaseController
include GeocodeEnterpriseAddress
before_action :override_owner, only: [:create, :update]
before_action :check_type, only: :update
before_action :override_sells, only: [:create, :update]
@@ -17,6 +19,7 @@ module Api
user_ids = enterprise_params.delete(:user_ids)
@enterprise = Enterprise.new(enterprise_params)
if @enterprise.save
geocode_address_if_use_geocoder
@enterprise.user_ids = user_ids
render json: @enterprise.id, status: :created
else
@@ -29,6 +32,7 @@ module Api
authorize! :update, @enterprise
if @enterprise.update(enterprise_params)
geocode_address_if_use_geocoder
render json: @enterprise.id, status: :ok
else
invalid_resource!(@enterprise)

View File

@@ -16,7 +16,7 @@ module Api
quantity = params[:quantity].to_i
@shipment = get_or_create_shipment(params[:stock_location_id])
@order.contents.add(variant, quantity, nil, @shipment)
@order.contents.add(variant, quantity, @shipment)
@shipment.refresh_rates
@shipment.save!
@@ -31,10 +31,12 @@ module Api
unlock = params[:shipment].delete(:unlock)
if unlock == 'yes'
@shipment.fee_adjustment.open
@shipment.fee_adjustment.fire_events(:open)
end
@shipment.update(shipment_params[:shipment])
if @shipment.update(shipment_params)
@order.updater.update_totals_and_states
end
if unlock == 'yes'
@shipment.fee_adjustment.close
@@ -68,7 +70,7 @@ module Api
variant = scoped_variant(params[:variant_id])
quantity = params[:quantity].to_i
@order.contents.add(variant, quantity, nil, @shipment)
@order.contents.add(variant, quantity, @shipment)
@order.recreate_all_fees!
render json: @shipment, serializer: Api::ShipmentSerializer, status: :ok
@@ -94,7 +96,7 @@ module Api
def find_and_update_shipment
@shipment = @order.shipments.find_by!(number: params[:id])
@shipment.update(shipment_params[:shipment]) if shipment_params[:shipment].present?
@shipment.update(shipment_params)
@shipment.reload
end
@@ -113,10 +115,9 @@ module Api
end
def shipment_params
params.permit(
[:id, :order_id, :variant_id, :quantity,
{ shipment: [:tracking, :selected_shipping_rate_id] }]
)
return {} unless params.has_key? :shipment
params.require(:shipment).permit(:tracking, :selected_shipping_rate_id)
end
end
end

View File

@@ -1,6 +1,6 @@
# frozen_string_literal: true
require_dependency 'spree/authentication_helpers'
require "spree/authentication_helpers"
require "application_responder"
require 'cancan'
require 'spree/core/controller_helpers/auth'
@@ -13,6 +13,20 @@ class ApplicationController < ActionController::Base
self.responder = ApplicationResponder
respond_to :html
helper 'spree/base'
helper 'spree/orders'
helper 'spree/payment_methods'
helper 'shared'
helper 'enterprises'
helper 'order_cycles'
helper 'order'
helper 'shop'
helper 'injection'
helper 'markdown'
helper 'footer_links'
helper 'discourse'
helper 'checkout'
protect_from_forgery
include Spree::Core::ControllerHelpers::Auth

View File

@@ -13,8 +13,6 @@ class BaseController < ApplicationController
include I18nHelper
include OrderCyclesHelper
helper 'spree/base'
before_action :set_locale
before_action :check_order_cycle_expiry

View File

@@ -55,7 +55,7 @@ class CheckoutController < ::BaseController
flash[:error] = I18n.t("checkout.failed")
action_failed(e)
ensure
@order.update!
@order.update_order!
end
# Clears the cached order. Required for #current_order to return a new order

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
module GeocodeEnterpriseAddress
extend ActiveSupport::Concern
def geocode_address_if_use_geocoder
AddressGeocoder.new(@enterprise.address).geocode if params[:use_geocoder] == "1"
end
end

View File

@@ -43,7 +43,7 @@ class LineItemsController < BaseController
order.update_shipping_fees!
order.update_payment_fees!
order.update_order_fees!
order.update!
order.update_order!
order.create_tax_charge!
end
end

View File

@@ -2,9 +2,12 @@ require 'open_food_network/spree_api_key_loader'
class RegistrationController < BaseController
include OpenFoodNetwork::SpreeApiKeyLoader
layout 'registration'
helper 'map'
before_action :load_spree_api_key, only: [:index]
before_action :check_user, except: :authenticate
layout 'registration'
def index
@enterprise_attributes = { sells: 'none' }

View File

@@ -14,7 +14,7 @@ module Spree
def update_order
@order.reload
@order.update!
@order.update_order!
end
def collection

View File

@@ -3,7 +3,15 @@ module Spree
class BaseController < ApplicationController
ssl_required
helper 'shared'
helper 'spree/admin/navigation'
helper 'spree/admin/orders'
helper 'admin/injection'
helper 'admin/orders'
helper 'admin/enterprises'
helper 'enterprise_fees'
helper 'angular_form'
layout '/spree/layouts/admin'
include I18nHelper
@@ -21,18 +29,6 @@ module Spree
flash[:notice] = warning if warning.present?
end
# This is in Spree::Core::ControllerHelpers::Auth
# But you can't easily reopen modules in Ruby
def unauthorized
if spree_current_user
flash[:error] = t(:authorization_failure)
redirect_to '/unauthorized'
else
store_location
redirect_to main_app.root_path(anchor: "login?after_login=#{request.env['PATH_INFO']}")
end
end
protected
def model_class

View File

@@ -68,14 +68,16 @@ module Spree
rescue Spree::Core::GatewayError => e
flash[:error] = e.message.to_s
ensure
redirect_to :back
redirect_back fallback_location: spree.admin_dashboard_path
end
def resend
Spree::OrderMailer.confirm_email_for_customer(@order.id, true).deliver_later
flash[:success] = t('admin.orders.order_email_resent')
respond_with(@order) { |format| format.html { redirect_to :back } }
respond_with(@order) do |format|
format.html { redirect_back(fallback_location: spree.admin_dashboard_path) }
end
end
def invoice

View File

@@ -9,6 +9,10 @@ module Spree
before_action :load_payment, only: [:fire, :show]
before_action :load_data
before_action :can_transition_to_payment
# We ensure that items are in stock before all screens if the order is in the Payment state.
# This way, we don't allow someone to enter credit card details for an order only to be told
# that it can't be processed.
before_action :ensure_sufficient_stock_lines
respond_to :html
@@ -142,6 +146,20 @@ module Spree
redirect_to spree.edit_admin_order_customer_url(@order)
end
def ensure_sufficient_stock_lines
return if !@order.payment? || @order.insufficient_stock_lines.blank?
flash[:error] = I18n.t("spree.orders.line_item.insufficient_stock",
on_hand: "0 #{out_of_stock_item_names}")
redirect_to spree.edit_admin_order_url(@order)
end
def out_of_stock_item_names
@order.insufficient_stock_lines.map do |line_item|
line_item.variant.name
end.join(", ")
end
def load_order
@order = Order.find_by!(number: params[:order_id])
authorize! action, @order

View File

@@ -8,7 +8,7 @@ module Spree
def fire
@return_authorization.public_send("#{params[:e]}!")
flash[:success] = Spree.t(:return_authorization_updated)
redirect_to :back
redirect_back fallback_location: spree.admin_dashboard_path
end
protected

View File

@@ -14,7 +14,7 @@ module Spree
respond_to :html
respond_to :json
before_action :update_distribution, only: :update
before_action :set_current_order, only: :update
before_action :filter_order_params, only: :update
before_action :enable_embedded_shopfront
@@ -26,8 +26,8 @@ module Spree
def show
@order = Spree::Order.find_by!(number: params[:id])
ProcessPaymentIntent.new(params["payment_intent"], @order).call!
@order.reload
handle_stripe_response
end
def empty
@@ -62,7 +62,7 @@ module Spree
associate_user
if @order.insufficient_stock_lines.present? || @unavailable_order_variants.present?
flash[:error] = t("spree.orders.error_flash_for_unavailable_items")
flash.now[:error] = t("spree.orders.error_flash_for_unavailable_items")
end
end
end
@@ -95,7 +95,7 @@ module Spree
@order.next_transition.run_callbacks if @order.cart?
redirect_to main_app.checkout_state_path(@order.checkout_steps.first)
elsif @order.complete?
redirect_to order_path(@order)
redirect_to main_app.order_path(@order)
else
redirect_to main_app.cart_path
end
@@ -109,24 +109,8 @@ module Spree
end
end
def update_distribution
def set_current_order
@order = current_order(true)
if params[:commit] == 'Choose Hub'
distributor = Enterprise.is_distributor.find params[:order][:distributor_id]
@order.set_distributor! distributor
flash[:notice] = I18n.t(:order_choosing_hub_notice)
redirect_to request.referer
elsif params[:commit] == 'Choose Order Cycle'
@order.empty! # empty cart
order_cycle = OrderCycle.active.find params[:order][:order_cycle_id]
@order.set_order_cycle! order_cycle
flash[:notice] = I18n.t(:order_choosing_hub_notice)
redirect_to request.referer
end
end
def filter_order_params
@@ -151,11 +135,24 @@ module Spree
else
flash[:error] = I18n.t(:orders_could_not_cancel)
end
redirect_to request.referer || order_path(@order)
redirect_to request.referer || main_app.order_path(@order)
end
private
# Stripe can redirect here after a payment is processed in the backoffice.
# We verify if it was successful here and persist the changes.
def handle_stripe_response
return unless params.key?("payment_intent")
result = ProcessPaymentIntent.new(params["payment_intent"], @order).call!
unless result.ok?
flash.now[:error] = "#{I18n.t("payment_could_not_process")}. #{result.error}"
end
@order.reload
end
def discard_empty_line_items
@order.line_items = @order.line_items.select { |li| li.quantity > 0 }
end
@@ -191,7 +188,7 @@ module Spree
if items.empty?
flash[:error] = I18n.t(:orders_cannot_remove_the_final_item)
redirect_to order_path(order_to_update)
redirect_to main_app.order_path(order_to_update)
end
end

View File

@@ -14,7 +14,7 @@ module Spree
def show
@payments_requiring_action = PaymentsRequiringAction.new(spree_current_user).query
@orders = orders_collection
@orders = orders_collection.includes(:line_items)
customers = spree_current_user.customers
@shops = Enterprise

View File

@@ -1,2 +1,13 @@
module MapHelper
def using_google_maps?
ENV["GOOGLE_MAPS_API_KEY"].present? || google_maps_configured_with_geocoder_api_key?
end
private
def google_maps_configured_with_geocoder_api_key?
ENV["GEOCODER_API_KEY"].present? && (
ENV["GEOCODER_SERVICE"].to_s == "google" || ENV["GEOCODER_SERVICE"].blank?
)
end
end

View File

@@ -1,11 +0,0 @@
module Spree
module Admin
module PaymentsHelper
def payment_method_name(payment)
# hack to allow us to retrieve the name of a "deleted" payment method
id = payment.payment_method_id
Spree::PaymentMethod.find_with_destroyed(id).name
end
end
end
end

View File

@@ -0,0 +1,9 @@
module Spree
module PaymentMethodsHelper
def payment_method_name(payment)
# hack to allow us to retrieve the name of a "deleted" payment method
id = payment.payment_method_id
Spree::PaymentMethod.find_with_destroyed(id).name
end
end
end

View File

@@ -90,13 +90,13 @@ class SubscriptionConfirmJob < ActiveJob::Base
end
def send_confirmation_email(order)
order.update!
order.update_order!
record_success(order)
SubscriptionMailer.confirmation_email(order).deliver_now
end
def send_failed_payment_email(order, error_message = nil)
order.update!
order.update_order!
record_and_log_error(:failed_payment, order, error_message)
SubscriptionMailer.failed_payment_email(order).deliver_now
rescue StandardError => e

View File

@@ -77,7 +77,7 @@ class SubscriptionPlacementJob < ActiveJob::Base
def handle_empty_order(order, changes)
order.reload.all_adjustments.destroy_all
order.update!
order.update_order!
send_empty_email(order, changes)
end

View File

@@ -4,7 +4,7 @@ module Spree
class OrderMailer < BaseMailer
helper 'checkout'
helper SpreeCurrencyHelper
helper Spree::Admin::PaymentsHelper
helper Spree::PaymentMethodsHelper
helper OrderHelper
helper MailerHelper
include I18nHelper

View File

@@ -3,7 +3,7 @@ class SubscriptionMailer < Spree::BaseMailer
helper MailerHelper
helper ShopMailHelper
helper OrderHelper
helper Spree::Admin::PaymentsHelper
helper Spree::PaymentMethodsHelper
include I18nHelper
def confirmation_email(order)

View File

@@ -1,6 +1,5 @@
# frozen_string_literal: false
require_dependency 'spree/calculator'
require 'open_food_network/enterprise_fee_calculator'
module Calculator

View File

@@ -1,6 +1,5 @@
# frozen_string_literal: false
require_dependency 'spree/calculator'
require 'spree/localized_number'
module Calculator

View File

@@ -1,4 +1,3 @@
require_dependency 'spree/calculator'
require 'spree/localized_number'
class Calculator::FlatPercentPerItem < Spree::Calculator

View File

@@ -1,6 +1,5 @@
# frozen_string_literal: false
require_dependency 'spree/calculator'
require 'spree/localized_number'
module Calculator

View File

@@ -1,6 +1,5 @@
# frozen_string_literal: false
require_dependency 'spree/calculator'
require 'spree/localized_number'
module Calculator

View File

@@ -1,6 +1,5 @@
# frozen_string_literal: false
require_dependency 'spree/calculator'
require 'spree/localized_number'
module Calculator

View File

@@ -1,6 +1,5 @@
# frozen_string_literal: false
require_dependency 'spree/calculator'
# For #to_d method on Ruby 1.8
require 'bigdecimal/util'
require 'spree/localized_number'

View File

@@ -100,13 +100,12 @@ class Enterprise < ApplicationRecord
before_validation :initialize_permalink, if: lambda { permalink.nil? }
before_validation :set_unused_address_fields
after_validation :geocode_address
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 :send_welcome_email
after_create_commit :send_welcome_email
after_rollback :restore_permalink
@@ -411,10 +410,6 @@ class Enterprise < ApplicationRecord
address.firstname = address.lastname = address.phone = 'unused' if address.present?
end
def geocode_address
address.geocode if address.andand.changed?
end
def ensure_owner_is_manager
users << owner unless users.include?(owner)
end

View File

@@ -22,11 +22,9 @@ module Spree
alias_attribute :last_name, :lastname
delegate :name, to: :state, prefix: true, allow_nil: true
geocoded_by :geocode_address
def self.default
country = begin
Spree::Country.find(Spree::Config[:default_country_id])
DefaultCountry.country
rescue StandardError
Spree::Country.first
end
@@ -89,10 +87,6 @@ module Spree
}
end
def geocode_address
render_address([address1, address2, zipcode, city, country.andand.name, state.andand.name])
end
def full_address
render_address([address1, address2, city, zipcode, state.andand.name])
end

View File

@@ -96,7 +96,7 @@ module Spree
# more than on line items at once via accepted_nested_attributes the order
# object on the association would be in a old state and therefore the
# adjustment calculations would not performed on proper values
def update!(calculable = nil, force: false)
def update_adjustment!(calculable = nil, force: false)
return amount if immutable? && !force
if originator.present?
@@ -127,11 +127,7 @@ module Spree
end
def set_absolute_included_tax!(tax)
# This rubocop issue can now fixed by renaming Adjustment#update! to something else,
# then AR's update! can be used instead of update_attributes!
# rubocop:disable Rails/ActiveRecordAliases
update_attributes! included_tax: tax.round(2)
# rubocop:enable Rails/ActiveRecordAliases
update! included_tax: tax.round(2)
end
def display_included_tax

View File

@@ -147,7 +147,7 @@ module Spree
end
def default_card_needs_updating?
is_default_changed? || gateway_customer_profile_id_changed?
saved_change_to_is_default? || saved_change_to_gateway_customer_profile_id?
end
def ensure_single_default_card

View File

@@ -87,7 +87,7 @@ module Spree
)
refund_transaction_response = provider.refund_transaction(refund_transaction)
if refund_transaction_response.success?
payment.source.update_attributes(
payment.source.update(
refunded_at: Time.now,
refund_transaction_id: refund_transaction_response.RefundTransactionID,
state: "refunded",

View File

@@ -129,7 +129,19 @@ module Spree
payment = fetch_payment(creditcard, gateway_options)
raise Stripe::StripeError, I18n.t(:no_pending_payments) unless payment&.response_code
Stripe::PaymentIntentValidator.new.call(payment.response_code, stripe_account_id)
payment_intent_response = Stripe::PaymentIntentValidator.new.
call(payment.response_code, stripe_account_id)
raise_if_not_in_capture_state(payment_intent_response)
payment.response_code
end
def raise_if_not_in_capture_state(payment_intent_response)
state = payment_intent_response.status
return if state == 'requires_capture'
raise Stripe::StripeError, I18n.t(:invalid_payment_state, state: state)
end
def fetch_payment(creditcard, gateway_options)

View File

@@ -66,7 +66,7 @@ module Spree
end
def update_order
order.update!
order.update_order!
end
end
end

View File

@@ -17,9 +17,9 @@ module Spree
end
def update_adjustments
adjustment_total = adjustments.additional.map(&:update!).compact.sum
included_tax_total = tax_adjustments.inclusive.reload.map(&:update!).compact.sum
additional_tax_total = tax_adjustments.additional.reload.map(&:update!).compact.sum
adjustment_total = adjustments.additional.map(&:update_adjustment!).compact.sum
included_tax_total = tax_adjustments.inclusive.reload.map(&:update_adjustment!).compact.sum
additional_tax_total = tax_adjustments.additional.reload.map(&:update_adjustment!).compact.sum
item.update_columns(
included_tax_total: included_tax_total,

View File

@@ -226,11 +226,11 @@ module Spree
end
def update_order
return unless changed? || destroyed?
return unless saved_changes.present? || destroyed?
# update the order totals, etc.
order.create_tax_charge!
order.update!
order.update_order!
end
def update_inventory_before_destroy

View File

@@ -2,9 +2,9 @@
module Spree
class OptionType < ApplicationRecord
has_many :products, through: :product_option_types
has_many :option_values, -> { order(:position) }, dependent: :destroy
has_many :product_option_types, dependent: :destroy
has_many :products, through: :product_option_types
validates :name, :presentation, presence: true
default_scope -> { order("#{table_name}.position") }

View File

@@ -126,38 +126,14 @@ module Spree
joins('LEFT OUTER JOIN spree_products ON (spree_products.id = spree_variants.product_id)')
}
scope :not_state, lambda { |state|
where.not(state: state)
}
# All the states an order can be in after completing the checkout
FINALIZED_STATES = %w(complete canceled resumed awaiting_return returned).freeze
scope :finalized, -> { where(state: FINALIZED_STATES) }
def self.by_number(number)
where(number: number)
end
def self.between(start_date, end_date)
where(created_at: start_date..end_date)
end
def self.by_customer(customer)
joins(:user).where("#{Spree.user_class.table_name}.email" => customer)
end
def self.by_state(state)
where(state: state)
end
def self.complete
where('completed_at IS NOT NULL')
end
def self.incomplete
where(completed_at: nil)
end
scope :complete, -> { where.not(completed_at: nil) }
scope :incomplete, -> { where(completed_at: nil) }
scope :by_state, lambda { |state| where(state: state) }
scope :not_state, lambda { |state| where.not(state: state) }
# For compatiblity with Calculator::PriceSack
def amount
@@ -236,7 +212,7 @@ module Spree
@updater ||= OrderManagement::Order::Updater.new(self)
end
def update!
def update_order!
updater.update
end
@@ -756,18 +732,24 @@ module Spree
def ensure_customer
return if associate_customer
customer_name = bill_address.andand.full_name
self.customer = Customer.create(enterprise: distributor, email: email_for_customer,
user: user, name: customer_name,
bill_address: bill_address.andand.clone,
ship_address: ship_address.andand.clone)
self.customer = Customer.new(
enterprise: distributor,
email: email_for_customer,
user: user,
name: bill_address.andand.full_name,
bill_address: bill_address.andand.clone,
ship_address: ship_address.andand.clone
)
customer.save
Bugsnag.notify(customer.errors.full_messages.join(", ")) unless customer.persisted?
end
def update_adjustment!(adjustment)
return if adjustment.finalized?
adjustment.update!(force: true)
update!
adjustment.update_adjustment!(force: true)
update_order!
end
# object_params sets the payment amount to the order total, but it does this

View File

@@ -2,7 +2,7 @@
module Spree
class OrderContents
attr_accessor :order, :currency
attr_accessor :order
def initialize(order)
@order = order
@@ -10,9 +10,9 @@ module Spree
# Get current line item for variant if exists
# Add variant qty to line_item
def add(variant, quantity = 1, currency = nil, shipment = nil)
def add(variant, quantity = 1, shipment = nil)
line_item = order.find_line_item_by_variant(variant)
add_to_line_item(line_item, variant, quantity, currency, shipment)
add_to_line_item(line_item, variant, quantity, shipment)
end
# Get current line item for variant
@@ -29,20 +29,14 @@ module Spree
private
def add_to_line_item(line_item, variant, quantity, currency = nil, shipment = nil)
def add_to_line_item(line_item, variant, quantity, shipment = nil)
if line_item
line_item.target_shipment = shipment
line_item.quantity += quantity.to_i
line_item.currency = currency unless currency.nil?
else
line_item = order.line_items.new(quantity: quantity, variant: variant)
line_item.target_shipment = shipment
if currency
line_item.currency = currency unless currency.nil?
line_item.price = variant.price_in(currency).amount
else
line_item.price = variant.price
end
line_item.price = variant.price
end
line_item.save

View File

@@ -50,6 +50,7 @@ module Spree
scope :failed, -> { with_state('failed') }
scope :valid, -> { where('state NOT IN (?)', %w(failed invalid)) }
scope :authorization_action_required, -> { where.not(cvv_response_message: nil) }
scope :with_payment_intent, ->(code) { where(response_code: code) }
# order state machine (see http://github.com/pluginaweek/state_machine/tree/master for details)
state_machine initial: :checkout do
@@ -144,6 +145,10 @@ module Spree
I18n.t('payment_method_fee')
end
def mark_as_processed
update_attribute(:cvv_response_message, nil)
end
private
# Don't charge fees for invalid or failed payments.
@@ -201,7 +206,7 @@ module Spree
end
def update_order
order.update!
OrderManagement::Order::Updater.new(order).after_payment_update(self)
end
# Necessary because some payment gateways will refuse payments with

View File

@@ -13,7 +13,11 @@ module Spree
return unless validate!
return if authorization_action_required?
charge_offline!
if preauthorized?
capture!
else
charge_offline!
end
end
def authorize!(return_url = nil)
@@ -184,6 +188,10 @@ module Spree
private
def preauthorized?
response_code.presence&.match("pi_")
end
def validate!
return false unless payment_method&.source_required?

View File

@@ -266,13 +266,6 @@ module Spree
duplicator.duplicate
end
# use deleted? rather than checking the attribute directly. this
# allows extensions to override deleted? if they want to provide
# their own definition.
def deleted?
!!deleted_at
end
# split variants list into hash which shows mapping of opt value onto matching variants
# eg categorise_variants_from_option(color) => {"red" -> [...], "blue" -> [...]}
def categorise_variants_from_option(opt_type)
@@ -433,7 +426,7 @@ module Spree
end
def update_units
return unless variant_unit_changed?
return unless saved_change_to_variant_unit?
option_types.delete self.class.all_variant_unit_option_types
option_types << variant_unit_option_type if variant_unit.present?
@@ -449,9 +442,9 @@ module Spree
end
def remove_previous_primary_taxon_from_taxons
return unless primary_taxon_id_changed? && primary_taxon_id_was
return unless saved_change_to_primary_taxon_id? && primary_taxon_id_before_last_save
taxons.destroy(primary_taxon_id_was)
taxons.destroy(primary_taxon_id_before_last_save)
end
def ensure_standard_variant
@@ -465,7 +458,7 @@ module Spree
# Spree creates a permalink already but our implementation fixes an edge case.
def sanitize_permalink
return unless permalink.blank? || permalink_changed?
return unless permalink.blank? || saved_change_to_permalink? || permalink_changed?
requested = permalink.presence || permalink_was.presence || name.presence || 'product'
self.permalink = create_unique_permalink(requested.parameterize)

View File

@@ -66,7 +66,7 @@ module Spree
order.shipped_shipments.collect{ |s| s.inventory_units.to_a }.flatten
end
# Used when Adjustment#update! wants to update the related adjustment
# Used when Adjustment#update_adjustment! wants to update the related adjustment
def compute_amount(*_args)
-amount.abs
end
@@ -105,7 +105,7 @@ module Spree
)
order.return if inventory_units.all?(&:returned?)
order.update!
order.update_order!
end
def allow_receive?

View File

@@ -331,6 +331,15 @@ module Spree
fee_adjustment.finalize!
send_shipped_email
touch :shipped_at
update_order_shipment_state
end
def update_order_shipment_state
new_state = order.updater.update_shipment_state
order.update_columns(
shipment_state: new_state,
updated_at: Time.zone.now,
)
end
def send_shipped_email

View File

@@ -50,7 +50,7 @@ module Spree
category = TaxCategory.includes(:tax_rates).find_by(is_default: true)
return 0 unless category
address ||= Address.new(country_id: Spree::Config[:default_country_id])
address ||= Address.new(country_id: DefaultCountry.id)
rate = category.tax_rates.detect { |tax_rate| tax_rate.zone.include? address }.try(:amount)
rate || 0

View File

@@ -166,13 +166,6 @@ module Spree
OpenFoodNetwork::EnterpriseFeeCalculator.new(distributor, order_cycle).fees_by_type_for self
end
# use deleted? rather than checking the attribute directly. this
# allows extensions to override deleted? if they want to provide
# their own definition.
def deleted?
deleted_at
end
def option_value(opt_name)
option_values.detect { |o| o.option_type.name == opt_name }.try(:presentation)
end

View File

@@ -1,5 +1,5 @@
class Api::LineItemSerializer < ActiveModel::Serializer
attributes :id, :quantity, :max_quantity, :price
attributes :id, :quantity, :max_quantity, :price, :order_id
has_one :variant, serializer: Api::VariantSerializer
end

View File

@@ -22,7 +22,7 @@ module Api
end
def item_count
object.line_items.sum(:quantity)
object.line_items.sum(&:quantity)
end
def completed_at

View File

@@ -0,0 +1,34 @@
# frozen_string_literal: true
class AddressGeocoder
def initialize(address)
@address = address
end
def geocode
latitude, longitude = Geocoder.coordinates(geocode_address)
return unless latitude.present? && longitude.present?
address.update(latitude: latitude, longitude: longitude)
end
private
attr_reader :address
def geocode_address
address_parts.select(&:present?).join(', ')
end
def address_parts
[
address.address1,
address.address2,
address.zipcode,
address.city,
address.country&.name,
address.state&.name
]
end
end

View File

@@ -0,0 +1,13 @@
class DefaultCountry
def self.id
country.id
end
def self.code
country.iso
end
def self.country
Spree::Country.find_by(iso: ENV["DEFAULT_COUNTRY_CODE"]) || Spree::Country.first
end
end

View File

@@ -2,9 +2,8 @@
# by setting entries on the Spree Config
# and initializing Spree:MailSettings that uses the Spree::Config.
class MailConfiguration
# @param entries [Hash] Spree Config entries
def self.entries=(entries)
entries.each do |name, value|
def self.apply!
configuration.each do |name, value|
Spree::Config[name] = value
end
apply_mail_settings
@@ -12,6 +11,21 @@ class MailConfiguration
private
def self.configuration
{
mail_host: ENV.fetch('MAIL_HOST'),
mail_domain: ENV.fetch('MAIL_DOMAIN'),
mail_port: ENV.fetch('MAIL_PORT'),
mail_auth_type: ENV.fetch('MAIL_AUTH_TYPE', 'login'),
smtp_username: ENV.fetch('SMTP_USERNAME'),
smtp_password: ENV.fetch('SMTP_PASSWORD'),
secure_connection_type: ENV.fetch('MAIL_SECURE_CONNECTION', 'None'),
mails_from: ENV.fetch('MAILS_FROM', "no-reply@#{ENV.fetch('MAIL_DOMAIN')}"),
mail_bcc: ENV.fetch('MAIL_BCC', ''),
intercept_email: ''
}
end
def self.apply_mail_settings
Spree::Core::MailSettings.init
end

View File

@@ -13,7 +13,7 @@ class OrderCheckoutRestart
clear_shipments
clear_payments
order.reload.update!
order.reload.update_order!
end
private

View File

@@ -24,7 +24,7 @@ class OrderFeesHandler
order.updater.persist_totals
end
order.update!
order.update_order!
end
def create_line_item_fees!
@@ -43,13 +43,13 @@ class OrderFeesHandler
def update_line_item_fees!(line_item)
line_item.adjustments.enterprise_fee.each do |fee|
fee.update!(line_item, force: true)
fee.update_adjustment!(line_item, force: true)
end
end
def update_order_fees!
order.adjustments.enterprise_fee.where(adjustable_type: 'Spree::Order').each do |fee|
fee.update!(order, force: true)
fee.update_adjustment!(order, force: true)
end
end

View File

@@ -44,7 +44,7 @@ module Permissions
def filtered_orders(orders)
return orders unless filter_orders?
orders.complete.not_state(:canceled).search(search_params).result
orders.complete.not_state(:canceled).ransack(search_params).result
end
def filter_orders?

View File

@@ -6,7 +6,8 @@ module PermittedAttributes
[
:firstname, :lastname, :address1, :address2,
:city, :country_id, :state_id, :zipcode,
:phone, :state_name, :alternative_phone, :company
:phone, :state_name, :alternative_phone, :company,
:latitude, :longitude
]
end
end

View File

@@ -35,23 +35,8 @@ module PermittedAttributes
:tag_list,
tags: [:text],
enterprise_fee_ids: [],
variants: permitted_variant_ids
variants: {}
]
end
# In rails 5 we will be able to permit random hash keys simply with :variants => {}
# See https://github.com/rails/rails/commit/e86524c0c5a26ceec92895c830d1355ae47a7034
#
# Until then, we need to create an array of variant IDs in order to permit them
def permitted_variant_ids
variant_ids(@params[:order_cycle][:incoming_exchanges]) +
variant_ids(@params[:order_cycle][:outgoing_exchanges])
end
def variant_ids(exchange_params)
return [] unless exchange_params
exchange_params.map { |exchange| exchange[:variants].map { |key, _value| key } }.flatten
end
end
end

View File

@@ -3,39 +3,82 @@
# When directing a customer to Stripe to authorize the payment, we specify a
# redirect_url that Stripe should return them to. When checking out, it's
# /checkout; for admin payments and subscription payemnts it's the order url.
#
# This class confirms that the payment intent matches what's in our database,
# marks the payment as complete, and removes the cvv_response_message field,
# which we use to indicate that authorization is required. It also completes the
# Order, if appropriate.
class ProcessPaymentIntent
class Result
attr_reader :error
def initialize(ok:, error: "")
@ok = ok
@error = error
end
def ok?
@ok
end
end
def initialize(payment_intent, order)
@payment_intent = payment_intent
@order = order
@last_payment = OrderPaymentFinder.new(order).last_payment
@payment = order.payments.pending.with_payment_intent(payment_intent).first
end
def call!
return unless valid?
return Result.new(ok: false) unless payment.present? && ready_for_capture?
return Result.new(ok: true) if already_processed?
last_payment.update_attribute(:cvv_response_message, nil)
OrderWorkflow.new(@order).next
last_payment.complete! if last_payment.can_complete?
process_payment
if payment.reload.completed?
payment.mark_as_processed
Result.new(ok: true)
else
Result.new(ok: false, error: I18n.t("payment_could_not_complete"))
end
rescue Stripe::StripeError => e
Result.new(ok: false, error: e.message)
end
private
attr_reader :order, :payment_intent, :last_payment
attr_reader :order, :payment_intent, :payment
def valid?
order.present? && valid_intent_string? && matches_last_payment?
def process_payment
if order.state == "payment"
# Moves the order to completed, which calls #process_payments!
OrderWorkflow.new(order).next
else
order.process_payments!
end
end
def valid_intent_string?
payment_intent&.starts_with?("pi_")
def ready_for_capture?
payment_intent_status == 'requires_capture'
end
def matches_last_payment?
last_payment&.state == "pending" && last_payment&.response_code == payment_intent
def already_processed?
payment_intent_status == 'succeeded'
end
def payment_intent_status
@payment_intent_status ||= Stripe::PaymentIntentValidator.new.
call(payment_intent, stripe_account_id).
status
end
def stripe_account_id
StripeAccount.find_by(enterprise_id: preferred_enterprise_id).stripe_user_id
end
def preferred_enterprise_id
payment.payment_method.preferred_enterprise_id
end
end

View File

@@ -97,7 +97,24 @@
%input.ofn-select2.fullwidth#enterprise_address_attributes_state_id{ name: 'enterprise[address_attributes][state_id]', type: 'number', data: 'countriesById[Enterprise.address.country_id].states', placeholder: t('admin.choose'), ng: { model: 'Enterprise.address.state_id' } }
.five.columns.omega
%input.ofn-select2.fullwidth#enterprise_address_attributes_country_id{ name: 'enterprise[address_attributes][country_id]', type: 'number', data: 'countries', placeholder: t('admin.choose'), ng: { model: 'Enterprise.address.country_id' } }
.row
.three.columns.alpha
= af.label :latitude, t(:latitude)
\/
= af.label :longitude, t(:longitude)
%span.required *
%div{'ofn-with-tip' => t('latitude_longitude_tip')}
%a= t('admin.whats_this')
.four.columns
= af.text_field :latitude, { placeholder: t(:latitude_placeholder) }
.four.columns.omega
= af.text_field :longitude, { placeholder: t(:longitude_placeholder) }
.row
.three.columns.alpha
= "&nbsp;".html_safe
.five.columns.omega
= check_box_tag "use_geocoder"
= label_tag "use_geocoder", t('use_geocoder')
.row
.twelve.columns.alpha
&nbsp;

View File

@@ -35,3 +35,21 @@
%input.ofn-select2.fullwidth#enterprise_address_attributes_state_id{ name: 'enterprise[address_attributes][state_id]', type: 'number', data: 'countriesById[Enterprise.address.country_id].states', placeholder: t('admin.choose'), ng: { model: 'Enterprise.address.state_id' } }
.four.columns.omega{ "ng-controller" => "countryCtrl" }
%input.ofn-select2.fullwidth#enterprise_address_attributes_country_id{ name: 'enterprise[address_attributes][country_id]', type: 'number', data: 'countries', placeholder: t('admin.choose'), ng: { model: 'Enterprise.address.country_id' } }
.row
.three.columns.alpha
= af.label :latitude, t(:latitude)
\/
= af.label :longitude, t(:longitude)
%span.required *
%div{'ofn-with-tip' => t('latitude_longitude_tip')}
%a= t('admin.whats_this')
.four.columns
= af.text_field :latitude, { placeholder: t(:latitude_placeholder) }
.four.columns.omega
= af.text_field :longitude, { placeholder: t(:longitude_placeholder) }
.row
.three.columns.alpha
= "&nbsp;".html_safe
.five.columns.omega
= check_box_tag "use_geocoder"
= label_tag "use_geocoder", t('use_geocoder')

View File

@@ -10,7 +10,7 @@
= "admin.enterprises"
= admin_inject_available_countries(module: 'admin.enterprises')
= admin_inject_json "admin.enterprises", "defaultCountryID", Spree::Config[:default_country_id]
= admin_inject_json "admin.enterprises", "defaultCountryID", DefaultCountry.id
-# Form

View File

@@ -38,7 +38,7 @@
= validated_input t(:postcode), "order.bill_address.zipcode"
.small-6.columns.right
= validated_select t(:country), "order.bill_address.country_id", {}, {"ng-init" => "order.bill_address.country_id = order.bill_address.country_id || #{Spree::Config[:default_country_id]}", "ng-options" => "c.id as c.name for c in countries"}
= validated_select t(:country), "order.bill_address.country_id", {}, {"ng-init" => "order.bill_address.country_id = order.bill_address.country_id || #{DefaultCountry.id}", "ng-options" => "c.id as c.name for c in countries"}
.row
.small-12.columns.text-right

View File

@@ -22,7 +22,7 @@
.small-6.columns
= validated_input t(:postcode), "order.ship_address.zipcode"
.small-6.columns.right
= validated_select t(:country), "order.ship_address.country_id", {}, {"ng-init" => "order.ship_address.country_id = order.ship_address.country_id || #{Spree::Config[:default_country_id]}", "ng-options" => "c.id as c.name for c in countries"}
= validated_select t(:country), "order.ship_address.country_id", {}, {"ng-init" => "order.ship_address.country_id = order.ship_address.country_id || #{DefaultCountry.id}", "ng-options" => "c.id as c.name for c in countries"}
.row
.small-6.columns
= validated_input t(:phone), "order.ship_address.phone"

View File

@@ -20,10 +20,6 @@
- content_for :order_cycle_form do
= render partial: "change_order_cycle"
- content_for :ordercycle_sidebar do
.show-for-large-up.large-4.columns
= render partial: "shopping_shared/order_cycles"
= render partial: "shopping_shared/header"
= render partial: "shopping_shared/tabs"

View File

@@ -27,7 +27,7 @@
#footer
%loading
%script{src: "//maps.googleapis.com/maps/api/js?libraries=places"}
%script{src: "//maps.googleapis.com/maps/api/js?libraries=places#{ ENV['GOOGLE_MAPS_API_KEY'] ? '&key=' + ENV['GOOGLE_MAPS_API_KEY'] : ''}"}
= javascript_include_tag "darkswarm/all"
= yield :scripts

View File

@@ -7,7 +7,6 @@
%h2= t('.headline')
%h5{ ng: { if: "::enterprise.type != 'own'" } }= t(".enterprise")
%h5{ ng: { if: "::enterprise.type == 'own'" } }= t(".producer")
%form{ name: 'details', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "selectIfValid('contact',details)" } }
.row
@@ -54,10 +53,12 @@
.small-12.medium-8.large-8.columns
.field
%label{ for: 'enterprise_country' }= t(".country_field")
%select.chunky{ id: 'enterprise_country', name: 'country', required: true, ng: { init: "setDefaultCountry(#{Spree::Config[:default_country_id]})", model: 'enterprise.country', options: 'c as c.name for c in countries' } }
%select.chunky{ id: 'enterprise_country', name: 'country', required: true, ng: { init: "setDefaultCountry(#{DefaultCountry.id})", model: 'enterprise.country', options: 'c as c.name for c in countries' } }
%span.error{ ng: { show: "details.country.$error.required && submitted" } }
= t(".country_field_error")
= render 'registration/steps/location_map' if using_google_maps?
.row.buttons
.small-12.columns
%hr

View File

@@ -0,0 +1,18 @@
%div
.center{ ng: {if: "latLong"}}
%strong {{'registration.steps.details.drag_pin' | t}}
.small-12.medium-9.large-12.columns.end
.map-container--registration{id: "registration-map", ng: {if: "!!map"}}
%ui-gmap-google-map{ center: "map.center", zoom: "map.zoom"}
%ui-gmap-marker{idKey: 1, coords: "latLong", options: '{ draggable: true}'}
.center
%input.button.primary{ type: "button", value: "{{'registration.steps.details.locate_address' | t}}", ng: { click: "locateAddress()" } }
.center{ ng: {if: "latLong"}}
.field
%input{ type: 'checkbox', id: 'confirm_address', name: 'confirm_address', ng: { click: 'toggleAddressConfirmed()' } }
%label{ for: 'confirm_address' } {{'registration.steps.details.confirm_address' | t}}
.small-12.medium-9.large-12.columns.end{ ng: {if: "latLong"}}
.field
%strong {{'registration.steps.details.drag_map_marker' | t}}

View File

@@ -1,5 +1,5 @@
- if Rails.env.test?
%script{type: "text/javascript"}
= render file: "spec/support/fixtures/stripejs-mock.js"
= raw render file: "spec/support/fixtures/stripejs-mock.js"
- else
%script{src: "https://js.stripe.com/v3/", type: "text/javascript"}

View File

@@ -1,4 +1,4 @@
.content.footer-pad{ "darker-background" => true, "ng-controller" => "ProductsCtrl", "ng-show" => "order_cycle.order_cycle_id == null" }
.content.footer-pad{ "darker-background" => true, "ng-show" => "order_cycle.order_cycle_id == null" }
.row
.small-12.columns
.select-oc-message

View File

@@ -1,5 +1,5 @@
%form{action: main_app.cart_path}
%products{"ng-controller" => "ProductsCtrl", "ng-init" => "refreshStaleData()", "ng-show" => "order_cycle.order_cycle_id != null", "ng-cloak" => true }
%products{"ng-init" => "refreshStaleData()", "ng-show" => "order_cycle.order_cycle_id != null", "ng-cloak" => true }
= render partial: "shop/products/searchbar"
@@ -9,7 +9,7 @@
.medium-12.large-9.columns.full
= render partial: "shop/products/search_feedback"
%div.pad-top{ "infinite-scroll" => "loadMore()", "infinite-scroll-distance" => "1", "infinite-scroll-disabled" => 'Products.loading' }
%div.pad-top{ "infinite-scroll" => "loadMore()", "infinite-scroll-distance" => "1", "infinite-scroll-disabled" => 'Products.loading', "infinite-scroll-immediate-check": "false" }
%product.animate-repeat{"ng-controller" => "ProductNodeCtrl", "ng-repeat" => "product in Products.products track by product.id", "id" => "product-{{ product.id }}"}
= render "shop/products/summary"
.shop-variants

View File

@@ -5,10 +5,11 @@
#shop-tabs{ ng: { controller: "PageSelectionCtrl", init: "whitelistPages(#{shop_tab_names.to_json})", cloak: true } }
.tab-buttons
.row
.flex.row
.columns.small-12.large-8
- shop_tabs.each do |tab|
.page{ "ng-class" => "{ selected: selectedPage() == '#{tab[:name]}' }" }
%a{ href: "##{tab[:name]}" }=tab[:title]
.columns.large-4.show-for-large-up
= render partial: "shopping_shared/order_cycles"
.page-view{ ng: {include: "'shop/' + selectedPage() + '.html'" } }

View File

@@ -2,10 +2,11 @@
.order-cycle-bar.hide-for-large-up
= render partial: "shopping_shared/order_cycles"
- if no_open_order_cycles?
= render partial: "shop/messages/closed_shop"
- else
= render partial: "shop/messages/select_oc"
%div{"ng-controller" => "ProductsCtrl"}
- if no_open_order_cycles?
= render partial: "shop/messages/closed_shop"
- else
= render partial: "shop/messages/select_oc"
-# Rendering the form, even if there are no open OCs, makes display only shops possible
= render partial: "shop/products/form"
-# Rendering the form, even if there are no open OCs, makes display only shops possible
= render partial: "shop/products/form"

View File

@@ -26,4 +26,4 @@
var shipments = [];
- @order.shipments.each do |shipment|
shipments.push(#{shipment.to_json(:root => false, :include => [:inventory_units, :stock_location]).html_safe});
= render :partial => 'spree/admin/shared/update_order_state', :handlers => [:erb]
= render :partial => 'spree/admin/shared/update_order_state', :handlers => [:erb], :formats => [:js]

View File

@@ -25,8 +25,7 @@
%span.centered.three.columns
= t "spree_admin_enterprises_fees"
%div.sixteen.columns.alpha.list
- @enterprises.each do |enterprise|
= render 'enterprise_row', { enterprise: enterprise }
= render partial: 'enterprise_row', collection: @enterprises, as: :enterprise
%a.sixteen.columns.alpha.button.bottom.blue{ href: "#{main_app.admin_enterprises_path}" }
= t "spree_admin_overview_enterprises_footer"

View File

@@ -14,5 +14,5 @@
.row
.three.columns
= label_tag :card_details, t(:card_details)
.six.columns
.nine.columns
%stripe-elements

View File

@@ -13,5 +13,5 @@
.row
.three.columns
= label_tag :card_details, t(:card_details)
.six.columns
.nine.columns
%stripe-elements

View File

@@ -11,8 +11,8 @@
= configurations_sidebar_menu_item Spree.t(:tax_settings), edit_admin_tax_settings_path
= configurations_sidebar_menu_item Spree.t(:zones), admin_zones_path
= configurations_sidebar_menu_item Spree.t(:countries), admin_countries_path
- if Spree::Config[:default_country_id]
= configurations_sidebar_menu_item Spree.t(:states), admin_country_states_path(Spree::Config[:default_country_id])
- if DefaultCountry.id
= configurations_sidebar_menu_item Spree.t(:states), admin_country_states_path(DefaultCountry.id)
= configurations_sidebar_menu_item Spree.t(:payment_methods), admin_payment_methods_path
= configurations_sidebar_menu_item Spree.t(:taxonomies), admin_taxonomies_path
= configurations_sidebar_menu_item Spree.t(:shipping_methods), admin_shipping_methods_path

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