Compare commits

...

1318 Commits

Author SHA1 Message Date
Pau Pérez Fabregat
0f2df6a941 Merge pull request #3891 from openfoodfoundation/2-0-1
Bring changes introduced in v2.0.1 into 2-0-stable
2019-06-03 22:01:22 +02:00
Luis Ramos
278147b81f Merge pull request #3892 from coopdevs/hide-product-from-shopfront-when-out-of-stock
Hide product from shopfront when out of stock
2019-05-31 19:21:47 +01:00
Pau Perez
7ea10f6d98 Refresh the products cache on stock change
This ensures the cache is up-to-date when a user accesses the shopfront
and we use the appropriate stock levels.

Besides, this makes the (very annoying) ProductsCacheIntegrityCheckerJob
succeed and thus Bugsnag won't be flooded with failures anymore.

As for the implementation of this. I'm not happy at all. It's disgusting
to use `class_eval` for this but it's a good trade-off to deliver this
fix ASAP. Katuma's been experiencing this error far too long
🙈. I was working on a better implementation that required
a bit of refactoring but it was taking too much time. I'll open another
PR with it soon.
2019-05-31 10:35:05 +02:00
Pau Perez
545c7c99ed Move spec to its spec/ folder 2019-05-31 09:30:26 +02:00
Pau Pérez Fabregat
cc3a0877c4 Merge pull request #3849 from luisramos0/pr_3839
Get PR 3839 to 2-0-1
2019-05-13 15:27:04 +02:00
Pau Perez
bb12592a74 Report cache diff to Bugsnag in a new tab
This will allow us to see the difference between the cache entry and the
actual shopfront. Otherwise, there is no way to see what wasn't
refreshed in the cache.
2019-05-10 22:02:11 +01:00
Pau Pérez Fabregat
f951ebe178 Merge pull request #3813 from luisramos0/3803-on-demand-default
Make stock locations backorderable_default false
2019-05-07 09:16:34 +02:00
luisramos0
bcc21cdade Make stock locations backorderable_default false.
This is required because when the default stock location is created, the backorderable_default column doesnt exist and when this column is created, the initial default is true. This is why we need to force it to false here. This column is the default value for on_demand which must be false.
2019-05-06 20:56:22 +01:00
Luis Ramos
6f0d155508 Merge pull request #3742 from openfoodfoundation/2-0-stable
Merge 2-0-stable to master
2019-05-04 00:06:27 +01:00
Luis Ramos
4afa0cdca1 Merge pull request #3589 from kristinalim/fix/2788-ship_address_changed
2788 [Subscriptions] Fix address issues when syncing subscriptions and orders
2019-05-03 23:48:32 +01:00
Luis Ramos
4f0930b77c Merge pull request #3717 from luisramos0/2-0-update-aws-sdk
[Spree Upgrade] Update to spree revision that depends on aws-sdk 1.11.1
2019-05-03 23:47:30 +01:00
luisramos0
53788625db Update to spree revision that depends on aws-sdk 1.11.1 making ofn gemfile.lock compatile with ofn/spree 2-0-4 gemspec 2019-05-03 13:16:25 +01:00
Luis Ramos
22a60e4fa9 Merge pull request #3769 from amers185/fix_rebase_error
Closes translation bug for enterprise fee settings
2019-05-03 12:53:52 +01:00
luisramos0
d7596b4066 Merge branch 'master' into fix_rebase_error 2019-05-03 12:10:57 +01:00
Pau Pérez Fabregat
969d3e863a Merge pull request #3768 from luisramos0/2-0-fix-on-demand
[Spree Upgrade] Migrate spree_variants.on_demand to spree_stock_items.backorderable
2019-05-03 10:52:16 +02:00
Luis Ramos
637e99367d Merge pull request #3747 from luisramos0/2-0-vo-ctrl-bug
[Spree Upgrade] Fix bug in Variant Overrides controller
2019-05-02 17:31:13 +01:00
luisramos0
4a9570b1a1 Merge branch '2-0-stable' into fix/2788-ship_address_changed 2019-05-02 16:17:53 +01:00
Luis Ramos
3b2e614c57 Merge pull request #3734 from luisramos0/2-0-validate-distribution
Removing a variant from OC will prevent user with that variant in the cart from checking out
2019-05-02 16:12:41 +01:00
Pau Pérez Fabregat
046d6ebdfc Merge pull request #3771 from luisramos0/2-0-stable-May2
[Spree Upgrade] LAST merge master into 2-0-stable 🎉
2019-05-02 14:26:24 +02:00
luisramos0
85cf4fa3e6 Merge branch 'master' into 2-0-stable-May2 2019-05-02 11:27:53 +01:00
Luis Ramos
edaf2479dc Merge pull request #3741 from luisramos0/2-0-stable-Apr15
[Spree Upgrade] Merging master into 2-0-stable (1st run in Apr2019)
2019-05-02 11:26:54 +01:00
luisramos0
f0f08f7cd3 Update all locales with the latest Transifex translations 2019-05-02 11:22:37 +01:00
Pau Pérez Fabregat
5f47a37fac Merge pull request #3763 from coopdevs/allow-passing-s3-region
Allow passing s3 region
2019-05-02 12:17:58 +02:00
luisramos0
340cbe5947 Eager load variants with variant overrides to avoid n+1 in the following line 2019-05-02 11:10:53 +01:00
luisramos0
116650595e Move test setup code to before block 2019-05-02 11:08:31 +01:00
luisramos0
42d1d3eff6 Migrate spree_variants.on_demand to spree_stock_items.backorderable 2019-05-02 10:59:27 +01:00
Pau Pérez Fabregat
2d77605e59 Merge pull request #3764 from Matt-Yorkley/s3_backups_without_images
Don't use s3 for images unless images bucket has been provisioned.
2019-05-01 17:55:01 +02:00
Syed Usama Amer
75a7745736 Closes translation bug for enterprise fee settings 2019-05-01 10:43:35 -05:00
Kristina Lim
19726061e4 Make Order#address_from_distributor public 2019-05-01 07:17:50 +08:00
Kristina Lim
92dc43d7a2 Make OrderUpdater#shipping_address_from_distributor public 2019-05-01 07:16:56 +08:00
Kristina Lim
0933d53134 Extract method OrderSyncer#update_ship_address_for 2019-05-01 07:16:56 +08:00
Kristina Lim
14d407879c Rename method OrderSyncer#update_ship_address_for
This method has become only a small part of the logic for updating the
order's ship address. This no longer follows the method naming
convention within OrderSyncer where update_*_for describes almost the
complete logic for updating the association.

This is renamed in preparation for extraction of the complete update
logic for ship_address. The new method will be named
update_ship_address_for.
2019-05-01 07:16:56 +08:00
Kristina Lim
6952f4ecd1 Improve readability of conditions in OrderSyncer 2019-05-01 07:16:55 +08:00
Kristina Lim
71f379a318 Uncomment passing specs for SubscriptionPlacementJob 2019-05-01 07:16:55 +08:00
Kristina Lim
b4b24931d9 Remove ignore for OrderSyncer spec file 2019-05-01 07:16:55 +08:00
Kristina Lim
46d63f43b9 Update check for pickup address manipulation
The way that the bill contact details and distributor address are set
for pickup orders has changed. At this point, after before_save_hook is
called, the bill contact details have already been set as well.
2019-05-01 07:16:54 +08:00
Kristina Lim
78aa9da2cf Uncomment and update OrderSyncer failing specs
This still achieves a logic issue before the Spree upgrade, where
switching from pick-up to delivery affects whether simultaneous changes
to shipping address are ignored or not.

This behaviour can be fixed in a separate PR.
2019-05-01 07:16:54 +08:00
Kristina Lim
bdf4132e01 Fix order shipment references in OrderUpdater 2019-05-01 07:16:54 +08:00
Pau Pérez Fabregat
88cbf5bd36 Merge pull request #3753 from openfoodfoundation/dependabot/bundler/whenever-0.11.0
Bump whenever from 0.10.0 to 0.11.0
2019-04-30 18:38:52 +02:00
Matt-Yorkley
732d0f7cf4 Don't use s3 for images unless images bucket has been provisioned.
Sets the "use_s3" (for images) option based on presence of `s3_images_bucket` from ofn-install instead of presence of s3 keys, for instances that use s3 for backups but not for images.
2019-04-30 17:06:42 +01:00
Pau Perez
d5b08c602a Allow passing a specific AWS region to S3 settings
This solves the error showed below when executed `bundle exec rake
db2fog:backup RAILS_ENV=staging` on Katuma staging

```
Excon::Error::BadRequest: Expected(200) <=> Actual(400 Bad Request)
excon.error.response
  :body          => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>AuthorizationHeaderMalformed</Code><Message>The authorization header is malformed; the region 'us-east-1' is wrong; expecting 'eu-central-1'</Message><Region>eu-central-1</Region><RequestId>3DE2763883FC601D</RequestId><HostId>1E6UapnblBqVZM0SeeLrdPNDd+VaQ0nxCWwrQ9mi8HjRo2xevAUwtSq5V3fxhsj4Cj9ynnDroco=</HostId></Error>"
```
2019-04-30 13:31:36 +02:00
Pau Perez
f36646d0a3 Store S3 keys in Config before calling db2fog
This ensures that Db2fog always picks up the latest value of the S3_*
env vars and not the one that was persisted last time. Now you can do
things like `S3_BUCKET=xxx bundle exec rake db2fog:backup` if you had
to.
2019-04-30 13:31:36 +02:00
Pau Pérez Fabregat
010f058618 Merge pull request #3744 from openfoodfoundation/dependabot/bundler/oj-3.7.12
Bump oj from 3.7.11 to 3.7.12
2019-04-30 11:53:44 +02:00
Pau Pérez Fabregat
6c9101dffa Merge pull request #3745 from openfoodfoundation/transifex
Transifex
2019-04-30 11:46:17 +02:00
dependabot[bot]
2c536c29c5 Bump whenever from 0.10.0 to 0.11.0
Bumps [whenever](https://github.com/javan/whenever) from 0.10.0 to 0.11.0.
- [Release notes](https://github.com/javan/whenever/releases)
- [Changelog](https://github.com/javan/whenever/blob/master/CHANGELOG.md)
- [Commits](https://github.com/javan/whenever/compare/v0.10.0...v0.11.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-04-23 19:18:23 +00:00
Pau Pérez Fabregat
380a9c561e Merge pull request #3725 from coopdevs/add-specs-for-cache-variant-deletion
Add specs for the cache refresh on variant removal
2019-04-19 19:02:04 +02:00
Maikel
99a4878bdf Merge pull request #3653 from mkllnk/2520-spree2-order-subscription
2520 Remove `process_payments!` override
2019-04-19 07:34:30 +10:00
Maikel
736ac49581 Merge pull request #3701 from luisramos0/2-0-fix-order-edit-issues
[Spree Upgrade] Fix two issues in admin orders edit page
2019-04-19 07:33:26 +10:00
luisramos0
a68b5eaf22 Fix bug in Variant Overrides controller. It was validating authorization for variant overrides of deleted variants 2019-04-17 15:31:19 +01:00
luisramos0
3d420d5727 Merge branch 'master' into 2-0-stable-Apr15 2019-04-16 21:14:11 +01:00
Transifex-Openfoodnetwork
225b159b9b Updating translations for config/locales/en_BE.yml 2019-04-17 02:23:46 +10:00
Transifex-Openfoodnetwork
e07ae3d931 Updating translations for config/locales/en_BE.yml 2019-04-17 02:20:37 +10:00
Luis Ramos
6b84edb6d9 Merge pull request #3736 from kristinalim/feature/enable_newrelic_test_mode
Install and set up newrelic_rpm gem for development environment
2019-04-16 15:35:36 +01:00
Luis Ramos
c5720bede5 Merge pull request #3697 from coopdevs/add-delayed-job-web
Add delayed job web
2019-04-16 15:33:59 +01:00
Luis Ramos
eeac75ade1 Merge pull request #3689 from luisramos0/2-0-fix-split-button-bug
[Spree Upgrade] Fix split button reappearing when editing line item quantity
2019-04-16 15:28:43 +01:00
Luis Ramos
67a7e26757 Merge pull request #3695 from luisramos0/2-0-emails-transl
[Spree Upgrade] Fix translation missing in order confirmation email subject and bring cancel email to ofn
2019-04-16 13:44:24 +01:00
Luis Ramos
29000ebe0d Merge pull request #3651 from luisramos0/2-0-enterprise-fee-report
[Spree Upgrade] Fix Enterprise fee report specs
2019-04-16 12:36:53 +01:00
Maikel Linke
278190a25c Update specs for Spree v2 payment requirement
This pull request removed the override of `process_payments!` which was based on v1. Spree v2 has an additional check: An order in payment state requires a payment. Some specs didn't care and didn't create payments before transitioning to `complete`.
2019-04-16 10:30:14 +10:00
Maikel Linke
8b9a814131 Remove obsolete Spree 2 backport on Order 2019-04-16 10:30:14 +10:00
Maikel Linke
6f12eee8ae Reduce the override of Order for subscriptions
Orders belonging to subscriptions get completed without payment. That
requires overriding Spree's functionality.

In Spree 2, an order in payment state without pending orders is invalid.
Instead we skip the payment state by not requiring a payment for
automatically generated orders until the order cycle is closed.
2019-04-16 10:30:14 +10:00
dependabot[bot]
2a025be032 Bump oj from 3.7.11 to 3.7.12
Bumps [oj](https://github.com/ohler55/oj) from 3.7.11 to 3.7.12.
- [Release notes](https://github.com/ohler55/oj/releases)
- [Changelog](https://github.com/ohler55/oj/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ohler55/oj/compare/v3.7.11...v3.7.12)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-04-15 19:14:59 +00:00
luisramos0
e8ccb55f47 Use rspec 3 syntax in order_cycle_distributed_variants_spec and checkout_controller_spec 2019-04-15 12:39:52 +01:00
Pau Pérez Fabregat
ffbea7d3fd Merge pull request #3712 from openfoodfoundation/transifex
Transifex
2019-04-15 12:58:30 +02:00
Pau Pérez Fabregat
6d0ecdc4a6 Merge pull request #3721 from Matt-Yorkley/subs_styles
Subs styles
2019-04-15 12:53:27 +02:00
luisramos0
8f39a18ca3 Merge branch 'master' into 2-0-stable-Apr15 2019-04-15 11:46:31 +01:00
Transifex-Openfoodnetwork
f76fada066 Updating translations for config/locales/es.yml 2019-04-15 19:15:24 +10:00
Transifex-Openfoodnetwork
1b01c44ce4 Updating translations for config/locales/es.yml 2019-04-15 19:12:19 +10:00
Transifex-Openfoodnetwork
10c917a693 Updating translations for config/locales/ca.yml 2019-04-15 17:08:06 +10:00
Transifex-Openfoodnetwork
418d80bdc0 Updating translations for config/locales/ca.yml 2019-04-15 17:05:00 +10:00
luisramos0
fce3d69345 Add flash and warning to the cart page when item becomes unavailable 2019-04-13 21:39:41 +01:00
luisramos0
d602375ac7 Redirect user to cart page if some item in the order is unavailable 2019-04-13 20:31:05 +01:00
Luis Ramos
1e85bf6a68 Merge pull request #3641 from luisramos0/2-0-update-spree-2-0-4-revision
[Spree Upgrade] Update spree revision to include last package_factory fix
2019-04-12 22:16:15 +01:00
Pau Pérez Fabregat
e0fd2fbaa9 Merge pull request #3726 from Matt-Yorkley/db2fog_patch
Db2fog patch
2019-04-12 14:26:46 +02:00
Kristina Lim
53bd421389 Add newrelic.yml to .gitignore 2019-04-12 13:57:50 +08:00
Kristina Lim
6f5a024be2 Update script/setup to create default newrelic.yml 2019-04-12 13:57:50 +08:00
Kristina Lim
d983e400cd Add config/newrelic.yml.example for newrelic_rpm gem 2019-04-12 13:57:50 +08:00
Kristina Lim
c5e4b283f1 Install latest newrelic_rpm gem with test mode 2019-04-12 13:57:47 +08:00
Luis Ramos
0f00f48f13 Merge pull request #3634 from luisramos0/2-0-fix-sample-data
[Spree Upgrade] Fix new sample data in v2
2019-04-11 23:07:15 +01:00
luisramos0
59ec52babe Refactor order_cycle_distributed_variants, better method names and simpler code 2019-04-11 22:15:24 +01:00
luisramos0
44b0592223 Move OrdercycleDistributedVariants from lib/open_food_network to app/services 2019-04-11 21:37:08 +01:00
luisramos0
96ee527f0c Rename distribution_change_validator to order_cycle_distributed_variants 2019-04-11 21:14:01 +01:00
Transifex-Openfoodnetwork
45ca63e751 Updating translations for config/locales/fr_BE.yml 2019-04-12 01:14:59 +10:00
Transifex-Openfoodnetwork
b6989c6d6e Updating translations for config/locales/nl_BE.yml 2019-04-12 01:05:30 +10:00
luisramos0
46278e3edd Set distributor in order and shipping methods so that refreshing shipment rates suceeds 2019-04-10 22:16:09 +01:00
luisramos0
5791eba9bd Enhance orders edit page spec to verify that shipping method can be edited and that shipping methods of other distributors are not listed 2019-04-10 22:16:09 +01:00
luisramos0
c852c616d5 Update spree revision to include last package_factory fix and update spree dependencies 2019-04-10 22:16:09 +01:00
Luis Ramos
ddd3443a86 Merge pull request #3659 from mkllnk/missing-translation
Fix "What's this?" on admin dashboard
2019-04-10 22:05:19 +01:00
Luis Ramos
4bf9320be8 Merge pull request #3666 from mkllnk/1830-v2-edit-shipping-fees
Close adjustments so that updates are effective
2019-04-10 21:58:22 +01:00
Luis Ramos
83a4771cdd Merge pull request #3720 from Matt-Yorkley/spree2/translations
Subs: missing translations
2019-04-10 21:47:47 +01:00
Luis Ramos
984155013c Merge pull request #3648 from luisramos0/2-0-fix-ui-issue
[Spree Upgrade] Fix "back to list" button overlap and remove configurations menu from payments methods list
2019-04-10 21:46:40 +01:00
Luis Ramos
97c920f1b0 Merge pull request #3667 from mkllnk/3477-display-eligible-adjustments
3477 Render only eligible adjustments on the order page
2019-04-10 21:44:16 +01:00
Matt-Yorkley
7373fff190 Define default s3_protocol as 'https' 2019-04-10 19:23:16 +01:00
Matt-Yorkley
4912a9e258 Ensure ENV vars in applications.yml actually update stored Spree::Config preferences 2019-04-10 19:10:31 +01:00
Matt-Yorkley
2ac981a9a3 Make db2fog tasks conditional 2019-04-10 17:17:43 +01:00
Matt-Yorkley
37cbfcb692 Use ENV var for backups bucket 2019-04-10 17:17:17 +01:00
Pau Perez
f20a15e955 Add specs for the cache refresh on variant removal
This is failing in `master` but thanks to the VariantDeleter it does work
in v2. This specs prove it.
2019-04-10 16:16:00 +02:00
Matt-Yorkley
14fd821283 Rename states SCSS file for clarity 2019-04-10 13:12:44 +01:00
Matt-Yorkley
e486a94fb4 Add missing translations in subscriptions 2019-04-10 12:16:31 +01:00
Matt-Yorkley
9e0f35d635 Re-adjust buttons. Much better! 2019-04-10 12:15:21 +01:00
Matt-Yorkley
e13db873b0 Fix subs panel button vertical alignment 2019-04-10 12:15:21 +01:00
Matt-Yorkley
896a45c399 Fix subs state buttons 2019-04-10 12:15:21 +01:00
Matt-Yorkley
3968cfd238 Fix chevron horizontal position 2019-04-10 12:15:21 +01:00
Matt-Yorkley
3578d82cbf Merge pull request #3718 from luisramos0/2-0-fix-build
[Spree Upgrade] Add order distributor to shipping method in reports_spec
2019-04-10 12:14:00 +01:00
luisramos0
e4c54a4954 Add order distributor to shipping method in reports_spec 2019-04-09 23:26:14 +01:00
Luis Ramos
4478d51aee Merge pull request #3668 from luisramos0/2-0-stable-Mar29
[Spree Upgrade] Merging master into 2-0-stable (4th run in Mar2019)
2019-04-09 17:46:36 +01:00
Luis Ramos
449e58723d Merge pull request #3591 from luisramos0/2-0-fix-migrations
[Spree Upgrade] Fix Migrations to 2.0
2019-04-09 13:16:34 +01:00
Transifex-Openfoodnetwork
029e8eb848 Updating translations for config/locales/de_DE.yml 2019-04-09 20:50:31 +10:00
Luis Ramos
ef2e00ae31 Merge pull request #3604 from luisramos0/2-0-fix-splitters
[Spree Upgrade] Override default spree splitters config
2019-04-09 09:19:00 +01:00
Transifex-Openfoodnetwork
44e6adbe34 Updating translations for config/locales/en_GB.yml 2019-04-09 00:21:57 +10:00
Transifex-Openfoodnetwork
fde3d72a66 Updating translations for config/locales/en_GB.yml 2019-04-09 00:18:48 +10:00
Pau Pérez Fabregat
6e727e12e2 Merge pull request #3711 from openfoodfoundation/transifex
Transifex
2019-04-08 15:15:28 +02:00
Transifex-Openfoodnetwork
0261baaed3 Updating translations for config/locales/pt.yml 2019-04-08 21:06:43 +10:00
Transifex-Openfoodnetwork
4a69fdef27 Updating translations for config/locales/pt.yml 2019-04-08 21:06:39 +10:00
Transifex-Openfoodnetwork
5e672dc7d4 Updating translations for config/locales/pt.yml 2019-04-08 21:03:32 +10:00
Pau Pérez Fabregat
ffce31ca45 Merge pull request #3710 from coopdevs/pull-Transifex-translations
Update locales with latest Transifex translations
2019-04-08 12:56:23 +02:00
Pau Perez
860414fa31 Update locales with latest Transifex translations 2019-04-08 12:27:19 +02:00
Pau Pérez Fabregat
fa31ca5a95 Merge pull request #3686 from openfoodfoundation/transifex
Transifex
2019-04-08 12:23:36 +02:00
luisramos0
e9491cecab Fix flaky spec by having only one variant with display name small bag 2019-04-06 10:14:19 +01:00
luisramos0
258a9efa0d Adapt product_importer_spec to ofn v2 where there’s no product.count_on_hand and on_hand does not default to infinity if product.on_demand 2019-04-05 22:09:46 +01:00
luisramos0
bb4cec1186 Fix order_and_distributor_report_spec by setting ofn shipping method the ofn v2 way 2019-04-05 22:06:44 +01:00
Transifex-Openfoodnetwork
f5ab89eb03 Updating translations for config/locales/it.yml 2019-04-06 07:38:45 +11:00
luisramos0
ecc60f3b61 Merge branch 'master' into 2-0-stable-Mar29 2019-04-05 15:47:46 +01:00
Pau Pérez Fabregat
0c75a070c6 Merge pull request #3650 from kristinalim/fix/2786-address_subscription_confirm_job_failing_specs
3487,2786 [Spree Upgrade] Address spec failures for SubscriptionConfirmJob
2019-04-05 15:45:41 +02:00
Pau Perez
3e7e24d700 Make VariantController specs aware of destroy call
In v2 we no longer rely on `Variant#delete` but `Variant#destroy` so
stubbed calls needed fixing.
2019-04-05 15:38:10 +02:00
Transifex-Openfoodnetwork
80fd367da0 Updating translations for config/locales/en_US.yml 2019-04-06 00:27:12 +11:00
Transifex-Openfoodnetwork
231fa28713 Updating translations for config/locales/en_US.yml 2019-04-06 00:24:05 +11:00
Pau Pérez Fabregat
10165c4246 Merge pull request #3680 from kristinalim/fix/3285-db_migration_bang_shipping_rates
[Spree Upgrade] Bang version of create in DB migration for shipping rates
2019-04-05 15:11:41 +02:00
luisramos0
5989a654d1 Remove stock location from stock levels table and fix Spree.t entry bug 2019-04-05 14:01:27 +01:00
Pau Pérez Fabregat
1b55d04963 Merge pull request #3673 from Matt-Yorkley/spree2/css
Spree2/css
2019-04-05 14:57:57 +02:00
Pau Pérez Fabregat
67376a29a6 Merge pull request #3694 from Matt-Yorkley/db2fog
Fix outdated db2fog initializer
2019-04-05 12:26:07 +02:00
Transifex-Openfoodnetwork
74b7418f59 Updating translations for config/locales/fr.yml 2019-04-05 04:39:15 +11:00
Transifex-Openfoodnetwork
545f2fefa4 Updating translations for config/locales/fr.yml 2019-04-05 04:36:07 +11:00
Pau Perez
aa3f0ac577 Reuse #superadmin? in Delayed Job Web route
This moves #superadmin? to the user decorator so it can be reused
outside FeatureFlags.
2019-04-04 16:00:27 +02:00
Pau Perez
bf20376667 Add Delayed Job Web for superadmins only
This adds https://github.com/ejschmitt/delayed_job_web to enable async
job management such as retries, removal of failed jobs, etc.

Only superadmins can access this web UI though. Therefore any sysadmin
that needs to use it should have access to the appropriate instance
superadmin credentials in Bitwarden.
2019-04-04 16:00:27 +02:00
luisramos0
87327f7aa9 Fix specs testing order cancelation email. The email template now needs a order distributor for the signoff part 2019-04-04 13:41:07 +01:00
Pau Pérez Fabregat
07888b355a Merge pull request #3679 from mkllnk/3477-missing-v2-translation
Add missing translation for order form in v2
2019-04-04 14:25:05 +02:00
Transifex-Openfoodnetwork
8d69180c8c Updating translations for config/locales/es.yml 2019-04-04 23:23:06 +11:00
Transifex-Openfoodnetwork
4b60a75eae Updating translations for config/locales/ca.yml 2019-04-04 23:22:59 +11:00
Matt-Yorkley
9b45269cbb Fix name of Spree::Config preference 2019-04-04 13:06:05 +01:00
luisramos0
cf3b2308e1 Fix translation problem in the subject of order confirmation emails 2019-04-04 12:55:36 +01:00
luisramos0
6e49cf9f87 Bring cancel email from spree so it gets the normal ofn style 2019-04-04 12:31:12 +01:00
Matt-Yorkley
7522594b85 Fix outdated db2fog initializer 2019-04-04 12:02:57 +01:00
Maikel Linke
84501b9e41 Move feature spec to controller spec
It reduces the runtime (3s instead of 10s).
2019-04-04 17:01:44 +11:00
Maikel Linke
7b116c0982 Remove unnecessary condition from spec 2019-04-04 16:51:18 +11:00
Maikel Linke
72458da465 Comply to code convention using I18n.t in specs 2019-04-04 16:26:52 +11:00
Pau Pérez Fabregat
ec00544130 Merge pull request #3665 from mkllnk/stripe-version
Relax stripe version requirement
2019-04-03 17:02:40 +02:00
Pau Pérez Fabregat
c515a8f115 Merge pull request #3537 from Matt-Yorkley/pi/on_demand_error
Fix nil values in on_hand column
2019-04-03 11:56:06 +02:00
Pau Pérez Fabregat
b288cb00c1 Merge pull request #3654 from mkllnk/3237-spec-overrides-in-inventory-report
Test inventory report to use variant overrides
2019-04-03 11:55:33 +02:00
Maikel Linke
d31b5efac6 Simplify orders helper 2019-04-03 11:15:54 +11:00
Maikel Linke
7035d57267 Better helper naming and spec cover 2019-04-03 11:13:56 +11:00
luisramos0
ea52600fc5 Fix split button reappearing when editing line item quantity 2019-04-02 21:58:29 +01:00
Transifex-Openfoodnetwork
898966fbea Updating translations for config/locales/pt.yml 2019-04-03 03:20:34 +11:00
Transifex-Openfoodnetwork
b8f8ea964e Updating translations for config/locales/pt.yml 2019-04-03 03:17:29 +11:00
Transifex-Openfoodnetwork
1874f55fa4 Updating translations for config/locales/pt.yml 2019-04-03 03:14:14 +11:00
luisramos0
5e64c9f392 Fix deface override to remove configurations menu from payment methods list, this is necessary because non-admin users do get to this page through enterprises management" 2019-04-02 16:58:50 +01:00
luisramos0
5c69d6c9dc Fix page action in the backoffice when translations are long 2019-04-02 16:58:45 +01:00
luisramos0
112a57d330 Remove association between adjustments and shipments that are going to be deleted in AddUniquenessOfOrderIdToSpreeShipments 2019-04-02 12:31:39 +01:00
luisramos0
40124b7421 Improve downloads_helper clear_downloads method 2019-04-02 11:39:52 +01:00
luisramos0
7cc5940e19 Load DownloadsHelper only for feature specs 2019-04-02 11:39:52 +01:00
luisramos0
e10264af86 Remove xfeature from enterprise fees summmary report spec 2019-04-02 11:39:52 +01:00
luisramos0
d9304916cc Add chrome driver config to make testing csv downloads with headless chrome possible 2019-04-02 11:39:52 +01:00
luisramos0
c36f7e003b Adapt assertions to new csv file download logic 2019-04-02 11:39:52 +01:00
luisramos0
4f803eba7e Add around blocks to clear downloads directory before and after every test 2019-04-02 11:39:52 +01:00
luisramos0
4795832db5 Add spec DownloadsHelper to support testing csv downloads with headless chrome 2019-04-02 11:39:52 +01:00
luisramos0
c291601d9f Fix rubocop warnings in enterprise_fee_summary report spec 2019-04-02 11:39:52 +01:00
Kristina Lim
3035d14369 Use bang version of create! in DB migration script 2019-04-02 15:21:58 +08:00
Maikel Linke
8b6561addd Add missing translation for order form in v2
I saw the following error on the 2-0-stable branch:

  translation missing: en.spree.line_item_adjustments

In a pending PR I change all three translations in the view file to use
lazy lookup. This commit backports the addition to the locale so that it
can be translated via Transifex before we release v2.
2019-04-02 17:52:24 +11:00
Maikel Linke
0c846758dd Add missing translation to order form
I saw the following error:

  translation missing: en.spree.line_item_adjustments

In this commit I change all three translations in the view file to use
lazy lookup.
2019-04-02 17:47:36 +11:00
Maikel Linke
2a6236823f Move adjustment filtering from view to helper 2019-04-02 17:25:33 +11:00
Maikel Linke
11c12787f6 Move adjustment selection to helper 2019-04-02 17:02:05 +11:00
Maikel Linke
d78c709ad2 Remove unused variables from view 2019-04-02 16:58:08 +11:00
Maikel Linke
500cf925ad Fix HTML validity and element finding in spec
The fixed partial was used twice on the same page. So the used element
id appeared twice on the page which is invalid HTML. It also confused
the spec.

Now we look at the actually displayed text to select the correct
element.
2019-04-02 16:50:44 +11:00
Luis Ramos
9c99e64f1f Merge pull request #3316 from luisramos0/2-0-phase2-reports
[Spree Upgrade] Phase 2 - Reports ready - all specs running and green (except enterprise fee report)
2019-04-01 21:46:31 +01:00
Luis Ramos
d48d2a748b Merge pull request #3662 from SDBowen/add_shipping_method
Add shipping method name to orders detail report
2019-04-01 15:37:57 +01:00
Matt-Yorkley
668a37f564 Fix "clear all" button spacing in inventory 2019-04-01 12:18:19 +01:00
Matt-Yorkley
4a0e5a42a3 Fix admin menu items different heights 2019-04-01 12:11:29 +01:00
Matt-Yorkley
082be15df2 Fix admin menu mixed font weights 2019-04-01 12:00:29 +01:00
Matt-Yorkley
fa91a66de6 Fix button padding after Spree 2 font changes increased the vertical height 2019-04-01 11:48:18 +01:00
Matt-Yorkley
3ad2c9f7c4 Fix 'clear all' button width on Order Cycles page 2019-04-01 11:41:46 +01:00
Kristina Lim
d866fad46e Persist variants in customer totals specs
This is to properly record the on hand quantity.
2019-03-31 18:32:09 +08:00
luisramos0
bc8bca074c Switch object in the ability to access reports. This adapts to this change in Spree: 3685569db4
Adapt NavigationHelper to return the controller object for reports so that Reports tab works correctly.
2019-03-29 22:16:39 +00:00
luisramos0
1fc4b7fd2a Add manual shipping adjustment
For some reason this adjustment is not being added to order through the callbacks as it was before. See PR #3371
2019-03-29 22:16:39 +00:00
luisramos0
d713c755e6 Uncomment report specs so we can make them work in v2 2019-03-29 22:16:38 +00:00
luisramos0
527cfc1601 Merge branch 'master' into 2-0-stable-Mar29 2019-03-29 13:48:49 +00:00
Maikel Linke
f630738b2c Fix HTML syntax in admin view 2019-03-29 18:42:06 +11:00
Maikel Linke
5760aed6a6 Render only eligible adjustments on the order page
https://github.com/openfoodfoundation/openfoodnetwork/issues/3477

The admin orders edit form was displaying adjustments even if they were
"not eligible". For example, an additional fee with amount `0` is not
eligible. They were already hidden in the adjustments view and we are
hiding them in reports.
2019-03-29 18:41:38 +11:00
Maikel Linke
fabca84001 Close adjustments so that updates are effective
Spree 2.0 keeps shipping fee adjustments open unless they are manually
closed. But open adjustments cannot be edited.
To preserve updates, like changing the amount of the shipping fee
we close the adjustment first.
2019-03-29 17:23:15 +11:00
Maikel
7348987567 Merge pull request #3315 from luisramos0/2-0-phase2-pi
[Spree Upgrade] Phase 2 - Product Import ready - all specs running and green
2019-03-29 15:16:35 +11:00
Maikel
6e31f0078a Merge pull request #3639 from coopdevs/fix-variant-cache-refreshing-on-delete
Fix variant cache refreshing on delete
2019-03-29 15:12:46 +11:00
Maikel Linke
29f32604f2 Relax stripe version requirement
We are using the latest version of the `stripe` gem. We don't depend on
any particular version. I'm proposing to drop our dependency declaration
on a particular version and just track the current used version in
Gemfile.lock. That means fewer code changes when updating, which happens
quite frequently with this gem.
2019-03-29 13:40:51 +11:00
Maikel
973ae3d43a Merge pull request #3656 from openfoodfoundation/dependabot/bundler/stripe-4.11.0
Bump stripe from 4.10.0 to 4.11.0
2019-03-29 13:39:08 +11:00
sdbowen
0f7ef2671f Add shipping method name to orders detail report
Added column allows users to see the shipping method of each order.
2019-03-28 16:08:10 -06:00
luisramos0
3742c70910 Add backup process to AddUniquenessOfOrderIdToSpreeShipments so that the deleted duplicated shipments can be recovered if something goes wrong 2019-03-28 18:49:38 +00:00
Maikel
fed2b60743 Merge pull request #3644 from kevinchristianson/master
Fixed producer profile translation bug
2019-03-28 15:51:45 +11:00
Maikel
6978e3fdb6 Merge pull request #3658 from mkllnk/3582-shipping-method-spec
Wait for entered tag before submitting
2019-03-28 13:46:56 +11:00
Maikel
74aea76c4c Merge pull request #3609 from luisramos0/2-0-delete-acct-invoices-last-bit
[Spree Upgrade] Finish up deleting account invoices
2019-03-28 13:42:01 +11:00
Kristina Lim
f0746eb643 Use :performing_deliveries in spec 2019-03-28 02:04:13 +08:00
luisramos0
b780823970 Fix specs to adapt to the fact that for the order workflow to get to delivery, the shipping method must be linked to the order distributor otherwise it's ignored when creating the order shipment 2019-03-27 14:10:51 +00:00
Luis Ramos
4455073f6d Merge pull request #3647 from luisramos0/fix-shipment-state-translation
Add missing translation key for order shipment state canceled
2019-03-27 13:02:14 +00:00
Maikel Linke
bcebb99967 Fix "What's this?" on admin dashboard
When a user has no enterprises, the admin dashboard displays a "What's
this?" hint in the right corner of the enterprises tab. The link text
and the tooltip were both broken (missing translation).
2019-03-27 11:04:08 +11:00
Maikel Linke
ef882b8293 Wait for entered tag before submitting
The changed spec was failing from time to time. This change seems to
make it stable. It may be worth moving tag entering into a helper that
verifies that the tag was entered (waits for it).
2019-03-27 10:58:00 +11:00
dependabot[bot]
6c97bb6cac Bump stripe from 4.10.0 to 4.11.0
Bumps [stripe](https://github.com/stripe/stripe-ruby) from 4.10.0 to 4.11.0.
- [Release notes](https://github.com/stripe/stripe-ruby/releases)
- [Changelog](https://github.com/stripe/stripe-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/stripe/stripe-ruby/compare/v4.10.0...v4.11.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-03-26 19:25:43 +00:00
luisramos0
249e2bc9e1 Merge branch '2-0-stable' into 2-0-fix-sample-data 2019-03-26 15:50:16 +00:00
luisramos0
ae66e864a5 Improve models/spree/order/checkout_spec: AR is here to help you :-D 2019-03-26 15:37:36 +00:00
luisramos0
428656e92e Add distributor to shipping method in factory completed_order_with_fees so that shipping method is not discarded during order processing in package.shipping_methods 2019-03-26 15:37:36 +00:00
luisramos0
beb19cdc8a Override default spree splitters config (was Shipping Category and Backordered) to use only Base splitter, this splitter does not split the orders into multiple shipments
In OFN we cannot split the orders because one order can only have one shipment

Additionally, add spec to validate that the order workflow now works with products with different shipping categories
2019-03-26 15:37:35 +00:00
Pau Pérez Fabregat
a8f81ae7a2 Merge pull request #3652 from kristinalim/fix/3410-address_proxy_orders_controller_failing_specs
3410 [Spree Upgrade] Address spec failures for Admin::ProxyOrdersController
2019-03-26 15:55:13 +01:00
luisramos0
5ce762a600 Uncomment product import specs so we can make them work in v2 2019-03-26 11:34:04 +00:00
Luis Ramos
c68b0d768a Merge pull request #3640 from luisramos0/2-0-stable-Mar22
[Spree Upgrade] Merging master into 2-0-stable (3rd run in Mar2019)
2019-03-26 10:42:27 +00:00
luisramos0
f35972cee9 Remove deleted menu entry product distributions 2019-03-26 09:08:52 +00:00
luisramos0
010007a2c7 Merge branch '2-0-stable' into 2-0-stable-Mar22 2019-03-26 09:07:48 +00:00
Luis Ramos
9a771ecbb8 Merge pull request #3613 from luisramos0/2-0-update-variants-stock
[Spree Upgrade] Add on_hand and on_demand to the variants create and edit pages
2019-03-26 08:55:34 +00:00
Maikel
d963df2c87 Merge pull request #3632 from openfoodfoundation/dependabot/bundler/oj-3.7.11
Bump oj from 3.7.10 to 3.7.11
2019-03-26 16:28:36 +11:00
Maikel
84246fedc9 Merge pull request #3631 from openfoodfoundation/dependabot/bundler/stripe-4.10.0
Bump stripe from 4.9.0 to 4.10.0
2019-03-26 16:28:08 +11:00
Maikel
6ad42fcceb Merge pull request #3636 from openfoodfoundation/transifex
Transifex
2019-03-26 16:27:50 +11:00
Maikel Linke
9d4589632b Test inventory report to use variant overrides 2019-03-26 16:13:50 +11:00
Maikel
9e3734fc3e Merge pull request #3646 from kristinalim/fix/3528-product_sku_in_report
3528 Scope Customer Totals report also by variant (not just product) and use variant SKU
2019-03-26 12:05:14 +11:00
Kristina Lim
db6dab2e54 Address failing specs for ProxyOrdersController 2019-03-26 00:56:02 +08:00
Transifex-Openfoodnetwork
a2f3110b06 Updating translations for config/locales/en_CA.yml 2019-03-26 03:33:01 +11:00
Transifex-Openfoodnetwork
e504783929 Updating translations for config/locales/fr_CA.yml 2019-03-26 03:06:18 +11:00
Kristina Lim
2aad5baac5 Make code style changes for SubscriptionConfirmJob specs 2019-03-25 22:22:11 +08:00
Kristina Lim
18fe35e130 Address spec failures for SubscriptionConfirmJob 2019-03-25 21:55:38 +08:00
Transifex-Openfoodnetwork
a4bc739d48 Updating translations for config/locales/de_DE.yml 2019-03-25 16:40:06 +11:00
Kristina Lim
807cdb4746 Code style changes for Customer Totals report 2019-03-25 07:46:32 +08:00
Kristina Lim
4a95578db2 Use name helpers in Customer Totals report 2019-03-25 07:46:31 +08:00
Kristina Lim
79d0b63069 Add Spree::Address#full_name_reverse 2019-03-25 07:46:31 +08:00
Kristina Lim
7c7d61fbc5 Simplify some logic for Customer Totals report
Line items belong to a single order.
2019-03-25 07:46:30 +08:00
Kristina Lim
c088fb9a49 Use shorter syntax for Customer Totals report 2019-03-25 07:46:30 +08:00
Kristina Lim
46e7090d11 Group report by variant and use variant SKU
This groups the Customer Totals report by variant too (among others,
including by product), and then changes the report to use the variant
SKU not the product SKU.

This adds a spec for customer totals grouping and details, which
replaces the test specific to the SKU column.
2019-03-25 07:45:32 +08:00
Maikel Linke
7bc735eea3 Cover report content with specs 2019-03-25 04:47:13 +08:00
Maikel Linke
fdd8c06823 Style reports spec 2019-03-25 04:47:13 +08:00
Maikel Linke
856603cadd Convert specs to RSpec 3.8.0 syntax with Transpec
This conversion is done by Transpec 3.4.0 with the following command:
    transpec spec/lib/open_food_network/orders_and_fulfillments_report_spec.rb

* 8 conversions
    from: == expected
      to: eq(expected)

* 8 conversions
    from: obj.should
      to: expect(obj).to

* 1 conversion
    from: obj.stub(:message)
      to: allow(obj).to receive(:message)

For more details: https://github.com/yujinakayama/transpec#supported-conversions
2019-03-25 04:47:13 +08:00
Maikel Linke
0a243ac9ca Give spec vars proper names 2019-03-25 04:47:12 +08:00
Maikel Linke
6ee27cd166 Fix spec to test the right report
Probably a copy&paste error. The PackingReport had exactly the same
spec.
2019-03-25 04:47:12 +08:00
Maikel Linke
dac4d4ff1a DRY report spec 2019-03-25 04:47:07 +08:00
luisramos0
2c97eaa62e Add missing translation key for order shipment state canceled 2019-03-24 15:33:14 +00:00
Transifex-Openfoodnetwork
b979a09478 Updating translations for config/locales/en_US.yml 2019-03-23 23:42:22 +11:00
Transifex-Openfoodnetwork
f050086d47 Updating translations for config/locales/pt.yml 2019-03-23 23:28:49 +11:00
Transifex-Openfoodnetwork
dc198b7b5d Updating translations for config/locales/pt.yml 2019-03-23 23:28:43 +11:00
Usama
698c71f039 Fixed producer profile translation bug 2019-03-22 18:25:40 -05:00
luisramos0
a8c0eef3d3 Improve admin variants controller create action, it doesn't try to set on_hand and on_demand if there are previous errors in the variant 2019-03-22 23:23:10 +00:00
luisramos0
78ea16c684 Remove unnecessary data-hooks from stock management deface override 2019-03-22 21:30:25 +00:00
luisramos0
01f82e5214 Move OrderSyncer spec to xdescribe until it is fixed as part of spree upgrade phase 2. This is a subscriptions specific spec 2019-03-22 13:06:45 +00:00
luisramos0
287ea6038a Remove distributors from product in completed_order_with_fees factory. This setter is no longer available after product distributions has been deleted 2019-03-22 11:50:24 +00:00
luisramos0
c1d14686a6 Merge branch 'master' into 2-0-stable-Mar22 2019-03-22 10:55:17 +00:00
Luis Ramos
6cd07cd107 Merge pull request #3605 from kristinalim/fix/2788-improve_specs_for_order_syncer
[Subscriptions] (v1) Fix assertions in specs for OrderSyncer
2019-03-22 10:31:01 +00:00
Luis Ramos
8d2d5a8708 Merge pull request #3579 from luisramos0/sanitize_data
Add sanitize and truncate data tasks
2019-03-22 10:29:57 +00:00
Pau Pérez Fabregat
846e6fdd90 Merge pull request #3560 from kristinalim/fix/2788-shipping_method_id_in_shipments
2696,2788 [Spree Upgrade] Fix use of shipping method ID for subscriptions
2019-03-22 11:08:23 +01:00
Pau Pérez Fabregat
deec4f83f8 Merge pull request #3633 from mkllnk/remove-product-distribution-from-sample-data
Remove usage of ProductDistribution which is dead
2019-03-22 10:54:59 +01:00
Pau Pérez Fabregat
4595ea033f Merge pull request #3624 from mkllnk/2873-spec-register-link
Add spec for registration link on Spree pages
2019-03-22 10:47:43 +01:00
Pau Pérez Fabregat
5b06f580e2 Merge pull request #3614 from mkllnk/3335-localized-number-for-weight-calculator
Support international decimals in weight calculator
2019-03-22 10:35:37 +01:00
Pau Pérez Fabregat
87f0ddabe7 Merge pull request #3548 from luisramos0/2-0-remove-unused-new-v2-features
[Spree Upgrade] Remove unused spree v2 features
2019-03-22 10:35:15 +01:00
Pau Perez
96b8c8ac2c Refresh products cache also on Variant#delete
Note that, as explained in
https://apidock.com/rails/v3.2.13/ActiveRecord/Relation/delete, `delete` does
not trigger callbacks and so it skips the products cache logic.

If we still want to avoid instantiating the AR object, we need to explicitly
call that logic for the cache to be up-to-date.
2019-03-22 09:57:15 +01:00
Pau Perez
b293e00777 Test that we refresh the cache on variant destroy
These tests prove that
https://github.com/openfoodfoundation/openfoodnetwork/issues/3629 is
indeed is a bug because we don't refresh the cache when deleting
a variant.
2019-03-22 09:38:24 +01:00
Pau Perez
fbc3fc6a51 Test spree/admin/variants_controller #destroy 2019-03-22 09:18:31 +01:00
Transifex-Openfoodnetwork
2ba10c416a Updating translations for config/locales/nb.yml 2019-03-22 07:41:18 +11:00
Kristina Lim
c222971e26 Clean up setup data for some OrderSyncer specs 2019-03-22 03:30:50 +08:00
Kristina Lim
0c2a75a227 Randomize bill and ship address of sample subscriptions
This also fixes some phone references in OrderSyncer specs.
2019-03-22 02:47:12 +08:00
Kristina Lim
7be669e1dd Add address factory with randomized attributes
Randomizing all addresses generated will be explored separately.
2019-03-22 02:45:50 +08:00
Kristina Lim
d047e04e33 Customize addresses for subscriptions in specs
This forces us to write correct assertions when adding specs affected by
subscription addresses.
2019-03-22 01:58:27 +08:00
Transifex-Openfoodnetwork
f0d985753f Updating translations for config/locales/fr.yml 2019-03-22 03:23:47 +11:00
Transifex-Openfoodnetwork
310b4a08b7 Updating translations for config/locales/fr.yml 2019-03-22 03:20:40 +11:00
luisramos0
e2f5515412 Fix sample data by setting on_demand in the product variant, setting product.on_demand is not possible in v2 2019-03-21 13:13:50 +00:00
luisramos0
88335c7f6c Fix sample data in v2 by adapting to the fact that shipping methods can now have multiple zones 2019-03-21 13:12:44 +00:00
luisramos0
98a262f86e Fix sample data in v2 by setting a Default shipping category in both products and shipping methods 2019-03-21 13:12:03 +00:00
Maikel Linke
42ee4b9f42 Remove usage of ProductDistribution which is dead
Sample data was failing since:
https://github.com/openfoodfoundation/openfoodnetwork/pull/3570
2019-03-21 13:11:05 +00:00
Kristina Lim
94606025c9 Separate call and call! for AdvanceOrderService 2019-03-21 20:34:51 +08:00
luisramos0
61433ee395 Make anonimize and truncate tasks respect rubocop rules 2019-03-21 11:16:56 +00:00
Maikel Linke
0b7192b82a Remove usage of ProductDistribution which is dead
Sample data was failing since:
https://github.com/openfoodfoundation/openfoodnetwork/pull/3570
2019-03-21 17:37:16 +11:00
Maikel Linke
3803094409 Add more examples to LocalizedNumber spec 2019-03-21 12:49:19 +11:00
Maikel Linke
3ef6878233 Avoid global state change by using config stub 2019-03-21 12:49:19 +11:00
Maikel Linke
1ea2f37c18 Support international decimals in weight calculator
A previous pull request added support for flexible decimal characters
when editing money amounts.
https://github.com/openfoodfoundation/openfoodnetwork/pull/1831

This pull request applies the same principle to the weight calculator
which was missed in the previous pull request.
2019-03-21 12:49:19 +11:00
Maikel
130ba64f2f Merge pull request #3619 from openfoodfoundation/dependabot/bundler/dalli-2.7.10
Bump dalli from 2.7.9 to 2.7.10
2019-03-21 12:47:29 +11:00
Maikel
f1ac33f304 Merge pull request #3590 from mkllnk/3576-bulk-order-spec
3576 Fix bulk order management race condition
2019-03-21 12:40:41 +11:00
Maikel Linke
d62908fd2d Add spec for registration link on Spree pages
The `registration_path` helper resolves to `/signup` in Spree
controllers due to spree_auth_device > config > routes.rb.
We worked around that in:
https://github.com/openfoodfoundation/openfoodnetwork/pull/3174

Here we add a spec for this so that we can test more easily if we
remove that workaround or detect it's accidental removal.
2019-03-21 10:06:15 +11:00
dependabot[bot]
6b01eba293 Bump oj from 3.7.10 to 3.7.11
Bumps [oj](https://github.com/ohler55/oj) from 3.7.10 to 3.7.11.
- [Release notes](https://github.com/ohler55/oj/releases)
- [Changelog](https://github.com/ohler55/oj/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ohler55/oj/compare/v3.7.10...v3.7.11)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-03-20 19:23:20 +00:00
dependabot[bot]
ee79f97aa0 Bump stripe from 4.9.0 to 4.10.0
Bumps [stripe](https://github.com/stripe/stripe-ruby) from 4.9.0 to 4.10.0.
- [Release notes](https://github.com/stripe/stripe-ruby/releases)
- [Changelog](https://github.com/stripe/stripe-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/stripe/stripe-ruby/compare/v4.9.0...v4.10.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-03-20 19:22:18 +00:00
Kristina Lim
d3c2d1859c Update all locales with the latest Transifex translations 2019-03-21 01:56:45 +08:00
Kristina Lim
b942dc1074 Merge pull request #3628 from openfoodfoundation/transifex
Transifex
2019-03-21 01:52:58 +08:00
Transifex-Openfoodnetwork
08894c242c Updating translations for config/locales/en_GB.yml 2019-03-21 04:04:33 +11:00
Transifex-Openfoodnetwork
eeb8f12b4e Updating translations for config/locales/en_GB.yml 2019-03-21 04:01:27 +11:00
Transifex-Openfoodnetwork
79eb89ac0b Updating translations for config/locales/en_GB.yml 2019-03-21 03:58:20 +11:00
Luis Ramos
61c778eeac Merge pull request #3555 from luisramos0/2-0-fix-order-state-translations
[Spree Upgrade] Improve order state translations in v2
2019-03-20 12:26:35 +00:00
Luis Ramos
59af77eb0e Merge pull request #3620 from mkllnk/3520-customers-spec
Fix flaky spec by waiting for modal animation
2019-03-20 12:02:11 +00:00
luisramos0
3841656979 Rename data sanitize task to data anonymize 2019-03-20 11:58:26 +00:00
luisramos0
fefced5400 Improve sanitize data: keep customers connected to users and let addresses' city and zipcode remain as they are 2019-03-20 11:49:55 +00:00
luisramos0
804375d1aa Delete obsolete pending delayed jobs related to the deleted account invoices feature 2019-03-20 11:24:57 +00:00
luisramos0
78d7222364 Drop account invoices and billable periods tables, the feature has been deleted 2019-03-20 11:19:48 +00:00
luisramos0
c0c14b16b6 Remove dynamic monthly pricing description that would come from the deleted business model configurations 2019-03-20 11:19:04 +00:00
Maikel
0f5e6474b8 Merge pull request #3602 from luisramos0/2-0-shipments-stock-location
[Spree Upgrade] Add migrations necessary to successfully migrate data to v2
2019-03-20 21:36:45 +11:00
Pau Pérez Fabregat
98a2e87587 Merge pull request #3610 from luisramos0/2-0-stable-Mar16
[Spree Upgrade] Merging master into 2-0-stable (2nd run in Mar2019)
2019-03-20 09:33:07 +01:00
Pau Pérez Fabregat
4f82808243 Merge pull request #3617 from luisramos0/edit-variants-specs
Add spec to cover editing on_hand and on_demand values in the variants edit page
2019-03-20 09:13:56 +01:00
Pau Pérez Fabregat
2a3a935c16 Merge pull request #3570 from luisramos0/byebye-prod-distributions
Delete dead feature product distributions
2019-03-20 09:01:23 +01:00
Maikel Linke
a66eb7fe1d Add spec for registration link on Spree pages
The `registration_path` helper resolves to `/signup` in Spree
controllers due to spree_auth_device > config > routes.rb.
We worked around that in:
https://github.com/openfoodfoundation/openfoodnetwork/pull/3174

Here we add a spec for this so that we can test more easily if we can
remove that workaround or detect it's accidental removal.
2019-03-20 15:02:30 +11:00
Maikel Linke
aef5cebeed Fix flaky spec by waiting for modal animation
Without waiting, `fill_in` can fail randomly:
https://github.com/teamcapybara/capybara/issues/1890
2019-03-20 12:15:01 +11:00
dependabot[bot]
b0854b6d51 Bump dalli from 2.7.9 to 2.7.10
Bumps [dalli](https://github.com/petergoldstein/dalli) from 2.7.9 to 2.7.10.
- [Release notes](https://github.com/petergoldstein/dalli/releases)
- [Changelog](https://github.com/petergoldstein/dalli/blob/master/History.md)
- [Commits](https://github.com/petergoldstein/dalli/compare/v2.7.9...v2.7.10)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-03-18 19:21:33 +00:00
luisramos0
21a10d0206 Add on_hand and on_demand back to variants form (both variant create and edit pagei), this is where they used to be in spree v1
The admin variants controller create action is adapted (same as in the admin ProductsController). This is necessary because variant.on_hand and on_demand cannot be mass assigned on creation in v2, see VariantStock for more details.

For now we are hiding the new stock management page that comes in spree v2 as we don't need the complexity added by the management of stock per stock location (only one stock location in ofn v2 for now)
2019-03-18 19:02:48 +00:00
luisramos0
9194a711ea De-deface product tabs
We do not include stock management from v2 because we will use the variants edit page to manage on_hand and on_demand
2019-03-18 18:47:25 +00:00
luisramos0
90a14d426b Add spec to cover editing on_hand and on_demand values in the variants edit page 2019-03-18 17:04:59 +00:00
luisramos0
9fff795162 Fix typo in en.yml in key new_shipping_category 2019-03-18 17:04:59 +00:00
luisramos0
b148b9ae46 Remove delete addresses SQL from truncate task 2019-03-18 12:04:37 +00:00
Pau Pérez Fabregat
fb29a7c7c2 Merge pull request #3606 from openfoodfoundation/dependabot/bundler/oj-3.7.10
Bump oj from 3.7.9 to 3.7.10
2019-03-18 12:12:13 +01:00
luisramos0
22a051e720 Enable products cache by default only in staging and production
We keep tests running by default without cache, keeping it as it was before 10a79d5a65

Additionally, cached_products_renderer no longer depends on Rails.env, so here we remove that dependency from it's spec.
2019-03-17 15:03:15 +00:00
luisramos0
60ee17204b Merge branch 'master' into 2-0-stable-Mar16 2019-03-16 16:17:38 +00:00
Kristina Lim
7505dd0410 Make order sync for shipping methods readable 2019-03-15 07:59:54 +11:00
dependabot[bot]
d7b25d63f9 Bump oj from 3.7.9 to 3.7.10
Bumps [oj](https://github.com/ohler55/oj) from 3.7.9 to 3.7.10.
- [Release notes](https://github.com/ohler55/oj/releases)
- [Changelog](https://github.com/ohler55/oj/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ohler55/oj/compare/v3.7.9...v3.7.10)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-03-14 19:25:55 +00:00
Kristina Lim
3ab00d862e Create subscriptions with set up shipping methods
The shipping methods are updated to their target settings after the
subscription order has been created, so the order is created with the
"require_ship_address" factory default which is "true".

The shipping method setting at time of order creation has implications
on whether a shipment is set up for the order or not.
2019-03-15 03:15:55 +08:00
Kristina Lim
ba100a6522 Specify order addresses in some OrderSyncer specs
This is to check that we are using the correct address data in
assertions.

This also clarifies the scenario for one of the specs.
2019-03-15 03:15:55 +08:00
Kristina Lim
7200e2c2c2 Specify hub address in some OrderSyncer specs
This fixes some assertions from using the same subscription shipping and
billing addresses, and distributor address.

One of the specs also pass because the subscription shipping address
matches the distributor address. This commit makes that scenario
clearer.
2019-03-15 03:15:55 +08:00
Kristina Lim
ad935e8d66 Require spec_helper.rb for OrderSyncer specs 2019-03-15 03:15:54 +08:00
Pau Pérez Fabregat
75abd4586e Merge pull request #3583 from coopdevs/handle-deleted-oc-refreshing-cache
Handle deleted order cycle when refreshing cache
2019-03-14 20:11:14 +01:00
Pau Pérez Fabregat
33b74bef0e Merge pull request #3599 from coopdevs/add-nl_BE-belgium
Bring in latest nl_BE translations
2019-03-14 18:59:57 +01:00
Pau Pérez Fabregat
baacea9f6a Merge pull request #3595 from coopdevs/instrument-products-cache
Instrument products cache
2019-03-14 18:58:43 +01:00
Pau Perez
e60437c6a2 Refactor test to execute public API instead 2019-03-14 18:53:11 +01:00
Pau Perez
b9636b975a Refactor test to stop using .any_instance
Although might be useful in very particular cases its use is discourage
by RSpec itself. See https://relishapp.com/rspec/rspec-mocks/docs/working-with-legacy-code/any-instance
2019-03-14 18:53:11 +01:00
Pau Perez
bc34d04c31 Do not retry when refreshing cache on deleted OC 2019-03-14 18:53:11 +01:00
luisramos0
cb78f8f8c8 Fetch latest nl_BE translations from transifex with correct menu links 2019-03-13 23:29:40 +00:00
Pau Perez
fede58289b Move Cache::Store config to new initializer
I don't know why but `Rails.logger` is still nil when evaluated from
`configure` block in `config/environments/development.rb`. The only way
I found to make ActiveSupport's cache to use the default logger is from
an initializer.

Note that `ActiveSupport::Cache::Store` uses `debug` level and so we
need to set the dev logger in that same level to see its messages. If
you want to debug in staging as well, you'll need to modify the log
level manually.
2019-03-13 19:08:46 +01:00
Pau Perez
15a95a3bf5 Use :file_store cache store in development
:memory_store uses the process' memory and therefore, what the
background job writes is not reachable for the rails server process when
it reads from the cache. See
https://github.com/openfoodfoundation/openfoodnetwork/wiki/Products-cache#development.
2019-03-13 19:08:46 +01:00
Pau Perez
10a79d5a65 Decouple CachedProductsRenderer from the Rails env
This way we don't need to touch the class implementation to enable the
products cache in development. Just change the default value in
`app/models/spree/app_configuration_decorator.rb`.
2019-03-13 19:08:46 +01:00
Pau Pérez Fabregat
13b2115a29 Merge pull request #3581 from coopdevs/cache-stylistic-improvements
Cache stylistic improvements
2019-03-13 19:05:38 +01:00
luisramos0
8965dedfd7 Add sanitize and truncate tasks to support loading live data into other environments safely 2019-03-13 16:08:07 +00:00
luisramos0
0bfeabbb3e Add migration to create default shipping category and set it in shipping methods and products that do not have a shipping category yet
This is a modified version of this spree migration: af16cf1d74
2019-03-13 15:36:21 +00:00
luisramos0
f914a6d869 Add migration to set default stock location on all shipments without stock location
This is a modified version of this spree migration: https://github.com/spree/spree/commit/219e09b
2019-03-13 14:38:56 +00:00
luisramos0
786ba15174 Remove unused translation 2019-03-13 12:24:40 +00:00
luisramos0
7a2bc384d5 Re-add spec removed in product distributions removal but now adapted to use order cycles 2019-03-13 12:24:40 +00:00
luisramos0
34d7070c6c Delete spec used to test product distributions (removed feature) 2019-03-13 12:24:40 +00:00
luisramos0
b62e350fab Improve reports controller decorator by removing some copy pasted code and deleting some code repeated across data_load and the main action methods 2019-03-13 12:24:40 +00:00
luisramos0
2401b947b9 Make load sample data rake task work without product distributions 2019-03-13 12:24:40 +00:00
luisramos0
05d42d475e Make reports and subscriptions specs work without product.distributors attribute 2019-03-13 12:24:40 +00:00
luisramos0
2de6c46834 Make order.order_cycle required in cart_service. There’s no more exception for that without product_distributions. 2019-03-13 12:24:40 +00:00
luisramos0
4768ca27c7 Remove all dependencies to product distributions including the validation to avoid deleting fees with product distributions 2019-03-13 11:50:35 +00:00
luisramos0
3117dbf624 Remove product distributions from order model 2019-03-13 11:50:35 +00:00
luisramos0
a022cebfc8 Remove product distributions from enterprise model and controller 2019-03-13 11:49:13 +00:00
luisramos0
ed9321e92d Remove product distributions from product model and controller 2019-03-13 11:47:50 +00:00
luisramos0
86f9b3d663 Delete product_distributions: drop table and remove models, controllers and BO edit page 2019-03-13 11:47:50 +00:00
Kristina Lim
8782f2087c Use service in admin/payments#create
This separates logic for bang and non-bang versions of
Spree::Order#next.

The different conditions used in both methods (state == "completed" vs
order.completed?) have implications in whether a transition is attempted
or not.
2019-03-13 17:00:31 +11:00
Kristina Lim
0e691815ea Use service in admin/orders/customer_details#update 2019-03-13 12:45:57 +08:00
Kristina Lim
abaf90fc41 Copy more actions advancing order from Spree
This copies the following:

* admin/orders/customer_details#update
* admin/payments#create
2019-03-13 12:45:57 +08:00
Kristina Lim
56e2ee5366 Fix specs for OrderSyncer 2019-03-13 12:45:56 +08:00
Kristina Lim
0cfee37567 Fix setup records for SubscriptionPlacementJob specs 2019-03-13 12:45:56 +08:00
Kristina Lim
7c3433425f Fix setup records for OrderFactory specs 2019-03-13 12:45:55 +08:00
Kristina Lim
182fde58e5 Uncomment now passing tests related to subscriptions 2019-03-13 12:45:55 +08:00
Kristina Lim
a261d912ea Simplify order sync logic for shipping methods 2019-03-13 12:45:54 +08:00
Kristina Lim
9316096d4d Fix updating of the shipping method for an order 2019-03-13 12:45:54 +08:00
Kristina Lim
5b5d1967fd Fix queries for pending order shipment in OrderSyncer 2019-03-13 12:45:53 +08:00
Kristina Lim
54991f8191 Retain shipping method when transitioning order 2019-03-13 12:45:53 +08:00
Kristina Lim
7a8bf76123 Move transitioning of order in admin/orders#edit to service 2019-03-13 12:45:50 +08:00
Maikel Linke
d129665d43 Wait for orders being loaded in bulk order manage
The bulk order management page tried to wait for orders being loaded.
But instead of receiving a request object with an a promise to wait for
the page received a simple array without promise. As a result, the page
didn't wait for orders being loaded.

When loading of orders took longer than loading of line items they or at
least not all of them were enriched with distributors and order cycles
and the line items were missing some orders. That lead to random spec
failures.
2019-03-13 10:37:24 +11:00
luisramos0
7c39c45f79 Stop using inexistent en.order_state translations keys and use existing en.spree.order_state in haml code and new js.admin.orders.order_state in JS code 2019-03-12 19:42:08 +00:00
luisramos0
77655bfffb Rename resource content to contents so that it matches the name of the controller ContentsController. This makes the is_active logic work on the configuration menu
See the menu is_active code here: f55722b38d/backend/app/helpers/spree/admin/navigation_helper.rb (L145)
2019-03-12 19:11:37 +00:00
luisramos0
bd9eba9ef8 Fix add_uniqueness_of_order_id_to_spree_shipments by first removing shipments from orders with more than one shipment 2019-03-12 18:00:06 +00:00
luisramos0
0c8c4be2ee Fix migrate tax categories to line items migration
This is bringing 67186f8ca7 from spree v2.2
2019-03-12 17:59:55 +00:00
luisramos0
2295981375 Merge branch '2-0-stable' into 2-0-remove-unused-new-v2-features 2019-03-12 16:55:48 +00:00
Pau Pérez Fabregat
2dd55770fe Merge pull request #3569 from luisramos0/delete-more-overrides
Delete some more dead overrides and more dead code
2019-03-12 17:48:12 +01:00
Pau Pérez Fabregat
01baba336d Merge pull request #3575 from openfoodfoundation/dependabot/bundler/unicorn-5.5.0
Bump unicorn from 5.4.1 to 5.5.0
2019-03-12 17:30:56 +01:00
Pau Perez
c4fcc25faa Bring in latest nl_BE translations
As we didn't reach 100% translation Transifex does not sync the changes
into the repo. However, the Belgian instance still needs it.
2019-03-12 15:30:52 +01:00
Kristina Lim
ce5691d080 Copy admin/orders#edit from Spree controller
This method needs to be updated to use custom order advance logic in
service.
2019-03-12 18:31:27 +08:00
Kristina Lim
f42eb3dab1 Create shipment when creating a order for a subscription
A spec has been added to check that the attributes for the order states
after "cart" ("address", "delivery", "payment") are retained if the
order is transitioned to completion, BUT currently this is passing
because it is the only shipping method available.
2019-03-12 18:31:27 +08:00
Kristina Lim
0306cc7ca7 Set shipping method when creating order for subscription 2019-03-12 18:31:26 +08:00
Kristina Lim
5f571aad2f Set required ship address in order in spec
The ship address of the order is properly set in
ProxyOrder#initialise_order! through OrderFactory.

The source of these spec failures seem to be a matter of how the records
are set up for the tests.
2019-03-12 18:31:26 +08:00
Maikel Linke
7270a9e8e8 DRY date calculation in BOM js
This also minimises the risk of values changing in the meantime.
2019-03-12 18:59:14 +11:00
Maikel
6722f21cb0 Merge pull request #3593 from openfoodfoundation/transifex
Transifex
2019-03-12 16:01:28 +11:00
Maikel
b94c6c1fb6 Merge pull request #3580 from luisramos0/2-0-stable-Mar6
[Spree Upgrade] Merging master into 2-0-stable (1st run in Mar2019)
2019-03-12 11:44:41 +11:00
Maikel Linke
49a6b5224d Remove duplicate expectations from spec 2019-03-12 11:35:06 +11:00
Maikel Linke
af9e80e55d Load data after all callbacks are installed 2019-03-12 09:46:27 +11:00
Maikel Linke
0c6a5d730b Add spaces around HAML brackets 2019-03-12 09:12:10 +11:00
Maikel Linke
6f875e83ec Remove unconventional and unused ng:cloak selector 2019-03-12 09:10:39 +11:00
Maikel Linke
9e33ef8140 Style ng-cloak directive 2019-03-12 09:09:52 +11:00
Maikel Linke
30c1a8d924 Move ng-cloak CSS to components 2019-03-12 08:59:59 +11:00
Pau Perez
931cb89a9d Move new class to services and rename it 2019-03-11 18:28:25 +01:00
Transifex-Openfoodnetwork
46f16c060b Updating translations for config/locales/en_US.yml 2019-03-12 00:38:22 +11:00
Transifex-Openfoodnetwork
8afd5e7050 Updating translations for config/locales/nb.yml 2019-03-09 06:33:01 +11:00
Luis Ramos
f6ecf3de64 Merge pull request #3568 from luisramos0/2-0-improve-order-factories
[Spree Upgrade] Improve order factories
2019-03-08 09:43:26 +00:00
Maikel Linke
4574a770d3 Synchronise dereferencing and initilising
This seems to make the spec 4 times more reliable. Still failing from
time to time.
2019-03-08 17:36:25 +11:00
Maikel Linke
e00a3ee263 Use clearer and more reliable waiting in spec 2019-03-08 17:24:31 +11:00
Maikel Linke
52fd7b102e Unify visiting bulk order management
DRYing the code allows for easier refactor and more consistency.
2019-03-08 14:46:58 +11:00
Maikel Linke
37d37a6057 Speed up initial spec log in 2019-03-08 14:46:39 +11:00
Maikel Linke
2d7498b77b Hide elements before Angular is loaded
The "Loading orders" spinner is still visible from the beginning so that
it can be used as indicator for when the page is loaded.

Before, the "No orders found" message was visible between page load and
Angular initilisation.
2019-03-08 14:23:18 +11:00
Maikel
22bac3daaf Merge pull request #3588 from openfoodfoundation/transifex
Transifex
2019-03-08 11:31:36 +11:00
Maikel
608c322770 Merge pull request #3585 from mkllnk/1829-missing-translation-product-category
1829 missing translation product category
2019-03-08 10:10:09 +11:00
luisramos0
61f1bf5ec8 Fix shipping_methods edit page missing translation 2019-03-07 17:15:06 +00:00
Transifex-Openfoodnetwork
2eb3b7acea Updating translations for config/locales/fr.yml 2019-03-08 04:06:14 +11:00
Transifex-Openfoodnetwork
66d6936452 Updating translations for config/locales/en_GB.yml 2019-03-08 01:36:28 +11:00
Pau Pérez Fabregat
f125686016 Merge pull request #3511 from coopdevs/update-bugsnag-notifier-library
Update Bugsnag from 5.5.0 to 6.11.1
2019-03-07 11:30:04 +01:00
Maikel Linke
972ebb5fc9 Fix missing translation by using AR default
Using the default fixes a missing translation. The text is slightly
changed but should be okay as well:

- "^Tax Category is required"
+ "Tax category can't be blank"
2019-03-07 11:54:04 +11:00
Maikel Linke
5ed13d1539 Fix translation by using ActiveRecord's default
Our translations are not available when decorators are loaded. The
message for a missing product category was missing:
https://github.com/openfoodfoundation/openfoodnetwork/issues/1829

I moved the translation to ActiveRecord's default scope so that it can
be picked up automatically.
2019-03-07 11:37:54 +11:00
Matt-Yorkley
3f6a6f7f33 Merge pull request #3572 from openfoodfoundation/transifex
Transifex
2019-03-07 00:17:49 +00:00
Matt-Yorkley
59fd5ce478 Merge branch 'master' into transifex 2019-03-07 00:17:14 +00:00
Matt-Yorkley
4fe7d276b4 Update all locales with the latest Transifex translations 2019-03-07 00:04:09 +00:00
Maikel Linke
f033cfcc12 Remove obsolete Bugsnag option
It prevents the app from booting with the new Bugsnag version.
2019-03-07 10:04:20 +11:00
Pau Perez
8db6560fe7 Update Bugsnag from 5.5.0 to 6.11.1
This brings lots of fixes and a great dose of enhancements such as
a rewritten `Delayed::Job` integration.
2019-03-07 10:03:43 +11:00
Maikel
4780a2193f Merge pull request #3209 from mkllnk/2072-test-data
2072 New sample data for testing
2019-03-07 08:49:12 +11:00
Pau Pérez Fabregat
e850182f95 Merge pull request #3563 from kristinalim/fix/3562-fix_payment_fee_for_order_based_calculator
3562 Fix error calculating payment fee using order-based calculator
2019-03-06 19:31:49 +01:00
Pau Pérez Fabregat
9f8d90cc0a Merge pull request #3305 from coopdevs/improve-shops-performance-take-2
Improve shops performance take 2
2019-03-06 16:25:28 +01:00
Transifex-Openfoodnetwork
9922ce070e Updating translations for config/locales/es.yml 2019-03-07 02:22:03 +11:00
Pau Perez
347aa3c4ae Replace #valid_products_distributed_by by class 2019-03-06 15:06:00 +01:00
Pau Perez
adb40d6c73 Test just the public method
This one is the one calling the private method that was tested now. It
involves some refactoring of the specs as well.
2019-03-06 13:38:53 +01:00
Pau Perez
7c533c6347 Extract DistributedValidProducts from OrderCycle 2019-03-06 13:35:43 +01:00
luisramos0
2470830ec8 Fix jquery ui merge mistake, it should be jquery.ui.all in v2, not jquery-ui 2019-03-06 11:28:50 +00:00
luisramos0
9644fcf67c Improve payment method factory in sample data by removing constantize 2019-03-06 10:01:17 +00:00
Pau Perez
2b58aab197 Extract method from cache key generation 2019-03-06 10:49:56 +01:00
Pau Perez
bbfd35c861 Fix CacheSettingsController violations 2019-03-06 10:45:45 +01:00
luisramos0
b325cea6cb Merge branch 'master' into 2-0-stable-Mar6 2019-03-06 09:19:53 +00:00
Transifex-Openfoodnetwork
0e2d303701 Updating translations for config/locales/ca.yml 2019-03-06 20:00:41 +11:00
Pau Pérez Fabregat
7e06807a11 Merge pull request #3539 from Matt-Yorkley/subs/confirmation_email
Don't process proxy_order if the order has been cancelled
2019-03-05 17:38:29 +01:00
Pau Pérez Fabregat
3ddee83be5 Merge pull request #3404 from luisramos0/2-0-disable-cache
[Spree Upgrade] Add checkbox to disable products cache
2019-03-05 14:51:11 +01:00
Pau Pérez Fabregat
30bbc5ee6f Merge pull request #3472 from pacodelaluna/fix-datetime-picker
Fix datetime picker on Order Cycle form
2019-03-05 14:50:34 +01:00
Pau Pérez Fabregat
b330db3b4b Merge pull request #2947 from Matt-Yorkley/pi/submenu_link
Pi/submenu link
2019-03-05 14:49:02 +01:00
Transifex-Openfoodnetwork
03aaea2a08 Updating translations for config/locales/ca.yml 2019-03-05 21:52:24 +11:00
dependabot[bot]
6ecb9cc848 Bump unicorn from 5.4.1 to 5.5.0
Bumps [unicorn](https://bogomips.org/unicorn/) from 5.4.1 to 5.5.0.

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-03-04 19:18:03 +00:00
Luis Ramos
72e9c1d002 Merge pull request #3321 from luisramos0/2-0-delete-acct-invoices
[Spree Upgrade] Delete Accounts and Billing dead feature code until we decide we want to start using it again
2019-03-04 15:54:09 +00:00
Pau Pérez Fabregat
2369c54f9d Merge pull request #3552 from luisramos0/2-0-fix-stock-migration
[Spree Upgrade] Fix create default stock migration
2019-03-04 12:07:18 +01:00
Transifex-Openfoodnetwork
5ddb8fb1ae Updating translations for config/locales/nb.yml 2019-03-04 21:22:36 +11:00
Pau Perez
54e120889f Remove useless array wrapping on AR relation 2019-03-04 11:08:34 +01:00
luisramos0
5ab4ae88f5 Remove distribution change in order_spec, order distributor cannot be changed, if distributor or oc is changed, the order is emptied 2019-03-02 13:08:39 +00:00
luisramos0
7ac4a99bc7 Remove product distributions spe that needed distribution_change_validator. Product distributions will be removed soon, see https://github.com/openfoodfoundation/openfoodnetwork/issues/3525 2019-03-02 13:08:39 +00:00
luisramos0
d7bd944af3 Fix distribution_change_validator spec 2019-03-02 13:08:35 +00:00
luisramos0
351555d4e2 Remove unused methods from add_to_cart helper and distribution change validator 2019-03-02 12:55:08 +00:00
luisramos0
93e13742be Delete some more dead overrides. We are not using spree/checkout (except for /checkout/payment) nor spree/products 2019-03-01 23:56:03 +00:00
luisramos0
d840fa7b77 Improve order factories:
- Make order_with_totals_and_distribution shorter by inheriting from order_with_distributor
- Make completed_order_with_fees more correct by inheriting only from order_with_distributor: this removes the line_item_with_shipment of order_with_totals_and_distribution that was causing an extra shipping adjustment to be kept in the order. This adjustment was being tested in the order controller spec (fixed the explanation comment in the spec which was wrong, there was no enterprise fee in this order)
2019-03-01 20:00:58 +00:00
Pau Pérez Fabregat
6c83f67b86 Merge pull request #3556 from Matt-Yorkley/pi/template
Add description to CSV template
2019-03-01 11:37:58 +01:00
Maikel
a14c785e69 Merge pull request #3435 from Matt-Yorkley/bug/tmpfile
Use Dir::Tmpname.make_tmpname for threadsafe file naming
2019-03-01 10:20:26 +11:00
Maikel
54679f6651 Merge pull request #3535 from luisramos0/translations-for-v2
Move to master all en.yml entries added so far to v2 and add more missing v2 translations
2019-03-01 10:04:13 +11:00
luisramos0
e4edfe0b61 Merge branch 'master' into translations-for-v2 2019-02-28 21:32:34 +00:00
Pau Pérez Fabregat
88e6fa84a2 Merge pull request #3534 from luisramos0/registration_trans_all
Move registration process translations to lazy lookups to better organize the en.yml file
2019-02-28 17:15:09 +01:00
Pau Pérez Fabregat
aa635106ac Merge pull request #3531 from mkllnk/document-stock-validation-rules
Document stock validation of variant overrides
2019-02-28 17:14:45 +01:00
Pau Pérez Fabregat
89708de7c1 Merge pull request #3512 from kristinalim/fix/3478-scope_enterprise_fee_summary_to_eligible
3466,3478 [Enterprise Fee Summary] Scope report to eligible: true and non-zero adjustments
2019-02-28 17:14:15 +01:00
Pau Pérez Fabregat
6f0479c27d Merge pull request #3547 from openfoodfoundation/dependabot/bundler/combine_pdf-1.0.16
Bump combine_pdf from 1.0.15 to 1.0.16
2019-02-28 17:13:50 +01:00
Pau Pérez Fabregat
63312a6d5f Merge pull request #3554 from coopdevs/bring-bugsnag-initializer
Bring in Bugsnag initializer from ofn-install
2019-02-28 16:41:59 +01:00
Kristina Lim
36e4a22b58 Use delegate for Payment#line_items 2019-02-28 09:52:56 +08:00
Kristina Lim
bd58667747 Remove stock check done for payment fees 2019-02-28 09:24:29 +08:00
Maikel Linke
958e98debd Document stock validation of variant overrides 2019-02-28 12:21:26 +11:00
Kristina Lim
ce658e9dfa Fix error computing payment fee when order-based 2019-02-28 12:17:45 +11:00
Kristina Lim
dfc8cc0f9e Add failing test for calculation of payment fee 2019-02-28 12:17:44 +11:00
Maikel
4ed0831e4c Merge pull request #3550 from openfoodfoundation/transifex
Transifex
2019-02-28 11:39:57 +11:00
Luis Ramos
f502ba0a1f Merge pull request #3504 from luisramos0/2-0-scoping
[Spree Upgrade] Add spec to order_cycle model covering variant scoping
2019-02-28 00:09:10 +00:00
Maikel
824beba066 Merge pull request #3505 from luisramos0/vo-false
Adapt scope_variant_to_hub to new VO rules where on_demand=nil means use_producer_settings
2019-02-28 10:26:23 +11:00
Maikel
c472d2fbbe Merge pull request #3498 from luisramos0/delete-dead-overrides
Remove dead overrides
2019-02-28 10:25:42 +11:00
luisramos0
03d242c061 Fix typo in sample_data zone creation (zonEable) and added clause to avoid re-adding the same country to the zone 2019-02-27 23:19:39 +00:00
Maikel
65ba9324de Merge pull request #3513 from luisramos0/2-0-remove-variant-count-on-hand
[Spree Upgrade] Remove variant.count_on_hand (keep variant.on_hand only)
2019-02-28 09:07:41 +11:00
luisramos0
ad5c379771 Make sample data zone read from the environment variable CHECKOUT_ZONE 2019-02-27 09:46:18 +00:00
luisramos0
d418ca1b1f Add mandatory payment method provider to sample data payment methods 2019-02-27 09:45:21 +00:00
Pau Pérez Fabregat
a04de6e3cd Merge pull request #3499 from openfoodfoundation/dependabot/bundler/stripe-4.9.0
Bump stripe from 4.5.0 to 4.9.0
2019-02-27 09:56:32 +01:00
Danni M
5b880f7bfe Update issue templates
Fixed headings on the story template
2019-02-27 10:41:39 +11:00
François Turbelin
82fbcd35a8 Update tests 2019-02-26 22:07:11 +01:00
Matt-Yorkley
9dd5b9dd6c Fix import button specificity in feature spec 2019-02-26 20:06:02 +00:00
Matt-Yorkley
25e2d2adda Update references to product_sub_menu view 2019-02-26 20:06:01 +00:00
Matt-Yorkley
777850259b Apply and delete overrides 2019-02-26 19:42:47 +00:00
Matt-Yorkley
f1e55507c3 Recreate product_sub_menu Spree view 2019-02-26 19:42:47 +00:00
Matt-Yorkley
32470f33ec Add description to CSV template 2019-02-26 19:36:44 +00:00
luisramos0
3f3581cdbc Add more missing translations for v2, remove unnecessary en.order_state and remove duplicated en.spree.payment_states and en.spree.shipment_states 2019-02-26 16:54:48 +00:00
Pau Perez
4d47276810 Bring Bugsnag initializer from ofn-install
This copies ofn-install's `roles/app/templates/bugsnag.rb.j2` to
`config/initializers/bugsnag.rb`. All tasks and templates
regarding Bugsnag can then be 🔥 from ofn-install.

As a result, it'll fix the issue that both Katuma and OFF are facing
where the `config/initializer/bugsnag.rb` symlink to
`shared/config/bugsnag.rb` does not exist thus, nothing gets notified to
Bugsnag since December 3rd (according to customer support).
2019-02-26 17:52:49 +01:00
luisramos0
4411e1ed43 Fix create default stock migration by adding a version of the code that works with the DB at that point in time, i.e., stock_locations without active column 2019-02-26 16:05:33 +00:00
luisramos0
7b05eebc5b Fix rubocop issue in db migration 2019-02-26 14:54:24 +00:00
luisramos0
a0594f7616 Re-add invoice settings controller removed by mistake 2019-02-26 14:14:17 +00:00
luisramos0
a36722cebf Merge branch '2-0-stable' into 2-0-remove-variant-count-on-hand 2019-02-26 12:47:11 +00:00
luisramos0
37685c8107 Move the code that hides the split order button from js to css 2019-02-26 12:34:07 +00:00
Pau Perez
a728da4f62 Cover product and producer props. in ctrl. spec 2019-02-26 12:09:26 +01:00
Pau Perez
915b5cf09e Inline also the active product properties query
This makes it easier to spot what are the differences and similarities
between active and non-active, which in turn, it'll help remove the N+1
the "active" branch causes.

Make it look `#distributed_producer_properties` with which seems to
share a lot.
2019-02-26 11:39:43 +01:00
Pau Perez
19cbda4128 Fix Rubocop violation 2019-02-26 11:39:43 +01:00
Pau Perez
24c031b3cd Extract #distributed_product_properties method 2019-02-26 11:39:43 +01:00
Pau Perez
6e9bb640f6 Add spacing between long scopes 2019-02-26 11:36:36 +01:00
Pau Perez
7b2d4f10ee Cover #distributed_properties \w a controller spec
This exercises the controller and the serializer ensuring the
integration works allowing to confidently refactor things further.
2019-02-26 11:36:36 +01:00
Pau Perez
e55fbf80fc Check property presentation attribute only in test
The PropertySerializer contains :id, :name and :presentation attributes
which leads to JSON objects like `{"id": 1, "name": "foo",
"presentation": "foo"}`. Because of this, we don't care about object
identity, just about their presentation attribute.
2019-02-26 11:36:36 +01:00
Pau Perez
d4635bd7cb Fetch Property instead of ProducerProps from query
By not having to treat producer properties differently we can filter and
fetch all properties from DB without having to process it with Ruby and
with a single query.
2019-02-26 11:36:36 +01:00
Pau Perez
92e2ed78d1 Test active distributor as well 2019-02-26 11:36:36 +01:00
Pau Perez
8eb35e491d Don't fetch rows by ids of DISTINCT records
There's no point on fetching the same records again by the resulting ids
of the previous query (nasty way of removing duplicates), when that
query has a DISTINCT.
2019-02-26 11:36:36 +01:00
Pau Perez
328cda66f5 Stop using PropertyMerge in serializer 2019-02-26 11:36:36 +01:00
Pau Perez
47a90e937b Have a duplicate product to test with 2019-02-26 11:36:36 +01:00
Pau Perez
8fef69387e Simplify test setup using factory transient attrs 2019-02-26 11:36:36 +01:00
Pau Perez
0782907f4d Setup a test order cycle with its exchanges 2019-02-26 11:36:36 +01:00
Pau Perez
64fb230297 Make it more obvious we talk about an enterprise 2019-02-26 11:36:36 +01:00
Pau Perez
a5f890cf36 Fix styling on method 2019-02-26 11:36:36 +01:00
Transifex-Openfoodnetwork
539544de28 Updating translations for config/locales/es.yml 2019-02-26 20:49:18 +11:00
Transifex-Openfoodnetwork
595fb75d82 Updating translations for config/locales/es.yml 2019-02-26 20:46:12 +11:00
luisramos0
15456577a3 Remove the button that enables user to split an order between stock locations
There's only one stock location in OFN so this feature is not useful at this point
2019-02-25 23:39:21 +00:00
luisramos0
ebf825e349 De-deface configuration menu
Remove stock locations and stock transfers from the menu
2019-02-25 23:38:50 +00:00
François Turbelin
e1953c279b Move jquery-ui-timepicker libs to vendor dir 2019-02-25 22:48:30 +01:00
François Turbelin
ab86332949 Tune up config and style 2019-02-25 22:22:27 +01:00
François Turbelin
68fd6de39b Update Jquery datetimepicker lib to v1.6.3 2019-02-25 22:22:27 +01:00
dependabot[bot]
a1647053cb Bump combine_pdf from 1.0.15 to 1.0.16
Bumps [combine_pdf](https://github.com/boazsegev/combine_pdf) from 1.0.15 to 1.0.16.
- [Release notes](https://github.com/boazsegev/combine_pdf/releases)
- [Changelog](https://github.com/boazsegev/combine_pdf/blob/master/CHANGELOG.md)
- [Commits](https://github.com/boazsegev/combine_pdf/compare/v1.0.15...v1.0.16)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-02-25 19:26:41 +00:00
luisramos0
8a59e06d36 Remove buttons 'open/close all adjustments' from order adjustments edit page
We may re-add this feature in the future, we are not introducing the capacity to open/close adjustments in OFN. See https://github.com/openfoodfoundation/openfoodnetwork/issues/1830 for context
2019-02-25 16:42:22 +00:00
luisramos0
0501db1782 Remove changes related to enterprise trials as they dont make sense without business models and account invoices 2019-02-25 14:37:16 +00:00
luisramos0
a870299ced Delete preferences and adjustments related to account invoices 2019-02-25 14:37:16 +00:00
luisramos0
36e2786a1e Delete Accounts and Billing dead feature code 2019-02-25 14:37:16 +00:00
Pau Pérez Fabregat
df77f6e051 Merge pull request #3536 from Matt-Yorkley/flaky/bom_spec
Wait for angular to load in BOM spec
2019-02-25 13:14:57 +01:00
Pau Pérez Fabregat
6004d09698 Merge pull request #3538 from Matt-Yorkley/flaky/shipping_methods_spec
Adjust expectations in flaky spec
2019-02-25 12:50:48 +01:00
Pau Pérez Fabregat
8a855edbda Merge pull request #3527 from luisramos0/2-0-fix-admin-edit-order-page
[Spree Upgrade] Fix edit ship method and tracking number in backoffice order page
2019-02-25 12:20:46 +01:00
Matt-Yorkley
6e77afbf35 Adjust expectations in flaky spec 2019-02-25 11:08:10 +00:00
Pau Pérez Fabregat
aed9c41b0d Merge pull request #3394 from mkllnk/3021-update-soft-delete
[Spree upgrade] 3021 update soft delete
2019-02-25 11:58:41 +01:00
Pau Pérez Fabregat
4e180f9f43 Merge pull request #3517 from openfoodfoundation/dependabot/bundler/oj-3.7.9
Bump oj from 3.7.8 to 3.7.9
2019-02-25 11:37:43 +01:00
Pau Pérez Fabregat
59962bbfb1 Merge pull request #3540 from openfoodfoundation/transifex
Transifex
2019-02-25 11:36:56 +01:00
Matt-Yorkley
bbfe71fd27 Improve readability and add code comment 2019-02-25 10:27:34 +00:00
Transifex-Openfoodnetwork
021220514e Updating translations for config/locales/ca.yml 2019-02-25 21:11:12 +11:00
luisramos0
963fddf159 Add missing translations
These translations are missing in v2 but some will also make v1 better
2019-02-24 22:29:44 +00:00
luisramos0
f40ff61f97 Move all en.yml entries added so far to v2 to master so that we can start the translation process now 2019-02-24 22:28:30 +00:00
Matt-Yorkley
627b101be9 Don't process proxy_order if the order has been cancelled 2019-02-24 12:06:58 +00:00
Matt-Yorkley
ea8be0ab95 Fine-tune angular helper 2019-02-23 21:45:33 +00:00
Matt-Yorkley
c4b646c583 Wait for angular to load in BOM spec 2019-02-23 16:12:37 +00:00
luisramos0
ee8fe4b6b4 Move registration process translations to lazy lookups to better organize the en.yml file 2019-02-22 14:37:45 +00:00
luisramos0
0b1ea1beda Rename VariantOverride.use_producer_settings to VariantOverride.use_producer_stock_settings 2019-02-22 09:57:21 +00:00
Pau Pérez Fabregat
439ea618df Merge pull request #3524 from luisramos0/2-0-stable-Feb20
[Spree Upgrade] Merging master into 2-0-stable (3rd run in Feb2019)
2019-02-22 09:01:40 +01:00
Pau Pérez Fabregat
632826a192 Merge pull request #3494 from luisramos0/break-oc-specs
Break order_cycle_spec.js in specific files and remove reference to product.count_on_hand in bulk_product_update_spec.js
2019-02-22 08:30:35 +01:00
luisramos0
45e5fed609 Improve scope_variant_to_hub code and spec by testing an invalid data state 2019-02-21 11:25:01 +00:00
Maikel
509e644cf7 Merge pull request #3526 from openfoodfoundation/transifex
Transifex
2019-02-21 16:05:21 +11:00
luisramos0
b73ca88811 Fix edit ship method and tracking number in backoffice order page
The data-hook is necessary to make spree js code work, in this case, activate click events on edit and save buttons
2019-02-20 23:57:57 +00:00
Transifex-Openfoodnetwork
4b21c9cb70 Updating translations for config/locales/en_CA.yml 2019-02-21 07:32:50 +11:00
luisramos0
5d51ad71b0 Merge branch 'master' into 2-0-stable-Feb20 2019-02-20 14:32:36 +00:00
Luis Ramos
34acaa4e03 Merge pull request #3425 from mkllnk/2783-product-importer-spec
Apply import defaults to variants of new products in Spree 2
2019-02-20 13:34:57 +00:00
Matt-Yorkley
f73221ed85 Use Dir::Tmpname.make_tmpname for threadsafe file naming 2019-02-20 13:10:47 +00:00
luisramos0
ef786adcfc Make variant_override.stock_overridden? simpler and add comment to explain relationship between count_on_hand and on_demand in a VO 2019-02-20 13:07:21 +00:00
Maikel
ec26948949 Merge pull request #3521 from openfoodfoundation/transifex
Transifex
2019-02-20 19:10:16 +11:00
Maikel
806226b404 Merge pull request #3496 from luisramos0/2-0-kill-allow-backorders
[Spree Upgrade] Remove allow_backorders from product stock verification
2019-02-20 13:09:05 +11:00
Transifex-Openfoodnetwork
aba4d742f6 Updating translations for config/locales/fr_CA.yml 2019-02-20 12:55:33 +11:00
luisramos0
5b4c986733 Add spec to cover variant scoping in order_cycle.items_bought_by_user 2019-02-20 00:05:28 +00:00
Maikel
e7e2d1d870 Merge pull request #3516 from openfoodfoundation/transifex
Transifex
2019-02-20 10:39:55 +11:00
Maikel Linke
8374c7dea4 Fix serializer spec for supplied products
In a previous commit we removed the now obsolete scope
Product.not_deleted. Calling Enterprise#supplied_products without
any scope does not issue a new SQL query but returns the products that
were present when the enterprise was loaded.

The fixed spec creates more products after loading the enterprise. So
the enterprise needs to be reloaded or the new products are not visible.
2019-02-20 08:45:58 +11:00
Transifex-Openfoodnetwork
7e59132bb2 Updating translations for config/locales/en_GB.yml 2019-02-20 06:50:52 +11:00
dependabot[bot]
47e154f2ac Bump oj from 3.7.8 to 3.7.9
Bumps [oj](https://github.com/ohler55/oj) from 3.7.8 to 3.7.9.
- [Release notes](https://github.com/ohler55/oj/releases)
- [Changelog](https://github.com/ohler55/oj/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ohler55/oj/compare/v3.7.8...v3.7.9)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-02-19 19:21:37 +00:00
Transifex-Openfoodnetwork
9688fe7540 Updating translations for config/locales/fr.yml 2019-02-20 06:15:01 +11:00
luisramos0
8ee14ccb4b Make variants_stock_levels return variants on_demand values 2019-02-19 11:56:02 +00:00
Maikel
f0a6f5ae3c Merge pull request #3514 from openfoodfoundation/transifex
Transifex
2019-02-19 15:40:30 +11:00
Transifex-Openfoodnetwork
0a50a74561 Updating translations for config/locales/en_US.yml 2019-02-19 15:23:20 +11:00
Maikel Linke
99f0be2f1c Remove unnecessary scope Variant.not_deleted
Spree made that scope default so that we don't need to define or call
it. There might be cases in which we were showing deleted variants and
now we are not, but I have not idea how to find them.

Related Spree commit:
- cd3add960e
2019-02-19 14:25:18 +11:00
Maikel Linke
b4d1e48693 Update soft-delete of variants
Spree changed their way of soft-deleting variants from calling `delete`
to calling `destroy`. We don't need our own implementation any more.
2019-02-19 14:25:18 +11:00
Maikel Linke
cdb49f88b0 Move Variant deletion into its own service
This keeps the override of Spree's model leaner. More importantly, it
prepares us for using `destroy` instead of `delete`.

In the past, `Product#delete` soft-deleted the product, but didn't
delete the variants. When we use `Product#destroy` to soft-delete the
product, it will also call destroy on the variants. If the model doesn't
allow the deletion of the last variant, it will fail. So when a product
is deleted we want to allow the deletion of all variants. But the user
should not be allowed to delete the last variant. That's why I'm moving
the check to the controller level.

Related commits:

- e6c7acdff3
- 2b47c9145a
- b9f19d5777 (diff-412c5af2ec1ba9f6643f6df5a673c1d4R105)
2019-02-19 14:25:18 +11:00
Maikel Linke
8f49f0006a Update products controller decorator with Spree
Spree changed the controller to deal with the updated soft-delete. This
commit brings these changes to our decorator.
2019-02-19 14:25:18 +11:00
Maikel Linke
5d828bd7ae Update soft-delete of products
Spree changed their way of soft-deleting products, variants and
some other models. `#destroy` is now soft-deleting and replaces
`#delete`.

This commit considers only products. Variants will follow in another
commit. The other models can be ignored, because we don't call `delete`
on them.
2019-02-19 14:25:18 +11:00
Maikel
bb4d42ef9d Merge pull request #3464 from openfoodfoundation/transifex
Transifex
2019-02-19 12:41:16 +11:00
Maikel
1b45033e33 Merge pull request #3506 from Matt-Yorkley/pi/parse_bom
Sanitize non-parsable BOM characters inserted by Excel
2019-02-19 11:24:11 +11:00
Maikel
be59a8ce32 Merge pull request #3434 from Matt-Yorkley/pi/fix_hash_merge
Fix hash merge for recording already created products by name
2019-02-19 11:21:49 +11:00
Maikel
b7abb72ed5 Merge pull request #3462 from luisramos0/delete-api-order-ctrl
Delete empty controller class eval and spec
2019-02-19 11:14:29 +11:00
Maikel
ae4d36b3ed Merge pull request #3451 from Matt-Yorkley/subs/currency
Use localized currency symbols in Subs pages
2019-02-19 09:55:36 +11:00
luisramos0
30967a5ffa Fix bulk product edit page. on_hand and on_demand should never be mixed on the server side, the UI can make the decision to show on_demand on the on_hand column if on_demand is true 2019-02-18 22:01:48 +00:00
luisramos0
12eab1bfa9 Merge variant_stock.count_on_hand into variant_stock.on_hand
variant.on_hand will not return infinity any longer if variant.on_demand is true. Clients of these methods will have to handle the combinations between on_hand and on_demand values
2019-02-18 22:00:16 +00:00
luisramos0
f0842fcbe5 Convert all calls to variant.count_on_hand to variant.on_hand 2019-02-18 21:54:07 +00:00
Matt-Yorkley
9705c249ac Sanitize no-parsable BOM characters inserted by Excel 2019-02-18 13:13:37 +00:00
luisramos0
5aee043b86 Remove allow_backorders from product stock verification because product.has_stock? already includes product.on_demand and in v2 allow_backorders becomes on_demand 2019-02-18 13:12:29 +00:00
Luis Ramos
8f192c39fb Merge pull request #3508 from luisramos0/2-0-green
[Spree Upgrade] Fix bulk_order_mgmt_spec - 2-0 build GREEN !!!
2019-02-18 13:05:17 +00:00
Kristina Lim
b0a82b0e21 Exclude $0 adjustments from report 2019-02-18 16:53:19 +08:00
Kristina Lim
36fd385f7d Add test showing $0 mandatory adjustments included 2019-02-18 16:53:19 +08:00
Kristina Lim
19f99255fa Exclude non-eligible entries from report 2019-02-18 16:53:18 +08:00
Kristina Lim
8ce7337c9d Add test showing $0 non-mandatory adjustments included 2019-02-18 16:53:18 +08:00
Kristina Lim
ca2c8e6ff2 Add test showing non-"eligible" entries included 2019-02-18 16:53:18 +08:00
Pau Pérez Fabregat
f5df10f5dc Merge pull request #3507 from openfoodfoundation/dependabot/bundler/selenium-webdriver-3.141.0
Bump selenium-webdriver from 3.12.0 to 3.141.0
2019-02-18 09:28:01 +01:00
luisramos0
a0bd290b6a Fix bulk_order_management spec by setting ship address on the stest order, this makes the order worflow work up to complete because the shipping methods will be validated against the address 2019-02-17 21:53:58 +00:00
Matt-Yorkley
09655b9f88 Fix nil values in on_hand column 2019-02-16 01:05:20 +00:00
dependabot[bot]
ed7015ae98 Bump selenium-webdriver from 3.12.0 to 3.141.0
Bumps [selenium-webdriver](https://github.com/SeleniumHQ/selenium) from 3.12.0 to 3.141.0.
- [Release notes](https://github.com/SeleniumHQ/selenium/releases)
- [Changelog](https://github.com/SeleniumHQ/selenium/blob/master/rb/CHANGES)
- [Commits](https://github.com/SeleniumHQ/selenium/compare/selenium-3.12.0...selenium-3.141.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-02-15 19:20:25 +00:00
Pau Pérez Fabregat
fb412cd9cd Merge pull request #3299 from luisramos0/2-0-admin-capture-payment
[Spree Upgrade] Fix order_with_totals_and_distribution factory by updating shipping fees
2019-02-15 18:37:43 +01:00
Pau Perez
4e35ea9149 Merge branch '2-0-stable' into 2-0-admin-capture-payment
* 2-0-stable:
  Perform delivery when checking deliveries in specs
2019-02-15 17:21:09 +01:00
Pau Pérez Fabregat
e67793b204 Merge pull request #3497 from coopdevs/fix-user-confirmation-spec
Perform delivery when checking deliveries in specs
2019-02-15 16:52:52 +01:00
luisramos0
75a79717cf Adapt scope_variant_to_hub to new VO rules where on_demand nil is seen as use_producer_settings 2019-02-15 14:05:24 +00:00
Transifex-Openfoodnetwork
9bf5531233 Updating translations for config/locales/nb.yml 2019-02-15 23:47:20 +11:00
Pau Pérez Fabregat
93c6271400 Merge pull request #3500 from openfoodfoundation/dependabot/bundler/bugsnag-5.5.0
Bump bugsnag from 4.1.0 to 5.5.0
2019-02-15 09:26:41 +01:00
Pau Pérez Fabregat
0a391783bc Merge pull request #3470 from kristinalim/fix/3426-intermittent_spec_failures
3426 [Flaky Spec] Address timing issues in enterprise users feature specs
2019-02-15 08:39:39 +01:00
Maikel Linke
6790e8895d Create sample payment methods with current environment 2019-02-15 16:44:55 +11:00
Maikel
d4589cc2f4 Merge pull request #3444 from mkllnk/3437-supplier-name-on-invoice
3437 supplier name on invoice
2019-02-15 16:31:29 +11:00
Matt-Yorkley
0c5cc23415 Fix hash merge for recording already created products by name 2019-02-14 21:38:18 +00:00
dependabot[bot]
7c5e58dd94 Bump bugsnag from 4.1.0 to 5.5.0
Bumps [bugsnag](https://github.com/bugsnag/bugsnag-ruby) from 4.1.0 to 5.5.0.
- [Release notes](https://github.com/bugsnag/bugsnag-ruby/releases)
- [Changelog](https://github.com/bugsnag/bugsnag-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bugsnag/bugsnag-ruby/compare/v4.1.0...v5.5.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-02-14 19:34:17 +00:00
dependabot[bot]
a369b48bf4 Bump stripe from 4.5.0 to 4.9.0
Bumps [stripe](https://github.com/stripe/stripe-ruby) from 4.5.0 to 4.9.0.
- [Release notes](https://github.com/stripe/stripe-ruby/releases)
- [Changelog](https://github.com/stripe/stripe-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/stripe/stripe-ruby/compare/v4.5.0...v4.9.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-02-14 19:30:48 +00:00
Pau Pérez Fabregat
6f2b894cfe Merge pull request #3403 from openfoodfoundation/dependabot/bundler/dalli-2.7.9
Bump dalli from 2.7.2 to 2.7.9
2019-02-14 20:12:06 +01:00
Pau Pérez Fabregat
43fff8f18d Merge pull request #3460 from openfoodfoundation/dependabot/bundler/spinjs-rails-1.4
Bump spinjs-rails from 1.3 to 1.4
2019-02-14 19:42:33 +01:00
luisramos0
4a35b53b43 Remove dead overrides 2019-02-14 18:00:25 +00:00
Pau Pérez Fabregat
34020f7bf6 Merge pull request #3377 from openfoodfoundation/dependabot/bundler/i18n-js-3.2.1
Bump i18n-js from 3.1.0 to 3.2.1
2019-02-14 18:26:49 +01:00
Pau Perez
f29707fea3 Perform delivery when checking deliveries in specs
Otherwise checking `ActionMailer::Base.deliveries.count` won't see any.
2019-02-14 18:24:33 +01:00
Kristina Lim
af95e3871f Move check for table presence out of helper 2019-02-15 01:15:58 +08:00
Pau Perez
e5dadd1ab1 Merge branch '2-0-stable' into 2-0-admin-capture-payment
* 2-0-stable: (121 commits)
  Stub default value for other calls to File.exist?
  Add specs for error cases in shipments_controller_spec
  Move features/admin/reports/enterprise_fee_summaries_spec to xdescribe (will be fixed as part of spree upgrade phase 2)
  Add missing translation to fix shipping methods spec
  Test tagging polymorphism on a payment method
  Workaround Rails inheritance bug in Spree::Gateway
  Improve method names in shipments_controller_spec
  Move ProductImporter spec to xdescribe until all its specs are green (spree upgrade phase 2)
  Make bulk invoices part of spree upgrade phase 2
  Make Api::ShipmentsController#create re-use order.shipment if it exists Improve code and add specs to this controller
  Decorate spree api shipments controller to scope variants as they are added/removed from shipments
  Delete all Spree::Admin::LineItemsController customizations as they are no longer used
  Update spec/controllers/spree/orders_controller_spec.rb
  Fix broken spec from refactored method
  Wait for button to disappear before checking flash
  Use flash matcher in shipping method feature specs
  Add RSpec matchers for flash messages
  Do not expect modal open when checking spinner gone
  Fix layout violation in Spree::Ability decorator
  Fix description for feature flag example groups
  ...
2019-02-14 17:41:54 +01:00
Pau Perez
caf4441fa3 Do not mutate config's state in specs 2019-02-14 17:01:43 +01:00
Pau Perez
609ff737ca Fix and simplify feature spec 2019-02-14 17:01:43 +01:00
Pau Perez
e9173f440f Associate shipment to appropriate order in specs 2019-02-14 17:01:43 +01:00
luisramos0
bf4ce90f98 Add product.on_hand and product.on_demand positive test, these should be returned if no variants are provided in the input
Also, removed product.count_on_hand negative test (there's no such attriubte in v2) and added product.on_hand, this should not be returned because a variant is provided
2019-02-14 15:58:15 +00:00
luisramos0
bfa0734cc6 Break order_cycle_spec.js in specific files like create controller, edit controller and services
Move bulk_product_update_spec.js to its apropriate place under /admin
2019-02-14 15:57:40 +00:00
Pau Pérez Fabregat
0a885af7a6 Merge pull request #3481 from mkllnk/simplify-stripe-creation-in-specs
Simplify specs with stripe factory
2019-02-14 09:42:05 +01:00
Pau Pérez Fabregat
fce92090db Merge pull request #3479 from luisramos0/2-0-stable-Feb12
[Spree Upgrade] Merging master into 2-0-stable (2nd run in Feb2019)
2019-02-14 09:40:28 +01:00
Transifex-Openfoodnetwork
a71c89f70e Updating translations for config/locales/en_GB.yml 2019-02-14 18:01:18 +11:00
Transifex-Openfoodnetwork
19568577f5 Updating translations for config/locales/es.yml 2019-02-14 18:01:18 +11:00
Transifex-Openfoodnetwork
71b24ba314 Updating translations for config/locales/ca.yml 2019-02-14 18:01:17 +11:00
Maikel
9058729a9d Merge pull request #3459 from openfoodfoundation/dependabot/bundler/rspec-rails-3.8.2
Bump rspec-rails from 3.8.1 to 3.8.2
2019-02-14 17:18:07 +11:00
Maikel Linke
87abfcd704 Simplify shopping spec 2019-02-14 11:42:46 +11:00
Pau Pérez Fabregat
2d2e25b9fa Merge pull request #3484 from coopdevs/fix-invoices-controller-spec
Stub default value for other calls to File.exist?
2019-02-13 20:32:13 +01:00
Luis Ramos
c6cd1b7ef2 Merge pull request #3471 from luisramos0/2-0-bulk-invoices-phase2
[Spree Upgrade] Make Bulk Invoices part of spree upgrade phase 2
2019-02-13 12:37:15 +00:00
Luis Ramos
576c203679 Merge pull request #3370 from mkllnk/3121-spree-gateway-inheritance
[Spree upgrade] Workaround Rails inheritance bug in Spree::Gateway
2019-02-13 12:27:59 +00:00
Pau Perez
59e27ffc0e Stub default value for other calls to File.exist?
This fixes the following error

```
 1) Spree::Admin::InvoicesController#poll when the file is available returns true
     Failure/Error: spree_get :poll, invoice_id: invoice_id

       #<File (class)> received :exist? with unexpected arguments
         expected: ("tmp/invoices/479186263.pdf")
              got: ("/home/pau/dev/openfoodnetwork/tmp/cache/paralleltests/3B7/CD1/spree%2Fapp_configuration%2Fredirect_https_to_http")
        Please stub a default value first if message might be received with other args as well.
     # ./spec/controllers/spree/admin/invoices_controller_spec.rb:28:in `block (4 levels) in <top (required)>'
     # -e:1:in `<main>'
```

`paralleltests` also relies on `File.exist?` and so stubbing it breaks
it unless we purposefully allow other calls.
2019-02-13 13:16:28 +01:00
Pau Pérez Fabregat
1b7edab3d6 Merge pull request #3441 from luisramos0/2-0-shipments-api
[Spree Upgrade] Adapt api shipments controller to OFN by scoping variants before each action
2019-02-13 12:36:08 +01:00
luisramos0
5ccbf7b3ca Add specs for error cases in shipments_controller_spec 2019-02-13 10:37:21 +00:00
luisramos0
728ed2c202 Move features/admin/reports/enterprise_fee_summaries_spec to xdescribe (will be fixed as part of spree upgrade phase 2) 2019-02-13 09:06:10 +00:00
luisramos0
ff2bf76e38 Add missing translation to fix shipping methods spec 2019-02-13 09:05:35 +00:00
Maikel Linke
5f5b0aaabf Simplify specs with stripe factory 2019-02-13 18:34:22 +11:00
Maikel Linke
612ea4c781 Simplify spec of invoice creation 2019-02-13 17:55:48 +11:00
Maikel
a36dc13192 Add issue templates for tech debt 2019-02-13 17:26:56 +11:00
Maikel Linke
3b9fdfa7ac Test tagging polymorphism on a payment method 2019-02-13 16:31:38 +11:00
Maikel Linke
9044bf60b9 Workaround Rails inheritance bug in Spree::Gateway
Due to a bug in ActiveRecord we need to load the tagging code in Gateway which
should have inherited it from its parent PaymentMethod.
We have to call it before loading the PaymentMethod decorator because the
tagging code won't load twice within the inheritance chain.

https://github.com/openfoodfoundation/openfoodnetwork/issues/3121
2019-02-13 14:47:44 +11:00
Pau Pérez Fabregat
bda5eb1b1f Merge pull request #3337 from kristinalim/feature-enterprise_fees_report-order_based_calculator_bug
3283 [Enterprise Fee Summary] Fix values when calculator is order-based
2019-02-12 20:07:57 +01:00
luisramos0
ba8096ff85 Improve method names in shipments_controller_spec 2019-02-12 17:31:58 +00:00
luisramos0
c652cfe4d5 Merge branch 'master' into 2-0-stable-Feb12 2019-02-12 16:03:33 +00:00
Kristina Lim
5e8a336e24 Initialize data representation classes with data
There is no more need to pass the summarizer.
2019-02-13 01:51:34 +11:00
Kristina Lim
ddc788ed5d Move data representation translations to class 2019-02-13 01:51:34 +11:00
Kristina Lim
bc95560598 Add descriptions for data representation classes 2019-02-13 01:51:33 +11:00
Kristina Lim
664943a6e5 Include UsingEnterpriseFee instead of inheriting 2019-02-13 01:51:33 +11:00
Kristina Lim
b9c144bb1f Prepare to change AssociatedEnterpriseFee to module
The superclasses will include this module, instead of inheriting the class.
2019-02-13 01:51:32 +11:00
Kristina Lim
373e3e1039 Simplify name of SQL data summarizer class 2019-02-13 01:51:32 +11:00
Kristina Lim
7a76355cfe Separate summarizing of SQL data by source 2019-02-13 01:51:32 +11:00
Kristina Lim
c4801aafd4 Fix Fee Calc on Transfer Through and Tax Category
For exchange fees with calculator that is order-based:

* "Fee Calc on Transfer Through" should show "Entire Orders through
  DISTRIBUTOR_NAME".
* For tax category:
  a. If the enterprise fee itself has a tax category, this is used.
  b. If the enterprise fee inherits the product's tax category, this is
     "Various".
  c. If the enterprise fee has no tax, this is blank.

For coordinator fees:

* "Fee Calc on Transfer Through" should be "All".
* For tax category: Same as abova.
2019-02-13 01:51:31 +11:00
Kristina Lim
8f65beeb0b Clarify method name in report scope 2019-02-13 01:51:31 +11:00
Kristina Lim
e550be9bda Add test for using order-based exchange fees
This is not filling the "Fee Calc on Transfer Through" column. This will
be addressed in another commit.
2019-02-13 01:51:31 +11:00
Kristina Lim
0212454041 Refactor SQL result summarizer for report 2019-02-13 01:51:30 +11:00
Kristina Lim
06ba5182b4 Add flat rate calculator traits to related factories 2019-02-13 01:51:30 +11:00
dependabot[bot]
0fc9ead934 Bump i18n-js from 3.1.0 to 3.2.1
Bumps [i18n-js](https://github.com/fnando/i18n-js) from 3.1.0 to 3.2.1.
- [Release notes](https://github.com/fnando/i18n-js/releases)
- [Changelog](https://github.com/fnando/i18n-js/blob/master/CHANGELOG.md)
- [Commits](https://github.com/fnando/i18n-js/compare/v3.1.0...v3.2.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-02-12 13:19:50 +00:00
Pau Pérez Fabregat
1f72eb9f68 Merge pull request #3378 from kevinchristianson/active-products-translation-fix
Add missing 'active products' translation on dashboard
2019-02-12 14:15:53 +01:00
Pau Pérez Fabregat
a0c144fd0c Merge pull request #3415 from openfoodfoundation/feature/enterprise_fee_summary
[Enterprise Fee Summary] Merge "Enterprise Fee Summary" report to master
2019-02-12 13:58:47 +01:00
Pau Pérez Fabregat
b6ca0ba24f Merge pull request #3456 from coopdevs/fix-last-orders-controller-spec
Fix orders controller spec
2019-02-12 12:47:15 +01:00
Pau Perez
24189ca88e Create shipping_rate earlier for callback to work
If the shipping_rate is not created at the time the `#after_save`'s
`#ensure_correct_adjustment` callback is executed its call to
`shipping_method.create_adjustment` won't be executed either.

As a result, the OrderUpdater wasn't able to see any adjustments related
to the shipment causing the order total to be outdated.
2019-02-12 12:11:55 +01:00
luisramos0
935c8cb0ce Move ProductImporter spec to xdescribe until all its specs are green (spree upgrade phase 2) 2019-02-12 10:38:03 +00:00
luisramos0
7c0b21eb83 Make bulk invoices part of spree upgrade phase 2 2019-02-12 10:37:22 +00:00
Pau Perez
ab0b759567 Merge branch '2-0-stable' into 2-0-admin-capture-payment
* 2-0-stable: (208 commits)
  Re implement orders ctrl update method so we can change redirection logic and add specs for it
  Improve readability in admin/orders_spec
  Add line items adjustments (order.price_adjustments) to the order edit page so that user is aware of adjustments included in the price like for example tax rates
  Adapt variants auto complete to spree v2 code with shipments
  Adapt customer search override to spree v2 and fix customer details spec in admin orders spec
  Fix distributor change spec in admin orders spec
  Fix admin orders spec non tax adjustments by adapting to new view
  Fix failing specs due to Spree 2's new order admin page Add missing form tag and OC and shops injectors on order form to make the OC field, the distributor field and the update button work
  Use Spree routes
  Fix shop accidentally becoming order coordinator
  Match date format in spec with import date filter
  Make in_stock? work for both variants and overrides by moving it from VariantStock to variant_decorator.
  Add unit test for VariantStock.can_supply?
  Remove rescue from products_reset_strategy in product import: if setting count_on_hand fails the import will raise a RuntimeError
  Change product import's product_reset_strategy from depending on the inexistent variant.count_on_hand DB field and instead make individual calls to variant.count_on_hand= defined in VariantStock. Also, added spec to test return value of the reset method: it should return number of updated records.
  Upgrade views to Spree 2 and apply overrides
  Updating translations for config/locales/en_US.yml
  Update name spaces for rake tasks to shorter 'ofn'.
  Refactor checking no preview image in specs
  Refactor checking of preview image path in specs
  ...
2019-02-12 11:12:40 +01:00
luisramos0
58ea28ebb4 Make Api::ShipmentsController#create re-use order.shipment if it exists
Improve code and add specs to this controller
2019-02-12 10:09:00 +00:00
luisramos0
77b390a836 Decorate spree api shipments controller to scope variants as they are added/removed from shipments 2019-02-12 10:09:00 +00:00
luisramos0
0f44beb477 Delete all Spree::Admin::LineItemsController customizations as they are no longer used 2019-02-12 10:09:00 +00:00
Pau Pérez Fabregat
a6c5e3423f Merge pull request #3474 from Matt-Yorkley/pi/broken_build
Fix broken spec from refactored method
2019-02-12 11:03:28 +01:00
Pau Pérez Fabregat
0cc2bd052e Merge pull request #3436 from luisramos0/2-0-orders-edit
[Spree Upgrade] Fix admin new order page flow (from order details to customer details)
2019-02-12 10:35:25 +01:00
Pau Pérez Fabregat
b51ad35cb1 Merge pull request #3445 from luisramos0/2-0-order-adjusts
[Spree Upgrade] Fix adjustments sections in admin order edit page
2019-02-12 10:16:30 +01:00
Pau Pérez Fabregat
92dca0cdfa Merge pull request #3194 from HugsDaniel/3109-fix-orders-new
[Spree Upgrade] Fix admin new order page
2019-02-12 09:58:29 +01:00
Luis Ramos
edd1da7d50 Update spec/controllers/spree/orders_controller_spec.rb
Fix typo in doc

Co-Authored-By: sauloperez <saulopefa@gmail.com>
2019-02-12 09:12:03 +01:00
Matt-Yorkley
097ffba323 Fix broken spec from refactored method 2019-02-11 23:57:13 +00:00
Pau Pérez Fabregat
4165ba5cdb Merge pull request #3463 from coopdevs/enable-catalan
Import Catalan translation from Transifex
2019-02-11 18:13:50 +01:00
Luis Ramos
dd44d6a0ca Merge pull request #3355 from luisramos0/2-0-pord-importer-spec
[Spree Upgrade] Phase 2 - Fix product_importer spec
2019-02-11 15:28:47 +00:00
Pau Perez
990de63728 Merge branch 'master' into active-products-translation-fix
* master: (46 commits)
  Wait for button to disappear before checking flash
  Use flash matcher in shipping method feature specs
  Add RSpec matchers for flash messages
  Do not expect modal open when checking spinner gone
  Update issue templates
  Update all locales with the latest Transifex translations
  Do not show table until first time dereferencing is done
  Remove unused have_no_selector argument in feature test
  Compile row ID with higher priority
  Compile edit link with higher priority
  Support selecting date in next months
  Improve sync between keyword filter and selecting all
  Wait for datepicker to associate and open before selecting date
  Update cancan permissions for second iteration of bulk invoices
  Fix shop accidentally becoming order coordinator
  Match date format in spec with import date filter
  Update name spaces for rake tasks to shorter 'ofn'.
  Refactor checking no preview image in specs
  Refactor checking of preview image path in specs
  Fix race condition in enterprise image feature specs
  ...
2019-02-11 16:12:52 +01:00
Pau Pérez Fabregat
9d065c8a0b Merge pull request #3233 from Matt-Yorkley/pi/inventories
Pi/inventories
2019-02-11 16:10:33 +01:00
Pau Pérez Fabregat
da09c8f86c Merge pull request #3467 from kristinalim/fix/3455-intermittent_spec_failure
3455 [Flaky Spec] Do not expect modal still open when checking that the spinner is gone
2019-02-11 15:58:22 +01:00
Pau Pérez Fabregat
b508d51406 Merge pull request #3469 from kristinalim/fix/3468-intermittent_spec_failures
3468 [Flaky Spec] Check for presence of flash div before trying to get its text
2019-02-11 15:54:33 +01:00
luisramos0
acc99fc9bb Improve readability of cached_product_renderer and respective spec 2019-02-11 11:46:04 +00:00
Kristina Lim
a876c2ab9f Address timing issues in enterprise roles specs 2019-02-11 13:02:40 +08:00
luisramos0
ad0e5bb093 Re implement orders ctrl update method so we can change redirection logic and add specs for it 2019-02-10 15:31:01 +00:00
Kristina Lim
0032a237a2 Wait for button to disappear before checking flash 2019-02-10 22:08:18 +08:00
Kristina Lim
175264f41f Use flash matcher in shipping method feature specs 2019-02-10 22:08:18 +08:00
Kristina Lim
e14c60c1c1 Add RSpec matchers for flash messages 2019-02-10 22:08:18 +08:00
Kristina Lim
f143540d0c Do not expect modal open when checking spinner gone
The element referenced in the following might no longer be visible:

  within "div.reveal-modal"
2019-02-09 22:40:40 +08:00
Kristina Lim
b6be8c48d1 Fix layout violation in Spree::Ability decorator 2019-02-08 21:26:39 +00:00
Kristina Lim
de30cf1198 Fix description for feature flag example groups 2019-02-08 21:26:39 +00:00
Kristina Lim
461b5725d1 Hide report link and resource from non-superadmins 2019-02-08 21:26:38 +00:00
Kristina Lim
1d3f4aa28a Add feature flag for enterprise fee summary 2019-02-08 21:26:38 +00:00
Kristina Lim
f59834ddc8 Use receiver as "Fee Calc on Transfer Through" for outgoing exchanges 2019-02-08 21:26:38 +00:00
Kristina Lim
ddf15f1d30 Add scenario test for enterprise fee summary
Add test for more complex scenario where there is a coordinator and
distributor fee for an incoming exchange, and a producer and coordinator
fee for an outgoing exchange.
2019-02-08 21:26:38 +00:00
Kristina Lim
c92d202612 Rename files for factories in spec/factories/
Make these follow the "#{SINGULAR_OBJECT}_factory.rb" convention.
2019-02-08 21:26:38 +00:00
Kristina Lim
625069cb5a Add :per_item factory trait to shipping and payment methods 2019-02-08 21:26:38 +00:00
Kristina Lim
d2e49b8b49 Move variant setup to new factory trait 2019-02-08 21:26:38 +00:00
Kristina Lim
f36d13a736 Rename helper for setting up incomplete order 2019-02-08 21:26:38 +00:00
Kristina Lim
ce030aeb07 Move order setup to new factory traits 2019-02-08 21:26:38 +00:00
Kristina Lim
a3aa594c42 Use enterprise fee factory trait where applicable 2019-02-08 21:26:38 +00:00
Kristina Lim
5dda3b67eb Use factory for tax category in entperprise fee summary tests 2019-02-08 21:26:38 +00:00
Kristina Lim
61ec43f868 Add enterprise fee factory trait for per item rate
We should not presume what is not default for an enterprise fee object.
2019-02-08 21:26:38 +00:00
Kristina Lim
53c458f817 Clean up setup data for enterprise fee summary tests 2019-02-08 21:26:38 +00:00
Kristina Lim
4a73b1d26c Do not include incomplete orders in report 2019-02-08 21:26:38 +00:00
Kristina Lim
eaa7800427 Do not assign I18n translation to constants
The preferred language could change dynamically.
2019-02-08 21:26:38 +00:00
Kristina Lim
6378afdddb Address Rubocop violation 2019-02-08 21:26:38 +00:00
Kristina Lim
c81be75530 Move engine libraries except Engine and Version to services 2019-02-08 21:26:38 +00:00
Kristina Lim
3e499faa7c Do not use ReportData::EnterpriseFeeTypeTotals 2019-02-08 21:26:38 +00:00
Kristina Lim
3f84d0008a Move some in OpenFoodNetwork to engine services
This removes the OpenFoodNetwork namespace from these too.
2019-02-08 21:26:38 +00:00
Kristina Lim
95e3a2f45d Move authorization to the ::Parameters class 2019-02-08 21:26:38 +00:00
Kristina Lim
c61a83faca Move routes for enterprise fee summary to engine 2019-02-08 21:26:38 +00:00
Kristina Lim
9e035efd50 Render enterprise fee report directly in renderer 2019-02-08 21:26:38 +00:00
Kristina Lim
c8b154b12a Separate enterprise fee summary action
Split the previous "index" action into "new" and "create" actions.
2019-02-08 21:26:38 +00:00
Kristina Lim
da914289ea Copy spree/admin/reports#index into application 2019-02-08 21:26:38 +00:00
Kristina Lim
a17fa8013f Clean up I18n scope in feature specs for report 2019-02-08 21:26:38 +00:00
Kristina Lim
c0e6b70131 Rename EnterpriseFeeSummaryReportController
Remove "Report" because this is redundant, and pluralize the resource
name.
2019-02-08 21:26:38 +00:00
Kristina Lim
207b6c7f30 Use shorthand for RSpec expect(subject).to 2019-02-08 21:26:38 +00:00
Kristina Lim
2063752b97 Improve specs for Enterprise Fee Summary
This also addresses a spec that has failed over the rebasing.
2019-02-08 21:26:38 +00:00
Kristina Lim
2bf38b3ea1 Improve code based on Rubocop recommendations 2019-02-08 21:26:38 +00:00
Kristina Lim
552bf1b9f7 Move report list to own class 2019-02-08 21:26:38 +00:00
Kristina Lim
b78e2b4720 Move lib files for enterprise fee summary to engine 2019-02-08 21:26:38 +00:00
Kristina Lim
0cdcd96bb5 Add skeleton for OrderManagement engine 2019-02-08 21:26:38 +00:00
Kristina Lim
dcb1d9fe25 Add feature tests for enterprise fee summary 2019-02-08 21:26:37 +00:00
Kristina Lim
edf0b0df76 Add navigation item for enterprise fee summary 2019-02-08 21:26:37 +00:00
Kristina Lim
d3e9a53120 Filter enterprise fee summary for user permissions 2019-02-08 21:26:37 +00:00
Kristina Lim
8ad53055c7 Allow non-admins to see enterprise fee summary
Relax controller permissions for enterprise fee summary. Even non-admin
enterprise users should be able to see these reports.

Filtering of data based on permissions is handled in:

* OrderManagement::Reports::EnterpriseFeeSummary::Authorizer and
* OrderManagement::Reports::EnterpriseFeeSummary::Permissions.
2019-02-08 21:26:37 +00:00
Kristina Lim
f81f4b7e4a Authorize filters before generating enterprise fee report 2019-02-08 21:26:37 +00:00
Kristina Lim
9ce313c7f5 Define filter authorizer for enterprise fee report 2019-02-08 21:26:37 +00:00
Kristina Lim
cd3e258b59 Rename report authorizers to reflect permissions 2019-02-08 21:26:37 +00:00
Kristina Lim
469988856d Define permissions for enterprise fee summary 2019-02-08 21:26:37 +00:00
Kristina Lim
5fce9d0a7d Add multi-distributor scope to shipping and payment methods 2019-02-08 21:26:37 +00:00
Kristina Lim
24ab2e7fb0 Add filtering to enterprise fee summary 2019-02-08 21:26:37 +00:00
Kristina Lim
2407531957 Make more code for report tests reusable 2019-02-08 21:26:37 +00:00
Kristina Lim
d573dc5023 Make order builder for enterprise fee summary flexible
This is in preparation for tests for filtering the report.
2019-02-08 21:26:37 +00:00
Kristina Lim
4a00aceba2 Include shipping fees in enterprise fee summary 2019-02-08 21:26:37 +00:00
Kristina Lim
1273cc085b Include payment fees in enterprise fee summary 2019-02-08 21:26:37 +00:00
Kristina Lim
7d74ddc85b Add HTML view for enterprise fee summary report 2019-02-08 21:26:37 +00:00
Kristina Lim
418050c1b8 Remove blank strings from array report parameters
Remove the blank strings that Rails multiple selects add by default to
make sure that blank lists are still submitted to the server as arrays
instead of nil.

https://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-select
2019-02-08 21:26:37 +00:00
Kristina Lim
6e03ab03f5 Extract general behaviour for report parameters 2019-02-08 21:26:37 +00:00
Kristina Lim
34dc16f8c9 Base filter options from initial authorizer object 2019-02-08 21:26:37 +00:00
Kristina Lim
bd2b4c0134 Add enterprise fee summary form without options
The objects will be filled in another commit. This simply sets up the
filters UI for now.
2019-02-08 21:26:37 +00:00
Kristina Lim
ec81e4221f Add basic action for enterprise fee summary 2019-02-08 21:26:37 +00:00
Kristina Lim
b7439d2574 Fix sort for nil cells in enterprise fee summary 2019-02-08 21:26:37 +00:00
Kristina Lim
5b6bbc3920 Add generation of CSV renderer filename 2019-02-08 21:26:37 +00:00
Kristina Lim
ed2b8e9b9f Add CSV renderer for enterprise fee summary report 2019-02-08 21:26:37 +00:00
Kristina Lim
00e70733b0 Add test data for enterprise fee summary report 2019-02-08 21:26:37 +00:00
Kristina Lim
e7ed625d5a Add processing of enterprise fee summary from DB 2019-02-08 21:26:37 +00:00
Kristina Lim
faf7079780 Specify sort order of enterprise fee totals data 2019-02-08 21:26:37 +00:00
Kristina Lim
3763cb98a3 Add data classes for Enterprise Fee Summary report 2019-02-08 21:26:37 +00:00
Kristina Lim
a097640464 Add basic form object for enterprise fee summary 2019-02-08 21:26:36 +00:00
Kristina Lim
519a7d2ee6 Add datetime and integer array validator matchers 2019-02-08 21:26:36 +00:00
Kristina Lim
f6e8f18d89 Add validator for integer arrays
Example usage:

    validates :related_post_ids, integer_array: true
2019-02-08 21:26:36 +00:00
Kristina Lim
de9cff6fc2 Add validator for datetime string
Example usage:

    validates :start_at, date_time_string: true
2019-02-08 21:26:36 +00:00
Pau Perez
f998748634 Clarify why we end up with 3 adjustments
And the second one is open.
2019-02-08 18:16:00 +01:00
Pau Perez
7359789903 Import Catalan translation from Transifex
Although we've started translating to Catalan and focused on it
recently, we never imported the file in the app thus the language menu
showed "English" for the "ca" locale and clicking on it switched to
English as well instead of Catalan.
2019-02-08 15:22:59 +01:00
luisramos0
3dc75c88d2 Delete empty controller class eval and spec. Useless left overs from 0ad2978926 2019-02-08 09:29:58 +00:00
Danni M
8ff5f9055b Update issue templates
I've created 3 types of templates based on those in the wiki and the default (bug) issue template. These can be edited or additional ones added at your leisure.

I also added the OFN software instance and version to the bugs template
2019-02-08 16:58:32 +11:00
Matt-Yorkley
f9ea93933e Use localizeCurrency filter in subscriptions 2019-02-07 22:58:49 +00:00
Matt-Yorkley
5582160e73 Add localizeCurrency filter to admin and inject currencyConfig data 2019-02-07 22:55:08 +00:00
luisramos0
1b4666fc6a Add checkbox to cache settings to disable products cache 2019-02-07 20:06:27 +00:00
dependabot[bot]
72cd0537fb Bump spinjs-rails from 1.3 to 1.4
Bumps [spinjs-rails](https://github.com/dnagir/spinjs-rails) from 1.3 to 1.4.
- [Release notes](https://github.com/dnagir/spinjs-rails/releases)
- [Commits](https://github.com/dnagir/spinjs-rails/compare/v1.3...v1.4)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-02-07 19:39:54 +00:00
dependabot[bot]
492b1c905f Bump rspec-rails from 3.8.1 to 3.8.2
Bumps [rspec-rails](https://github.com/rspec/rspec-rails) from 3.8.1 to 3.8.2.
- [Release notes](https://github.com/rspec/rspec-rails/releases)
- [Changelog](https://github.com/rspec/rspec-rails/blob/master/Changelog.md)
- [Commits](https://github.com/rspec/rspec-rails/compare/v3.8.1...v3.8.2)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-02-07 19:39:25 +00:00
Pau Pérez Fabregat
88247064c4 Merge pull request #3397 from luisramos0/2-0-subs-allow-backorders
[Spree Upgrade] Remove allow backorders from subscriptions specs
2019-02-07 20:32:49 +01:00
luisramos0
93aabf6741 Update all locales with the latest Transifex translations 2019-02-07 19:26:00 +00:00
Pau Pérez Fabregat
676fa3d84d Merge pull request #3433 from Matt-Yorkley/bi/user_permission
Update cancan permissions for second iteration of bulk invoices
2019-02-07 20:17:34 +01:00
Pau Perez
cde465edad Fix orders controller spec 2019-02-07 16:05:18 +01:00
Pau Pérez Fabregat
9613aa5a4d Merge pull request #3400 from luisramos0/2-0-ship-methods
[Spree Upgrade] Change app config to keep using ofn customized spree v1 shipping method calculators, not the new spree v2 ones
2019-02-07 15:41:06 +01:00
Pau Pérez Fabregat
fbde4a6c97 Merge pull request #3328 from luisramos0/2-0-pi-prod-reset
[Spree Upgrade] Phase 2 - Product Import - Adapt product_reset_strategy
2019-02-07 15:35:44 +01:00
Pau Pérez Fabregat
259a5b211b Merge pull request #3429 from luisramos0/2-0-in-stock
[Spree Upgrade] 3428 Fix in_stock? and shopping/variant_overrides_spec
2019-02-07 15:25:43 +01:00
Pau Pérez Fabregat
56425139c0 Merge pull request #3439 from luisramos0/2-0-stable-Feb5
[Spree Upgrade] Merging master into 2-0-stable (1st run in Feb2019)
2019-02-07 15:09:23 +01:00
luisramos0
fe0fb22814 Improve readability in admin/orders_spec 2019-02-07 13:45:04 +00:00
Luis Ramos
8c0683938a Merge pull request #3416 from kristinalim/fix/race_condition_in_bulk_order_management_feature_specs
3417,2962,3358 [Flaky Spec] Address some race conditions for bulk order management specs
2019-02-07 11:28:54 +00:00
luisramos0
3ed6aea9ab Add line items adjustments (order.price_adjustments) to the order edit page so that user is aware of adjustments included in the price like for example tax rates
This change happens in spree v2.2 together with other changes (like adding the, not yet available in v2.0, shipment_adjustments this way). See commit for more details: 636d87dd77
2019-02-07 11:14:45 +00:00
Maikel Linke
5ee3dbf9f2 Re-use renderer object 2019-02-07 10:12:06 +11:00
Luis Ramos
2d0df7ffdf Update app/controllers/spree/admin/orders_controller_decorator.rb
Co-Authored-By: mkllnk <maikel@email.org.au>
2019-02-07 09:19:19 +11:00
Kristina Lim
0030428647 Do not show table until first time dereferencing is done 2019-02-07 04:39:45 +08:00
Kristina Lim
428e58f8f7 Remove unused have_no_selector argument in feature test 2019-02-07 04:39:44 +08:00
Kristina Lim
35ecbe1584 Compile row ID with higher priority 2019-02-07 04:39:44 +08:00
Kristina Lim
ed5856afa4 Compile edit link with higher priority 2019-02-07 04:39:44 +08:00
Kristina Lim
fdede83086 Support selecting date in next months
This was causing failures when selecting tomorrow when running tests on
the last day of the month.
2019-02-07 04:39:43 +08:00
Kristina Lim
bb51f7e36b Improve sync between keyword filter and selecting all 2019-02-07 04:36:28 +08:00
Kristina Lim
3eedee313e Wait for datepicker to associate and open before selecting date 2019-02-07 04:36:24 +08:00
Pau Pérez Fabregat
8f63be9519 Merge pull request #2733 from kristinalim/fix-subscription_should_not_require_future_oc
Reduce restrictions for adding a variant to a subscription
2019-02-06 21:24:57 +01:00
Pau Pérez Fabregat
cd1f469588 Merge pull request #3389 from openfoodfoundation/dependabot/bundler/redcarpet-3.4.0
Bump redcarpet from 3.2.3 to 3.4.0
2019-02-06 21:23:21 +01:00
Pau Pérez Fabregat
433d10c42f Merge pull request #3386 from leandroalemao/fix-moment-deprecation-warning
[ISSUE-3348] LC: Fix moment.js deprecation warning
2019-02-06 21:22:58 +01:00
Pau Pérez Fabregat
b4ba9e65e1 Merge pull request #3367 from openfoodfoundation/dependabot/bundler/jwt-2.1.0
Bump jwt from 1.5.6 to 2.1.0
2019-02-06 21:22:37 +01:00
Pau Pérez Fabregat
6239397589 Merge pull request #3357 from openfoodfoundation/dependabot/bundler/stripe-4.5.0
Bump stripe from 3.3.2 to 4.5.0
2019-02-06 21:22:19 +01:00
Matt-Yorkley
2c3eeec2b9 Update cancan permissions for second iteration of bulk invoices 2019-02-06 18:19:53 +00:00
Luis Ramos
11304ef6fd Merge pull request #3371 from luisramos0/2-0-xero-invoices
[Spree Upgrade] Fix xero invoices report specs
2019-02-06 16:48:49 +00:00
Maikel Linke
4a3e5f1d0a Print supplier name on invoice 2019-02-06 15:07:05 +11:00
Maikel Linke
3aea16e9ba Cover alternative invoice template with specs 2019-02-06 15:06:44 +11:00
Maikel Linke
d97fa60c31 Remove code duplication and test PDF creation 2019-02-06 14:53:05 +11:00
Maikel Linke
7c5b430a37 Test execution of BulkInvoiceService#start_pdf_job
The spec just tested if a job was enqueued, but not if the job can
actually be executed. Unfortunately, this test is quite slow.
2019-02-06 11:26:22 +11:00
luisramos0
1b8445eb99 Merge branch 'master' into 2-0-stable-Feb5 2019-02-05 11:16:23 +00:00
Maikel Linke
cc46bfd002 Rename namespace to ofn 2019-02-05 16:30:46 +11:00
Maikel Linke
659aa269de Fix creation of sample payment methods on staging
Due to an unknown reason my chosen way of creating calculator and
assigning it to a payment method didn't work in staging environment even
though it was working in development.

Without diving deeper into the cause of this, I decided to change the
record assignments and fix the problem that way.
2019-02-05 16:24:30 +11:00
Maikel Linke
7a723d9061 Use new sample data during setup 2019-02-05 16:24:30 +11:00
Maikel Linke
c6393b6077 Warn about deprecation via ActiveSupport 2019-02-05 16:23:17 +11:00
Maikel Linke
c3029c612a Fix sample product creation and use bang methods
Mistakes like the missing fee when creating product distributions were
hidden, because I didn't use the bang methods to create records.
2019-02-05 16:23:17 +11:00
Maikel Linke
1d07327325 Add descriptions to enterprises 2019-02-05 16:23:17 +11:00
Maikel Linke
4b389ba357 Move sample data factories into their own files 2019-02-05 16:23:17 +11:00
Maikel Linke
3ab02d90df Move sample data address module to own file 2019-02-05 16:23:17 +11:00
Maikel Linke
bec9f5eb2e Move sample data logger to own module 2019-02-05 16:23:17 +11:00
Maikel Linke
fae05ff713 Deprecate old sample data task 2019-02-05 16:23:17 +11:00
Maikel Linke
876e73a989 Rewrite task to generate sample data
https://github.com/openfoodfoundation/openfoodnetwork/issues/2072

We need more and better structured sample data for dev testing and to
bootstrap staging data. This new task aims to replace
openfoodnetwork:dev:sample_data.
2019-02-05 16:23:17 +11:00
Maikel
a910468fc7 Merge pull request #3418 from Jefferson-Faseler/change-rake-tasks-namespace
Update Rake task namespace
2019-02-05 16:21:59 +11:00
Maikel Linke
dbfcbc6db9 Apply import defaults to variants of new products
Spree 2 doesn't have `Product#on_hand=` any more. We actually can't save
stock levels without saving the product first which creates a stock
item.

This hacky solution overwrites the attribute in the entry so that it
gets copied to the variant later on. I think a better solution needs
some refactoring as proposed in:
https://github.com/openfoodfoundation/openfoodnetwork/issues/2783#issuecomment-459601530
2019-02-05 15:41:19 +11:00
luisramos0
d598831d67 Adapt variants auto complete to spree v2 code with shipments 2019-02-04 18:59:41 +00:00
luisramos0
698ba4618d Adapt customer search override to spree v2 and fix customer details spec in admin orders spec 2019-02-04 18:58:02 +00:00
luisramos0
e5fdc89659 Fix distributor change spec in admin orders spec 2019-02-04 18:58:01 +00:00
luisramos0
c612df5174 Fix admin orders spec non tax adjustments by adapting to new view 2019-02-04 18:58:01 +00:00
Hugo Daniel
c823f942b4 Fix failing specs due to Spree 2's new order admin page
Add missing form tag and OC and shops injectors on order form to make the OC field, the distributor field and the update button work
2019-02-04 18:57:51 +00:00
Hugo Daniel
ae799eb2b6 Use Spree routes 2019-02-04 18:56:28 +00:00
Luis Ramos
5a4205d151 Merge pull request #3432 from kristinalim/fix/3327-intermittent_spec_failures
3327 [Flaky Spec] Fix shop accidentally becoming order coordinator
2019-02-03 19:32:40 +00:00
Luis Ramos
4b133bbc31 Merge pull request #3412 from kristinalim/fix/3059-race_condition_in_enterprise_image_specs
3059 [Flaky Spec] Fix race condition in enterprise image feature specs
2019-02-03 19:32:11 +00:00
Luis Ramos
a0b5509850 Merge pull request #3430 from kristinalim/fix/3420-intermittent_spec_failures
3420 [Flaky Spec] Fix date format in spec when single-digit day of month
2019-02-03 19:30:22 +00:00
Luis Ramos
8fdd1db2c3 Merge pull request #3380 from mkllnk/3379-payment-method-spec
Use patch to hide Paypal gateway password
2019-02-02 09:54:18 +00:00
Luis Ramos
2dce3373af Merge pull request #3385 from luisramos0/2-0-gemfilelock-fix
[Spree Upgrade] Fix conflicts in gemfile lock
2019-02-02 09:48:51 +00:00
Luis Ramos
6de23fcea1 Merge pull request #3374 from luisramos0/2-0-order-cycle-mgmt-report
[Spree Upgrade] Fix order_cycle_management_report shipping methods filter
2019-02-02 09:47:45 +00:00
Kristina Lim
3104862739 Fix shop accidentally becoming order coordinator
The original setup of the order calls:

  create(:simple_order_cycle)

Which picks an arbitrary distributor as coordinator:

  coordinator { Enterprise.is_distributor.first || ... }

There is a chance that any of the existing distributor enterprises
becomes coordinator, causing a test to intermittently fail.

This commit makes the relationship between the reference enterprises and
the order consistent.
2019-02-01 20:28:36 +00:00
Kristina Lim
4bff256f6d Match date format in spec with import date filter
This was failing if the current day of month only has one digit. The
test could not find the date in the import date filter.

Before this commit, the resulting string in the test replaced "  " with
" ", so "February  2" was being changed to "February 2". The import date
filter however uses two spaces in this case, even if the browser shows
only one (HTML inline text renders two spaces as just one).
2019-02-02 01:43:52 +08:00
Pau Pérez Fabregat
e1fb005e70 Merge pull request #3387 from kristinalim/fix/3384-product_import_timeout
3384 [Product Import] Process only one batch of rows at a time
2019-02-01 17:29:04 +01:00
luisramos0
e584fd2155 Make in_stock? work for both variants and overrides by moving it from VariantStock to variant_decorator.
Added tests for it in scope_hub_to_variant and improved VO shopping specs
2019-02-01 16:18:09 +00:00
luisramos0
5d82efa213 Add unit test for VariantStock.can_supply? 2019-02-01 16:16:04 +00:00
Isaac Haseley
09d3cea830 Lazy-load one more translation 2019-02-01 09:22:26 -06:00
luisramos0
80af7c770b Remove rescue from products_reset_strategy in product import: if setting count_on_hand fails the import will raise a RuntimeError 2019-02-01 08:32:45 +00:00
luisramos0
4b9be6f1a8 Change product import's product_reset_strategy from depending on the inexistent variant.count_on_hand DB field and instead make individual calls to variant.count_on_hand= defined in VariantStock.
Also, added spec to test return value of the reset method: it should return number of updated records.
2019-02-01 08:22:50 +00:00
Pau Pérez Fabregat
faea876ff0 Merge pull request #3361 from luisramos0/2-0-report-spec
[Spree Upgrade] Phase 2 - Fix some specs in reports_spec and in lettuce share report
2019-02-01 08:26:55 +01:00
Isaac Haseley
73a58435a8 Adopt one/other pluralization 2019-01-31 21:45:57 -06:00
Isaac Haseley
a18c98191a Better accomodate different sentence structures 2019-01-31 21:45:57 -06:00
Isaac Haseley
8543bb7cfb Add missing 'active products' translation on dashboard 2019-01-31 21:45:57 -06:00
Hugo Daniel
fa1525bdd3 Upgrade views to Spree 2 and apply overrides 2019-01-31 12:59:05 +01:00
Maikel
a9bac2c1af Merge pull request #3411 from openfoodfoundation/transifex
Transifex
2019-01-31 13:42:50 +11:00
Transifex-Openfoodnetwork
32c5c48709 Updating translations for config/locales/en_US.yml 2019-01-31 12:38:44 +11:00
Jefferson Faseler
d4d0489328 Update name spaces for rake tasks to shorter 'ofn'. 2019-01-30 17:14:00 -05:00
Kristina Lim
65438e2619 Refactor checking no preview image in specs 2019-01-31 05:04:18 +08:00
Kristina Lim
a3c808a172 Refactor checking of preview image path in specs 2019-01-31 05:02:57 +08:00
Kristina Lim
777712a0e9 Fix race condition in enterprise image feature specs 2019-01-31 04:52:40 +08:00
Transifex-Openfoodnetwork
24c12897de Updating translations for config/locales/fr_CA.yml 2019-01-31 07:42:29 +11:00
Transifex-Openfoodnetwork
bd43e06605 Updating translations for config/locales/fr_CA.yml 2019-01-31 07:41:40 +11:00
luisramos0
3595abc08a Fix seeds script for cases where default stock location already exists in the DB 2019-01-30 15:08:37 +00:00
luisramos0
f6e6f67e7d Switch Spree::Config test setup with a mock in reports_spec to keep global test setup untouched 2019-01-30 15:03:23 +00:00
Maikel Linke
18b3363e65 Use patch to hide Paypal gateway password 2019-01-30 15:43:59 +11:00
Maikel
155b205ac2 Merge pull request #3401 from luisramos0/2-0-stable-jan-29th
[Spree Upgrade] Merging master into 2-0-stable (4th run in Jan2019)
2019-01-30 14:44:40 +11:00
luisramos0
6d2765e352 Convert if statement in case statement in product import entry validator 2019-01-29 23:53:37 +00:00
Maikel
f3ff7ca2fe Merge pull request #3366 from coopdevs/fix-orders-controller-spec
Fix orders controller spec
2019-01-30 10:27:17 +11:00
dependabot[bot]
8750310648 Bump dalli from 2.7.2 to 2.7.9
Bumps [dalli](https://github.com/petergoldstein/dalli) from 2.7.2 to 2.7.9.
- [Release notes](https://github.com/petergoldstein/dalli/releases)
- [Changelog](https://github.com/petergoldstein/dalli/blob/master/History.md)
- [Commits](https://github.com/petergoldstein/dalli/compare/v2.7.2...v2.7.9)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-01-29 19:14:15 +00:00
luisramos0
cc4825290b Fix type conversion problem in product import entry validator 2019-01-29 15:45:22 +00:00
luisramos0
dce2524353 Added now mandatory shipping_category_id to CSVs in tests in admin/product_import_spec 2019-01-29 14:55:19 +00:00
luisramos0
ab2397785b Adapted product import EntryProcessor and EntryValidator to new VariantStock logic where on_hand is set at variant level (not at product level) and only after saving the variant 2019-01-29 14:55:18 +00:00
luisramos0
2ffc5305d7 Adapted VariantStock to handle on_hand string values (product import is set on_hand with string values) 2019-01-29 14:55:18 +00:00
luisramos0
fc1004cb3a Added now mandatory shipping_category_id to CSVs in most tests in models/product_importer_spec 2019-01-29 14:55:18 +00:00
luisramos0
729feb16f1 Merge branch 'master' into 2-0-stable-jan-29th 2019-01-29 12:38:34 +00:00
Pau Perez
c50fa1224b Do not restore adjustments that got deleted
If something in the block deleted the adjustment update_attribute will
fail.
2019-01-29 09:40:54 +01:00
Pau Perez
59f39b14f4 Do not restore adjustments that aren't in the hash
This way we don't modify adjustments that get created as part of the
passed block. We don't know how this might be used in the future.
2019-01-29 09:40:54 +01:00
Pau Perez
f4b790eefa Restore adjustments state after updating
We don't know exactly if all adjustments are closed in all
circumstances, so it's better to be conservative until we figure out.
Chances are that non-completed orders have them open.
2019-01-29 09:40:54 +01:00
Pau Perez
8eab3c5ec1 Extract meaningful methods from controller action
This sets the ground for future refactorings while providing some more
readability and context.
2019-01-29 09:40:54 +01:00
Pau Perez
c9429760cd Trigger the appropriate callbacks from controller 2019-01-29 09:40:54 +01:00
Pau Perez
0b62b4621f Make expectation easier to reason about 2019-01-29 09:40:54 +01:00
Pau Perez
9d1d8513e7 Make controller req. params a bit more obvious 2019-01-29 09:40:54 +01:00
Pau Perez
f589d4125d Restore distributor in test that relies on it 2019-01-29 09:40:54 +01:00
Pau Perez
1bceb0748a Do not modify config's state in test 2019-01-29 09:40:53 +01:00
luisramos0
8a86c0473d Change app config to keep using the same v1 shipping method calculators and not the ones spree v2 introduces, these are copy pasted versions that work with packages
See this commit for more details: 18e5b98f5c (diff-b0846898827183f530c113ad7b83b8ea)

Also:
- remove shipping method restriction on calculators to inherit from Spree::Shipping::ShippingCalculator so that OFN customized calculators keep working
- add shipping method serializer spec to test serialization of all shipping methods configured
2019-01-27 21:03:32 +00:00
luisramos0
bd24d3e27a Remove setting the now inexistent global config allow_backorders to false in subs specs because the default value for on_demand (set through stocklocation.backorderabl_default) is false in all specs 2019-01-25 22:12:13 +00:00
luisramos0
216afce6fe Add missing translations detected in features/admin/subscriptions_spec 2019-01-25 22:11:29 +00:00
Kristina Lim
5992bba97b Import color variables in new page SCSS partials
"admin/all.css" which imports these SCSS partials already imports the
color variables in "admin/variables", so actually there should be no
need to import the variables again.

However, "application.css" calls "require_tree", which means asset
precompilation through Sprockets would attempt to compile each of the
SCSS partials individually. When compiled individually, the color
variables are not available to these partials.

This is a quick solution to allow precompilation of "application.css" to
complete.
2019-01-26 03:29:19 +08:00
Kristina Lim
4a58aedf09 Use clearer translation for "No Upcoming OC" 2019-01-26 02:03:57 +08:00
Kristina Lim
c33808e8f5 Extract some actions in tests into methods 2019-01-26 02:03:56 +08:00
Kristina Lim
da4d6a092a Add spec helper for choosing today from datepicker 2019-01-26 02:03:56 +08:00
Kristina Lim
9965e95c65 Refactor methods in SubscriptionVariantsService 2019-01-26 02:03:55 +08:00
Kristina Lim
b691d727a7 Move OFN::SubscriptionService to SubscriptionVariantsService 2019-01-26 02:03:55 +08:00
Kristina Lim
c23002102c Add warning for unavailable subscription items 2019-01-26 02:03:55 +08:00
Kristina Lim
929290fc77 Reduce restrictions for creating subscriptions
Allow the following variants:

* Variants of permitted producers
* Variants of hub
* Variants that are in outgoing exchanges where the hub is receiver
2019-01-26 02:03:54 +08:00
Kristina Lim
57f6a7a3b9 Support clicking different text for select2 helper
Interaction with the variant autocomplete is not precise. The specs only
search for the product name, then click the first result that matches
the product name which they see.

This could have been the case because searching using the full variant
name does not match the variant. For example, searching "Some Product -
1kg" would not have results, while searching only "Some Product" (the
product name) would list "Some Product - 1kg".

Clicking the first match does not work in all scenarios.

This allows using a separate text for searching and for clicking.
2019-01-26 02:03:54 +08:00
Kristina Lim
d3f20289f8 Move setup of feature specs for creating subscriptions 2019-01-26 02:03:53 +08:00
Kristina Lim
35c0bcb3df Add tests for eligible variants for a subscription 2019-01-26 02:03:53 +08:00
Kristina Lim
28c70c7719 Fix nesting of specs for editing subscriptions 2019-01-26 02:03:53 +08:00
Kristina Lim
b9492d6483 Fix setup in tests for SubscriptionValidator 2019-01-26 02:03:49 +08:00
Kristina Lim
b6d8611359 Return early in JS if last batch 2019-01-25 09:06:25 +08:00
Kristina Lim
4425b0416d Rename import_data feature test method 2019-01-25 04:42:11 +08:00
Kristina Lim
b0efc3a2fa Add feature spec for large file import 2019-01-25 04:42:06 +08:00
dependabot[bot]
5610f64c7a Bump redcarpet from 3.2.3 to 3.4.0
Bumps [redcarpet](https://github.com/vmg/redcarpet) from 3.2.3 to 3.4.0.
- [Release notes](https://github.com/vmg/redcarpet/releases)
- [Changelog](https://github.com/vmg/redcarpet/blob/master/CHANGELOG.md)
- [Commits](https://github.com/vmg/redcarpet/compare/v3.2.3...v3.4.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-01-24 19:14:52 +00:00
Kristina Lim
b67ba89aca Process batches of the import CSV one after another
Start the HTTP request for processing next batches only after the
previous batch has completed.

A con of this approach is that the user needs to keep their browser open
for later parts of the large CSV to be processed, but this is better
than a higher chance of requests timing out.
2019-01-25 00:33:13 +08:00
Kristina Lim
bf084cd8df Move import batch size outside method 2019-01-25 00:28:56 +08:00
leandroalemao
dfa11834e3 [ISSUE-3348] LC: Fix moment.js deprecation warning 2019-01-24 11:16:31 +00:00
luisramos0
9f0958d0a4 Fix conflicts in gemfile lock 2019-01-24 09:36:57 +00:00
Maikel
937aaf67c3 Merge pull request #3250 from coopdevs/open-adjustments-for-update
[Spree Upgrade] Open adjustments to enable update
2019-01-24 10:25:16 +11:00
luisramos0
40014b83bd Fix order_cycle_management_report shipping methods filter
The original fix to adapt to v2 was wrong and still using deprecated order.shipping_method_id, this new version is now filtering the correct shipping_method_id in shipping_rates
2019-01-23 16:43:17 +00:00
luisramos0
908c32587b Fix xero invoices specs in reports_spec by removing the shipping adjustment as this is put in the order by the standard order callbacks when line items are added 2019-01-23 15:07:31 +00:00
dependabot[bot]
ea7f62123b Bump jwt from 1.5.6 to 2.1.0
Bumps [jwt](https://github.com/jwt/ruby-jwt) from 1.5.6 to 2.1.0.
- [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/v1.5.6...v2.1.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-01-21 19:14:44 +00:00
Pau Pérez Fabregat
2b95b5e797 Merge pull request #3347 from luisramos0/2-0-default-on-demand
[Spree Upgrade] Sets StockLocation.backorderable_default to false in test factories
2019-01-21 17:34:46 +01:00
luisramos0
0f26080d79 In lettuce share report spec, call method directly instead of using send 2019-01-21 15:00:37 +00:00
Pau Pérez Fabregat
d8710d283a Merge pull request #3320 from luisramos0/2-0-subs-mailer
[Spree Upgrade] Phase 2 - Subscriptions - Specify :mailer type in SubscriptionMailer spec
2019-01-21 15:09:56 +01:00
Pau Pérez Fabregat
807c45a25c Merge pull request #3349 from coopdevs/fix-shipment-without-fee
Fix shipment without fee
2019-01-21 14:51:10 +01:00
Pau Pérez Fabregat
659c47340e Merge pull request #3353 from luisramos0/2-0-stable-jan-17th
[Spree Upgrade] Merging master into 2-0-stable (third run in Jan2019)
2019-01-21 11:06:57 +01:00
luisramos0
9b2fb56025 Fix reports_spec sales tax report test by calling count_on_hand setter, setting shipping_method in the right step in the checkout workflow and changing login method to match all other tests in this spec 2019-01-20 20:40:14 +00:00
luisramos0
4669c71b19 Fix lettuce_share_report_spec by adapting count_on_hand setter, it's not a db column anymore 2019-01-20 20:40:14 +00:00
luisramos0
5d86d3769e Improve variable names in lettuce_share_report_spec 2019-01-20 20:40:14 +00:00
dependabot[bot]
990b90009e Bump stripe from 3.3.2 to 4.5.0
Bumps [stripe](https://github.com/stripe/stripe-ruby) from 3.3.2 to 4.5.0.
- [Release notes](https://github.com/stripe/stripe-ruby/releases)
- [Changelog](https://github.com/stripe/stripe-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/stripe/stripe-ruby/compare/v3.3.2...v4.5.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-01-18 19:17:05 +00:00
Pau Perez
a99a4725c9 Add #shipment to conform to OFN's decision
This ensures we can still use Order#shipment although Spree deprecates
it, while fixing a bug at the same time. The problem that was making the
test fail was on `Order#shipment` that Spree defines.

If the shipments association changes, `#shipment` returns stale data.
That is because the order object we might be using is still alive, and
so its @shipment ivar still holds an old shipment object (it's not nil)
and thus `@shipment ||= shipments.last` doesn't evaluate the right-hand
side of the expression.

Note that we need to `prepend` the evaluation of the concern (which it's
been rename) for our methods to take precedence over Spree ones. With
`include`, Spree's `#shipment` would still be picked up making the test
fail.
2019-01-18 16:02:51 +01:00
luisramos0
01f0671f6d Add missing accept alert in products_spec when deleting product properties 2019-01-18 12:45:29 +00:00
luisramos0
6da94fc960 Adapt cart_controller_spec to new variant_stock where variant count_on_hand can only be set after saving the variant 2019-01-18 12:45:29 +00:00
luisramos0
eac365182f Adapt variants_stock_levels_spec to new variant_stock where variant count_on_hand can only be set after saving the variant 2019-01-18 12:45:25 +00:00
luisramos0
13d65a4a39 Fix Gemfile.lock by running bundle install 2019-01-18 11:43:58 +00:00
luisramos0
0460e7fc6c Merge branch 'master' into 2-0-stable-jan-17th 2019-01-17 22:51:25 +00:00
luisramos0
f896e78e6f Set StockLocation.backorderable_default to false in DefaultStockLocation and in StockLocation factory.
This makes the default value of variant.on_demand false in all environments and in tests.

Additionally, adapt VariantStock.on_demand test and product factory to this change (setting on_hand value in product factory so it's not out of stock by default).
2019-01-17 20:28:05 +00:00
luisramos0
1d60732581 Improve readability of payment_method_spec 2019-01-17 20:18:43 +00:00
luisramos0
b52c99ac26 Delete on_hand test in product spec, this is already covered in product_stock_spec 2019-01-17 20:18:43 +00:00
Matt-Yorkley
a3b9936f37 Improve matching inventory using 'items' unit type 2019-01-17 09:33:39 +00:00
Pau Perez
1e03835391 Update order while adjustments are open
Spree supports updating line items as the model contains these two
callbacks:

f55722b38d/core/app/models/spree/line_item.rb (L27-L28)

However, as
f55722b38d/core/app/models/spree/adjustment.rb (L1-L7)
clearly states, due to Adjustment's state machine, once the order is
finalized it can't be updated. Then, if we want to have an up-to-date
adjustment_total attribute for a complete order we must update it while
the adjustments are open. Otherwise, the following `immutable?` check
does not pass.

f55722b38d/core/app/models/spree/adjustment.rb (L84-L92)
2019-01-16 15:28:54 +01:00
Pau Pérez Fabregat
b05b2c3a5a Merge pull request #3254 from coopdevs/add-default-stock-location
[Spree Upgrade] Create the default StockLocation in DB
2019-01-16 12:57:45 +01:00
Pau Pérez Fabregat
d37d964ab9 Merge pull request #3311 from luisramos0/2-0-stable-jan-11th
[Spree Upgrade] Merging master into 2-0-stable (second run in Jan2019)
2019-01-16 12:32:52 +01:00
Matt-Yorkley
79dce01aef Add spec for new on_demand logic 2019-01-16 01:19:01 +00:00
Matt-Yorkley
7dc7ffe1b7 Update inventory template 2019-01-16 01:18:46 +00:00
luisramos0
0009b663e7 Specify :mailer type in specs
According to RSpec docs we need to specify type: :mailer for mails to
work. Check it out:
https://relishapp.com/rspec/rspec-rails/v/3-8/docs/mailer-specs.

This fixes all specs in SubscriptionMailer
2019-01-13 15:50:35 +00:00
Pau Perez
5b8c0dffe2 Remove test for a state that is no longer possible 2019-01-11 16:39:06 +01:00
Pau Perez
817bf4caa1 Explain why a index forbids more than a location 2019-01-11 16:39:06 +01:00
Pau Perez
10a678bdfe Rely on Spree's default StockLocation 2019-01-11 16:39:06 +01:00
Pau Perez
730d5ff7d6 Include the default location in seed data
This ensures that new OFN instances will have the proper stock location
set up.
2019-01-11 15:52:25 +01:00
Pau Perez
9ebe112bcc Abstract OFN's default stock location into a class 2019-01-11 15:52:09 +01:00
luisramos0
9ab99f13c4 Merge branch 'master' into 2-0-stable-jan-11th 2019-01-11 11:58:24 +00:00
Matt-Yorkley
3f62d82afc Add more inventory testing for visibility in the inventory UI 2019-01-11 11:26:38 +00:00
luisramos0
292f22af4e Adapt factory completed_order_with_fees to new parent order_with_totals_and_distribution by cleaning up duplicate shipping fees 2019-01-09 23:31:40 +00:00
luisramos0
e787a317dc Adapt user_balance_calculator_spec to new order_with_totals_and_distribution with shipping fee correctly included in its total 2019-01-09 16:02:09 +00:00
luisramos0
e45f7571fb Fix order_with_totals_and_distribution by updating shipping fees 2019-01-09 15:20:28 +00:00
Pau Pérez Fabregat
0eefd2455c Merge pull request #3293 from luisramos0/2-0-stable-jan-8th
[Spree Upgrade] Merging master into 2-0-stable (first run in Jan2019)
2019-01-09 16:11:18 +01:00
luisramos0
2cc8a0e9e3 Fix models/variant_override_spec by setting mandatory on_demand true when count_on_hand is nil 2019-01-08 15:32:10 +00:00
luisramos0
134a51ab1d Fix merge typo in the cancel email method of the order mailer decorator 2019-01-08 15:31:28 +00:00
luisramos0
e28f9a7c84 Merge branch 'master' into 2-0-stable-jan-8th 2019-01-08 14:29:50 +00:00
Maikel
14ccb39478 Merge pull request #3287 from luisramos0/2-0-edit-variants
[Spree Upgrade] Fix variant edit page optiontype deface code
2019-01-08 16:37:38 +11:00
Maikel
abbbfd6191 Merge pull request #3286 from luisramos0/2-0-order-spec
[Spree Upgrade] Fix specs in admin orders spec
2019-01-08 16:35:59 +11:00
Maikel
a46180ef78 Merge pull request #3282 from luisramos0/2-0-credit-card
[Spree Upgrade] Fix credit card spec that was depending on current year
2019-01-08 16:34:03 +11:00
Maikel
68df27df02 Merge pull request #3281 from luisramos0/2-0-tab-ransl
[Spree Upgrade] 3119, 3112 and 3073 - fix menu translations
2019-01-08 16:31:41 +11:00
luisramos0
676f0e71b8 Fix variant edit page optiontype deface code 2019-01-07 12:16:47 +00:00
luisramos0
bdefc0ebd1 Fix admin orders spec by adapting the spec to the recently de-defaced page 2019-01-07 12:16:28 +00:00
luisramos0
42eb92c40a Add missing translation related to capture payments in the backoffice 2019-01-07 12:16:28 +00:00
luisramos0
503d515930 Fix credit card spec that was depending on current year
After this commit 5d93d1dedb, this static fix was meant to fail 3f33e28839
2019-01-07 12:16:09 +00:00
luisramos0
d3325ed7bb Add translation entries for admin menu tabs.
This was moved to new namespace tab in spree 2, see 4c82bfdf48
2019-01-07 12:15:36 +00:00
Luis Ramos
db6d39cedd Merge pull request #3277 from openfoodfoundation/revert-3246-2-0-create-variants
Revert "[Spree Upgrade] Set on_demand default value to false in test factories"
2019-01-07 11:46:37 +00:00
Luis Ramos
116b842852 Revert "[Spree Upgrade] Set on_demand default value to false in test factories" 2019-01-03 23:54:17 +00:00
Maikel
832dca9742 Merge pull request #3247 from coopdevs/fix-anonymous-checkout-spec
[Spree Upgrade] Provide anonymous user instead of nil
2019-01-02 18:13:06 +11:00
Maikel
63ec4b59fe Merge pull request #3246 from luisramos0/2-0-create-variants
[Spree Upgrade] Set on_demand default value to false in test factories
2019-01-02 18:02:34 +11:00
Maikel
f68fd6eea9 Merge pull request #3242 from luisramos0/2-0-line-item-destroy
[Spree Upgrade] Fix line item destroy by forcing quantity to zero and update_inventory
2019-01-02 17:44:25 +11:00
Maikel
a3b7364c75 Merge pull request #3241 from luisramos0/2-0-checkout-out-of-stock
[Spree Upgrade] Fix checkout_controller_spec
2019-01-02 17:37:34 +11:00
Maikel
3ec7ccb12c Merge pull request #3240 from luisramos0/2-0-orders-ctrl-api
[Spree Upgrade] Fix api orders controller spec broken tests
2019-01-02 17:36:40 +11:00
Maikel
d5c48d7c41 Merge pull request #3239 from luisramos0/2-0-ship-method-restart-checkout
[Spree Upgrade] Fix restart checkout spec
2019-01-02 17:33:48 +11:00
Pau Perez
3e793652e8 Provide anonymous user instead of nil
As explained in
0181835fb6/app/models/spree/user.rb (L26-L32),
all orders have a user so checking out as a guest is just using an
automatically generated user by means of `.anonymous!`.
2018-12-27 12:18:27 +01:00
luisramos0
467623f000 Sets StockLocation.backorderable_default to false in test factories
This makes the default value of variant.on_demand be false
2018-12-26 22:16:05 +00:00
luisramos0
d44c4778e1 Improve line item code by merging multiple destroy hooks into a single hook: update_inventory_on_destroy. This makes the code easier to read 2018-12-24 16:39:06 +00:00
luisramos0
429e513a77 Improve line_item code by moving order.shipment reload to a line_item after_destroy hook 2018-12-23 09:15:18 +00:00
luisramos0
b83ec8d357 Add order.shipments reload to line_item.update_inventory. This is necessary when destroying line items as update_inventory may delete the shipment from the order 2018-12-23 00:23:49 +00:00
luisramos0
26b5250f2c Fix line item destroy by forcing quantity to zero and update_inventory before_destroy so that the variant is restocked 2018-12-22 23:27:27 +00:00
luisramos0
4dd41bae9c Change out of stock message in spec. Now the checkout controller is returning the error message, not the line items validator 2018-12-21 21:50:13 +00:00
luisramos0
c2e05e7d87 In api orders controller spec, remove inventory_units_shipment_id_null as the filter was removed in spree 2
Also set the distributor used in the tests on completed_order_with_fees so results for that distributor are correct
2018-12-21 16:10:31 +00:00
luisramos0
8970131685 In restart checkout spec, create failed payment before the valid payment otherwise the failed payment will invalidate the previous payment, even if it is a good one
In spree 2, every new payment will invalidate all previous payments in the order
See here: c9eebba4f7
2018-12-21 15:13:52 +00:00
luisramos0
7155f28acf Remove shipping_method_id from RestartCheckout, destroying shipments is now enough as order.shipping_method_id is no longer used and will be dropped. See #2683 for more details 2018-12-21 15:13:43 +00:00
Luis Ramos
1007addddb Merge pull request #3232 from luisramos0/2-0-out-of-stock
[Spree Upgrade] Scope variants in line items availability validator
2018-12-21 12:05:43 +00:00
Luis Ramos
6935bfdf8b Merge pull request #3210 from luisramos0/2-0-bom-on-hand
[Spree Upgrade] Fix availability validator to include inventory_units in it's validation
2018-12-21 12:04:18 +00:00
luisramos0
6c70998b64 Move StockLocation.fill_status to VariantStock so we can easily override it 2018-12-21 11:33:07 +00:00
luisramos0
17ced61b3d Override Spree::Variant.in_stock? in VariantStock so that we don’t depend on Spree::Stock::Quantifier 2018-12-21 11:33:07 +00:00
luisramos0
1835d97013 Adapt line_item.sufficient_stock? to spree 2 2018-12-21 11:33:07 +00:00
luisramos0
d641705053 Add variant scoping to availability_validator_decorator by using line_item.scoper and moving Spree::Stock::Quantifier.can_supply? to VariantStock so that it becomes overridable 2018-12-21 11:33:07 +00:00
luisramos0
c0a095ffaf Improve variant_overrides_spec variable names 2018-12-21 11:33:07 +00:00
luisramos0
4f79fd5be0 Improve availability validator spec readability and remove unnecessary expect statements 2018-12-21 11:19:12 +00:00
luisramos0
c1aeb2e9a3 Improve naming in availability_validator_decorator and cover it with tests 2018-12-20 14:26:34 +00:00
luisramos0
bc22b0a58e Fix capping quantity to stock levels by always validating line items with quantity zero
Stock::Quantifier.can_supply? returns false for an input of zero when stock level is negative
2018-12-20 14:26:34 +00:00
luisramos0
3085e15961 Fix order factory by making line_item.skip_stock_check work in spree 2 2018-12-20 14:26:34 +00:00
luisramos0
88b1bb61d6 Fix availability validator to include inventory_units in it's validation 2018-12-20 14:26:34 +00:00
Luis Ramos
0aaa41ced0 Merge pull request #3228 from luisramos0/2-0-stable-dec-18th
[Spree Upgrade] Merging master into 2-0-stable (third run in Dec2018)
2018-12-19 09:30:57 +00:00
Maikel
4201549992 Merge pull request #3219 from luisramos0/2-0-payment-ctrl
[Spree Upgrade] Adapt payment controller spec to spree 2
2018-12-19 15:23:11 +11:00
luisramos0
6fc3562a73 Merge branch 'master' into 2-0-stable-dec-18th 2018-12-18 23:32:45 +00:00
Pau Pérez Fabregat
0c8cb8abe2 Merge pull request #3218 from coopdevs/handle-soft-deleted-products-in-serializer-spec
Handle soft deleted products in serializer spec
2018-12-18 08:59:36 +01:00
Luis Ramos
dc6509aa83 use association on updates rather than #find
Co-Authored-By: sauloperez <saulopefa@gmail.com>
2018-12-17 10:31:52 +01:00
luisramos0
a5bf7a1f35 Adapt payment controller spec to spree 2
In spree 2, since 5ed6015916, to fire a payment event the order needs to be in either payment or complete state
2018-12-14 16:04:19 +00:00
Pau Perez
be6c8be07a Handle soft deleted products when refreshing cache
Since cd3add960e Spree soft-deletes products and as such the models not
destroyed but updated setting a value for the `deleted_at` field.

This turns what used to be deletes into updates thus triggering AR's
update callbacks instead of the destroy ones. As a result, this bypasses
the logic to refresh the products cache on destroy and hits the
`after_save` callback.

Furthermore, since act_as_paranoid (the soft-delete gem Spree uses) uses
a default scope to avoid retrieving soft-deleted records we need to
purposefully fetch them in order to refresh the cache.
2018-12-14 15:13:06 +01:00
Pau Perez
51e277a183 Make test setup more readable 2018-12-14 15:12:41 +01:00
Maikel
24ca66bd71 Merge pull request #3207 from luisramos0/2-0-insuf-stock-transl
[Spree Upgrade] Add missing spree translations related to insufficient stock
2018-12-14 12:05:06 +11:00
Maikel
1ed880e353 Merge pull request #3206 from coopdevs/fix-redirection-on-admin-products-specs
[Spree Upgrade] Fix redirection on admin products specs
2018-12-14 11:59:21 +11:00
Maikel
f0d3992511 Merge pull request #3203 from luisramos0/2-0-fix-prod-images-delete
[Spree Upgrade] Fix product properties and images deletion
2018-12-14 11:54:05 +11:00
Maikel
eedba7a35b Merge pull request #3197 from luisramos0/2-0-product-stock
[Spree Upgrade] Adapt Product level stock management to Spree 2
2018-12-13 10:53:46 +11:00
luisramos0
5183c90c89 Add missing spree translations related to insufficient stock 2018-12-12 15:34:48 +00:00
Pau Perez
43cacfc2fc Fix redirection on admin/products controller specs
In Spree v2.0 the product attributes being sent were no longer valid.
Providing a shipping category and setting a stock location on the DB so
that a stock item can be created fixes them.

Remember `Variant#create_stock_item`, which is defined as an
`after_create` callback, relies on `StockLocation` to create the item.
2018-12-12 13:10:39 +01:00
luisramos0
47be452ca0 Make ProductsController#create and #update work by not mass-assigning the provided on_hand and on_demand values and set them in product variant after the product is created 2018-12-12 12:10:29 +00:00
luisramos0
66e69edca4 Rename ProductOnDemand to ProductStock; move product.on_hand into it; add product.on_demand; and remove unnecessary on_demand= 2018-12-12 12:10:25 +00:00
Pau Perez
28cb1bf687 Clarify nasty boolean logic on method 2018-12-12 12:57:23 +01:00
luisramos0
181915c63a Fix deletion of product properties 2018-12-11 15:53:40 +00:00
luisramos0
4b74e50353 Make ProductsController#bulk_update work by making ProductSet#create_variant not mass-assigning the provided on_hand and on_demand values and set them after each variant is created 2018-12-11 15:18:00 +00:00
luisramos0
b5379a204b Fix deletion of product images 2018-12-11 15:10:26 +00:00
Maikel
1819fc8493 Merge pull request #3199 from luisramos0/2-0-stable-dec-10th
[Spree Upgrade] Merging master into 2-0-stable (second run in Dec2018)
2018-12-11 18:50:24 +11:00
Pau Pérez Fabregat
7834fa4d00 Merge pull request #3190 from luisramos0/2-0-new-product
[Spree Upgrade] Fix "new product" page specs and an html issue
2018-12-11 08:35:26 +01:00
Maikel
d63ae792b3 Merge pull request #2775 from luisramos0/2-0-checkout-ship-method
[Spree Upgrade] Handle shipping_method_id in checkout
2018-12-11 11:59:03 +11:00
luisramos0
cdee7c0422 Merge branch 'master' into 2-0-stable-dec-10th 2018-12-10 16:41:29 +00:00
Luis Ramos
1bc51dea40 Merge pull request #3195 from mkllnk/2938-fix-create-order
[Spree Upgrade] 2938 Fix Create Order in Admin - missing translation
2018-12-10 13:20:02 +00:00
Pau Pérez Fabregat
b8a61257da Merge pull request #3188 from luisramos0/2-0-ctrl-specs
[Spree Upgrade] Fix line_item_controller spec by adpating to new spree 2 factories
2018-12-10 12:31:26 +01:00
luisramos0
4f4fc00549 Improve code, specs and comments in the shipping_method selection process in the checkout controller 2018-12-09 20:05:10 +00:00
luisramos0
8fb103ce8d Fix new_product div in new product page 2018-12-08 14:53:50 +00:00
luisramos0
7ecce51b8b Create default stock location and set required product.shipping_category in specs that create products 2018-12-08 14:52:50 +00:00
Maikel Linke
cac4fa4816 Use I18n.t instead of Spree's JS t function 2018-12-07 23:38:05 +11:00
Maikel
da6dc20fcf Merge pull request #3165 from coopdevs/fix-send-confirmation-instructions-specs
[Spree Upgrade] Fix send confirmation instructions specs
2018-12-06 16:24:40 +11:00
Maikel
883e9bbdd8 Merge pull request #3166 from luisramos0/2-0-orders-tab-without-shipments
[Spree Upgrade] Remove shipments option from orders tab (gone in spree 2)
2018-12-06 15:39:14 +11:00
Maikel
1b94b10bb0 Merge pull request #3171 from luisramos0/2-0-var-over-hide
[Spree Upgrade] Remove hide class from the hide button in the inventory list
2018-12-06 15:21:34 +11:00
luisramos0
7df869bd35 Fix line_item_controller spec by adpating to new spree 2 factories 2018-12-05 22:22:15 +00:00
luisramos0
afd243c548 Replace stub with allow in checkout_controller_spec 2018-12-05 15:40:14 +00:00
luisramos0
460e010408 Removed shipments from orders tab. This option is removed in spree 2 2018-12-05 11:38:16 +00:00
Pau Pérez Fabregat
72a4b4f8e2 Merge pull request #3158 from luisramos0/2-0-vos-scoping
[Spree Upgrade] Scopes variants on order completion and on changes to completed orders
2018-12-05 12:12:49 +01:00
Pau Perez
6af8544c52 Restore perform_deliveries value in tests 2018-12-05 10:20:13 +01:00
Pau Perez
25eb297215 Perform delivery when checking deliveries in specs 2018-12-05 10:05:39 +01:00
Pau Perez
064d9cf183 Do not hide flaky tests under endless retries
If it fails, needs fixing, not hiding the problem and making the test
suite longer.
2018-12-05 10:05:39 +01:00
Pau Perez
5845f80af0 Remove commented out code
Because git keeps it for you.
2018-12-05 10:05:39 +01:00
Pau Perez
6594529cda Fix manager invitation controller spec 2018-12-05 10:05:39 +01:00
Maikel
a2c8bea147 Merge pull request #3147 from luisramos0/2-0-vos
[Spree Upgrade] Adapt variant overrides to spree 2
2018-12-05 10:50:20 +11:00
luisramos0
02d0b7e88c Improve comment on VariantStock#move 2018-12-04 15:25:38 +00:00
Pau Pérez Fabregat
30e7d32cea Merge pull request #3157 from coopdevs/fix-producer-mailer-specs
[Spree Upgrade] Specify :mailer type in specs
2018-12-04 15:21:17 +01:00
luisramos0
7f7e7ea65e Remove hide class from the hide button in the inventory list
The hide button should not be hidden. The hide css class was no active in v1 but it is in v2, so we need to remove it
2018-12-04 10:55:55 +00:00
Maikel
60c8147391 Merge pull request #3164 from luisramos0/2-0-stable-dec-3rd
[Spree Upgrade] Merging master into 2-0-stable (first run in Dec2018)
2018-12-04 13:38:02 +11:00
Maikel
214235d8dd Merge pull request #3152 from coopdevs/fix-product-spec
[Spree Upgrade] Fix product spec
2018-12-04 12:07:33 +11:00
luisramos0
3776b891ce Merge branch 'master' into 2-0-stable-dec-3rd 2018-12-03 15:30:16 +00:00
Pau Perez
46bf4c9eea Specify :mailer type in specs
According to RSpec docs we need to specify type: :mailer for mails to
work. Check it out:
https://relishapp.com/rspec/rspec-rails/v/3-8/docs/mailer-specs.

This fixes all specs in producer_mailer_spec.rb.
2018-12-03 15:41:58 +01:00
luisramos0
258287b88d Add tests to cover CheckoutController#update with shipping_method_id 2018-11-30 17:04:46 +00:00
luisramos0
e23c4dda68 Add order_shipping_method specs to cover select_shipping_method 2018-11-30 12:58:27 +00:00
luisramos0
7a8c65b3ea In the checkout controller update process, grab shipping_method_id from form data and inject it in the order when the order workflow gets to delivery (which is when the order gets shipments created) 2018-11-30 10:46:31 +00:00
luisramos0
c032401eb0 Refactor checkout controller update method 2018-11-30 10:45:42 +00:00
Maikel
f859b7d3de Merge pull request #3153 from coopdevs/fix-missing-translations-in-password-edit
[Spree Upgrade] Add missing translations causing a test failure
2018-11-30 15:48:42 +11:00
luisramos0
d962358f15 Fix rubocop and transpec models/variant_override and its spec 2018-11-30 00:43:55 +00:00
luisramos0
0577011f5b Refactor variant override model and its spec: simplify move_stock and remove unused methods 2018-11-30 00:22:04 +00:00
luisramos0
782530d93b Scope variants in shipment manifest as they are fetched from DB 2018-11-29 20:43:15 +00:00
luisramos0
a18d289292 Scope variants on line_item before save hook update_inventory 2018-11-29 20:43:10 +00:00
luisramos0
6156aca467 Delegate stock_location.move to variant, and override it in the variant overrides scope 2018-11-29 19:32:52 +00:00
Luis Ramos
2284bfb604 Merge pull request #3150 from luisramos0/new-knapsack-report
[Spree Upgrade] New up to date knapsack report for 2-0-stable branch
2018-11-29 11:13:51 +00:00
Pau Perez
957c38e4f2 Add missing translations causing a test failure 2018-11-28 18:38:09 +01:00
Pau Perez
7834b1d3f3 Fix test case for invalid product master 2018-11-28 17:39:59 +01:00
Pau Perez
ab542cfdb2 Remove commented out code 2018-11-28 17:39:51 +01:00
luisramos0
3009ab2f1a New up to date kanpsack report for 2-0-stable branch 2018-11-28 12:36:22 +00:00
Luis Ramos
1bc06e7384 Merge pull request #3139 from luisramos0/2-0-bulk-prod-update-spec-fix
[Spree Upgrade] Fix tests in bulk_product_update spec
2018-11-27 18:36:36 +00:00
Pau Pérez Fabregat
c5ae9bdce2 Merge pull request #3132 from luisramos0/2-0-variant-ondemand
[Spree Upgrade] Add VariantStock.on_demand as attribute_accessible
2018-11-27 18:05:34 +01:00
luisramos0
64d16258cf Fix tests in bulk_product_update spec by:
- setting on_hand in the variant and not in the product directly
- setting variant on_demand to false (default from the factory is on_demand true)
- saving the variant after doing this to trigger appropriate callbacks like creating missing variant stock items
2018-11-27 16:03:52 +00:00
Maikel
1b58c2519a Merge pull request #3138 from luisramos0/2-0-stable-nov-24th
[Spree Upgrade] Merging master into 2-0-stable (third run in Nov2018)
2018-11-27 16:16:32 +11:00
Maikel
296029ef28 Merge pull request #3131 from coopdevs/fix-restart-checkout-spec
[Spree Upgrade] Fix checkout spec due to shipments
2018-11-27 15:16:01 +11:00
luisramos0
e153510a71 Merge branch 'master' into 2-0-stable-nov-24th 2018-11-24 15:19:38 +00:00
Luis Ramos
94a2972d57 Merge pull request #3133 from HugsDaniel/3029-products-renderer-spec
[Spree Upgrade] Fix ProductsRenderer specs
2018-11-23 18:23:33 +00:00
luisramos0
73ed5eeaac Fix product import spec related to this change, the value provided to on_hand must be an integer 2018-11-23 18:07:51 +00:00
luisramos0
f509fa6c86 Make variantStock.on_demand= save the variant so that it doesn't impact on_hand that is already saving the variant with a lock 2018-11-23 18:07:08 +00:00
luisramos0
ba8aa110c2 Fix VariantStock.overwrite_stock_levels by using stock_item.adjust_count_on_hand. This makes product_controller_decorator.bulk_update work 2018-11-23 18:06:48 +00:00
Hugo Daniel
f1dc52fe4e Set variant.on_demand to false 2018-11-23 14:30:14 +01:00
luisramos0
6cdaaa9e7d Add VariantStock.on_demand as attribute_accessible so it can be mass assigned from product_controller_decorator.bulk_update 2018-11-23 12:04:00 +00:00
Pau Pérez Fabregat
0237432ba4 Merge pull request #3125 from luisramos0/2-0-variant-stock-item
[Spree Upgrade] Fix Product model spec and small refactoring in VariantStock
2018-11-23 12:53:52 +01:00
Pau Perez
23421758fa Fix checkout spec due to shipments 2018-11-23 12:28:31 +01:00
luisramos0
7257ab30f1 Fix typo in inventory_error_flash_for_insufficient_quantity translation 2018-11-23 08:39:46 +00:00
luisramos0
d28f47046a Fix product model spec by removing unnecessary on_hand setter and adding required fields for a new product 2018-11-22 20:38:58 +00:00
luisramos0
134b73d730 Improve VariantStock code by extracting stockitems.first to a separate method 2018-11-22 20:38:46 +00:00
Luis Ramos
0052d571b9 Merge pull request #3100 from HugsDaniel/2999-checkout-feature-specs
[Spree Upgrade] Fix checkout feature specs
2018-11-22 16:49:41 +00:00
Hugo Daniel
d7a148bb75 Fix checkout feature specs 2018-11-22 17:01:39 +01:00
Luis Ramos
d060d31051 Merge pull request #3117 from HugsDaniel/3034-api-products-controller-spec
Use :user factory instead of build_stubbed to create the current_api_…
2018-11-22 14:10:05 +00:00
Hugo Daniel
a08ddd8171 Use :user factory instead of build_stubbed to create the current_api_user 2018-11-22 14:29:37 +01:00
Pau Pérez Fabregat
064ec7d270 Merge pull request #3108 from luisramos0/2-0-new-order
[Spree Upgrade] Add missing translation to admin new order creation page
2018-11-22 10:39:06 +01:00
luisramos0
2abf4e39cb Add missing translation to admin new order creation page 2018-11-21 23:22:43 +00:00
Luis Ramos
391deb94b0 Merge pull request #3102 from luisramos0/2-0-fix-admin-adjusts-spec
[Spree Upgrade] Fix spec/features/admin/adjustments_spec
2018-11-21 22:27:28 +00:00
luisramos0
24a7494103 Fix admin/adjustments spec by renaming test adjustment from Shipping to Extra Adjustment.
This was causing an error because the order factory now includes a Shipping adjustment
2018-11-21 13:41:16 +00:00
Maikel
733a018f37 Merge pull request #3081 from luisramos0/2-0-enterprise-groups
[Spree Upgrade] Fix features/admin/enterprise_groups_spec by replacing select2_search with select2_select
2018-11-20 16:41:05 +11:00
Maikel
b05bfc5cc7 Merge pull request #3075 from luisramos0/2-0-setting-transl
[Spree Upgrade] Fix translation issue in settings spec
2018-11-20 16:39:54 +11:00
Maikel
5e82d38bec Merge pull request #3071 from luisramos0/2-0-xdescribe-proxy-order
[Spree Upgrade] Move ProxyOrder controller to xdescribe
2018-11-20 16:38:42 +11:00
Maikel
6835d24fbf Merge pull request #3004 from luisramos0/2-0-mail-method-fix
[Spree Upgrade] Fix line Item specs with problems related to VariantStock.on_hand=
2018-11-20 16:37:19 +11:00
Luis Ramos
a7bd793ad2 Merge pull request #3074 from luisramos0/2-0-acct-transl
[Spree Upgrade] Fix missing translation in User transaction history
2018-11-20 00:43:24 +00:00
Luis Ramos
e297b19a91 Merge pull request #3069 from luisramos0/2-0-check-missing-translation
[Spree Upgrade] Add missing translation in the checkout confirmation page
2018-11-20 00:39:05 +00:00
Luis Ramos
d984d76e6b Merge pull request #3070 from luisramos0/2-0-order-spec-restart
[Spree Upgrade] Fix order spec restart checkout test and orders controller enterprise with fees test
2018-11-20 00:38:11 +00:00
luisramos0
5f48f2b8a1 Fix enterprise groups spec by replacing select2_search with select2_select for country and state in enterprise group address 2018-11-19 12:44:25 +00:00
Pau Pérez Fabregat
27267926dc Merge pull request #3079 from luisramos0/2-0-order-feature-spec
[Spree Upgrade] Fix 3 tests in shopping/orders_spec
2018-11-19 12:51:07 +01:00
luisramos0
bf32a21155 Allow adapted on_hand attr to be mass assigned in VariantStock.
Without specifying it in `attr_accessible`, `#assign_attributes` won't
work. See details in
https://apidock.com/rails/v3.2.13/ActiveRecord/Persistence/update_attributes
and https://apidock.com/rails/ActiveRecord/Base/assign_attributes.
2018-11-19 10:05:17 +00:00
luisramos0
9deb249dec Fix order by changing expected results: order is paid.
These tests use order factory order_with_credit_payment with ‘amount: order.total + 10000’ and since spree 2 when order payment state is credit_owned (customer has credit after the order), the order is considered paid 71c6c4f297
2018-11-18 20:58:55 +00:00
luisramos0
a20aba26cd Fix order feature spec by adapting to new spree 2 order factory with 5 line_items by default. Removed currency sign to avoid having problems with it, it's not really part of the spec objective 2018-11-18 16:51:43 +00:00
luisramos0
d29778e2d1 Fix translation issue in spec by refering the correct translation namespace: spree 2018-11-18 16:36:03 +00:00
luisramos0
d282823d3a Fix missing translation in user transaction history 2018-11-18 16:15:35 +00:00
luisramos0
d1071acfdb Move ProxyOrder controller to xdescribe. It's part of non-core feature subscriptions and will be left for spree upgrade phase 2 2018-11-17 12:23:52 +00:00
luisramos0
b40c0e5b80 Fix order controller spec with enterprise fees by adapting to new order factory with 5 line items by default 2018-11-17 12:11:23 +00:00
luisramos0
ee8d77bc09 Fix order spec restart checkout test by adding a required line_item to the order being tested 2018-11-17 11:57:16 +00:00
luisramos0
1fc11c5658 Add missing translation in the checkout confirmation page 2018-11-16 22:56:41 +00:00
Maikel
5ecea06098 Merge pull request #3024 from luisramos0/2-0-credit-card-ctrl
[Spree Upgrade] Fix credit card controller
2018-11-16 10:43:16 +11:00
Maikel
5d200b7753 Merge pull request #3026 from luisramos0/2-0-calculator-line-items-for
[Spree Upgrade] Improve failed_checkout_spec by making calculator decorator line_items_for work with new Stock::Package
2018-11-16 10:41:29 +11:00
Luis Ramos
f985e723e8 Merge pull request #3048 from mkllnk/2882-spree2-email-config
[Spree Upgrade] Update test mail setup for Spree 2
2018-11-15 22:25:50 +00:00
Luis Ramos
1dc5cc6d42 Merge pull request #3040 from luisramos0/2-0-refactor-factories
[Spree Upgrade] Simplify completed_order_with_fees factory and make shipment_with an ofn factory
2018-11-15 11:24:49 +00:00
luisramos0
9ba0fc268e Run transpec and clean up rubocop issues in credit_card_controller and spec 2018-11-15 11:07:43 +00:00
Pau Pérez Fabregat
fb56293748 Merge pull request #3046 from luisramos0/2-0-knapsack-report
[Spree Upgrade] New knapsack report
2018-11-15 09:32:10 +01:00
Maikel
d109f882fc Merge pull request #3038 from luisramos0/2-0-order-factory
[Spree Upgrade] Remove shipping_method_id from order factory
2018-11-15 15:22:31 +11:00
Maikel
a2c9ba60d8 Merge pull request #3035 from luisramos0/2-0-order-ctrl-line-item-delete
[Spree Upgrade] Fix orders controller spec when removing line items from order
2018-11-15 15:20:31 +11:00
Maikel
ebbe02523e Merge pull request #3019 from luisramos0/more-x-spec-reports
[Spree Upgrade] Make broken report specs xdescribe and leave them for spree upgrade pha…
2018-11-15 15:17:04 +11:00
Maikel
2d3f706c05 Merge pull request #3042 from luisramos0/2-0-stable-nov-14th
[Spree Upgrade] Merging master into 2-0-stable (second run in Nov2018)
2018-11-15 15:02:21 +11:00
Maikel Linke
1e312dfa41 Update test mail setup for Spree 2
https://github.com/openfoodfoundation/openfoodnetwork/issues/2882

The email setup differs between Spree 1 and Spree 2. We already
encapsulated that setup in a single method which now needed changing.
2018-11-15 14:30:46 +11:00
Maikel
a25cdd90de Merge pull request #3014 from luisramos0/2-0-payments_spec
[Spree Upgrade] Fix admin payments spec
2018-11-15 13:02:28 +11:00
luisramos0
ece21a674a Simplify completed_order_with_fees factory and make shipment_with factory an ofn factory to avoid creating extra dummy shipping_method in every test 2018-11-14 23:13:05 +00:00
luisramos0
688ec5fb21 Fix rubocop issues in calculator_decorator and calculator/flat_percent_item_total_spec 2018-11-14 23:04:38 +00:00
luisramos0
7c0627a823 Improve failed_checkout_spec by making calculator decorator line_items_for work with new Stock::Package 2018-11-14 23:04:38 +00:00
luisramos0
a5fb3e337d New knapsack report
New knapsack report for 2-0-stable. Makes the 4 jobs with 20 mins each.
2018-11-14 22:58:09 +00:00
Luis Ramos
c19e954113 Merge pull request #3009 from HugsDaniel/authenticate-api-use-through-logged-in-user
[Spree Upgrade] Authenticate API user through logged in user
2018-11-14 14:27:30 +00:00
luisramos0
0a77eeb4b6 Merge branch 'master' into 2-0-stable-nov-14th 2018-11-14 11:35:58 +00:00
luisramos0
19321b6d4f Fix admin payments spec. Add missing payment method to order.distributor 2018-11-14 11:26:26 +00:00
Hugo Daniel
3dd981ca05 Use logged in user (spree_current_user) for API authentication (current_api_user) 2018-11-14 11:58:28 +01:00
Pau Pérez Fabregat
a65e2487c4 Merge pull request #3013 from luisramos0/2-0-api-orders-ctrl-spec
[Spree Upgrade] Fix api/orders_controller_spec
2018-11-14 11:48:34 +01:00
luisramos0
2947d7a98c Remove shipping_method_id from order factory. This attribute is gone in spree 2 and doesnt need to be the responsibility of the order factory to handle order shipping method. The shipping method is selected only when the order workflow is progressed on checkout 2018-11-13 21:25:59 +00:00
luisramos0
9b894c6a55 Fix orders controller spec when removing line items from order. Improved spec and adapted to the fact that in spree 2 the default number of line items in this factory is 5 2018-11-13 19:51:26 +00:00
luisramos0
a234308a06 Fix credit card controller by adding a rescue for wrong arguments passed in params 2018-11-13 15:28:10 +00:00
luisramos0
2037413df7 Make some report specs xdescribe and leave them for spree upgrade phase 2 2018-11-13 14:53:42 +00:00
luisramos0
ef5d679f90 Fix api/orders_controller_spec by fixing expectations on order attributes: remove old attributes shipments_path and show_path 2018-11-12 16:31:57 +00:00
luisramos0
bbdbfc1374 Fix opi/orders_controller_spec by providing line items with shipment and thus make the order workflow work 2018-11-12 16:29:38 +00:00
Maikel
57efc36448 Merge pull request #2993 from Matt-Yorkley/user_class
Deal with failing Spree::LegacyUser test
2018-11-09 10:21:31 +11:00
Luis Ramos
0ea0016fc9 Merge pull request #2998 from coopdevs/adapt-product-on-demand
[Spree Upgrade] Adapt product on demand
2018-11-08 19:21:46 +00:00
Luis Ramos
ed7c12bd26 Merge pull request #2997 from luisramos0/2-0-stable-nov-8th
[Spree Upgrade] Merging master into 2-0-stable (first run in Nov2018)
2018-11-08 19:20:42 +00:00
Luis Ramos
4149c95c65 Merge pull request #2991 from Matt-Yorkley/missing_resource_translation
[Spree Upgrade] Import missing translations from Spree 2 to fix some tests
2018-11-08 12:34:53 +00:00
Luis Ramos
30bca40ed0 Merge pull request #2996 from coopdevs/update-products-new-js-template
[Spree Upgrade] Bring Spree changes on admin/products/new.js.erb
2018-11-08 12:13:47 +00:00
Luis Ramos
a3da941d8f Merge pull request #2992 from Matt-Yorkley/credit-cards
[Spree Upgrade] Failing credit card spec
2018-11-08 12:12:34 +00:00
Pau Perez
de31823151 Add #on_demand= to make product creation page work
We're bringing in the setter that got removed in Spree 2.0 so that we
can still pass an on_demand value from the product creation form.

However, we won't keep the getter to keep things simple. The frontend
seems to be checking the existence of variants anyway, so then it can
also check for product.master.on_demand and we avoid some logic on the
backend.
2018-11-08 11:41:58 +00:00
luisramos0
fcdb5cd7af Merge branch 'master' into 2-0-stable-nov-8th 2018-11-08 11:18:54 +00:00
Pau Perez
18c51dc596 Bring Spree changes on admin/products/new.js.erb
We copied it from Spree to then append a little change on it. Since the
original version changed in Spree 2.0 we need to update our copy.
2018-11-08 10:45:04 +00:00
Matt-Yorkley
8aa6b2c0ac Stub spree_api_key on Spree::LegacyUser when signing in as regular user 2018-11-08 00:07:24 +00:00
Matt-Yorkley
edbfd64a44 Set the Spree.user_class explicitly in spree initializer 2018-11-08 00:04:04 +00:00
Matt-Yorkley
fae0617639 Merge pull request #2986 from HugsDaniel/2985-api-product-images-specs
[Spree Upgrade] Add an API key for admin user
2018-11-08 00:01:46 +00:00
Matt-Yorkley
3f33e28839 Fix outdated credit card spec 2018-11-07 20:48:54 +00:00
Matt-Yorkley
cfc31f1fbd Import missing translations from Spree 2 to fix some tests 2018-11-07 19:23:28 +00:00
Hugo Daniel
bc9af7c45f Add an API key for admin user 2018-11-07 16:47:35 +01:00
Pau Pérez Fabregat
8547d5302c Merge pull request #2978 from Matt-Yorkley/spree-upgrade/orders#show
[Spree Upgrade] orders#show
2018-11-06 16:20:47 +00:00
Pau Pérez Fabregat
a4139a14a8 Merge pull request #2977 from luisramos0/2-0-payment-translation
[Spree Upgrade] Add missing failed authorization translation
2018-11-06 16:01:00 +00:00
Luis Ramos
86721d6d42 Merge pull request #2974 from luisramos0/2-0-user-balance
[Spree Upgrade] Fix User Balance Calculator spec
2018-11-06 16:00:44 +00:00
Pau Perez
71702af3c3 Have a single attributes list in serializer 2018-11-06 15:52:02 +00:00
Matt-Yorkley
d0b7b57017 Remove OrderSerializer#show_path and adjust to use #edit over #show 2018-11-06 11:07:14 +00:00
Matt-Yorkley
aaaec4777d Remove admin order #show link from helper 2018-11-06 11:03:06 +00:00
luisramos0
c191a1feb8 Add missing translation related to authorization failure 2018-11-06 10:20:52 +00:00
luisramos0
79fcc7bce0 Fix user balance calculator spec by setting a target_shipment on line item of the order being tested 2018-11-05 19:23:09 +00:00
Pau Pérez Fabregat
6bc14f4bab Merge pull request #2970 from Matt-Yorkley/2939-edit-order-button
Remove workaround in failing feature spec
2018-11-05 19:25:00 +01:00
Pau Pérez Fabregat
057412111d Merge pull request #2972 from coopdevs/mark-last-failing-enterprise-spec-pending
[Spree Upgrade] Mark last failing enterprises spec as pending
2018-11-05 18:59:47 +01:00
Pau Pérez Fabregat
e76bf81e2a Merge pull request #2973 from coopdevs/deliver-email-in-spec
[Spree Upgrade] Perform mail delivery in spec to make it pass
2018-11-05 18:58:37 +01:00
Pau Perez
f7b6867c28 Perform mail delivery in spec to make it pass
We need to purposefully enable deliveries for the deliveries array to
list this email. Otherwise the delivery logic is not executed and thus
the deliveries array never filled.
2018-11-05 17:49:08 +00:00
Pau Perez
21d756a1af Mark last failing enterprises spec as pending
This will get solved once we complete
https://github.com/openfoodfoundation/openfoodnetwork/issues/2971. Until
then, let's not focus on this spec to reach our 100% green test suite.
2018-11-05 16:45:53 +00:00
Matt-Yorkley
fd47756e2f Remove workaround in failing feature spec
Removed an old workaround that clicked a button multiple times.
This was no longer working and causing the spec to fail.
2018-11-05 11:19:57 +00:00
Pau Pérez Fabregat
50a06d1bd9 Merge pull request #2969 from luisramos0/2897-2-0-price-fix
[Spree Upgrade] Fix specs creating deleted variants
2018-11-05 11:59:06 +01:00
luisramos0
4f992a18f7 Fix specs creating deleted variants
Spree checks that each price belongs to a variant
Since we were creating deleted variants, the price models couldnt see those
2018-11-05 10:43:10 +00:00
Pau Pérez Fabregat
fe8303cb19 Merge pull request #2957 from luisramos0/2-0-paypal-spec
[Spree Upgrade] Fix occurrences of order.shipping_method= by replacing with order.shipments
2018-11-02 15:50:59 +01:00
Pau Pérez Fabregat
834520491c Merge pull request #2900 from luisramos0/raise_error_if_no_stock_item_available
[Spree Upgrade] Avoiding variantStock raise by creating variant first and then setting `count_on_hand`
2018-11-02 15:49:21 +01:00
Pau Pérez Fabregat
e635cfc9c1 Merge pull request #2901 from luisramos0/variants_including_master
[Spree Upgrade] Adapt product_decorator code to spree 2 with new variants_including_master
2018-11-02 15:48:19 +01:00
Pau Pérez Fabregat
b1f3fa14e5 Merge pull request #2880 from luisramos0/backorders
[Spree Upgrade] Replace allow_backorders with variant.on_demand in the cart
2018-11-02 15:47:02 +01:00
Pau Pérez Fabregat
ad743a03ac Merge pull request #2888 from luisramos0/backorders-line-items
[Spree Upgrade] Replace allow_backorders with variant.on_demand in the line_item_decorator
2018-11-02 15:45:25 +01:00
Pau Pérez Fabregat
a910fc50f5 Merge pull request #2926 from luisramos0/2-0-stable-oct-25
[Spree Upgrade] Merging master into 2-0-stable (second run in October2018)
2018-11-02 15:37:34 +01:00
luisramos0
8a034a1538 Fix occurrences of order.shipping_method= by replacing with order.shipments= 2018-10-30 13:37:45 +00:00
Luis Ramos
4422cdc691 Merge pull request #2936 from luisramos0/2933-2-0-orders-admin
[Spree Upgrade] Fix some tests in orders admin spec
2018-10-29 23:17:48 +00:00
luisramos0
b16ed86b2d Fix shipping_method basic test. Adapt to spree 2 that needs shipping_categories to be set and sets them on the base factory in a after_create block, the build command was not picking it up 2018-10-27 20:34:25 +01:00
luisramos0
4450380cb0 Add missing translation to filter on orders admin page 2018-10-26 21:32:16 +01:00
luisramos0
a5d4c50dea Fix some specs in admin orders. Fixed path to order edit page and some html class identifiers that were changed in spree 2. Subtotal line is gone in spree 2, removed test. 2018-10-26 21:32:16 +01:00
luisramos0
90d7b7f4a0 Merge branch 'master' into 2-0-stable-oct-25 2018-10-25 14:28:58 +01:00
Pau Pérez Fabregat
f32e4dddb1 Merge pull request #2902 from luisramos0/more-pending-tests
[Spree Upgrade] Mark specs from secondary features as xfeature
2018-10-23 19:00:49 +02:00
Pau Pérez Fabregat
9a06c1ef98 Merge pull request #2899 from luisramos0/2898-2-0-fix-orders-admin
[Spree Upgrade] Fix orders admin page by removing a filter that is gone in spree 2
2018-10-23 18:59:01 +02:00
Pau Pérez Fabregat
235d42024a Merge pull request #2903 from luisramos0/2884-2-0-order-ships-path
[Spree Upgrade] In order list page, the shipment state is now a label, not a link. The shipments page is gone in spree 2.
2018-10-23 18:57:05 +02:00
Luis Ramos
a9b390d0aa Merge pull request #2761 from HugsDaniel/2744_fix_feature_specs
[Spree Upgrade] Fix feature specs for shipping_methods
2018-10-22 23:12:20 +01:00
luisramos0
d0d9038308 Removed order.shipments_path from order serializer. In order list page the shipment state is now a label, not a link. The shipmeents page is gone in spree 2 2018-10-22 11:24:01 +01:00
luisramos0
34d1e6ffdb Remove pending from bulk_product_update_spec because it's a core spec and should not be left for later in the upgrade process. This reverts PR#2794 2018-10-21 22:13:15 +01:00
luisramos0
7ae5a615b2 Move all specs in update_account_invoices_spec and finalize_account_invoices_spec.rb temporarily to pending 2018-10-21 22:09:21 +01:00
luisramos0
6f78f3c595 Move all specs in proxy_order_spec temporarily to pending 2018-10-21 22:08:10 +01:00
luisramos0
b0ffb0f91a Move all specs in subscription_confirm_job_spec temporarily to pending 2018-10-21 22:07:23 +01:00
luisramos0
2e64226d29 Move all specs in spec/features/admin/subscriptions_spec temporarily to pending 2018-10-21 22:06:31 +01:00
luisramos0
ca786249a6 Move all specs in subscription_form_spec temporarily to pending 2018-10-21 22:05:45 +01:00
luisramos0
3afc59c864 Move all specs in products_reset_strategy_spec (part of product import feature) temporarily to pending 2018-10-21 22:04:16 +01:00
luisramos0
5b6b0f408f Move all specs in product_importer_spec temporarily to pending. There were 11 temporarily pending tests but more were failing 2018-10-21 22:02:34 +01:00
luisramos0
5d36450de2 Move all specs in reports_spec temporarily to pending. There were 6 temporarily pending tests but 3 more were failing 2018-10-21 21:56:55 +01:00
luisramos0
92c7db2249 Adapt product_decorator code to spree 2 where variants_including_master now makes use of Paranoi gem 2018-10-20 23:43:33 +01:00
luisramos0
f3ef3d0c3e Avoiding variantStock raise by creating variant first and then setting count_on_hand 2018-10-20 23:28:22 +01:00
luisramos0
653c67971f Remove order admin page filter 'show only unfulfilled orders' as done on spree 2 2018-10-20 15:11:47 +01:00
luisramos0
c373d5ab33 Replace usage of global allow_backorders with variant.on_demand in line item sufficient stock method 2018-10-18 19:44:38 +01:00
luisramos0
df36e0b344 In cart population, replace usage of global allow_backorders with variant.on_demand adapter 2018-10-18 18:37:09 +01:00
Pau Pérez Fabregat
32632addfb Merge pull request #2823 from luisramos0/2-0-order-spec-fees
[Spree Upgrade] Fix fees tests in models/spree/order_spec
2018-10-18 13:30:15 +02:00
luisramos0
a92e8c9923 Improve readability of shipment decorator 2018-10-18 10:54:21 +01:00
luisramos0
a83af367b4 Fix order_spec related to retrieving previously ordered items
In spree 2, each completed_order_with_totals comes with 5 line items (see order_factory in spree), so instead of 1+1+1=3 the calculation becomes 5+5+1=11
2018-10-18 10:54:21 +01:00
luisramos0
74eff8730b Fix tests of fees in a completed order in models/spree/order_spec by:
- set distributor with taxes on the order
- simplify the factory completed_order_with_fees by replacing shipment with shipping_method and ship_address and letting the order workflow handle shipments and inventory units
2018-10-18 10:54:21 +01:00
luisramos0
91f52d80c8 Fix problem in order and adjustment model specs by fixing the order.adjustment association
This fix was taken from spree 2.1  here 3fa44165c7
2018-10-18 10:53:00 +01:00
luisramos0
2ccbb87adc Fix payment decorator bug
Payment line items must come from the order, payment does not have inventory_units
2018-10-18 10:53:00 +01:00
Maikel
3a2e52cc98 Merge pull request #2780 from luisramos0/2-0-stripe-factory
[Spree Upgrade] Fix Stripe connect factory
2018-10-18 14:54:28 +11:00
Maikel
01c21c302c Merge pull request #2811 from luisramos0/2-0-adjust-basic-spec-fix
[Spree Upgrade] Fixes shipping tests in adjustment spec
2018-10-18 14:49:28 +11:00
luisramos0
98161daa90 Refactor duplicated distributors association in payment_method and gateway to a concern 2018-10-16 20:27:22 +01:00
Pau Pérez Fabregat
601e0b927a Merge pull request #2816 from luisramos0/2-0-adjust-enterprise-fees-spec-fix-aplicator
[Spree Upgrade] Fix enterprise fees specs in adjustment_spec - enterprise_fee_aplicator
2018-10-16 19:47:10 +02:00
Pau Pérez Fabregat
54f0ccab93 Merge pull request #2861 from luisramos0/2-0-stable-spree-revision
[Spree Upgrade] Update spree 2-0-4-stable revision used to pick up latest commits
2018-10-16 19:41:08 +02:00
Luis Ramos
3e4f92fe92 Merge branch '2-0-stable' into 2-0-adjust-basic-spec-fix 2018-10-16 17:33:33 +01:00
Pau Pérez Fabregat
c99fec44da Merge pull request #2824 from luisramos0/2-0-order-spec
[Spree Upgrade] Fix taxes tests in models/spree/order_spec
2018-10-16 18:09:33 +02:00
Pau Pérez Fabregat
f2fe3c8cff Merge pull request #2812 from luisramos0/2-0-adjust-enterprise-fees-spec-fix
[Spree Upgrade] Fix enterprise fees specs in adjustment_spec - tax_rate
2018-10-16 18:02:21 +02:00
luisramos0
b3c56e6823 Duplicated payment method distributors association to gateway. This fixes the inheritance problem found in stripe gateway
See PR 2780 for more details
2018-10-16 16:55:18 +01:00
Pau Pérez Fabregat
db9669b4ce Merge pull request #2817 from coopdevs/remove-reference-to-on-demand
[Spree Upgrade] Remove on_demand from Product serializers
2018-10-16 17:52:42 +02:00
Luis Ramos
faf8322c59 Merge pull request #2785 from luisramos0/2-0-order-updater-fix
[Spree Upgrade] Fix order_updater_spec by using create (instead of build) in shipment
2018-10-16 16:43:42 +01:00
luisramos0
570016463b Fix order_updater_spec by using create (instead of build) in shipment. Also simplified spec by using prebuild shipment_with and shipping_method factories 2018-10-16 16:37:36 +01:00
Pau Pérez Fabregat
afe1d7caef Merge pull request #2863 from luisramos0/2-0-stable-oct
[Spree Upgrade] Merging master into 2-0-stable (one month of commits in master)
2018-10-16 17:09:56 +02:00
luisramos0
87cd73ddba Merge branch 'master' into 2-0-stable-oct 2018-10-15 17:09:26 +01:00
Pau Perez
a5a2cb8ea7 Revert "Merge pull request #2856 from luisramos0/2-0-adjust-clean-up"
This reverts commit fa689b6607, reversing
changes made to 2aeed9763c.
2018-10-15 15:48:48 +02:00
Pau Pérez Fabregat
fa689b6607 Merge pull request #2856 from luisramos0/2-0-adjust-clean-up
[Spree Upgrade] Running Transpec and Rubocop in "new" models/spree/adjustment_spec
2018-10-15 11:13:46 +02:00
luisramos0
f133524a9c Remove useless comment from spec factories 2018-10-12 23:09:36 +01:00
luisramos0
4380ff7bd7 Drop calculated_adjustments_decorator. This file was introduced in ofn's a0b740f52d. The change is already in spree 2.0.4, see here 2c82aab566 (diff-00aa4190da81ca29804a406252f1d0f4) 2018-10-12 23:09:36 +01:00
luisramos0
a5522b90f6 Fix Shipment adjustments specs on adjustment_spec by setting Config values before test objects are created 2018-10-12 23:09:35 +01:00
luisramos0
bd31348b94 Improve docs and readability on tax_rate_decorator 2018-10-12 23:09:35 +01:00
luisramos0
5693f44f5e Fix shipping adjustment basic test in adjustment_spec by removing extra shipping_method from test shipment 2018-10-12 23:09:35 +01:00
luisramos0
1b6f7485b8 Update spree 2-0-4-stable revision used to pick up latest commits 2018-10-12 12:05:18 +01:00
luisramos0
3b6d29968d Fix spree/models/adjustment_spec rubocop issues 2018-10-11 23:02:17 +01:00
luisramos0
6aa8978fe9 Convert specs to RSpec 3.7.1 syntax with Transpec
This conversion is done by Transpec 3.3.0 with the following command:
    transpec spec/models/spree/adjustment_spec.rb

* 30 conversions
    from: obj.should
      to: expect(obj).to

* 25 conversions
    from: == expected
      to: eq(expected)

* 3 conversions
    from: obj.should_not
      to: expect(obj).not_to

For more details: https://github.com/yujinakayama/transpec#supported-conversions
2018-10-11 23:02:17 +01:00
luisramos0
23ed4f705c Fix Enterprise Fee tax category inheritance spec by ensuring the line item is assigned to the order when the order is created. That way the tax category from product is correctly copied to the line item 2018-10-11 23:02:17 +01:00
luisramos0
b7416e42f4 Adapt tax_rate_decorator to new spree version. Spree's default tax calculator now is checking line_items tax category, not the product tax category. See Spree's change here: a0a4b91f13 (diff-46e557ca8717d6ab5039470a40d00ea8) 2018-10-11 23:02:17 +01:00
luisramos0
8b0726b815 Fix enterprise fee calculation. The adjustment.source value of the fee is now allowing the inheritance of the tax category from line items 2018-10-11 23:02:17 +01:00
luisramos0
8aee0f9438 Reorganize code in EnterpriseFeeApplicator 2018-10-11 23:02:17 +01:00
luisramos0
ed429dd20d Fix models/spree/order_spec tests related to tax on shipments:
- make Spree::Config be picked up correctly by reordering test object creation
- make sure line item is loaded in the order when the order is created
2018-10-11 18:06:33 +01:00
luisramos0
56ff4fe90d Remove useless comment from spec factories 2018-10-11 17:16:58 +01:00
luisramos0
dcf0eefe04 Drop calculated_adjustments_decorator. This file was introduced in ofn's a0b740f52d. The change is already in spree 2.0.4, see here 2c82aab566 (diff-00aa4190da81ca29804a406252f1d0f4) 2018-10-11 17:16:58 +01:00
luisramos0
39d232daaf Fix Enterprise Fee tax category inheritance spec by ensuring the line item is assigned to the order when the order is created. That way the tax category from product is correctly copied to the line item 2018-10-09 19:50:35 +01:00
Pau Pérez Fabregat
2aeed9763c Merge pull request #2789 from luisramos0/pending_order_syncer
[Spree Upgrade] Making broken OrderSyncerSpec tests pending, 9 tests to be fixed in issue #2788
2018-10-08 17:51:36 +02:00
Pau Pérez Fabregat
c30458b90a Merge pull request #2787 from luisramos0/pending_subs_mailer
[Spree Upgrade] Making SubsMailerSpec pending, 21 tests to be fixed in issue #2786
2018-10-08 17:51:24 +02:00
Pau Pérez Fabregat
875f0c01bc Merge pull request #2794 from luisramos0/pending_bulk_prod_update
[Spree Upgrade] Making BulkOrderUpdateSpec pending, 33 out of 34 tests to be fixed in #2790
2018-10-08 17:51:08 +02:00
Pau Pérez Fabregat
d2720652bb Merge pull request #2795 from luisramos0/pending_subs_pacement_job
[Spree Upgrade] Making SubsPlacementJobSpec pending, 6 tests to be fixed in issue #2793
2018-10-08 17:50:58 +02:00
Pau Pérez Fabregat
b51bd4aa4b Merge pull request #2796 from luisramos0/pending_prod_import
[Spree Upgrade] Making product import and product importer specs pending, 17 tests to be fixed in #2791
2018-10-08 17:50:48 +02:00
Pau Pérez Fabregat
86d9f4d56a Merge pull request #2797 from luisramos0/pending_reports
[Spree Upgrade] Making reports and reports_controller specs pending, 18 tests to be fixed in #2792
2018-10-08 17:50:25 +02:00
Maikel
d15f524cb1 Merge pull request #2779 from luisramos0/2-0-shipment-specs
[Spree Upgrade] Fixed several specs by defining line_items.target_shipmnt
2018-10-08 17:43:54 +11:00
Pau Perez
f8ec198f9f Remove on_demand from Api::CachedProductSerializer
This fixes lots of specs like the whole
spec/controllers/shop_controller_spec.rb, almost all specs of
spec/lib/open_food_network/products_renderer_spec.rb and most of
spec/features/consumer/shopping/shopping_spec.rb.
2018-10-03 14:27:59 +02:00
Pau Perez
75ad4254a6 Remove on_demand from Api::Admin::ProductSerializer
This change also moves the spec file to its appropriate place for the
sake of consistency and RSpec3-izes the test example.
2018-10-03 13:06:13 +02:00
luisramos0
8a22567291 Fix enterprise fee calculation. The adjustment.source value of the fee is now allowing the inheritance of the tax category from line items 2018-10-02 23:44:38 +01:00
luisramos0
1ce431b671 Reorganize code in EnterpriseFeeApplicator 2018-10-02 23:39:31 +01:00
luisramos0
3fbb98519d Adapt tax_rate_decorator to new spree version. Spree's default tax calculator now is checking line_items tax category, not the product tax category. See Spree's change here: a0a4b91f13 (diff-46e557ca8717d6ab5039470a40d00ea8) 2018-10-02 23:28:47 +01:00
luisramos0
c559cf0394 Fix Shipment adjustments specs on adjustment_spec by setting Config values before test objects are created 2018-10-02 16:17:26 +01:00
luisramos0
bed4ec4102 Improve docs and readability on tax_rate_decorator 2018-10-02 16:15:10 +01:00
luisramos0
795441484d Fix shipping adjustment basic test in adjustment_spec by removing extra shipping_method from test shipment 2018-10-02 16:15:00 +01:00
luisramos0
d2fe203c89 Fixes error undefined 'stock_location' by adding shipment to line_items in the following specs: features/admin/reports_spec, lib/open_food_network/bulk_coop_report_spec, lib/open_food_network/customers_report_spec, lib/open_food_network/order_cycle_management_report_spec, lib/open_food_network/orders_and_fulfillments_report_spec and lib/open_food_network/packing_report_spec 2018-10-01 11:57:36 +01:00
luisramos0
1ff1e32398 Making reports and reports_controller specs pending, 18 tests to be fixed in issue #2792 2018-09-30 00:30:49 +01:00
luisramos0
7dfce6c368 Making product import and product importer specs pending, 17 tests to be fixed in issue #2791 2018-09-30 00:21:43 +01:00
luisramos0
1d49edb194 Making SubsPlacementJobSpec pending, 6 tests to be fixed in issue #2793 2018-09-30 00:10:31 +01:00
luisramos0
50ac519dd5 Making BulkOrderUpdateSpec pending, 33 out of 34 tests to be fixed in issue #2790 2018-09-30 00:04:33 +01:00
luisramos0
e79d184db0 Making broken OrderSyncerSpec tests pending, 9 tests to be fixed in issue #2788 2018-09-29 23:42:35 +01:00
luisramos0
801c4d1cab Making SubsMailerSpec pending, 21 tests to be fixed in issue #2786 2018-09-29 23:31:11 +01:00
luisramos0
6c05be9772 Fixed 22 out of 30 broken tests in bulk_order_management_spec.rb by providing target_shipment in test line_items. 2018-09-27 21:13:11 +01:00
Luis Ramos
f0183cd17e Merge pull request #2762 from luisramos0/2-0-order-model-spec
[Spree Upgrade] Fixed updates of order.shipping_method_id and improved order, stock_location and shipment factories
2018-09-27 13:43:58 +01:00
Pau Pérez Fabregat
060b3c55f1 Merge pull request #2751 from luisramos0/2-0-order-details
[Spree Upgrade] Refactored spree/order_details, extracted delivery and pickup details into separate partials
2018-09-27 14:30:42 +02:00
Pau Pérez Fabregat
037432d1a7 Merge pull request #2767 from luisramos0/order_empty
[Spree Upgrade] Destroy all shipments when clearing order
2018-09-26 08:54:11 +02:00
Maikel
267edbdb45 Merge pull request #2752 from HugsDaniel/apply_overrides_to_shipping_methods_new
[Spree Upgrade] Replace Spree::ShippingMethods new view by our own and apply overrides
2018-09-25 11:37:46 +10:00
Maikel
5ede6a40e7 Merge pull request #2766 from HugsDaniel/2744_add_require_ship_address_to_shipping_methods_form
[Spree Upgrade] Add require_shipping_address to shipping_methods_form
2018-09-25 11:37:15 +10:00
luisramos0
4f32a8efc2 Fixed shipment factory by making shipments unique per order and stock_location factory by making stock_location unique 2018-09-25 00:49:03 +01:00
Pau Perez
eb64569c9a Destroy all shipments when clearing order
Now we only clear the order's shipping_method, and in Spree 2.0 it can
have many shipments.
2018-09-24 15:25:33 +01:00
luisramos0
89114655fd Fixed shipping_method update in features/consumer/shopping/orders_spec, order.shipment is now updated instead of order.shipping_method_id 2018-09-24 15:13:36 +01:00
luisramos0
4476b88044 Fixed shipping_method update in models/spree/order_spec, order.shipment is now updated instead of order.shipping_method_id 2018-09-24 15:13:36 +01:00
luisramos0
99fff3d279 Fixed factory completed_order_with_fees by skipping a failing and unnecessary part of the checkout workflow
Fixed factory's shipment_with shipping_fees trait by ensuring only one shipping_rate in the shipment
2018-09-24 15:13:35 +01:00
Luis Ramos
08104c62be Merge pull request #2667 from luisramos0/2-0-ship-method-last-used-address
[Spree Upgrade] Adapt Address_Finder.last_used_ship_address to spree 2
2018-09-24 15:07:27 +01:00
Luis Ramos
0eb2854f8a Merge pull request #2680 from luisramos0/2-0-stable-x
[Spree Upgrade] Fixed inexistent order#shipping_method= in several specs
2018-09-24 15:07:04 +01:00
Hugo Daniel
0dd1b1a976 Fix feature specs for shipping_methods 2018-09-24 12:40:59 +02:00
Hugo Daniel
06ee75981a Add require_shipping_address to shipping_methods_form 2018-09-24 12:35:40 +02:00
Pau Pérez Fabregat
128ec1623a Merge pull request #2760 from luisramos0/2-0-admin-enterprise-spec
[Spree Upgrade] In admin enterprises spec, replacing select2_search with select2_select
2018-09-24 11:15:18 +02:00
Pau Pérez Fabregat
52a412a218 Merge pull request #2638 from coopdevs/unit-test-variant-stock
Unit test variant stock
2018-09-24 11:14:03 +02:00
Maikel
26eb79f5f2 Merge pull request #2729 from luisramos0/2-0-ship-method-curr-order-ser
[Spree Upgrade] Replace order.shipping_method_id in current_order_serializer
2018-09-24 08:56:21 +10:00
Maikel
9b10fbde2d Merge pull request #2728 from luisramos0/2-0-ship-method-ctrl
[Spree Upgrade] Remove use of Order#shipping_method_id from ShippingMethodsControllerDecorator
2018-09-24 08:54:03 +10:00
Pau Pérez Fabregat
3c4ec62352 Merge pull request #2753 from HugsDaniel/apply_overrides_to_shipping_methods_edit
[Spree Upgrade] Replace Spree::ShippingMethods edit view by our own and apply overrides
2018-09-21 16:16:25 +02:00
Pau Pérez Fabregat
33fa687c28 Merge pull request #2755 from HugsDaniel/apply_overrides_to_shipping_methods_form
[Spree Upgrade] Replace Spree::ShippingMethods form partial by our own and apply overrides
2018-09-21 15:35:41 +02:00
Pau Pérez Fabregat
36bdde6cc4 Merge pull request #2754 from HugsDaniel/apply_overrides_to_shipping_methods_index
[Spree Upgrade] Replace Spree::ShippingMethods index view by our own and apply overrides
2018-09-21 15:28:44 +02:00
luisramos0
a04e90d188 In admin enterprises spec, replacing select2_search with select2_select makes all tests pass. Also made screen size longer to avoid errors with overlaying components 2018-09-20 23:58:14 +01:00
Hugo Daniel
f9c5e732d8 Replace Spree::ShippingMethods form partial by our own and apply overrides 2018-09-20 19:21:02 +02:00
Hugo Daniel
0d7e24e554 Change to new ruby hash syntax 2018-09-20 14:34:10 +02:00
Hugo Daniel
b0fa76f519 Change to new ruby hash syntax 2018-09-20 14:32:27 +02:00
Hugo Daniel
07cbb08b42 Change to new ruby hash syntax 2018-09-20 14:28:20 +02:00
Hugo Daniel
56c1b073ee Replace Spree::ShippingMethods new view by our own and apply overrides 2018-09-20 12:37:26 +02:00
Hugo Daniel
493da83378 Replace Spree::ShippingMethods index view by our own and apply overrides 2018-09-20 12:35:49 +02:00
Hugo Daniel
a14337df5c Replace Spree::ShippingMethods edit view by our own and apply overrides 2018-09-20 12:34:16 +02:00
luisramos0
57bb1fec9a Adapt ShippingMethodsController to keep disallowing delete of shipping_methods associated with orders. Added controller tests to verify behaviour 2018-09-19 16:21:12 +01:00
Pau Pérez Fabregat
99ba9d7d1b Merge branch '2-0-stable' into unit-test-variant-stock 2018-09-19 15:41:21 +02:00
Pau Perez
b77dd41eb0 Refactored spree/order_details, extracted delivery and pickup details into separate partials.
This was copied/adapted from 6f7c8bb8b1
2018-09-19 14:20:44 +01:00
Pau Perez
0491a96d44 Ask to use backorderable? instead of on_demand 2018-09-19 15:12:38 +02:00
luisramos0
edcdf59621 In current_order_serializer, serialize shipping_method_id from order.shipping_method.id. Adapted respective spec. 2018-09-18 16:11:01 +01:00
Pau Perez
314ad5400f Move variant_stock.rb to concerns/ 2018-09-18 12:18:50 +02:00
Pau Pérez Fabregat
e79f7c13f1 Merge pull request #2727 from luisramos0/2-0-shipment-adjustment
[Spree Upgrade] Adapt order_decorator.shipments.adjustments to spree 2
2018-09-18 09:37:10 +02:00
Maikel
1130bb341d Merge pull request #2677 from luisramos0/2-0-sample-data
[Spree Upgrade] Fixed db:load_sample_data
2018-09-18 16:37:22 +10:00
luisramos0
843cd44b23 In paypal_spec, fixed setting shipping_method in order, this is now done through order shipments 2018-09-17 00:51:01 +01:00
luisramos0
c66b611b99 Fixed setting shipping_method in the order through order.shipments in proxy_order_spec, lib/open_food_network/customers_report_spec and features/admin/shipping_methods_spec 2018-09-17 00:51:01 +01:00
luisramos0
75656668cd Fixed query in order_cycle_management_report and fixed the respective spec by setting shipping_method in order through shipments 2018-09-17 00:51:01 +01:00
luisramos0
38c2f52278 In features/admin/reports_spec, fixed setting shipping_method in order, this is now done through order shipments 2018-09-17 00:51:01 +01:00
luisramos0
fbd2d96b05 Moved shipment and shipping_method factories with flat rate and shipping fees to traits 2018-09-17 00:51:01 +01:00
luisramos0
7b6e4825e7 Fixed controllers/spree/admin/orders/customer_details_controller_spec:
- fixed order creation to use order.shipments instead of order.shipping_method
- adapted test to new spree 2 controller logic (shipments page is gone since 67f568914988bcc0a1fc520d15ed6444a6d12824 and redirect logic changed on e9cde1b4d570dd4f7f979ac71a58d6f3f342ebb4)
2018-09-17 00:44:14 +01:00
luisramos0
93ac99b5cc Added new factory for shipping_method_with trait delivery to fix order.shipping_method issue in features/admin/orders_spec 2018-09-17 00:44:14 +01:00
luisramos0
8e5f43ed25 Fixed current order serializer spec name 2018-09-14 23:12:00 +01:00
luisramos0
238d2f4feb Removed unnecessary code copied and replaced with call to identical super class 2018-09-14 22:20:21 +01:00
luisramos0
5b3a529487 Adapted address_finder_spec to spree 2 shipments 2018-09-14 18:41:59 +01:00
luisramos0
d685b706ad In order_decorator.update_shipping_fees! and order_decorator.update_payment_fees!, only update adjustment if it exists 2018-09-14 17:13:20 +01:00
luisramos0
2da7cc00f8 Fixed Address Finder last_used_ship_address. It now uses order.shipments.shipping_methods instead of order.shipping_method 2018-09-14 16:43:20 +01:00
luisramos0
6b3fd22db8 Adapted order_decorator to spree 2 by fixing adjustment.update! call on update_adjustment 2018-09-14 16:40:59 +01:00
Pau Pérez Fabregat
692101db36 Merge pull request #2691 from coopdevs/fix-variant-override-spec
Fix failing spec due to wrong attribute
2018-09-13 12:21:35 +02:00
Pau Perez
ce148e0197 Fix failing spec due to wrong attribute 2018-09-12 18:19:08 +02:00
luisramos0
145b4385a4 Fixed db:load_sample_data shipping_method build 2018-09-11 22:21:43 +01:00
Pau Pérez Fabregat
e58f7269c3 Merge pull request #2652 from luisramos0/2-0-within-zone
[Spree 2 Upgrade] Removed unused shipping_method.within_zone, customization not needed
2018-09-11 08:43:06 +02:00
Pau Pérez Fabregat
288f685fd4 Merge pull request #2654 from luisramos0/2-0-ship-method
[Spree 2 Upgrade] - Added adapted order.shipping_method
2018-09-11 08:27:36 +02:00
luisramos0
c00e6a5dc7 Added DB uniqueness constraint on order_id to shipments
By forbidding more than a row per order in the spree_shipments table we ensure all orders have no more than one shipment associated
2018-09-11 00:24:50 +01:00
luisramos0
3577f3790d Moved order.shipping_method to the OrderShippingMethod concern 2018-09-11 00:24:35 +01:00
luisramos0
62951f7d48 Removing duplicated factories inserted by previous PRs: 2668 and 2670 2018-09-10 16:51:20 +01:00
luisramos0
f24b20d28c Added adapted implementation of order.shipping_method to order_decorator 2018-09-10 14:32:50 +01:00
Pau Perez
8d8670bdf4 Fix typos in comments 2018-09-10 14:26:19 +02:00
Pau Pérez Fabregat
cde2f98514 Merge pull request #2590 from luisramos0/spree2_mail_method_create
Spree 2 - MailMethod - CreateMailMethod is now MailConfiguration
2018-09-10 12:08:23 +02:00
Pau Pérez Fabregat
a906ad15bd Merge pull request #2670 from luisramos0/2-0-ship-method-adjustment-spec
[Spree 2 Upgrade] Fix issues related to shipments in adjustment_spec
2018-09-10 11:32:54 +02:00
luisramos0
44d81622ac CreateMailMethod is now MailConfiguration and it uses Spree Config instead of MailMethod. The call from db/seeds was updated accordingly 2018-09-10 10:21:23 +01:00
Pau Pérez Fabregat
5a11af9118 Merge pull request #2668 from luisramos0/2-0-ship-method-order-spec
[Spree 2 Upgrade] Fixed models/order_spec issues related to order.shipping_method
2018-09-10 11:18:10 +02:00
Maikel
bce2c1cfd5 Merge pull request #2588 from luisramos0/spree2_mail_method_specs
Spree 2 Upgrade - MailMethod - Fix "undefined mail method" error in specs
2018-09-10 11:28:34 +10:00
luisramos0
2f1616a286 Changed reference from order.shipping_method to order.shipments in adjustment_spec 2018-09-09 23:32:59 +01:00
luisramos0
5bcc49a61c Removed calls to the now inexistent order.create_shipment! from specs 2018-09-09 23:16:19 +01:00
luisramos0
73512d3591 Replaced order.shipping_method with order.shipments in models.order_spec.
Fixed factory completed_order_with_fees used in order_spec and also in line_items_controller_spec and orders_controller_spec.
2018-09-09 23:13:32 +01:00
luisramos0
afedbe45ab Fixed scenario "guest order with registered email" in order_spec
Spree order factory requires user (we are setting it to nil below so, no impact on the test)
Defining shipping method is not necessary for this test
2018-09-09 23:13:32 +01:00
luisramos0
d6cff9bc68 Removed calls to the now inexistent order.create_shipment! from specs 2018-09-09 23:13:27 +01:00
Maikel
ce7c7b3867 Merge pull request #2640 from luisramos0/2-0-stable-spree-revision
Updated spree 2-0-4 revision used
2018-09-08 15:00:50 +10:00
luisramos0
d2f4f8ccb2 Removed unused shipping_method.within_zone, customization not needed 2018-09-06 20:29:04 +01:00
Pau Perez
cd53ec1a4f Replace exception with DB uniqueness constraint
By forbidding more than a row per variant in the spree_stock_items we
can ensure all variants have a single stock_item associated.
2018-09-06 13:21:22 +02:00
Pau Perez
8848af15ee Raise when a variant has more than a stock item
This means we violated the business rules of having a single stock
location for the OFN instance and hence a single stock item per variant.

Although it is too late to preserve the data integrity we can know data
needs to be cleaned up.
2018-09-06 13:20:52 +02:00
Pau Perez
59883f9509 Add deprecation warnings for VariantStock methods
This will prevent other devs from relying on this methods and will tell
us the exact lines that call this methods, which will come in handy when
removing this module.
2018-09-06 13:20:52 +02:00
Pau Perez
fc5882686a Add unit tests to VariantStock
This also replaces the after_save callback to after_update.

We enforce a stock_item exists when modifying the variant and the
stock_item gets created on variant's after_create. This means it's not
possible to use any of the VariantStock's setters before the variant is
persisted so executing the callback on creation is pointless.
2018-09-06 13:20:52 +02:00
Maikel
417c33a870 Merge pull request #2639 from luisramos0/2-0-stable-sept
Merging master into 2-0-stable (one month of commits in master)
2018-09-06 08:50:47 +10:00
luisramos0
89d51d75ae Merge branch 'master' into 2-0-stable-sept 2018-09-04 17:43:20 +01:00
Maikel
1b6bb72966 Merge pull request #2587 from luisramos0/spree2_order_mailer_decorator_bug
Spree 2 Upgrade - MailMethod - Fixed bug on order_mailer_decorator (only visible in spree 2)
2018-09-04 11:29:51 +10:00
luisramos0
d29a1ebf9a Updated spree 2-0-4 revision used 2018-09-04 00:41:29 +01:00
Pau Pérez Fabregat
0f118baa4e Merge pull request #2615 from mkllnk/2575-variant-on-hand-api
2575 variant on hand api
2018-09-03 11:16:02 +02:00
luisramos0
8004abbb9f Improved Order mailer and Subscriptions mailer specs by removing dependency to old mail method 2018-09-03 10:03:06 +01:00
luisramos0
921c8dfdf4 Removed unnecessary cancel_email from order_email_decorator (spree one is equivalent after ofn PR#2589). Also refactored remaining order_mailer_decorator methods by extracting duplicated code. 2018-09-03 10:03:02 +01:00
Maikel
c510bbd8d0 Merge pull request #2589 from luisramos0/spree2_base_mailer_dec_update
Spree 2 Upgrade - MailMethod - Delete outdated base_mailer_decorator.from_address
2018-09-03 11:05:48 +10:00
Maikel
42936be40a Merge pull request #2578 from luisramos0/spree2_fix_test_line_items
Spree2 fix test line items
2018-08-31 13:26:25 +10:00
Maikel Linke
cebcdea40c Replace obsolete count_on_hand call for variant
The variant factory supports only `on_hand` now.
2018-08-30 13:55:12 +10:00
Maikel Linke
e9c1868759 Update factory to fix tests
In Spree 2, products don't have `on_hand` or `on_demand` any more. But
we always create a standard variant in an after-save hook which accepts
these values due to our backwards compatibility patch.
2018-08-30 13:55:12 +10:00
Maikel Linke
c7648d67bd Add Variant stock API of Spree 1 2018-08-30 13:55:12 +10:00
luisramos0
efcf680094 Fixed bulk_line_items_controller_spec by setting shipment on test line_items and by allowing shipment decorator to allow no adjustments in the shipment
Fixed 5 out of 7 tests in orders_and_fulfillments_report_spec by providing target_shipment in test line_items
Fixed 12 out of 44 broken tests in bulk_order_management_spec.rb by providing target_shipment in test line_items.” “The remaining 32 failing tests are now failing with the very common: undefined method on_hand= on Spree::Variant
Improved 1 test in reports_spec.rb by providing target_shipment in test line_items. Test now fails with undefined method Spree::Order.shipping_method
Fixed 9 tests in orders_controller_spec by providing target_shipment in test line_items
Fixed 4 tests in packing_report_spec.rb by providing target_shipment in test line_items. Failing tests are now failing with undefined product.on_hand? method
Fixed 8 tests in line_items_controller_spec by providing target_shipment in test line_items
Fixed 1 test in update_billable_periods_spec by providing target_shipment in test line_items
Fixed 4 tests in bulk_coop_report_spec by providing target_shipment in test line_items. The 2 failing tests are now failing with undefined product.on_hand? method
Improved 1 test in line_items_controller_spec by providing target_shipment in test line_items. Test is still failing with an unexpected method call
Fixed 1 test in order_and_distributor_report_spec by providing target_shipment in test line_items
2018-08-30 00:33:15 +01:00
Maikel
189bd0911b Merge pull request #2574 from luisramos0/bulk_line_items_controller_spec_fix
Spree2 - Bulk line items controller spec fix
2018-08-28 16:47:04 +10:00
luisramos0
082f9e404b Fixed test on order_cycle_spec by replacing eq with match_array 2018-08-27 21:04:18 +01:00
luisramos0
b5038fa5dc Changed calls to MailMethod in specs to calls to Spree::Config[:mails_from] 2018-08-27 21:02:54 +01:00
luisramos0
0de691b821 Delete outdated base_mailer_decorator.from_address (it used old MailMethod). This way we rely on the correct spree base_mailer.from_address (that gets it from Spree::Config 2018-08-25 13:47:05 +01:00
luisramos0
27f5e6db8a Fixed bug on order_mailer_decorator. When cancel_email is called with order id in paramater order, order.number will fail. This is only seen in spree 2 because only spree 2 calls this method with order id. Bug introduced here: 32d2adc8a2 (diff-aa82d768109073ea8ad7858146630be4R9). Spree change introduced here: 8d90ae15f8 (diff-1e2ba31309f1f1abd2a4b626036d316fR94) 2018-08-25 12:50:36 +01:00
luisramos0
a97138dd58 Fixed bulk_line_items_controller_spec by setting shipment on test line_items and by allowing shipment decorator to allow no adjustments in the shipment 2018-08-22 23:20:30 +01:00
luisramos0
898e41acfb Removed monkeypatchs to scope variants on inventory_unit and line_item decorators. We need to make the scoping somewhere else in spree2, see #2559 2018-08-19 20:23:31 +01:00
Maikel
f04903bca0 Merge pull request #2493 from HugsDaniel/2433-change-from-simple-product-to-base-product
Reimplement Spree's simple_product in OFN factory
2018-07-31 07:40:42 +10:00
Hugo Daniel
ce46f3de39 Removed empty line 2018-07-30 12:11:02 +02:00
Pau Perez
43bf7293bf Merge branch 'master' into 2-0-stable
* master: (125 commits)
  Fix syntax error in GETTING_STARTED.md
  Fix syntax error in README.md
  Fix link syntax errors in REAME.md and GETTING_STARTED.md
  Style recently merged code
  Update gem i18n-js to pick up locale changes
  Fix embedded shopfront menu responsiveness
  Add communications links to README
  Fix script/setup by making it less clever
  Change import and reset logic to work with first page
  Move options to first page
  Fix wrong sort predicates in customer index
  Reset reverse when clicking another column to sort
  Move logic for toggling by column into SortOptions
  Generalize sorting through SortOptions service
  Remove unused sorting preferences in ColumnsCtrl
  Fix frontend sorting in "Bulk Order Management"
  Fix frontend sorting in "Customers" index
  Change sorting to be done in ascending order first
  Wrap rows in customer index with TBODY tag
  Update .rubocop_todo.yml
  ...
2018-07-27 10:21:47 +02:00
Pau Pérez Fabregat
67bac8aae4 Merge pull request #2503 from coopdevs/upgrade-spree-2-0-4-version
[Spree upgrade] Update Gemfile.lock to fetch the latest revision
2018-07-27 08:51:06 +02:00
Maikel
238a07dbd6 Merge pull request #2488 from HugsDaniel/2434-remove-dash-dependency
[Spree Upgrade] Remove dependency to Dash and Jirafe
2018-07-27 13:00:15 +10:00
Pau Perez
6fb95d30c3 Update Gemfile.lock to fetch the latest revision
Since https://github.com/openfoodfoundation/spree/pull/6 got merged, we
need the app to use the latest Spree fork revision to pick up those
changes.
2018-07-26 18:06:57 +02:00
Pau Pérez Fabregat
5a4bc0c584 Merge pull request #2366 from coopdevs/refactor-ship-address-from-distributor
Refactor ship address from distributor
2018-07-26 12:04:02 +02:00
Pau Perez
eaf108718c Add doc to method 2018-07-25 13:52:05 +02:00
Pau Perez
a0d2ec5666 Enable OFN's custom OrderUpdater 2018-07-25 13:51:01 +02:00
Pau Perez
d1e65691cf Copy distributor addr. when using a pick up method
This copies the distributor's address when at least one of the order shipments
uses a shipping method that requires shipping address.
2018-07-25 11:07:16 +02:00
Pau Perez
f1896313b3 Move shipping_address_from_distributor to OrderUpdater
This is still Spree-1.3 compatible not considering multiple shipments
and shipping methods.
2018-07-25 11:07:16 +02:00
Pau Perez
21d905a092 Refactor OrderUpdater to decorate Spree's one
This replaces the nasty class eval and provides some encapsulation
2018-07-25 11:07:16 +02:00
Pau Perez
72f02ee1ee RSpec3-ize OrderUpdater spec 2018-07-25 11:07:16 +02:00
Pau Pérez Fabregat
a3cace46e0 Merge pull request #2431 from mkllnk/2007-no-shipment-for-payment
2007 Skip shipment creation for payment step
2018-07-25 08:46:47 +02:00
Hugo Daniel
eab04e0d86 Reimplement Spree<2.0 :simple_product factory in OFN 2018-07-24 16:27:30 +02:00
Hugo Daniel
ec751c0a78 Remove admin analytics ability 2018-07-24 15:27:22 +02:00
Hugo Daniel
514fc0a781 Remove dependency to Dash and Jirafe 2018-07-20 13:04:58 +02:00
Maikel Linke
2334f0854c Less invasive modifying the checkout state machine 2018-07-11 10:55:12 +10:00
Maikel Linke
c7f7e420ea Skip shipment creation for payment step
https://github.com/openfoodfoundation/openfoodnetwork/issues/2007

Spree 2.0.4 creates in-memory shipments for the payment step. That means
we don't need to create a shipment in that transition. This change
copies the checkout_flow from the Spree code, but leaves one last
customisation: removal of the confirm step.
75ec77dc31
2018-07-05 16:34:11 +10:00
Pau Perez
7707df354b Merge branch 'master' into 2-0-stable
* master: (206 commits)
  embedded groups layout changes
  embedded groups initial test
  Allow html requests for OrderCycleController#update
  Move applicator calls to OrderCycleForm
  Refactor OrderCycleForm to make logic clearer
  Extract schedule syncing logic into OrderCycleForm
  Add basic specs for OrderCyclesController#create
  Add basic OrderCycleForm to handle create/update logic
  Remove unnecessary respond_to blocks from OrderCyclesController
  Include admin users as managers on new enterprises
  Remove obsolete goWithoutHashFragments
  Simplify Navigation.go, not preserving hash fragments
  Only show change warning for open order cycles
  Use a SubscriptionsCount query object to provide counts to IndexOrderCycleSerializer
  Preload subscription counts for serialization in order cycle collection actions
  Request the subscription count for change warning each time, don't cache
  Ask user to confirm oc date change for open order cycles with subsciptions
  Fix ordering of Gemfile.lock
  Add rack-rewrite to handle redirects
  Renames product bulk edit action to index
  ...
2018-06-22 13:23:18 +02:00
Pau Pérez Fabregat
d5310eed6c Merge pull request #2371 from HugsDaniel/2359_js_libs_not_found_or_not_defined
Changed require syntax to fit jquery-ui-rails v<5.0
2018-06-13 09:12:57 +02:00
Hugo Daniel
6e2966d7e8 Changed require syntax to fit jquery < 5.0 2018-06-12 15:59:41 +02:00
Maikel
0befc714ce Merge pull request #2358 from coopdevs/revert-current-order-argument
Spree 2.0: Fix GET "/"
2018-06-07 10:45:06 +10:00
Pau Perez
daf12d1300 Revert "Refactor Order#current_order argument"
This reverts commit ae935202be.
2018-06-05 18:42:41 +02:00
Pau Perez
89c2733f50 Revert "Removing redundant curly braces"
This reverts commit 03173d4f7b.
2018-06-05 18:42:31 +02:00
Pau Perez
32069cffe1 Revert "Removing useless spaces"
This reverts commit d81b6be259.
2018-06-05 18:42:19 +02:00
Pau Pérez Fabregat
5b89f6a159 Merge pull request #2285 from coopdevs/get-last-spree-fork-changes
Upgrade spree to point to 1c3dfc7fb
2018-05-16 08:42:41 +02:00
Pau Pérez Fabregat
6033981ad5 Merge pull request #2283 from coopdevs/remove-outdated-specs
Remove no longer valid tests
2018-05-14 13:22:00 +02:00
Pau Perez
6f8317b007 Upgrade spree to point to 1c3dfc7fb
This will fetch latest changes applied in the fork. It also changes the
Github organization we fetch it from. From now on we'll work there and
not in Coopdevs org.
2018-05-14 13:05:51 +02:00
Pau Perez
5c260dae51 Remove no longer valid tests
`#available_to_order?` is gone in Spree 2.0 and our customization on top
of it went away with #2256.
2018-05-14 12:30:11 +02:00
Pau Pérez Fabregat
1991a7f34d Merge pull request #2256 from coopdevs/add-custom-package
Add custom package
2018-05-14 10:44:05 +02:00
Pau Perez
776b5a23f6 Skip methods that distributor can't use in Package
This ensures that Spree's shipping methods take into account the ones
the order's distributor uses.

This reimplements what `#available_to_order_with_distributor_check?`
used to do and it doesn't work with Spree 2.0.4.
2018-05-02 13:58:25 +02:00
Pau Perez
6784621c1b Remove invalid spree config
According to
5ef8dc67df
"Backorders can be configured now as per stock location or stock item".
2018-04-30 13:53:23 +02:00
Pau Perez
c3132e87d6 Rename and fix simple_product to base_product
This factory has been merged into the base_product factory. Besides,
products no longer have on_hand attribute.
2018-04-30 13:49:52 +02:00
Pau Pérez Fabregat
e7b1d933f4 Merge pull request #2253 from coopdevs/apply-spree-2.0-migrations
Apply spree 2.0 migrations
2018-04-30 12:51:29 +02:00
Pau Perez
19870eccdc Install and run Spree v2.0.4 migrations 2018-04-27 17:02:28 +02:00
Pau Pérez Fabregat
9840f3bb6b Merge pull request #2252 from coopdevs/use-patched-spree-2.0.4
Use OFN's Spree fork of 2.0.4 to get fixes
2018-04-27 16:58:33 +02:00
Pau Perez
97e8adf7a7 Use OFN's Spree fork of 2.0.4 to get fixes
We encountered the bug that
3fd1535e75
fixes, which is needed to boot the app using Spree 2.0.4.

This stems from
https://github.com/openfoodfoundation/openfoodnetwork/issues/2236#issuecomment-384633612
2018-04-26 16:35:28 +02:00
Pau Pérez Fabregat
a1645477e0 Merge pull request #2235 from coopdevs/upgrade-to-spree-2.0.4
Upgrade Spree to 2.0.4 instead of 2.0.13
2018-04-23 12:14:49 +02:00
Pau Perez
58f3b5a97e Upgrade Spree to 2.0.4 instead of 2.0.13
Although we don't know how big the fixes introduced between 2.0.4 and
2.0.13 are, jumping from roughly 1.3.99 to 2.0.13 seems too big of
a change to do in one go.

Unless more issues like this one come up that force us to upgrade to
a newer version I believe it's best to be conservative. You'll find an
in-depth explanation in
https://github.com/openfoodfoundation/openfoodnetwork/wiki/Spree-2.0-upgrade#getting-to-version-204-

A previous effort was done to upgrade to v2.0.13 in
https://github.com/openfoodfoundation/openfoodnetwork/pull/2209
2018-04-18 08:56:03 +02:00
Pau Perez
06ef2a4c63 Remove commented out gem from Gemfile 2018-04-17 16:10:41 +02:00
Hugo Daniel
595a622d5b Removing useless spaces 2018-04-17 16:10:41 +02:00
Hugo Daniel
d9f451b6fe Removing redundant curly braces 2018-04-17 16:10:41 +02:00
Hugo Daniel
abe5d3596c Refactor Order#current_order argument 2018-04-17 16:10:41 +02:00
Hugo Daniel
e6b58c6db4 Remove ssl deprecated configuration 2018-04-17 16:10:40 +02:00
Hugo Daniel
6f3663f1b9 update gemfile to spree 2.0.13 2018-04-17 16:10:40 +02:00
677 changed files with 32332 additions and 15490 deletions

61
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,61 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
## Description
<!-- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug -->
## Expected Behavior
<!-- Tell us what should happen -->
## Actual Behaviour
<!-- Tell us what happens instead -->
## Steps to Reproduce
<!-- Provide an unambiguous set of steps to reproduce this bug -->
<!-- Include code to reproduce if relevant -->
1.
2.
3.
4.
## Animated Gif/Screenshot
<!-- Provide a screenshot or brief animated gif reproducing the bug. Linux users can use
[Peek](https://github.com/phw/peek#ubuntu) while Mac users can use [Recordit](http://recordit.co/) -->
## Context
<!-- How has this bug affected you? What were you trying to accomplish? -->
## Severity
<!-- Assign a label and explain the impact.
bug-s1: a critical feature is broken: checkout, payments, signup, login
bug-s2: a non-critical feature is broken, no workaround
bug-s3: a feature is broken but there is a workaround
bug-s4: it's annoying, but you can use it
bug-s5: we can live with it, only a few users impacted
https://github.com/openfoodfoundation/openfoodnetwork/wiki/Bug-severity
-->
## Your Environment
<!-- Include relevant details about the environment you experienced the bug in -->
* Version used:
* Browser name and version:
* Operating System and version (desktop or mobile):
* OFN Platform instance where you discovered the bug, and which version of the software they are using.
## Possible Fix
<!-- Not obligatory, but suggest a fix or reason for the bug -->

View File

@@ -0,0 +1,35 @@
---
name: Feature template
about: Create feature epics that detail the larger feature or functionality to be
delivered.
title: ''
labels: ''
assignees: ''
---
## What is the problem we are solving
<!-- Describe the problem this feature is supposed to solve. Should be described in the icebox item (in Discourse). -->
## Success factors = expected outcome
<!-- Describe what is the expected outcome: when the feature is released, what would it look like? What will make you say "the problem is solved"? Can be metrics like "Platform has less than 1% service interruption", or yes/no statements like "People can checkout on mobiles. -->
## Useful information for inception
<!-- List here any information that can be useful for the inception stage. -->
## Link to the "Product Development - Backlog" item in Discourse
<!-- Put the link here, and put this epic link in the Discourse item as well for cross-referencing. -->
Add a custom footer
Pages 70
Home
Development environment setup
macOS (Sierra, HighSierra and Mojave)
OS X (El Capitan)
OS X (Mavericks)
Ubuntu
On Heroku
Rubocop
General guidelines
Spree Commerce customisation

View File

@@ -0,0 +1,18 @@
---
name: Story template
about: Create stories that are small chunks of work that devs will pick up and deliver
title: ''
labels: ''
assignees: ''
---
## Description
<!-- Describe the story in detail:
**- As a:** (enterprise user, super admin, user...)
**- On page:** (provide url of the page you want to modify. If not provide where will be created the new url and the name we want to give it)
**- I want to be able to do:** (specify the desired behavior)
(Link to others issues or resources to provide context > only if really necessary). -->
## Acceptance Criteria
<!-- Document the outcomes that need to be achieved before this component can be considered complete. -->

View File

@@ -0,0 +1,21 @@
---
name: Tech debt template
about: File a refactoring task that aids future development
title: ''
labels: tech debt
assignees: ''
---
### What we should change and why (this is tech debt)
<!-- The use of X changed and part y is now redundant. We can remove it and... -->
### Context
<!-- This came up in PR #3451#issuecomment-461616636. -->
### Impact and timeline
<!-- Example: This simplifies the upgrade to Spree 3 and should be done after upgrading to Spree 2. -->

2
.gitignore vendored
View File

@@ -33,11 +33,11 @@ public/images
public/spree
config/abr.yml
config/initializers/feature_toggle.rb
config/initializers/db2fog.rb
NERD_tree*
coverage
libpeerconnection.log
/config/application.yml
/config/newrelic.yml
node_modules
vendor/bundle/
coverage

View File

@@ -22,10 +22,7 @@
Metrics/LineLength:
Max: 100
Exclude:
- app/controllers/admin/accounts_and_billing_settings_controller.rb
- app/controllers/admin/bulk_line_items_controller.rb
- app/controllers/admin/business_model_configuration_controller.rb
- app/controllers/admin/cache_settings_controller.rb
- app/controllers/admin/contents_controller.rb
- app/controllers/admin/customers_controller.rb
- app/controllers/admin/enterprise_fees_controller.rb
@@ -63,7 +60,6 @@ Metrics/LineLength:
- app/controllers/stripe/callbacks_controller.rb
- app/controllers/user_confirmations_controller.rb
- app/helpers/admin/account_helper.rb
- app/helpers/admin/business_model_configuration_helper.rb
- app/helpers/admin/injection_helper.rb
- app/helpers/angular_form_builder.rb
- app/helpers/angular_form_helper.rb
@@ -79,16 +75,12 @@ Metrics/LineLength:
- app/helpers/spree/admin/navigation_helper_decorator.rb
- app/helpers/spree/admin/orders_helper_decorator.rb
- app/helpers/spree/orders_helper.rb
- app/jobs/finalize_account_invoices.rb
- app/jobs/products_cache_integrity_checker_job.rb
- app/jobs/subscription_confirm_job.rb
- app/jobs/subscription_placement_job.rb
- app/jobs/update_account_invoices.rb
- app/jobs/update_billable_periods.rb
- app/mailers/producer_mailer.rb
- app/mailers/spree/order_mailer_decorator.rb
- app/mailers/subscription_mailer.rb
- app/models/billable_period.rb
- app/models/column_preference.rb
- app/models/content_configuration.rb
- app/models/customer.rb
@@ -99,7 +91,6 @@ Metrics/LineLength:
- app/models/exchange.rb
- app/models/inventory_item.rb
- app/models/order_cycle.rb
- app/models/product_distribution.rb
- app/models/product_import/entry_processor.rb
- app/models/product_import/entry_validator.rb
- app/models/product_import/product_importer.rb
@@ -160,13 +151,10 @@ Metrics/LineLength:
- engines/web/app/helpers/web/cookies_policy_helper.rb
- Gemfile
- lib/discourse/single_sign_on.rb
- lib/open_food_network/accounts_and_billing_settings_validator.rb
- lib/open_food_network/available_payment_method_filter.rb
- lib/open_food_network/bill_calculator.rb
- lib/open_food_network/bulk_coop_report.rb
- lib/open_food_network/business_model_configuration_validator.rb
- lib/open_food_network/customers_report.rb
- lib/open_food_network/distribution_change_validator.rb
- app/services/order_cycle_distributed_variants.rb
- lib/open_food_network/enterprise_fee_applicator.rb
- lib/open_food_network/enterprise_fee_calculator.rb
- lib/open_food_network/enterprise_issue_validator.rb
@@ -201,7 +189,6 @@ Metrics/LineLength:
- lib/tasks/dev.rake
- lib/tasks/enterprises.rake
- spec/archive/features/consumer/checkout_spec.rb
- spec/controllers/admin/accounts_and_billing_settings_controller_spec.rb
- spec/controllers/admin/bulk_line_items_controller_spec.rb
- spec/controllers/admin/column_preferences_controller_spec.rb
- spec/controllers/admin/customers_controller_spec.rb
@@ -245,7 +232,6 @@ Metrics/LineLength:
- spec/controllers/stripe/webhooks_controller_spec.rb
- spec/controllers/user_confirmations_controller_spec.rb
- spec/controllers/user_registrations_controller_spec.rb
- spec/features/admin/accounts_and_billing_settings_spec.rb
- spec/features/admin/adjustments_spec.rb
- spec/features/admin/bulk_order_management_spec.rb
- spec/features/admin/bulk_product_update_spec.rb
@@ -289,7 +275,6 @@ Metrics/LineLength:
- spec/features/consumer/shopping/shopping_spec.rb
- spec/features/consumer/shopping/variant_overrides_spec.rb
- spec/features/consumer/shops_spec.rb
- spec/helpers/admin/business_model_configuration_helper_spec.rb
- spec/helpers/admin/subscriptions_helper_spec.rb
- spec/helpers/checkout_helper_spec.rb
- spec/helpers/enterprises_helper_spec.rb
@@ -298,17 +283,14 @@ Metrics/LineLength:
- spec/helpers/order_cycles_helper_spec.rb
- spec/helpers/spree/admin/base_helper_spec.rb
- spec/jobs/confirm_order_job_spec.rb
- spec/jobs/finalize_account_invoices_spec.rb
- spec/jobs/refresh_products_cache_job_spec.rb
- spec/jobs/subscription_confirm_job_spec.rb
- spec/jobs/subscription_placement_job_spec.rb
- spec/jobs/update_account_invoices_spec.rb
- spec/jobs/update_billable_periods_spec.rb
- spec/lib/open_food_network/address_finder_spec.rb
- spec/lib/open_food_network/bulk_coop_report_spec.rb
- spec/lib/open_food_network/cached_products_renderer_spec.rb
- spec/lib/open_food_network/customers_report_spec.rb
- spec/lib/open_food_network/distribution_change_validator_spec.rb
- spec/services/order_cycle_distributed_variants.rb
- spec/lib/open_food_network/enterprise_fee_applicator_spec.rb
- spec/lib/open_food_network/enterprise_fee_calculator_spec.rb
- spec/lib/open_food_network/enterprise_injection_data_spec.rb
@@ -319,7 +301,6 @@ Metrics/LineLength:
- spec/lib/open_food_network/order_cycle_form_applicator_spec.rb
- spec/lib/open_food_network/order_cycle_permissions_spec.rb
- spec/lib/open_food_network/order_grouper_spec.rb
- spec/lib/open_food_network/orders_and_fulfillments_report_spec.rb
- spec/lib/open_food_network/packing_report_spec.rb
- spec/lib/open_food_network/permissions_spec.rb
- spec/lib/open_food_network/products_and_inventory_report_spec.rb
@@ -337,7 +318,6 @@ Metrics/LineLength:
- spec/mailers/order_mailer_spec.rb
- spec/mailers/producer_mailer_spec.rb
- spec/mailers/subscription_mailer_spec.rb
- spec/models/billable_period_spec.rb
- spec/models/column_preference_spec.rb
- spec/models/customer_spec.rb
- spec/models/enterprise_caching_spec.rb
@@ -349,7 +329,6 @@ Metrics/LineLength:
- spec/models/model_set_spec.rb
- spec/models/order_cycle_spec.rb
- spec/models/producer_property_spec.rb
- spec/models/product_distribution_spec.rb
- spec/models/product_importer_spec.rb
- spec/models/proxy_order_spec.rb
- spec/models/spree/ability_spec.rb
@@ -412,7 +391,6 @@ Metrics/LineLength:
- spec/support/request/shop_workflow.rb
- spec/support/request/web_helper.rb
- spec/support/seeds.rb
- spec/support/spree/init.rb
Metrics/AbcSize:
Max: 15
@@ -452,18 +430,13 @@ Metrics/AbcSize:
- app/controllers/user_confirmations_controller.rb
- app/controllers/user_passwords_controller.rb
- app/controllers/user_registrations_controller.rb
- app/helpers/admin/business_model_configuration_helper.rb
- app/helpers/checkout_helper.rb
- app/helpers/i18n_helper.rb
- app/helpers/order_cycles_helper.rb
- app/helpers/spree/admin/orders_helper_decorator.rb
- app/helpers/spree/orders_helper.rb
- app/jobs/finalize_account_invoices.rb
- app/jobs/subscription_placement_job.rb
- app/jobs/update_account_invoices.rb
- app/jobs/update_billable_periods.rb
- app/mailers/producer_mailer.rb
- app/models/billable_period.rb
- app/models/calculator/flat_percent_per_item.rb
- app/models/column_preference.rb
- app/models/enterprise_group.rb
@@ -492,7 +465,6 @@ Metrics/AbcSize:
- app/services/order_syncer.rb
- app/services/subscription_validator.rb
- lib/discourse/single_sign_on.rb
- lib/open_food_network/bill_calculator.rb
- lib/open_food_network/bulk_coop_report.rb
- lib/open_food_network/customers_report.rb
- lib/open_food_network/enterprise_issue_validator.rb
@@ -534,13 +506,10 @@ Metrics/CyclomaticComplexity:
- app/controllers/checkout_controller.rb
- app/controllers/spree/admin/orders_controller_decorator.rb
- app/controllers/spree/orders_controller_decorator.rb
- app/helpers/admin/business_model_configuration_helper.rb
- app/helpers/checkout_helper.rb
- app/helpers/i18n_helper.rb
- app/helpers/order_cycles_helper.rb
- app/helpers/spree/admin/orders_helper_decorator.rb
- app/jobs/update_account_invoices.rb
- app/jobs/update_billable_periods.rb
- app/models/enterprise.rb
- app/models/enterprise_relationship.rb
- app/models/product_import/entry_processor.rb
@@ -553,7 +522,6 @@ Metrics/CyclomaticComplexity:
- app/models/variant_override_set.rb
- app/services/cart_service.rb
- lib/discourse/single_sign_on.rb
- lib/open_food_network/bill_calculator.rb
- lib/open_food_network/bulk_coop_report.rb
- lib/open_food_network/enterprise_issue_validator.rb
- lib/open_food_network/orders_and_fulfillments_report.rb
@@ -569,12 +537,10 @@ Metrics/PerceivedComplexity:
- app/controllers/checkout_controller.rb
- app/controllers/spree/admin/orders_controller_decorator.rb
- app/controllers/spree/orders_controller_decorator.rb
- app/helpers/admin/business_model_configuration_helper.rb
- app/helpers/checkout_helper.rb
- app/helpers/i18n_helper.rb
- app/helpers/order_cycles_helper.rb
- app/helpers/spree/admin/orders_helper_decorator.rb
- app/jobs/update_account_invoices.rb
- app/models/enterprise_relationship.rb
- app/models/product_import/entry_processor.rb
- app/models/product_import/entry_validator.rb
@@ -624,12 +590,8 @@ Metrics/MethodLength:
- app/helpers/checkout_helper.rb
- app/helpers/order_cycles_helper.rb
- app/helpers/spree/admin/orders_helper_decorator.rb
- app/jobs/finalize_account_invoices.rb
- app/jobs/subscription_placement_job.rb
- app/jobs/update_account_invoices.rb
- app/jobs/update_billable_periods.rb
- app/mailers/producer_mailer.rb
- app/models/billable_period.rb
- app/models/column_preference.rb
- app/models/enterprise.rb
- app/models/enterprise_relationship.rb

View File

@@ -194,6 +194,8 @@ Metrics/BlockNesting:
Metrics/ClassLength:
Max: 100
Exclude:
- engines/order_management/app/services/order_management/reports/enterprise_fee_summary/scope.rb
Metrics/ModuleLength:
Max: 100
@@ -203,6 +205,8 @@ Metrics/CyclomaticComplexity:
Metrics/MethodLength:
Max: 10
Exclude:
- engines/order_management/app/services/order_management/reports/enterprise_fee_summary/scope.rb
Metrics/ParameterLists:
Max: 5

View File

@@ -20,7 +20,6 @@ Layout/AlignArray:
Exclude:
- 'lib/open_food_network/bulk_coop_report.rb'
- 'lib/open_food_network/customers_report.rb'
- 'lib/open_food_network/order_and_distributor_report.rb'
- 'lib/open_food_network/orders_and_fulfillments_report.rb'
- 'lib/open_food_network/packing_report.rb'
- 'spec/lib/open_food_network/order_grouper_spec.rb'
@@ -143,7 +142,6 @@ Layout/EmptyLines:
- 'app/helpers/angular_form_helper.rb'
- 'app/helpers/injection_helper.rb'
- 'app/helpers/spree/admin/base_helper_decorator.rb'
- 'app/jobs/finalize_account_invoices.rb'
- 'app/jobs/products_cache_integrity_checker_job.rb'
- 'app/jobs/refresh_products_cache_job.rb'
- 'app/models/coordinator_fee.rb'
@@ -151,10 +149,7 @@ Layout/EmptyLines:
- 'app/models/exchange.rb'
- 'app/models/exchange_fee.rb'
- 'app/models/inventory_item.rb'
- 'app/models/order_cycle.rb'
- 'app/models/producer_property.rb'
- 'app/models/product_distribution.rb'
- 'app/models/spree/calculator_decorator.rb'
- 'app/models/spree/classification_decorator.rb'
- 'app/models/spree/gateway/migs.rb'
- 'app/models/spree/gateway/pin.rb'
@@ -219,7 +214,6 @@ Layout/EmptyLines:
- 'spec/features/consumer/shopping/variant_overrides_spec.rb'
- 'spec/features/consumer/shops_spec.rb'
- 'spec/helpers/checkout_helper_spec.rb'
- 'spec/jobs/finalize_account_invoices_spec.rb'
- 'spec/jobs/heartbeat_job_spec.rb'
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
- 'spec/lib/open_food_network/option_value_namer_spec.rb'
@@ -233,7 +227,6 @@ Layout/EmptyLines:
- 'spec/models/enterprise_fee_spec.rb'
- 'spec/models/enterprise_spec.rb'
- 'spec/models/model_set_spec.rb'
- 'spec/models/product_distribution_spec.rb'
- 'spec/models/spree/adjustment_spec.rb'
- 'spec/models/spree/line_item_spec.rb'
- 'spec/models/spree/order_spec.rb'
@@ -262,7 +255,6 @@ Layout/EmptyLinesAroundBlockBody:
- 'app/controllers/spree/api/orders_controller_decorator.rb'
- 'app/controllers/spree/checkout_controller_decorator.rb'
- 'app/models/spree/calculator/default_tax_decorator.rb'
- 'app/models/spree/calculator_decorator.rb'
- 'app/models/spree/money_decorator.rb'
- 'app/models/spree/option_value_decorator.rb'
- 'lib/open_food_network/group_buy_report.rb'
@@ -280,18 +272,14 @@ Layout/EmptyLinesAroundBlockBody:
- 'spec/features/consumer/shopping/embedded_groups_spec.rb'
- 'spec/features/consumer/shopping/embedded_shopfronts_spec.rb'
- 'spec/features/consumer/shopping/shopping_spec.rb'
- 'spec/helpers/admin/business_model_configuration_helper_spec.rb'
- 'spec/helpers/shared_helper_spec.rb'
- 'spec/helpers/shop_helper_spec.rb'
- 'spec/helpers/spree/orders_helper_spec.rb'
- 'spec/jobs/update_billable_periods_spec.rb'
- 'spec/lib/open_food_network/group_buy_report_spec.rb'
- 'spec/lib/open_food_network/lettuce_share_report_spec.rb'
- 'spec/lib/open_food_network/order_grouper_spec.rb'
- 'spec/lib/open_food_network/referer_parser_spec.rb'
- 'spec/lib/open_food_network/user_balance_calculator_spec.rb'
- 'spec/models/billable_period_spec.rb'
- 'spec/models/product_distribution_spec.rb'
- 'spec/models/spree/ability_spec.rb'
- 'spec/models/spree/product_spec.rb'
- 'spec/models/tag_rule/filter_payment_methods_spec.rb'
@@ -309,8 +297,6 @@ Layout/EmptyLinesAroundBlockBody:
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
Layout/EmptyLinesAroundClassBody:
Exclude:
- 'app/controllers/admin/account_controller.rb'
- 'app/controllers/admin/cache_settings_controller.rb'
- 'app/controllers/admin/enterprise_fees_controller.rb'
- 'app/controllers/admin/inventory_items_controller.rb'
- 'app/controllers/admin/tag_rules_controller.rb'
@@ -325,7 +311,7 @@ Layout/EmptyLinesAroundClassBody:
- 'app/serializers/api/currency_config_serializer.rb'
- 'app/serializers/api/product_serializer.rb'
- 'lib/discourse/single_sign_on.rb'
- 'lib/open_food_network/distribution_change_validator.rb'
- 'app/services/order_cycle_distributed_variants.rb'
- 'lib/open_food_network/lettuce_share_report.rb'
- 'lib/open_food_network/order_and_distributor_report.rb'
- 'lib/open_food_network/rack_request_blocker.rb'
@@ -360,7 +346,6 @@ Layout/ExtraSpacing:
- 'lib/open_food_network/variant_and_line_item_naming.rb'
- 'lib/spree/product_filters.rb'
- 'lib/tasks/karma.rake'
- 'spec/controllers/admin/accounts_and_billing_settings_controller_spec.rb'
- 'spec/features/admin/bulk_order_management_spec.rb'
- 'spec/features/admin/bulk_product_update_spec.rb'
- 'spec/features/admin/orders_spec.rb'
@@ -375,7 +360,6 @@ Layout/ExtraSpacing:
- 'spec/models/spree/adjustment_spec.rb'
- 'spec/models/spree/gateway/stripe_connect_spec.rb'
- 'spec/models/spree/order_spec.rb'
- 'spec/models/variant_override_spec.rb'
- 'spec/serializers/admin/for_order_cycle/enterprise_serializer_spec.rb'
- 'spec/serializers/admin/for_order_cycle/supplied_product_serializer_spec.rb'
- 'spec/spec_helper.rb'
@@ -412,7 +396,6 @@ Layout/IndentationConsistency:
- 'lib/open_food_network/permissions.rb'
- 'spec/controllers/admin/tag_rules_controller_spec.rb'
- 'spec/features/consumer/shopping/checkout_spec.rb'
- 'spec/helpers/admin/business_model_configuration_helper_spec.rb'
- 'spec/models/spree/line_item_spec.rb'
- 'spec/models/spree/product_spec.rb'
@@ -428,7 +411,6 @@ Layout/IndentationWidth:
- 'app/serializers/api/admin/for_order_cycle/supplied_product_serializer.rb'
- 'app/serializers/api/admin/order_cycle_serializer.rb'
- 'spec/features/consumer/shopping/variant_overrides_spec.rb'
- 'spec/helpers/admin/business_model_configuration_helper_spec.rb'
- 'spec/helpers/groups_helper_spec.rb'
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
- 'spec/lib/open_food_network/order_grouper_spec.rb'
@@ -442,7 +424,6 @@ Layout/IndentationWidth:
Layout/LeadingCommentSpace:
Exclude:
- 'Gemfile'
- 'app/models/billable_period.rb'
- 'app/models/content_configuration.rb'
- 'app/models/spree/inventory_unit_decorator.rb'
- 'app/models/spree/taxon_decorator.rb'
@@ -452,7 +433,6 @@ Layout/LeadingCommentSpace:
- 'spec/controllers/spree/api/line_items_controller_spec.rb'
- 'spec/features/admin/products_spec.rb'
- 'spec/features/admin/reports_spec.rb'
- 'spec/jobs/finalize_account_invoices_spec.rb'
- 'spec/lib/open_food_network/order_grouper_spec.rb'
- 'spec/lib/open_food_network/user_balance_calculator_spec.rb'
- 'spec/models/enterprise_spec.rb'
@@ -474,7 +454,6 @@ Layout/MultilineBlockLayout:
- 'spec/features/admin/variant_overrides_spec.rb'
- 'spec/features/consumer/shopping/cart_spec.rb'
- 'spec/helpers/enterprises_helper_spec.rb'
- 'spec/jobs/update_billable_periods_spec.rb'
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
- 'spec/lib/open_food_network/permissions_spec.rb'
- 'spec/lib/open_food_network/user_balance_calculator_spec.rb'
@@ -492,7 +471,6 @@ Layout/MultilineBlockLayout:
Layout/MultilineHashBraceLayout:
Exclude:
- 'app/controllers/spree/admin/products_controller_decorator.rb'
- 'app/models/billable_period.rb'
- 'lib/spree/product_filters.rb'
- 'spec/support/request/authentication_workflow.rb'
@@ -531,7 +509,6 @@ Layout/MultilineOperationIndentation:
- 'app/models/producer_property.rb'
- 'app/models/spree/ability_decorator.rb'
- 'app/models/variant_override_set.rb'
- 'lib/open_food_network/accounts_and_billing_settings_validator.rb'
- 'lib/open_food_network/order_cycle_permissions.rb'
- 'lib/open_food_network/sales_tax_report.rb'
- 'lib/open_food_network/users_and_enterprises_report.rb'
@@ -543,7 +520,6 @@ Layout/SpaceAfterColon:
- 'spec/features/admin/variants_spec.rb'
- 'spec/features/consumer/account_spec.rb'
- 'spec/models/spree/ability_spec.rb'
- 'spec/models/variant_override_spec.rb'
- 'spec/spec_helper.rb'
# Offense count: 83
@@ -555,8 +531,6 @@ Layout/SpaceAfterComma:
- 'app/controllers/spree/orders_controller_decorator.rb'
- 'app/models/column_preference.rb'
- 'lib/discourse/single_sign_on.rb'
- 'lib/open_food_network/accounts_and_billing_settings_validator.rb'
- 'lib/open_food_network/business_model_configuration_validator.rb'
- 'lib/open_food_network/order_cycle_form_applicator.rb'
- 'lib/open_food_network/users_and_enterprises_report.rb'
- 'spec/controllers/admin/enterprises_controller_spec.rb'
@@ -565,7 +539,6 @@ Layout/SpaceAfterComma:
- 'spec/features/admin/bulk_product_update_spec.rb'
- 'spec/features/admin/customers_spec.rb'
- 'spec/features/admin/variant_overrides_spec.rb'
- 'spec/jobs/update_account_invoices_spec.rb'
- 'spec/lib/open_food_network/group_buy_report_spec.rb'
- 'spec/lib/open_food_network/subscription_summary_spec.rb'
- 'spec/models/content_configuration_spec.rb'
@@ -612,9 +585,6 @@ Layout/SpaceAroundEqualsInParameterDefault:
- 'app/models/spree/taxon_decorator.rb'
- 'app/models/variant_override_set.rb'
- 'lib/discourse/single_sign_on.rb'
- 'lib/open_food_network/accounts_and_billing_settings_validator.rb'
- 'lib/open_food_network/bill_calculator.rb'
- 'lib/open_food_network/business_model_configuration_validator.rb'
- 'lib/open_food_network/enterprise_fee_calculator.rb'
- 'lib/open_food_network/enterprise_issue_validator.rb'
- 'lib/open_food_network/order_cycle_form_applicator.rb'
@@ -635,8 +605,6 @@ Layout/SpaceAroundEqualsInParameterDefault:
Layout/SpaceAroundOperators:
Exclude:
- 'app/controllers/checkout_controller.rb'
- 'app/helpers/admin/business_model_configuration_helper.rb'
- 'app/jobs/update_billable_periods.rb'
- 'app/overrides/remove_search_bar.rb'
- 'app/overrides/remove_side_bar.rb'
- 'app/overrides/replace_shipping_address_form_with_distributor_details.rb'
@@ -648,7 +616,6 @@ Layout/SpaceAroundOperators:
- 'spec/features/consumer/shopping/checkout_spec.rb'
- 'spec/helpers/checkout_helper_spec.rb'
- 'spec/helpers/order_cycles_helper_spec.rb'
- 'spec/jobs/update_billable_periods_spec.rb'
- 'spec/lib/open_food_network/order_grouper_spec.rb'
- 'spec/lib/stripe/account_connector_spec.rb'
- 'spec/spec_helper.rb'
@@ -698,7 +665,6 @@ Layout/SpaceInsideArrayLiteralBrackets:
- 'lib/open_food_network/users_and_enterprises_report.rb'
- 'spec/controllers/admin/variant_overrides_controller_spec.rb'
- 'spec/features/admin/reports_spec.rb'
- 'spec/jobs/update_billable_periods_spec.rb'
- 'spec/lib/open_food_network/order_grouper_spec.rb'
- 'spec/lib/open_food_network/users_and_enterprises_report_spec.rb'
- 'spec/models/spree/order_spec.rb'
@@ -719,8 +685,6 @@ Layout/SpaceInsideBlockBraces:
- 'lib/spree/product_filters.rb'
- 'lib/tasks/karma.rake'
- 'spec/archive/features/consumer/checkout_spec.rb'
- 'spec/controllers/admin/accounts_and_billing_settings_controller_spec.rb'
- 'spec/controllers/admin/business_model_configuration_controller_spec.rb'
- 'spec/controllers/admin/inventory_items_controller_spec.rb'
- 'spec/controllers/admin/tag_rules_controller_spec.rb'
- 'spec/controllers/admin/variant_overrides_controller_spec.rb'
@@ -736,12 +700,8 @@ Layout/SpaceInsideBlockBraces:
- 'spec/helpers/enterprises_helper_spec.rb'
- 'spec/helpers/injection_helper_spec.rb'
- 'spec/helpers/spree/orders_helper_spec.rb'
- 'spec/jobs/finalize_account_invoices_spec.rb'
- 'spec/jobs/update_account_invoices_spec.rb'
- 'spec/jobs/update_billable_periods_spec.rb'
- 'spec/lib/open_food_network/order_cycle_form_applicator_spec.rb'
- 'spec/lib/open_food_network/order_grouper_spec.rb'
- 'spec/lib/open_food_network/orders_and_fulfillments_report_spec.rb'
- 'spec/lib/open_food_network/products_renderer_spec.rb'
- 'spec/lib/open_food_network/tag_rule_applicator_spec.rb'
- 'spec/models/column_preference_spec.rb'
@@ -763,7 +723,6 @@ Layout/SpaceInsideBlockBraces:
# SupportedStylesForEmptyBraces: space, no_space
Layout/SpaceInsideHashLiteralBraces:
Exclude:
- 'app/controllers/admin/cache_settings_controller.rb'
- 'app/controllers/admin/enterprise_relationships_controller.rb'
- 'app/controllers/admin/enterprise_roles_controller.rb'
- 'app/controllers/api/statuses_controller.rb'
@@ -771,7 +730,6 @@ Layout/SpaceInsideHashLiteralBraces:
- 'app/controllers/spree/admin/line_items_controller_decorator.rb'
- 'app/controllers/spree/admin/products_controller_decorator.rb'
- 'app/controllers/spree/admin/search_controller_decorator.rb'
- 'app/helpers/admin/business_model_configuration_helper.rb'
- 'app/helpers/admin/injection_helper.rb'
- 'app/helpers/angular_form_builder.rb'
- 'app/helpers/injection_helper.rb'
@@ -779,9 +737,7 @@ Layout/SpaceInsideHashLiteralBraces:
- 'app/helpers/serializer_helper.rb'
- 'app/helpers/spree/admin/base_helper_decorator.rb'
- 'app/helpers/spree/admin/navigation_helper_decorator.rb'
- 'app/jobs/update_billable_periods.rb'
- 'app/mailers/spree/base_mailer_decorator.rb'
- 'app/models/billable_period.rb'
- 'app/models/enterprise.rb'
- 'app/models/enterprise_group.rb'
- 'app/models/enterprise_relationship.rb'
@@ -800,8 +756,6 @@ Layout/SpaceInsideHashLiteralBraces:
- 'lib/open_food_network/sales_tax_report.rb'
- 'lib/open_food_network/variant_and_line_item_naming.rb'
- 'lib/open_food_network/xero_invoices_report.rb'
- 'spec/controllers/admin/accounts_and_billing_settings_controller_spec.rb'
- 'spec/controllers/admin/business_model_configuration_controller_spec.rb'
- 'spec/controllers/admin/enterprises_controller_spec.rb'
- 'spec/controllers/admin/manager_invitations_controller_spec.rb'
- 'spec/controllers/admin/order_cycles_controller_spec.rb'
@@ -820,7 +774,6 @@ Layout/SpaceInsideHashLiteralBraces:
- 'spec/controllers/spree/user_sessions_controller_spec.rb'
- 'spec/controllers/user_passwords_controller_spec.rb'
- 'spec/controllers/user_registrations_controller_spec.rb'
- 'spec/features/admin/accounts_and_billing_settings_spec.rb'
- 'spec/features/admin/image_settings_spec.rb'
- 'spec/features/admin/products_spec.rb'
- 'spec/features/admin/reports_spec.rb'
@@ -841,7 +794,6 @@ Layout/SpaceInsideHashLiteralBraces:
- 'spec/models/enterprise_relationship_spec.rb'
- 'spec/models/exchange_spec.rb'
- 'spec/models/model_set_spec.rb'
- 'spec/models/product_distribution_spec.rb'
- 'spec/models/product_importer_spec.rb'
- 'spec/models/spree/ability_spec.rb'
- 'spec/models/spree/gateway/stripe_connect_spec.rb'
@@ -852,7 +804,6 @@ Layout/SpaceInsideHashLiteralBraces:
- 'spec/models/spree/taxon_spec.rb'
- 'spec/models/spree/variant_spec.rb'
- 'spec/models/tag_rule/discount_order_spec.rb'
- 'spec/models/variant_override_spec.rb'
- 'spec/performance/orders_controller_spec.rb'
- 'spec/requests/checkout/failed_checkout_spec.rb'
- 'spec/requests/checkout/stripe_connect_spec.rb'
@@ -938,7 +889,6 @@ Lint/DuplicateMethods:
Lint/IneffectiveAccessModifier:
Exclude:
- 'app/models/column_preference.rb'
- 'app/models/variant_override.rb'
- 'lib/open_food_network/feature_toggle.rb'
- 'lib/open_food_network/products_cache.rb'
- 'spec/lib/open_food_network/reports/report_spec.rb'
@@ -978,7 +928,6 @@ Lint/ShadowingOuterLocalVariable:
# Cop supports --auto-correct.
Lint/StringConversionInInterpolation:
Exclude:
- 'app/controllers/admin/accounts_and_billing_settings_controller.rb'
- 'app/controllers/enterprises_controller.rb'
- 'app/helpers/admin/injection_helper.rb'
- 'app/helpers/injection_helper.rb'
@@ -1031,8 +980,6 @@ Lint/UnusedMethodArgument:
- 'app/helpers/angular_form_helper.rb'
- 'app/helpers/order_cycles_helper.rb'
- 'app/helpers/spree/base_helper_decorator.rb'
- 'app/jobs/finalize_account_invoices.rb'
- 'app/jobs/update_account_invoices.rb'
- 'app/models/spree/ability_decorator.rb'
- 'app/models/spree/product_decorator.rb'
- 'lib/open_food_network/enterprise_fee_applicator.rb'
@@ -1084,7 +1031,6 @@ Lint/Void:
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
- 'spec/lib/open_food_network/enterprise_issue_validator_spec.rb'
- 'spec/lib/open_food_network/group_buy_report_spec.rb'
- 'spec/lib/open_food_network/orders_and_fulfillments_report_spec.rb'
- 'spec/lib/open_food_network/packing_report_spec.rb'
- 'spec/lib/open_food_network/reports/report_spec.rb'
- 'spec/lib/open_food_network/reports/rule_spec.rb'
@@ -1100,7 +1046,6 @@ Lint/Void:
- 'spec/models/spree/payment_spec.rb'
- 'spec/models/spree/product_spec.rb'
- 'spec/models/spree/variant_spec.rb'
- 'spec/models/variant_override_spec.rb'
- 'spec/serializers/enterprise_serializer_spec.rb'
- 'spec/support/request/web_helper.rb'
@@ -1344,8 +1289,6 @@ Rails/HasAndBelongsToMany:
# Include: app/models/**/*.rb
Rails/HasManyOrHasOneDependent:
Exclude:
- 'app/models/account_invoice.rb'
- 'app/models/billable_period.rb'
- 'app/models/customer.rb'
- 'app/models/enterprise.rb'
- 'app/models/order_cycle.rb'
@@ -1382,7 +1325,6 @@ Rails/HttpStatus:
- 'app/controllers/shop_controller.rb'
- 'app/controllers/spree/admin/line_items_controller_decorator.rb'
- 'app/controllers/spree/admin/products_controller_decorator.rb'
- 'app/controllers/spree/credit_cards_controller.rb'
- 'app/controllers/spree/store_controller_decorator.rb'
- 'app/controllers/stripe/callbacks_controller.rb'
- 'app/controllers/stripe/webhooks_controller.rb'
@@ -1402,8 +1344,6 @@ Rails/OutputSafety:
Rails/PluralizationGrammar:
Exclude:
- 'spec/features/admin/order_cycles_spec.rb'
- 'spec/jobs/update_account_invoices_spec.rb'
- 'spec/jobs/update_billable_periods_spec.rb'
- 'spec/models/order_cycle_spec.rb'
- 'spec/models/spree/product_spec.rb'
@@ -1463,7 +1403,6 @@ Rails/TimeZone:
- 'spec/lib/open_food_network/products_cache_refreshment_spec.rb'
- 'spec/lib/open_food_network/products_cache_spec.rb'
- 'spec/models/enterprise_relationship_spec.rb'
- 'spec/models/variant_override_spec.rb'
# Offense count: 1
# Configuration parameters: Environments.
@@ -1484,9 +1423,7 @@ Rails/Validation:
- 'app/models/enterprise_role.rb'
- 'app/models/exchange.rb'
- 'app/models/order_cycle.rb'
- 'app/models/product_distribution.rb'
- 'app/models/spree/product_decorator.rb'
- 'app/models/variant_override.rb'
# Offense count: 18
# Cop supports --auto-correct.
@@ -1525,15 +1462,9 @@ Style/BracesAroundHashParameters:
- 'app/controllers/checkout_controller.rb'
- 'app/controllers/spree/admin/products_controller_decorator.rb'
- 'app/controllers/spree/admin/search_controller_decorator.rb'
- 'app/helpers/admin/account_helper.rb'
- 'app/helpers/admin/business_model_configuration_helper.rb'
- 'app/helpers/angular_form_builder.rb'
- 'app/helpers/checkout_helper.rb'
- 'app/helpers/spree/admin/orders_helper_decorator.rb'
- 'app/jobs/finalize_account_invoices.rb'
- 'app/jobs/update_account_invoices.rb'
- 'app/jobs/update_billable_periods.rb'
- 'app/models/billable_period.rb'
- 'app/models/exchange.rb'
- 'app/models/spree/adjustment_decorator.rb'
- 'app/models/spree/line_item_decorator.rb'
@@ -1543,8 +1474,6 @@ Style/BracesAroundHashParameters:
- 'lib/open_food_network/reports/rule.rb'
- 'lib/open_food_network/variant_and_line_item_naming.rb'
- 'lib/open_food_network/xero_invoices_report.rb'
- 'spec/controllers/admin/accounts_and_billing_settings_controller_spec.rb'
- 'spec/controllers/admin/business_model_configuration_controller_spec.rb'
- 'spec/controllers/admin/enterprises_controller_spec.rb'
- 'spec/controllers/admin/manager_invitations_controller_spec.rb'
- 'spec/controllers/admin/order_cycles_controller_spec.rb'
@@ -1562,20 +1491,14 @@ Style/BracesAroundHashParameters:
- 'spec/controllers/spree/orders_controller_spec.rb'
- 'spec/controllers/user_confirmations_controller_spec.rb'
- 'spec/controllers/user_registrations_controller_spec.rb'
- 'spec/features/admin/accounts_and_billing_settings_spec.rb'
- 'spec/features/admin/business_model_configuration_spec.rb'
- 'spec/features/admin/order_cycles_spec.rb'
- 'spec/features/admin/products_spec.rb'
- 'spec/features/admin/reports_spec.rb'
- 'spec/features/admin/tax_settings_spec.rb'
- 'spec/helpers/order_cycles_helper_spec.rb'
- 'spec/jobs/finalize_account_invoices_spec.rb'
- 'spec/jobs/update_account_invoices_spec.rb'
- 'spec/lib/open_food_network/feature_toggle_spec.rb'
- 'spec/lib/open_food_network/order_cycle_form_applicator_spec.rb'
- 'spec/lib/open_food_network/subscription_summarizer_spec.rb'
- 'spec/models/billable_period_spec.rb'
- 'spec/models/product_distribution_spec.rb'
- 'spec/models/spree/ability_spec.rb'
- 'spec/models/spree/order_spec.rb'
- 'spec/models/spree/product_spec.rb'
@@ -1598,10 +1521,6 @@ Style/CaseEquality:
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Exclude:
- 'app/controllers/admin/account_controller.rb'
- 'app/controllers/admin/accounts_and_billing_settings_controller.rb'
- 'app/controllers/admin/business_model_configuration_controller.rb'
- 'app/controllers/admin/cache_settings_controller.rb'
- 'app/controllers/spree/store_controller_decorator.rb'
- 'app/helpers/angular_form_helper.rb'
- 'app/models/calculator/flat_percent_per_item.rb'
@@ -1768,7 +1687,6 @@ Style/FormatStringToken:
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'app/controllers/admin/accounts_and_billing_settings_controller.rb'
- 'app/controllers/admin/enterprises_controller.rb'
- 'app/controllers/admin/order_cycles_controller.rb'
- 'app/controllers/admin/product_import_controller.rb'
@@ -1785,8 +1703,6 @@ Style/GuardClause:
- 'app/controllers/spree/orders_controller_decorator.rb'
- 'app/controllers/spree/paypal_controller_decorator.rb'
- 'app/jobs/products_cache_integrity_checker_job.rb'
- 'app/jobs/update_account_invoices.rb'
- 'app/jobs/update_billable_periods.rb'
- 'app/models/enterprise.rb'
- 'app/models/enterprise_group.rb'
- 'app/models/producer_property.rb'
@@ -1796,7 +1712,6 @@ Style/GuardClause:
- 'app/models/spree/product_decorator.rb'
- 'app/models/spree/user_decorator.rb'
- 'lib/discourse/single_sign_on.rb'
- 'lib/open_food_network/accounts_and_billing_settings_validator.rb'
- 'lib/open_food_network/order_cycle_form_applicator.rb'
- 'lib/open_food_network/products_cache.rb'
- 'lib/open_food_network/products_renderer.rb'
@@ -1815,7 +1730,6 @@ Style/GuardClause:
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
Style/HashSyntax:
Exclude:
- 'app/controllers/admin/accounts_and_billing_settings_controller.rb'
- 'app/controllers/admin/contents_controller.rb'
- 'app/controllers/admin/enterprise_fees_controller.rb'
- 'app/controllers/admin/enterprises_controller.rb'
@@ -1833,7 +1747,6 @@ Style/HashSyntax:
- 'app/controllers/spree/paypal_controller_decorator.rb'
- 'app/controllers/spree/store_controller_decorator.rb'
- 'app/controllers/user_passwords_controller.rb'
- 'app/helpers/admin/account_helper.rb'
- 'app/helpers/angular_form_builder.rb'
- 'app/helpers/application_helper.rb'
- 'app/helpers/checkout_helper.rb'
@@ -1842,7 +1755,6 @@ Style/HashSyntax:
- 'app/helpers/spree/admin/orders_helper_decorator.rb'
- 'app/mailers/enterprise_mailer.rb'
- 'app/mailers/spree/user_mailer_decorator.rb'
- 'app/models/billable_period.rb'
- 'app/models/calculator/flat_percent_per_item.rb'
- 'app/models/enterprise.rb'
- 'app/models/enterprise_fee.rb'
@@ -1850,7 +1762,6 @@ Style/HashSyntax:
- 'app/models/enterprise_role.rb'
- 'app/models/exchange_variant.rb'
- 'app/models/order_cycle.rb'
- 'app/models/product_distribution.rb'
- 'app/models/spree/adjustment_decorator.rb'
- 'app/models/spree/classification_decorator.rb'
- 'app/models/spree/gateway/migs.rb'
@@ -1864,17 +1775,9 @@ Style/HashSyntax:
- 'app/models/spree/product_decorator.rb'
- 'app/models/spree/taxon_decorator.rb'
- 'app/models/spree/user_decorator.rb'
- 'app/overrides/add_distributor_details_js_to_product.rb'
- 'app/overrides/add_distributor_details_to_product.rb'
- 'app/overrides/add_distributor_to_add_to_cart_form.rb'
- 'app/overrides/add_enterprise_fees_to_admin_configurations_menu.rb'
- 'app/overrides/add_source_to_product.rb'
- 'app/overrides/remove_search_bar.rb'
- 'app/overrides/remove_side_bar.rb'
- 'app/overrides/replace_checkout_payment_button.rb'
- 'app/overrides/replace_order_details_steps_data.rb'
- 'app/overrides/replace_payment_name_with_description.rb'
- 'app/overrides/replace_shipping_address_form_with_distributor_details.rb'
- 'app/overrides/set_auth_token_in_backend.rb'
- 'app/overrides/set_auth_token_in_frontend.rb'
- 'app/presenters/variant_presenter.rb'
@@ -1906,7 +1809,6 @@ Style/HashSyntax:
- 'spec/controllers/spree/admin/payments_controller_spec.rb'
- 'spec/controllers/spree/api/products_controller_spec.rb'
- 'spec/controllers/spree/api/variants_controller_spec.rb'
- 'spec/controllers/spree/credit_cards_controller_spec.rb'
- 'spec/controllers/spree/user_sessions_controller_spec.rb'
- 'spec/controllers/user_registrations_controller_spec.rb'
- 'spec/features/admin/bulk_order_management_spec.rb'
@@ -1939,8 +1841,6 @@ Style/HashSyntax:
- 'spec/models/enterprise_spec.rb'
- 'spec/models/exchange_spec.rb'
- 'spec/models/order_cycle_spec.rb'
- 'spec/models/product_distribution_spec.rb'
- 'spec/models/spree/calculator/flat_percent_item_total_spec.rb'
- 'spec/models/spree/calculator/flat_rate_spec.rb'
- 'spec/models/spree/image_spec.rb'
- 'spec/models/spree/order_spec.rb'
@@ -2001,7 +1901,7 @@ Style/MethodDefParentheses:
Exclude:
- 'app/helpers/enterprises_helper.rb'
- 'app/models/spree/product_decorator.rb'
- 'lib/open_food_network/distribution_change_validator.rb'
- 'app/services/order_cycle_distributed_variants.rb'
- 'lib/open_food_network/feature_toggle.rb'
- 'lib/open_food_network/group_buy_report.rb'
- 'spec/support/request/authentication_workflow.rb'
@@ -2020,7 +1920,6 @@ Style/MixinUsage:
- 'spec/features/admin/orders_spec.rb'
- 'spec/lib/open_food_network/bulk_coop_report_spec.rb'
- 'spec/lib/open_food_network/order_cycle_management_report_spec.rb'
- 'spec/lib/open_food_network/orders_and_fulfillments_report_spec.rb'
- 'spec/lib/open_food_network/packing_report_spec.rb'
# Offense count: 4
@@ -2102,9 +2001,7 @@ Style/NumericLiterals:
Style/NumericPredicate:
Exclude:
- 'spec/**/*'
- 'app/helpers/admin/business_model_configuration_helper.rb'
- 'app/helpers/checkout_helper.rb'
- 'app/jobs/update_account_invoices.rb'
- 'app/models/spree/calculator/flexi_rate_decorator.rb'
- 'app/models/spree/line_item_decorator.rb'
- 'app/models/spree/order_decorator.rb'
@@ -2184,7 +2081,6 @@ Style/RedundantReturn:
Exclude:
- 'app/controllers/admin/enterprise_fees_controller.rb'
- 'app/controllers/admin/enterprises_controller.rb'
- 'app/controllers/spree/credit_cards_controller.rb'
- 'app/models/enterprise_fee.rb'
- 'app/models/spree/adjustment_decorator.rb'
- 'app/models/spree/classification_decorator.rb'
@@ -2194,7 +2090,6 @@ Style/RedundantReturn:
# Cop supports --auto-correct.
Style/RedundantSelf:
Exclude:
- 'app/models/billable_period.rb'
- 'app/models/calculator/flat_percent_per_item.rb'
- 'app/models/enterprise.rb'
- 'app/models/exchange.rb'
@@ -2215,7 +2110,6 @@ Style/RedundantSelf:
- 'app/models/spree/taxon_decorator.rb'
- 'app/models/spree/user_decorator.rb'
- 'app/models/spree/variant_decorator.rb'
- 'app/models/variant_override.rb'
- 'lib/open_food_network/locking.rb'
- 'lib/open_food_network/rack_request_blocker.rb'
- 'lib/open_food_network/reports/report.rb'
@@ -2275,7 +2169,6 @@ Style/Send:
- 'spec/models/enterprise_spec.rb'
- 'spec/models/exchange_spec.rb'
- 'spec/models/order_cycle_spec.rb'
- 'spec/models/product_distribution_spec.rb'
- 'spec/models/spree/gateway/stripe_connect_spec.rb'
- 'spec/models/spree/line_item_spec.rb'
- 'spec/models/spree/order_spec.rb'
@@ -2309,7 +2202,6 @@ Style/StabbyLambdaParentheses:
Style/StringLiteralsInInterpolation:
Exclude:
- 'app/controllers/application_controller.rb'
- 'app/jobs/update_billable_periods.rb'
- 'lib/discourse/single_sign_on.rb'
- 'lib/open_food_network/users_and_enterprises_report.rb'
- 'spec/features/admin/bulk_order_management_spec.rb'
@@ -2387,12 +2279,9 @@ Style/UnneededCondition:
# Cop supports --auto-correct.
Style/UnneededInterpolation:
Exclude:
- 'app/controllers/admin/accounts_and_billing_settings_controller.rb'
- 'app/controllers/admin/resource_controller.rb'
- 'app/helpers/admin/business_model_configuration_helper.rb'
- 'app/helpers/angular_form_builder.rb'
- 'app/helpers/injection_helper.rb'
- 'app/jobs/update_billable_periods.rb'
- 'lib/discourse/single_sign_on.rb'
- 'spec/features/admin/bulk_order_management_spec.rb'
- 'spec/features/admin/bulk_product_update_spec.rb'

View File

@@ -39,7 +39,7 @@ before_script:
script:
- 'if [ "$KARMA" = "true" ]; then bundle exec rake karma:run; else echo "Skipping karma run"; fi'
- 'if [ "$RSPEC_ENGINES" = "true" ]; then bundle exec rake openfoodnetwork:specs:engines:rspec; else echo "Skipping RSpec run in engines"; fi'
- 'if [ "$RSPEC_ENGINES" = "true" ]; then bundle exec rake ofn:specs:engines:rspec; else echo "Skipping RSpec run in engines"; fi'
- "bundle exec rake 'knapsack:rspec[--format progress --tag ~performance]'"
after_success:

View File

@@ -75,7 +75,7 @@ Then the main application tests can be run with:
The tests of all custom engines can be run with:
bundle exec rake openfoodnetwork:specs:engines:rspec
bundle exec rake ofn:specs:engines:rspec
Note: If your OS is not explicitly supported in the setup guides then not all tests may pass. However, you may still be able to develop. Get in touch with the [#dev][slack-dev] channel on Slack to troubleshoot issues and determine if they will preclude you from contributing to OFN.

28
Gemfile
View File

@@ -5,33 +5,40 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}.git" }
gem 'rails', '~> 3.2.22'
gem 'rails-i18n', '~> 3.0.0'
gem 'i18n', '~> 0.6.11'
gem 'i18n-js', '~> 3.1.0'
gem 'i18n-js', '~> 3.2.1'
# Patched version. See http://rubysec.com/advisories/CVE-2015-5312/.
gem 'nokogiri', '>= 1.6.7.1'
gem "order_management", path: "./engines/order_management"
gem 'web', path: './engines/web'
gem 'pg'
gem 'spree', github: 'openfoodfoundation/spree', branch: 'step-6a', ref: '41906362d931695e0616194341a68d2c4c85aaaf'
# OFN-maintained and patched version of Spree v2.0.4. See
# https://github.com/openfoodfoundation/openfoodnetwork/wiki/Spree-2.0-upgrade
# for details.
gem 'spree', github: 'openfoodfoundation/spree', branch: '2-0-4-stable'
gem 'spree_i18n', github: 'spree/spree_i18n', branch: '1-3-stable'
gem 'spree_auth_devise', github: 'openfoodfoundation/spree_auth_devise', branch: 'spree-upgrade-intermediate'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-0-stable'
# Our branch contains two changes
# - Pass customer email and phone number to PayPal (merged to upstream master)
# - Change type of password from string to password to hide it in the form
gem 'spree_paypal_express', github: "openfoodfoundation/better_spree_paypal_express", branch: "spree-upgrade-intermediate"
#gem 'spree_paypal_express', github: "spree-contrib/better_spree_paypal_express", branch: "1-3-stable"
gem 'stripe', '~> 3.3.2'
gem 'spree_paypal_express', github: "openfoodfoundation/better_spree_paypal_express", branch: "2-0-stable"
gem 'stripe'
# We need at least this version to have Digicert's root certificate
# which is needed for Pin Payments (and possibly others).
gem 'activemerchant', '~> 1.78'
gem 'oauth2', '~> 1.4.1' # Used for Stripe Connect
gem 'jwt', '~> 1.5'
gem 'jwt', '~> 2.1'
gem 'delayed_job_active_record'
gem 'daemons'
gem 'delayed_job_web'
# Fix bug in simple_form preventing collection_check_boxes usage within form_for block
# When merged, revert to upstream gem
@@ -54,8 +61,8 @@ gem 'rabl'
# Once Rails is updated to 5.x we should bump directly to 0.10.x
gem "active_model_serializers", "0.8.4"
gem 'oj'
gem 'deface', github: 'spree/deface', ref: '1110a13'
gem 'paperclip'
gem 'deface', '1.0.0'
gem 'paperclip', '~> 3.4.1'
gem 'dalli'
gem 'geocoder'
gem 'gmaps4rails'
@@ -102,7 +109,7 @@ end
gem "foundation-rails"
gem 'foundation_rails_helper', github: 'willrjmarshall/foundation_rails_helper', branch: "rails3"
gem 'jquery-rails'
gem 'jquery-rails', '3.0.0'
gem 'jquery-migrate-rails'
gem 'ofn-qz', github: 'openfoodfoundation/ofn-qz', ref: '60da2ae4c44cbb4c8d602f59fb5fff8d0f21db3c'
@@ -136,6 +143,7 @@ end
group :development do
gem 'byebug', '~> 9.0.0' # 9.1 requires ruby 2.2
gem "newrelic_rpm", "~> 3.0"
gem 'pry-byebug', '>= 3.4.3'
gem 'debugger-linecache'
gem 'guard'

View File

@@ -14,12 +14,12 @@ GIT
GIT
remote: https://github.com/openfoodfoundation/better_spree_paypal_express.git
revision: 8d95f4544c682634812becaf50999fba0cd04df0
branch: spree-upgrade-intermediate
revision: 27ad7165ea4c6e8c5f120b42b676cb9c2c272100
branch: 2-0-stable
specs:
spree_paypal_express (2.0.3)
paypal-sdk-merchant (= 1.106.1)
spree_core (~> 1.3.99)
spree_core (~> 2.0.3)
GIT
remote: https://github.com/openfoodfoundation/ofn-qz.git
@@ -31,87 +31,72 @@ GIT
GIT
remote: https://github.com/openfoodfoundation/spree.git
revision: 41906362d931695e0616194341a68d2c4c85aaaf
ref: 41906362d931695e0616194341a68d2c4c85aaaf
branch: step-6a
revision: 46d6f8f5fd434105b0c69958276d1727a3066a97
branch: 2-0-4-stable
specs:
spree (1.3.99)
spree_api (= 1.3.99)
spree_backend (= 1.3.99)
spree_cmd (= 1.3.99)
spree_core (= 1.3.99)
spree_dash (= 1.3.99)
spree_frontend (= 1.3.99)
spree_sample (= 1.3.99)
spree_api (1.3.99)
rabl (= 0.7.2)
spree_core (= 1.3.99)
versioncake (= 0.4.0)
spree_backend (1.3.99)
spree (2.0.4)
spree_api (= 2.0.4)
spree_backend (= 2.0.4)
spree_cmd (= 2.0.4)
spree_core (= 2.0.4)
spree_frontend (= 2.0.4)
spree_sample (= 2.0.4)
spree_api (2.0.4)
rabl (= 0.8.4)
spree_core (= 2.0.4)
versioncake (= 1.0.0)
spree_backend (2.0.4)
deface (>= 0.9.0)
jquery-rails (~> 2.0)
jquery-rails (~> 3.0.0)
jquery-ui-rails (~> 4.0.0)
rails (~> 3.2.8)
select2-rails (~> 3.2)
spree_api (= 1.3.99)
spree_core (= 1.3.99)
stringex (~> 1.3.2)
spree_cmd (1.3.99)
select2-rails (~> 3.4.7)
spree_api (= 2.0.4)
spree_core (= 2.0.4)
spree_cmd (2.0.4)
thor (>= 0.14.6)
spree_core (1.3.99)
activemerchant (~> 1.50)
acts_as_list (= 0.1.9)
spree_core (2.0.4)
activemerchant (~> 1.34)
acts_as_list (= 0.2.0)
awesome_nested_set (= 2.1.5)
aws-sdk (~> 1.11.1)
cancan (= 1.6.8)
deface (>= 0.9.0)
ffaker (~> 1.15.0)
highline (= 1.6.15)
httparty (= 0.9.0)
json (>= 1.5.5)
kaminari (= 0.13.0)
money (= 5.1.0)
cancan (~> 1.6.10)
deface (>= 0.9.1)
ffaker (~> 1.16)
highline (= 1.6.18)
httparty (~> 0.11)
json (>= 1.7.7)
kaminari (~> 0.14.1)
money (= 5.1.1)
paperclip (~> 3.0)
rails (~> 3.2.13)
paranoia (~> 1.3)
rails (~> 3.2.14)
ransack (= 0.7.2)
state_machine (= 1.2.0)
stringex (~> 1.3.2)
stringex (~> 1.5.1)
truncate_html (= 0.9.2)
spree_dash (1.3.99)
httparty (~> 0.9.0)
spree_backend (= 1.3.99)
spree_frontend (= 1.3.99)
spree_frontend (1.3.99)
spree_frontend (2.0.4)
canonical-rails
deface (>= 0.9.0)
jquery-rails (~> 2.2.1)
rails (~> 3.2.8)
select2-rails (~> 3.2)
spree_api (= 1.3.99)
spree_core (= 1.3.99)
stringex (~> 1.3.2)
spree_sample (1.3.99)
spree_core (= 1.3.99)
jquery-rails (~> 3.0.0)
rails (~> 3.2.13)
spree_api (= 2.0.4)
spree_core (= 2.0.4)
stringex (~> 1.5.1)
spree_sample (2.0.4)
spree_core (= 2.0.4)
GIT
remote: https://github.com/openfoodfoundation/spree_auth_devise.git
revision: da9eecefc6fe13dedf4c6f3febec79caad839ec3
branch: spree-upgrade-intermediate
remote: https://github.com/spree/spree_auth_devise.git
revision: 0181835fb6ac77a05191d26f6f32a0f4a548d851
branch: 2-0-stable
specs:
spree_auth_devise (2.0.0)
devise (~> 2.2.5)
devise-encryptable (= 0.1.2)
spree_backend (~> 1.3.6)
spree_core (~> 1.3.6)
spree_frontend (~> 1.3.6)
GIT
remote: https://github.com/spree/deface.git
revision: 1110a1336252109bce7f98f9182042e0bc2930ae
ref: 1110a13
specs:
deface (1.0.0.rc3)
colorize (>= 0.5.8)
nokogiri (~> 1.6.0)
rails (>= 3.1)
spree_backend (~> 2.0.0)
spree_core (~> 2.0.0)
spree_frontend (~> 2.0.0)
GIT
remote: https://github.com/spree/spree_i18n.git
@@ -133,6 +118,11 @@ GIT
activemodel (>= 3.0)
railties (>= 3.0)
PATH
remote: engines/order_management
specs:
order_management (0.0.1)
PATH
remote: engines/web
specs:
@@ -178,7 +168,8 @@ GEM
multi_json (~> 1.0)
acts-as-taggable-on (3.5.0)
activerecord (>= 3.2, < 5)
acts_as_list (0.1.9)
acts_as_list (0.2.0)
activerecord (>= 3.0)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
andand (1.3.3)
@@ -204,10 +195,13 @@ GEM
bcrypt-ruby (3.1.5)
bcrypt (>= 3.1.3)
blockenspiel (0.5.0)
bugsnag (4.1.0)
bugsnag (6.11.1)
concurrent-ruby (~> 1.0)
builder (3.0.4)
byebug (9.0.6)
cancan (1.6.8)
cancan (1.6.10)
canonical-rails (0.1.0)
rails (>= 3.1, < 5.1)
capybara (2.18.0)
addressable
mini_mime (>= 0.1.3)
@@ -234,7 +228,7 @@ GEM
execjs
coffee-script-source (1.10.0)
colorize (0.8.1)
combine_pdf (1.0.15)
combine_pdf (1.0.16)
ruby-rc4 (>= 0.1.5)
compass (1.0.3)
chunky_png (~> 1.2)
@@ -252,23 +246,34 @@ GEM
compass (~> 1.0.0)
sass-rails (< 5.1)
sprockets (< 4.0)
concurrent-ruby (1.1.4)
connection_pool (2.2.2)
crack (0.4.3)
safe_yaml (~> 1.0.0)
css_parser (1.6.0)
addressable
daemons (1.3.1)
dalli (2.7.2)
dalli (2.7.10)
database_cleaner (0.7.1)
db2fog (0.9.0)
activerecord (>= 3.2.0, < 5.0)
fog (~> 1.0)
rails (>= 3.2.0, < 5.0)
debugger-linecache (1.2.0)
deface (1.0.0)
colorize (>= 0.5.8)
nokogiri (~> 1.6.0)
rails (>= 3.1)
delayed_job (4.1.5)
activesupport (>= 3.0, < 5.3)
delayed_job_active_record (4.1.3)
activerecord (>= 3.0, < 5.3)
delayed_job (>= 3.0, < 5)
delayed_job_web (1.4.3)
activerecord (> 3.0.0)
delayed_job (> 2.0.3)
rack-protection (>= 1.5.5)
sinatra (>= 1.4.4)
devise (2.2.8)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
@@ -287,15 +292,15 @@ GEM
eventmachine (1.2.7)
excon (0.62.0)
execjs (2.7.0)
factory_bot (4.8.2)
factory_bot (4.10.0)
activesupport (>= 3.0.0)
factory_bot_rails (4.8.2)
factory_bot (~> 4.8.2)
factory_bot_rails (4.10.0)
factory_bot (~> 4.10.0)
railties (>= 3.0.0)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
ffaker (1.15.0)
ffi (1.9.25)
ffaker (1.22.1)
ffi (1.10.0)
figaro (1.1.1)
thor (~> 0.14)
fission (0.5.0)
@@ -485,15 +490,14 @@ GEM
haml (4.0.7)
tilt
hashdiff (0.3.7)
highline (1.6.15)
highline (1.6.18)
hike (1.2.3)
http_parser.rb (0.6.0)
httparty (0.9.0)
multi_json (~> 1.0)
multi_xml
httparty (0.16.2)
multi_xml (>= 0.5.2)
i18n (0.6.11)
i18n-js (3.1.0)
i18n (>= 0.6.6, < 2)
i18n-js (3.2.1)
i18n (>= 0.6.6)
immigrant (0.3.6)
activerecord (>= 3.0)
io-like (0.3.0)
@@ -501,18 +505,19 @@ GEM
jaro_winkler (1.5.1)
journey (1.0.4)
jquery-migrate-rails (1.2.1)
jquery-rails (2.2.2)
jquery-rails (3.0.0)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
jquery-ui-rails (4.0.5)
railties (>= 3.1.0)
json (1.8.6)
json_spec (1.1.5)
multi_json (~> 1.0)
rspec (>= 2.0, < 4.0)
jwt (1.5.6)
kaminari (0.13.0)
jwt (2.1.0)
kaminari (0.14.1)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
railties (>= 3.0.0)
kgio (2.11.2)
knapsack (1.17.1)
rake
@@ -534,12 +539,15 @@ GEM
mini_portile2 (2.1.0)
momentjs-rails (2.20.1)
railties (>= 3.1)
money (5.1.0)
money (5.1.1)
i18n (~> 0.6.0)
multi_json (1.13.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nenv (0.3.0)
net-http-persistent (3.0.0)
connection_pool (~> 2.2)
newrelic_rpm (3.18.1.330)
nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0)
notiffany (0.1.1)
@@ -551,17 +559,20 @@ GEM
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
oj (3.7.8)
oj (3.7.12)
orm_adapter (0.5.0)
paper_trail (5.2.3)
activerecord (>= 3.0, < 6.0)
request_store (~> 1.1)
paperclip (3.5.4)
paperclip (3.4.2)
activemodel (>= 3.0.0)
activerecord (>= 3.0.0)
activesupport (>= 3.0.0)
cocaine (~> 0.5.3)
cocaine (~> 0.5.0)
mime-types
parallel (1.11.2)
paranoia (1.3.4)
activerecord (~> 3.1)
parser (2.5.1.0)
ast (~> 2.4.0)
paypal-sdk-core (0.2.10)
@@ -581,14 +592,15 @@ GEM
byebug (>= 9.0, < 9.1)
pry (~> 0.10)
public_suffix (3.0.3)
rabl (0.7.2)
rabl (0.8.4)
activesupport (>= 2.3.14)
multi_json (~> 1.0)
rack (1.4.7)
rack-cache (1.8.0)
rack (>= 0.4)
rack-mini-profiler (0.10.7)
rack (>= 1.2.0)
rack-protection (1.5.5)
rack
rack-rewrite (1.5.1)
rack-ssl (1.3.4)
rack
@@ -629,7 +641,7 @@ GEM
trollop (~> 2.1)
rdoc (3.12.2)
json (~> 1.4)
redcarpet (3.2.3)
redcarpet (3.4.0)
ref (2.0.0)
request_store (1.4.1)
rack (>= 1.4)
@@ -658,7 +670,7 @@ GEM
rspec-mocks (3.8.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-rails (3.8.1)
rspec-rails (3.8.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
@@ -687,11 +699,12 @@ GEM
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
select2-rails (3.5.10)
select2-rails (3.4.9)
sass-rails
thor (~> 0.14)
selenium-webdriver (3.12.0)
selenium-webdriver (3.141.0)
childprocess (~> 0.5)
rubyzip (~> 1.2)
rubyzip (~> 1.2, >= 1.2.2)
shellany (0.0.1)
shoulda-matchers (2.8.0)
activesupport (>= 3.0.0)
@@ -700,11 +713,15 @@ GEM
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
sinatra (1.4.6)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
skylight (1.7.2)
activesupport (>= 3.0.0)
spinjs-rails (1.3)
spinjs-rails (1.4)
rails (>= 3.1)
spreadsheet (1.1.4)
spreadsheet (1.1.7)
ruby-ole (>= 1.0)
spring (1.7.2)
spring-commands-rspec (1.0.4)
@@ -715,9 +732,10 @@ GEM
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
state_machine (1.2.0)
stringex (1.3.3)
stripe (3.3.2)
faraday (~> 0.9)
stringex (1.5.1)
stripe (4.11.0)
faraday (~> 0.13)
net-http-persistent (~> 3.0)
therubyracer (0.12.0)
libv8 (~> 3.16.14.0)
ref
@@ -736,14 +754,14 @@ GEM
uglifier (4.1.20)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.3.2)
unicorn (5.4.1)
unicorn (5.5.0)
kgio (~> 2.6)
raindrops (~> 0.7)
unicorn-rails (2.2.1)
rack
unicorn
uuidtools (2.1.5)
versioncake (0.4.0)
versioncake (1.0.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
@@ -753,7 +771,7 @@ GEM
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
whenever (0.10.0)
whenever (0.11.0)
chronic (>= 0.6.3)
wicked_pdf (1.1.0)
wkhtmltopdf-binary (0.12.4)
@@ -789,8 +807,9 @@ DEPENDENCIES
database_cleaner (= 0.7.1)
db2fog
debugger-linecache
deface!
deface (= 1.0.0)
delayed_job_active_record
delayed_job_web
diffy
eventmachine (>= 1.2.3)
factory_bot_rails
@@ -808,22 +827,24 @@ DEPENDENCIES
guard-rspec (~> 4.7.3)
haml
i18n (~> 0.6.11)
i18n-js (~> 3.1.0)
i18n-js (~> 3.2.1)
immigrant
jquery-migrate-rails
jquery-rails
jquery-rails (= 3.0.0)
json_spec (~> 1.1.4)
jwt (~> 1.5)
jwt (~> 2.1)
knapsack
letter_opener (>= 1.4.1)
listen (= 3.0.8)
momentjs-rails
newrelic_rpm (~> 3.0)
nokogiri (>= 1.6.7.1)
oauth2 (~> 1.4.1)
ofn-qz!
oj
order_management!
paper_trail (~> 5.2.3)
paperclip
paperclip (~> 3.4.1)
pg
pry-byebug (>= 3.4.3)
rabl
@@ -853,7 +874,7 @@ DEPENDENCIES
spree_paypal_express!
spring (= 1.7.2)
spring-commands-rspec
stripe (~> 3.3.2)
stripe
therubyracer (= 0.12.0)
timecop
truncate_html

View File

@@ -1 +0,0 @@
angular.module("admin.accounts_and_billing_settings", ["admin.utils"])

View File

@@ -1,14 +0,0 @@
angular.module("admin.accounts_and_billing_settings").directive "methodSettingsFor", ->
template: "<div ng-include='include_html'></div>"
restrict: 'A'
scope: {
enterprise_id: '=methodSettingsFor'
}
link: (scope, element, attrs) ->
scope.include_html = ""
scope.$watch "enterprise_id", (newVal, oldVal)->
if !newVal? || newVal == ""
scope.include_html = ""
else
scope.include_html = "/admin/accounts_and_billing_settings/show_methods?enterprise_id=#{newVal};"

View File

@@ -8,8 +8,8 @@
//= require jquery
//= require jquery-migrate-min
//= require jquery_ujs
//= require jquery-ui
//= require shared/jquery-ui-timepicker-addon
//= require jquery.ui.all
//= require jquery-ui-timepicker-addon
//= require angular
//= require angular-resource
//= require angular-animate
@@ -23,8 +23,6 @@
//= require angular-rails-templates
//= require_tree ../templates/admin
//= require ./admin_ofn
//= require ./accounts_and_billing_settings/accounts_and_billing_settings
//= require ./business_model_configuration/business_model_configuration
//= require ./customers/customers
//= require ./dropdown/dropdown
//= require ./enterprises/enterprises

View File

@@ -1 +0,0 @@
angular.module("admin.businessModelConfiguration", ["admin.utils"])

View File

@@ -1,25 +0,0 @@
angular.module("admin.businessModelConfiguration").controller "BusinessModelConfigCtrl", ($scope, $filter) ->
$scope.turnover = 1000
$scope.bill = ->
return $filter('currency')(0) unless $scope.fixed || $scope.rate
Number($scope.fixed) + Number($scope.turnover) * Number($scope.rate)
$scope.cappedBill = ->
return $scope.bill() if !$scope.cap? || Number($scope.cap) == 0
Math.min($scope.bill(), Number($scope.cap))
$scope.finalBill = ->
return 0 if Number($scope.turnover) < Number($scope.minBillableTurnover)
$scope.cappedBill()
$scope.capReached = ->
return t('no') if !$scope.cap? || Number($scope.cap) == 0
if $scope.bill() >= Number($scope.cap) then t('yes') else t('no')
$scope.includedTax = ->
return 0 if !$scope.taxRate? || Number($scope.taxRate) == 0
($scope.cappedBill() * Number($scope.taxRate))
$scope.total = ->
$scope.finalBill() + $scope.includedTax()

View File

@@ -1,6 +1,6 @@
angular.module('admin.enterpriseFees').controller 'enterpriseFeesCtrl', ($scope, $http, $window, enterprises, tax_categories, calculators) ->
$scope.enterprises = enterprises
$scope.tax_categories = [{id: -1, name: "Inherit From Product"}].concat tax_categories
$scope.tax_categories = [{id: -1, name: t('js.admin.enterprise_fees.inherit_from_product') }].concat tax_categories
$scope.calculators = calculators
$scope.enterpriseFeesUrl = ->

View File

@@ -1,8 +0,0 @@
angular.module("admin.enterprises").directive "monthlyPricingDescription", (monthlyBillDescription) ->
restrict: 'E'
scope:
joiner: "@"
template: "<span ng-bind-html='billDescription'></span>"
link: (scope, element, attrs) ->
joiners = { comma: ", ", newline: "<br>" }
scope.billDescription = monthlyBillDescription.replace("{joiner}", joiners[scope.joiner])

View File

@@ -26,18 +26,21 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
$scope.startDate = moment(OrderCycles.byID[$scope.orderCycleFilter].orders_open_at).format('YYYY-MM-DD')
$scope.endDate = moment(OrderCycles.byID[$scope.orderCycleFilter].orders_close_at).startOf('day').format('YYYY-MM-DD')
formatted_start_date = moment($scope.startDate).format()
formatted_end_date = moment($scope.endDate).add(1,'day').format()
RequestMonitor.load $scope.orders = Orders.index(
"q[state_not_eq]": "canceled",
"q[completed_at_not_null]": "true",
"q[completed_at_gteq]": "#{moment($scope.startDate).format()}",
"q[completed_at_lt]": "#{moment($scope.endDate).add(1,'day').format()}"
"q[completed_at_gteq]": formatted_start_date,
"q[completed_at_lt]": formatted_end_date
)
RequestMonitor.load $scope.lineItems = LineItems.index(
"q[order][state_not_eq]": "canceled",
"q[order][completed_at_not_null]": "true",
"q[order][completed_at_gteq]": "#{moment($scope.startDate).format()}",
"q[order][completed_at_lt]": "#{moment($scope.endDate).add(1,'day').format()}"
"q[order][completed_at_gteq]": formatted_start_date,
"q[order][completed_at_lt]": formatted_end_date
)
unless $scope.initialized
@@ -45,11 +48,9 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
RequestMonitor.load $scope.orderCycles = OrderCycles.index(ams_prefix: "basic", as: "distributor", "q[orders_close_at_gt]": "#{moment().subtract(90,'days').format()}")
RequestMonitor.load $scope.suppliers = Enterprises.index(action: "visible", ams_prefix: "basic", "q[is_primary_producer_eq]": "true")
RequestMonitor.load $q.all([$scope.orders.$promise, $scope.distributors.$promise, $scope.orderCycles.$promise]).then ->
RequestMonitor.load $q.all([$scope.orders.$promise, $scope.distributors.$promise, $scope.orderCycles.$promise, $scope.suppliers.$promise, $scope.lineItems.$promise]).then ->
Dereferencer.dereferenceAttr $scope.orders, "distributor", Enterprises.byID
Dereferencer.dereferenceAttr $scope.orders, "order_cycle", OrderCycles.byID
RequestMonitor.load $q.all([$scope.orders.$promise, $scope.suppliers.$promise, $scope.lineItems.$promise]).then ->
Dereferencer.dereferenceAttr $scope.lineItems, "supplier", Enterprises.byID
Dereferencer.dereferenceAttr $scope.lineItems, "order", Orders.byID
$scope.bulk_order_form.$setPristine()
@@ -59,8 +60,6 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
$timeout ->
$scope.resetSelectFilters()
$scope.refreshData()
$scope.$watch 'bulk_order_form.$dirty', (newVal, oldVal) ->
if newVal == true
StatusMessage.display 'notice', t('js.unsaved_changes')
@@ -154,3 +153,5 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
if lineItem.quantity > 0
lineItem.final_weight_volume = LineItems.pristineByID[lineItem.id].final_weight_volume * lineItem.quantity / LineItems.pristineByID[lineItem.id].quantity
$scope.weightAdjustedPrice(lineItem)
$scope.refreshData()

View File

@@ -10,17 +10,19 @@ angular.module('admin.orderCycles', ['ngTagsInput', 'admin.indexUtils', 'admin.e
# using $parse instead of scope[attrs.datetimepicker] for cases
# where attrs.datetimepicker is 'foo.bar.lol'
$(element).datetimepicker
dateFormat: 'yy-mm-dd'
timeFormat: 'HH:mm:ss'
showOn: "button"
buttonImage: "<%= asset_path 'datepicker/cal.gif' %>"
buttonImageOnly: true
stepMinute: 15
onSelect: (dateText, inst) ->
scope.$apply(->
dateFormat: 'yy-mm-dd'
timeFormat: 'HH:mm'
showOn: 'button'
controlType: 'select'
oneLine: true
buttonImage: "<%= asset_path 'datepicker/cal.gif' %>"
buttonImageOnly: true
stepMinute: 15
onSelect: (dateText, inst) ->
scope.$apply(->
element.val(dateText)
parsed = $parse(attrs.datetimepicker)
parsed.assign(scope, dateText)
parsed = $parse(attrs.datetimepicker)
parsed.assign(scope, dateText)
)

View File

@@ -24,3 +24,8 @@ angular.module("admin.orders").controller "orderCtrl", ($scope, shops, orderCycl
for shop in $scope.shops
shop.disabled = !$scope.distributorHasOrderCycles(shop)
# Removes the split button introduced by spree in the order form
# We only have one stock location in OFN so it's meaningless to split the order between stock locations
# We delete it instead of hiding or changing CSS so that, when spree code toggles the element, nothing hapens
$('.split-item').remove()

View File

@@ -33,7 +33,6 @@ angular.module("admin.orders").controller "ordersCtrl", ($scope, RequestMonitor,
'q[bill_address_lastname_start]': $scope['q']['bill_address_lastname_start'],
# Set default checkbox values to null. See: https://github.com/openfoodfoundation/openfoodnetwork/pull/3076#issuecomment-440010498
'q[completed_at_not_null]': $scope['q']['completed_at_not_null'] || null,
'q[inventory_units_shipment_id_null]': $scope['q']['inventory_units_shipment_id_null'] || null,
'q[distributor_id_in]': $scope['q']['distributor_id_in'],
'q[order_cycle_id_in]': $scope['q']['order_cycle_id_in'],
'q[order_cycle_id_in]': $scope['q']['order_cycle_id_in'],

View File

@@ -10,6 +10,7 @@ angular.module("admin.productImport").controller "ImportFormCtrl", ($scope, $htt
$scope.updated_ids = []
$scope.update_errors = []
$scope.batchSize = 50
$scope.step = 'settings'
$scope.chunks = 0
$scope.completed = 0
@@ -51,19 +52,28 @@ angular.module("admin.productImport").controller "ImportFormCtrl", ($scope, $htt
$scope.start = () ->
$scope.started = true
total = ams_data.item_count
size = 50
$scope.chunks = Math.ceil(total / size)
$scope.chunks = Math.ceil(total / $scope.batchSize)
i = 0
# Process only the first batch.
$scope.processBatch($scope.step, 0, $scope.chunks)
while i < $scope.chunks
start = (i*size)+1
end = (i+1)*size
if $scope.step == 'import'
$scope.processImport(start, end)
if $scope.step == 'save'
$scope.processSave(start, end)
i++
$scope.processBatch = (step, batchIndex, batchCount) ->
start = (batchIndex * $scope.batchSize) + 1
end = (batchIndex + 1) * $scope.batchSize
isLastBatch = batchCount == batchIndex + 1
promise = if step == 'import'
$scope.processImport(start, end)
else if step == 'save'
$scope.processSave(start, end)
return if isLastBatch
processNextBatch = ->
$scope.processBatch(step, batchIndex + 1, batchCount)
# Process next batch whether or not processing of the current batch succeeds.
promise.then(processNextBatch, processNextBatch)
$scope.processImport = (start, end) ->
$http(

View File

@@ -9,7 +9,7 @@ angular.module("admin.resources").factory 'Orders', ($q, OrderResource, RequestM
request = OrderResource.index params, (data) =>
@load(data)
(callback || angular.noop)(data)
RequestMonitor.load(request.$promise)
@all.$promise = request.$promise
@all
load: (data) ->

View File

@@ -19,4 +19,4 @@ angular.module("admin.subscriptions").controller "OrdersPanelController", ($scop
text = if closes_at > moment() then t('js.subscriptions.closes') else t('js.subscriptions.closed')
"#{text} #{closes_at.fromNow()}"
$scope.stateText = (state) -> t("spree.order_state.#{state}")
$scope.stateText = (state) -> t("js.admin.orders.order_state.#{state}")

View File

@@ -6,7 +6,11 @@ angular.module("admin.subscriptions").controller "SubscriptionController", ($sco
$scope.schedules = Schedules.all
$scope.paymentMethods = PaymentMethods.all
$scope.shippingMethods = ShippingMethods.all
$scope.distributor_id = $scope.subscription.shop_id # variant selector requires distributor_id
# Variant selector requires these
$scope.distributor_id = $scope.subscription.shop_id
$scope.eligible_for_subscriptions = true
$scope.view = if $scope.subscription.id? then 'review' else 'details'
$scope.nextCallbacks = {}
$scope.backCallbacks = {}

View File

@@ -1 +1 @@
angular.module("admin.subscriptions", ['ngResource','admin.indexUtils','admin.dropdown'])
angular.module("admin.subscriptions", ['ngResource','admin.indexUtils','admin.dropdown', 'admin.utils'])

View File

@@ -1,12 +1,15 @@
$(document).ready(function() {
$('.datetimepicker').datetimepicker({
dateFormat: 'yy-mm-dd',
timeFormat: 'HH:mm',
dayNames: Spree.translations.abbr_day_names,
dayNamesMin: Spree.translations.abbr_day_names,
monthNames: Spree.translations.month_names,
prevText: Spree.translations.previous,
nextText: Spree.translations.next,
showOn: "button",
showOn: 'button',
controlType: 'select',
oneLine: true,
buttonImage: "<%= asset_path 'datepicker/cal.gif' %>",
buttonImageOnly: true,
stepMinute: 15

View File

@@ -22,7 +22,9 @@ angular.module("admin.utils").directive "variantAutocomplete", ($timeout) ->
q: term
distributor_id: scope.distributor_id
order_cycle_id: scope.order_cycle_id
eligible_for_subscriptions: scope.eligible_for_subscriptions
results: (data, page) ->
window.variants = data # this is how spree auto complete JS code picks up variants
results: data
formatResult: (variant) ->
if variant["images"][0] != undefined && variant["images"][0].image != undefined

View File

@@ -0,0 +1,14 @@
angular.module("admin.utils").filter "localizeCurrency", (currencyConfig)->
# Convert number to string currency using injected currency configuration.
(amount) ->
# Set country code (eg. "US").
currency_code = if currencyConfig.display_currency then " " + currencyConfig.currency else ""
# Set decimal points, 2 or 0 if hide_cents.
decimals = if currencyConfig.hide_cents == "true" then 0 else 2
# Set format if the currency symbol should come after the number, otherwise (default) use the locale setting.
format = if currencyConfig.symbol_position == "after" then "%n %u" else undefined
# We need to use parseFloat as the amount should come in as a string.
amount = parseFloat(amount)
# Build the final price string.
I18n.toCurrency(amount, {precision: decimals, unit: currencyConfig.symbol, format: format}) + currency_code

View File

@@ -1,6 +1,6 @@
#= require jquery
#= require jquery_ujs
#= require jquery-ui
#= require jquery.ui.all
#= require spin
#
#= require angular

View File

@@ -15,7 +15,7 @@ Darkswarm.directive "ofnOnHand", ->
ngModel.$parsers.push (viewValue) ->
on_hand = parseInt(attr.ofnOnHand)
if parseInt(viewValue) > on_hand
alert t('insufficient_stock', {on_hand: on_hand})
alert t("js.insufficient_stock", {on_hand: on_hand})
viewValue = on_hand
ngModel.$setViewValue viewValue
ngModel.$render()

View File

@@ -4,7 +4,7 @@ Darkswarm.filter "date_in_words", ->
Darkswarm.filter "sensible_timeframe", (date_in_wordsFilter)->
(date) ->
if moment().add('days', 2) < moment(date)
if moment().add(2, 'days') < moment(date)
t 'orders_open'
else
t('closing') + date_in_wordsFilter(date)

View File

@@ -57,18 +57,20 @@ Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http, $modal, $roo
scope = $rootScope.$new(true)
scope.variants = []
# TODO: These changes to quantity/max_quantity trigger another cart update, which
# is unnecessary.
# TODO: These changes to quantity/max_quantity trigger another cart update, which is unnecessary.
for li in @line_items when li.quantity > 0
if stockLevels[li.variant.id]?
li.variant.count_on_hand = stockLevels[li.variant.id].on_hand
if li.quantity > li.variant.count_on_hand
li.quantity = li.variant.count_on_hand
scope.variants.push li.variant
if li.variant.count_on_hand == 0 && li.max_quantity > li.variant.count_on_hand
li.max_quantity = li.variant.count_on_hand
scope.variants.push(li.variant) unless li.variant in scope.variants
continue unless stockLevels[li.variant.id]?
li.variant.on_hand = stockLevels[li.variant.id].on_hand
li.variant.on_demand = stockLevels[li.variant.id].on_demand
continue if li.variant.on_demand
if li.quantity > li.variant.on_hand
li.quantity = li.variant.on_hand
scope.variants.push li.variant
if li.variant.on_hand == 0 && li.max_quantity > li.variant.on_hand
li.max_quantity = li.variant.on_hand
scope.variants.push(li.variant) unless li.variant in scope.variants
if scope.variants.length > 0
$modal.open(templateUrl: "out_of_stock.html", scope: scope, windowClass: 'out-of-stock-modal')

File diff suppressed because it is too large Load Diff

View File

@@ -19,10 +19,6 @@
%h3
{{ 'js.admin.panels.enterprise_package.hub_shop' | t }}
%p
%strong
%monthly-pricing-description{ joiner: "comma" }
%p
{{ 'js.admin.panels.enterprise_package.hub_shop_text1' | t }}
@@ -66,10 +62,6 @@
%h3
{{ 'js.admin.panels.enterprise_package.producer_shop' | t }}
%p
%strong
%monthly-pricing-description{ joiner: "comma" }
%p
{{ 'js.admin.panels.enterprise_package.producer_shop_text1' | t }}
@@ -80,10 +72,6 @@
%h3
{{ 'js.admin.panels.enterprise_package.producer_hub' | t }}
%p
%strong
%monthly-pricing-description{ joiner: "comma" }
%p
{{ 'js.admin.panels.enterprise_package.producer_hub_text1' | t }}
@@ -121,8 +109,6 @@
{{ 'js.admin.panels.enterprise_package.hub_shop' | t }}
%p
{{ 'js.admin.panels.enterprise_package.sell_produce_others' | t }}
.bottom
%monthly-pricing-description{ joiner: "newline" }
%div{ ng: { switch: { when: "true" } } }
%a.button.selector.producer-profile{ ng: { click: "enterprise.owned && (enterprise.sells='none')", class: "{selected: enterprise.sells=='none', disabled: !enterprise.owned}" } }
@@ -139,8 +125,6 @@
{{ 'js.admin.panels.enterprise_package.producer_shop' | t }}
%p
{{ 'js.admin.panels.enterprise_package.sell_own_produce' | t }}
.bottom
%monthly-pricing-description{ joiner: "newline" }
%a.button.selector.producer-hub{ ng: { click: "enterprise.owned && (enterprise.sells='any')", class: "{selected: enterprise.sells=='any', disabled: !enterprise.owned}" } }
.top
@@ -148,8 +132,6 @@
{{ 'js.admin.panels.enterprise_package.producer_hub' | t }}
%p
{{ 'js.admin.panels.enterprise_package.sell_both' | t }}
.bottom
%monthly-pricing-description{ joiner: "newline" }
%a.button.update.fullwidth{ ng: { show: "enterprise.owned", class: "{disabled: saved() && !saving, saving: saving}", click: "save()" } }
%span{ ng: {hide: "saved() || saving" } }

View File

@@ -9,7 +9,7 @@
%p{'ng-repeat' => "v in variants"}
%em {{ v.name_to_display }} - {{ v.unit_to_display }}
%span{'ng-if' => "v.count_on_hand == 0"}
%span{'ng-if' => "v.on_hand == 0"}
{{ 'js.out_of_stock.now_out_of_stock' | t }}
%span{'ng-if' => "v.count_on_hand > 0"}
{{ 'js.out_of_stock.only_n_remainging' | t:{ num: v.count_on_hand } }}
%span{'ng-if' => "v.on_hand > 0"}
{{ 'js.out_of_stock.only_n_remainging' | t:{ num: v.on_hand } }}

View File

@@ -7,6 +7,6 @@
placeholder: "0",
"ofn-disable-scroll" => true,
"ng-model" => "variant.line_item.quantity",
"ofn-on-hand" => "{{variant.on_demand && 9999 || variant.count_on_hand }}",
"ng-disabled" => "!variant.on_demand && variant.count_on_hand == 0",
"ofn-on-hand" => "{{variant.on_demand && 9999 || variant.on_hand }}",
"ng-disabled" => "!variant.on_demand && variant.on_hand == 0",
name: "variants[{{::variant.id}}]", id: "variants_{{::variant.id}}"}

View File

@@ -9,7 +9,7 @@
"ng-model" => "variant.line_item.quantity",
placeholder: "{{::'shop_variant_quantity_min' | t}}",
"ofn-disable-scroll" => true,
"ofn-on-hand" => "{{variant.on_demand && 9999 || variant.count_on_hand }}",
"ofn-on-hand" => "{{variant.on_demand && 9999 || variant.on_hand }}",
name: "variants[{{::variant.id}}]", id: "variants_{{::variant.id}}"}
%span.bulk-input
%input.bulk.second{type: :number,

View File

@@ -1,7 +1,7 @@
.container
.row.modal-centered
%h2 {{'welcome_to_ofn' | t}}
%h5 {{'signup_or_login' | t}}:
%h2 {{'js.registration.welcome_to_ofn' | t}}
%h5 {{'js.registration.signup_or_login' | t}}:
%div{"ng-controller" => "AuthenticationCtrl"}
%tabset
%ng-include{src: "'signup.html'"}
@@ -9,9 +9,9 @@
%ng-include{src: "'forgot.html'"}
%div{ ng: { show: "active('/signup')"} }
%hr
{{'have_an_account' | t}}
{{'js.registration.have_an_account' | t}}
%a{ href: "", ng: { click: "select('/login')"}}
{{'action_login' | t}}
{{'js.registration.action_login' | t}}
%a.close-reveal-modal{"ng-click" => "$close()"}
%i.ofn-i_009-close

View File

@@ -1,19 +0,0 @@
@import "variables";
.row.invoice_title {
margin-bottom: 0px;
}
table.invoice_summary {
margin-bottom: 70px;
tr.total {
font-weight: bold;
}
}
.invoice_title {
.balance {
color: $spree-green;
}
}

View File

@@ -7,13 +7,15 @@
*= require admin/spree_backend
*= require admin/spree_auth
*= require shared/jquery-ui-timepicker-addon
*= require jquery-ui-timepicker-addon
*= require shared/textAngular
*= require shared/ng-tags-input.min
*= require admin/custom
*= require_self
*/
@import 'variables';
@import 'components/*';
@import 'pages/*';
@import '*';

View File

@@ -0,0 +1,12 @@
#admin-menu {
li {
a {
font-weight: 600;
}
a::before {
font-weight: normal;
padding-top: 0;
}
}
}

View File

@@ -0,0 +1,8 @@
// https://docs.angularjs.org/api/ng/directive/ngCloak
[ng-cloak],
[data-ng-cloak],
[x-ng-cloak],
.ng-cloak,
.x-ng-cloak {
display: none !important;
}

View File

@@ -0,0 +1,10 @@
.page-actions {
li {
margin-top: 1px;
margin-bottom: 1px;
}
a {
display: inline-block;
}
}

View File

@@ -1,7 +1,18 @@
@import "../variables";
.state {
@extend .state;
#subscriptions .state {
border-radius: 3px;
text-transform: uppercase;
font-weight: 600;
border: 1px solid transparent;
padding: 2px 5px;
width: 100%;
display: inline-block;
text-align: center;
&:before {
display: none;
}
&.active {
background-color: $spree-green;

View File

@@ -1,12 +0,0 @@
@import "../variables";
#trial_progress_bar {
position: fixed;
left: 0px;
bottom: 0px;
width: 100vw;
padding: 8px 10px;
font-weight: bold;
background-color: $spree-blue;
color: white;
}

View File

@@ -0,0 +1,2 @@
/* Custom fix */
.ui-timepicker-div.ui-timepicker-oneLine dl dd { width: 25%; }

View File

@@ -14,6 +14,7 @@ tbody.panel-ctrl {
i.icon-chevron::before {
font-size: 1.2rem;
content: "\f078";
padding: 0;
}
&.error::before {
@@ -109,6 +110,12 @@ tbody.panel-ctrl {
border-color: #6788a2;
padding: 0;
.panel {
.actions {
.button {
display: inline-block;
}
}
.row{
margin: 0px -4px;

View File

@@ -2,6 +2,7 @@
input[type="submit"], input[type="button"], button, .button {
cursor: pointer;
font-size: 85%;
}
.text-center {

View File

@@ -0,0 +1,7 @@
@import '../variables';
.admin-subscription-form-subscription-line-items {
.not-in-open-and-upcoming-order-cycles-warning {
color: $warning-red;
}
}

View File

@@ -0,0 +1,7 @@
@import '../variables';
.admin-subscription-review-subscription-line-items {
.not-in-open-and-upcoming-order-cycles-warning {
color: $warning-red;
}
}

View File

@@ -1,10 +0,0 @@
.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
.ui-timepicker-div dl { text-align: left; }
.ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
.ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
.ui-timepicker-div td { font-size: 90%; }
.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
.ui-timepicker-rtl{ direction: rtl; }
.ui-timepicker-rtl dl { text-align: right; }
.ui-timepicker-rtl dl dd { margin: 0 65px 10px 10px; }

View File

@@ -1,6 +0,0 @@
class Admin::AccountController < Spree::Admin::BaseController
def show
@invoices = spree_current_user.account_invoices
end
end

View File

@@ -1,74 +0,0 @@
require 'open_food_network/accounts_and_billing_settings_validator'
class Admin::AccountsAndBillingSettingsController < Spree::Admin::BaseController
before_filter :load_distributors, only: [:edit, :update, :start_job]
before_filter :load_jobs, only: [:edit, :update, :start_job]
before_filter :load_settings, only: [:edit, :update, :start_job]
before_filter :require_valid_settings, only: [:update, :start_job]
before_filter :require_known_job, only: [:start_job]
def update
Spree::Config.set(params[:settings])
flash[:success] = t(:successfully_updated, :resource => t(:billing_and_account_settings))
redirect_to_edit
end
def start_job
if @update_account_invoices_job || @finalize_account_invoices_job
flash[:error] = I18n.t(:accounts_and_billing_task_already_running_error)
else
new_job = "#{params[:job][:name]}".camelize.constantize.new
Delayed::Job.enqueue new_job
flash[:success] = I18n.t(:accounts_and_billing_start_task_notice)
end
redirect_to_edit
end
def show_methods
@enterprise = Enterprise.find_by_id(params[:enterprise_id])
@shipping_methods = @enterprise.shipping_methods
@payment_methods = @enterprise.payment_methods
render partial: 'method_settings'
end
private
def redirect_to_edit
redirect_to main_app.edit_admin_accounts_and_billing_settings_path
end
def require_valid_settings
render :edit unless @settings.valid?
end
def known_jobs
['update_account_invoices', 'finalize_account_invoices']
end
def require_known_job
unless known_jobs.include?(params[:job][:name])
flash[:error] = "Unknown Task: #{params[:job][:name].to_s}"
redirect_to_edit
end
end
def load_settings
@settings = OpenFoodNetwork::AccountsAndBillingSettingsValidator.new(params[:settings] || {
accounts_distributor_id: Spree::Config[:accounts_distributor_id],
default_accounts_payment_method_id: Spree::Config[:default_accounts_payment_method_id],
default_accounts_shipping_method_id: Spree::Config[:default_accounts_shipping_method_id],
auto_update_invoices: Spree::Config[:auto_update_invoices],
auto_finalize_invoices: Spree::Config[:auto_finalize_invoices]
})
end
def load_distributors
@distributors = Enterprise.is_distributor.select([:id, :name])
end
def load_jobs
@update_account_invoices_job = Delayed::Job.where("handler LIKE (?)", "%UpdateAccountInvoices%").last
@finalize_account_invoices_job = Delayed::Job.where("handler LIKE (?)", "%FinalizeAccountInvoices%").last
end
end

View File

@@ -1,35 +0,0 @@
require 'open_food_network/business_model_configuration_validator'
class Admin::BusinessModelConfigurationController < Spree::Admin::BaseController
before_filter :load_settings, only: [:edit, :update]
before_filter :require_valid_settings, only: [:update]
def update
Spree::Config.set(params[:settings])
flash[:success] = t(:successfully_updated,
resource: t('admin.business_model_configuration.edit.business_model_configuration'))
redirect_to_edit
end
private
def redirect_to_edit
redirect_to main_app.edit_admin_business_model_configuration_path
end
def load_settings
@settings = OpenFoodNetwork::BusinessModelConfigurationValidator.new(params[:settings] || {
shop_trial_length_days: Spree::Config[:shop_trial_length_days],
account_invoices_monthly_fixed: Spree::Config[:account_invoices_monthly_fixed],
account_invoices_monthly_rate: Spree::Config[:account_invoices_monthly_rate],
account_invoices_monthly_cap: Spree::Config[:account_invoices_monthly_cap],
account_invoices_tax_rate: Spree::Config[:account_invoices_tax_rate],
minimum_billable_turnover: Spree::Config[:minimum_billable_turnover]
})
end
def require_valid_settings
render :edit unless @settings.valid?
end
end

View File

@@ -1,13 +1,27 @@
require 'open_food_network/products_cache_integrity_checker'
class Admin::CacheSettingsController < Spree::Admin::BaseController
module Admin
class CacheSettingsController < Spree::Admin::BaseController
def edit
@results = Exchange.cachable.map do |exchange|
checker = OpenFoodNetwork::ProductsCacheIntegrityChecker
.new(exchange.receiver, exchange.order_cycle)
def show
@results = Exchange.cachable.map do |exchange|
checker = OpenFoodNetwork::ProductsCacheIntegrityChecker.new(exchange.receiver, exchange.order_cycle)
{
distributor: exchange.receiver,
order_cycle: exchange.order_cycle,
status: checker.ok?,
diff: checker.diff
}
end
end
{distributor: exchange.receiver, order_cycle: exchange.order_cycle, status: checker.ok?, diff: checker.diff}
def update
Spree::Config.set(params[:preferences])
respond_to do |format|
format.html { redirect_to main_app.edit_admin_cache_settings_path }
end
end
end
end

View File

@@ -18,7 +18,7 @@ module Admin
flash[:success] = t(:successfully_updated, :resource => I18n.t('admin.contents.edit.your_content'))
redirect_to main_app.edit_admin_content_path
redirect_to main_app.edit_admin_contents_path
end
private

View File

@@ -64,10 +64,6 @@ module Admin
attributes = { sells: params[:sells], visible: true }
if ['own', 'any'].include? params[:sells]
attributes[:shop_trial_start_date] = @enterprise.shop_trial_start_date || Time.zone.now
end
if @enterprise.update_attributes(attributes)
flash[:success] = I18n.t(:enterprise_register_success_notice, enterprise: @enterprise.name)
redirect_to admin_path

View File

@@ -79,12 +79,11 @@ module Admin
end
def save_uploaded_file(upload)
filename = 'import' + Time.zone.now.strftime('%d-%m-%Y-%H-%M-%S')
extension = '.' + upload.original_filename.split('.').last
directory = 'tmp/product_import'
Dir.mkdir(directory) unless File.exist?(directory)
File.open(Rails.root.join(directory, filename + extension), 'wb') do |f|
f.write(upload.read)
extension = File.extname(upload.original_filename)
directory = Dir.mktmpdir 'product_import'
File.open(File.join(directory, "import#{extension}"), 'wb') do |f|
data = UploadSanitizer.new(upload.read).call
f.write(data)
f.path
end
end

View File

@@ -13,7 +13,8 @@ module Admin
def build
@subscription_line_item.assign_attributes(params[:subscription_line_item])
@subscription_line_item.price_estimate = price_estimate
render json: @subscription_line_item, serializer: Api::Admin::SubscriptionLineItemSerializer
render json: @subscription_line_item, serializer: Api::Admin::SubscriptionLineItemSerializer,
shop: @shop, schedule: @schedule
end
private
@@ -26,7 +27,7 @@ module Admin
@shop = Enterprise.managed_by(spree_current_user).find_by_id(params[:shop_id])
@schedule = permissions.editable_schedules.find_by_id(params[:schedule_id])
@order_cycle = @schedule.andand.current_or_next_order_cycle
@variant = Spree::Variant.stockable_by(@shop).find_by_id(params[:subscription_line_item][:variant_id])
@variant = variant_if_eligible(params[:subscription_line_item][:variant_id]) if @shop.present?
end
def new_actions
@@ -50,5 +51,9 @@ module Admin
OpenFoodNetwork::ScopeVariantToHub.new(@shop).scope(@variant)
@variant.price + fee_calculator.indexed_fees_for(@variant)
end
def variant_if_eligible(variant_id)
SubscriptionVariantsService.eligible_variants(@shop).find_by_id(variant_id)
end
end
end

View File

@@ -76,7 +76,8 @@ module Admin
end
def collection
@variant_overrides = VariantOverride.for_hubs(params[:hub_id] || @hubs)
@variant_overrides = VariantOverride.includes(:variant).for_hubs(params[:hub_id] || @hubs)
@variant_overrides.select { |vo| vo.variant.present? }
end
def collection_actions

View File

@@ -13,5 +13,13 @@ module Api
def respond_with_conflict(json_hash)
render json: json_hash, status: :conflict
end
private
# Use logged in user (spree_current_user) for API authentication (current_api_user)
def authenticate_user
@current_api_user = try_spree_current_user
super
end
end
end

View File

@@ -1,7 +1,7 @@
module Api
class CustomersController < BaseController
def index
@customers = current_api_user.customers.of_regular_shops
@customers = current_api_user.customers
render json: @customers, each_serializer: CustomerSerializer
end

View File

@@ -22,45 +22,48 @@ class CheckoutController < Spree::CheckoutController
end
def update
if @order.update_attributes(object_params)
check_order_for_phantom_fees
fire_event('spree.checkout.update')
while @order.state != "complete"
if @order.state == "payment"
return if redirect_to_paypal_express_form_if_needed
end
shipping_method_id = object_params.delete(:shipping_method_id)
next if advance_order_state(@order)
return update_failed unless @order.update_attributes(object_params)
if @order.errors.present?
flash[:error] = @order.errors.full_messages.to_sentence
else
flash[:error] = t(:payment_processing_failed)
end
update_failed
return
check_order_for_phantom_fees
fire_event('spree.checkout.update')
while @order.state != "complete"
if @order.state == "payment"
return if redirect_to_paypal_express_form_if_needed
end
if @order.state == "complete" || @order.completed?
set_default_bill_address
set_default_ship_address
ResetOrderService.new(self, current_order).call
session[:access_token] = current_order.token
if @order.state == "delivery"
@order.select_shipping_method(shipping_method_id)
end
flash[:notice] = t(:order_processed_successfully)
respond_to do |format|
format.html do
respond_with(@order, :location => order_path(@order))
end
format.json do
render json: {path: order_path(@order)}, status: 200
end
end
next if advance_order_state(@order)
if @order.errors.present?
flash[:error] = @order.errors.full_messages.to_sentence
else
update_failed
flash[:error] = t(:payment_processing_failed)
end
else
update_failed
return
end
return update_failed unless @order.state == "complete" || @order.completed?
set_default_bill_address
set_default_ship_address
ResetOrderService.new(self, current_order).call
session[:access_token] = current_order.token
flash[:notice] = t(:order_processed_successfully)
respond_to do |format|
format.html do
respond_with(@order, :location => order_path(@order))
end
format.json do
render json: {path: order_path(@order)}, status: 200
end
end
end
@@ -166,7 +169,7 @@ class CheckoutController < Spree::CheckoutController
def load_order
@order = current_order
redirect_to main_app.shop_path and return unless @order and @order.checkout_allowed?
raise_insufficient_quantity and return if @order.insufficient_stock_lines.present?
redirect_to_cart_path and return unless valid_order_line_items?
redirect_to main_app.shop_path and return if @order.completed?
before_address
setup_for_current_state
@@ -181,8 +184,11 @@ class CheckoutController < Spree::CheckoutController
@order.ship_address = finder.ship_address
end
# Overriding Spree's methods
def raise_insufficient_quantity
def valid_order_line_items?
@order.insufficient_stock_lines.empty? && OrderCycleDistributedVariants.new(@order.order_cycle, @order.distributor).distributes_order_variants?(@order)
end
def redirect_to_cart_path
respond_to do |format|
format.html do
redirect_to cart_path

View File

@@ -3,7 +3,7 @@ module Spree
AdjustmentsController.class_eval do
prepend_before_filter :set_included_tax, only: [:create, :update]
before_filter :set_default_tax_rate, only: :edit
before_filter :enable_updates, only: :update
private
@@ -38,6 +38,17 @@ module Spree
params[:adjustment][:included_tax] = 0
end
end
# Spree 2.0 keeps shipping fee adjustments open unless they are manually
# closed. But open adjustments cannot be edited.
# To preserve updates, like changing the amount of the shipping fee,
# we close the adjustment first.
#
# The Spree admin interface allows to open and close adjustments manually
# but we removed that functionality as it had no purpose for us.
def enable_updates
@adjustment.close
end
end
end
end

View File

@@ -0,0 +1,6 @@
Spree::Admin::ImagesController.class_eval do
# This will make resource controller redirect correctly after deleting product images.
# This can be removed after upgrading to Spree 2.1.
# See here https://github.com/spree/spree/commit/334a011d2b8e16355e4ae77ae07cd93f7cbc8fd1
belongs_to 'spree/product', :find_by => :permalink
end

View File

@@ -2,6 +2,7 @@ module Spree
module Admin
class InvoicesController < Spree::Admin::BaseController
respond_to :json
authorize_resource class: false
def create
invoice_service = BulkInvoiceService.new

View File

@@ -1,60 +0,0 @@
require 'open_food_network/scope_variant_to_hub'
Spree::Admin::LineItemsController.class_eval do
prepend_before_filter :load_order, except: :index
around_filter :apply_enterprise_fees_with_lock, only: :update
def create
variant = Spree::Variant.find(params[:line_item][:variant_id])
OpenFoodNetwork::ScopeVariantToHub.new(@order.distributor).scope(variant)
@line_item = @order.add_variant(variant, params[:line_item][:quantity].to_i)
if @order.save
respond_with(@line_item) do |format|
format.html { render :partial => 'spree/admin/orders/form', :locals => { :order => @order.reload } }
end
else
respond_with(@line_item) do |format|
format.js { render :action => 'create', :locals => { :order => @order.reload } }
end
end
end
# TODO: simplify this, 3 formats per action is too much
# we need `js` format for admin/orders/edit (jquery-rails gem)
# we don't know if `html` format is needed
def update
respond_to do |format|
format.html { render_order_form }
format.js {
if @line_item.update_attributes(params[:line_item])
render nothing: true, status: 204 # No Content, does not trigger ng resource auto-update
else
render json: { errors: @line_item.errors }, status: 412
end
}
end
end
private
def render_order_form
respond_to do |format|
format.html { render partial: 'spree/admin/orders/form', locals: {order: @order.reload} }
end
end
def load_order
@order = Spree::Order.find_by_number!(params[:order_id])
authorize! :update, @order
end
def apply_enterprise_fees_with_lock
authorize! :read, @order
@order.with_lock do
yield
@order.update_distribution_charge!
end
end
end

View File

@@ -1,6 +1,22 @@
Spree::Admin::Orders::CustomerDetailsController.class_eval do
before_filter :set_guest_checkout_status, only: :update
def update
if @order.update_attributes(params[:order])
if params[:guest_checkout] == "false"
@order.associate_user!(Spree.user_class.find_by_email(@order.email))
end
AdvanceOrderService.new(@order).call
@order.shipments.map &:refresh_rates
flash[:success] = Spree.t('customer_details_updated')
redirect_to admin_order_customer_path(@order)
else
render :action => :edit
end
end
# Inherit CanCan permissions for the current order
def model_class
load_order unless @order

View File

@@ -27,6 +27,34 @@ Spree::Admin::OrdersController.class_eval do
# within the page then fetches the data it needs from Api::OrdersController
end
def edit
@order.shipments.map &:refresh_rates
AdvanceOrderService.new(@order).call
# The payment step shows an error of 'No pending payments'
# Clearing the errors from the order object will stop this error
# appearing on the edit page where we don't want it to.
@order.errors.clear
end
# Re-implement spree method so that it redirects to edit instead of rendering edit
# This allows page reloads while adding variants to the order (/edit), without being redirected to customer details page (/update)
def update
unless @order.update_attributes(params[:order]) && @order.line_items.present?
@order.errors.add(:line_items, Spree.t('errors.messages.blank')) if @order.line_items.empty?
return redirect_to edit_admin_order_path(@order), :flash => { :error => @order.errors.full_messages.join(', ') }
end
@order.update!
if @order.complete?
redirect_to edit_admin_order_path(@order)
else
# Jump to next step if order is not complete
redirect_to admin_order_customer_path(@order)
end
end
# Overwrite to use confirm_email_for_customer instead of confirm_email.
# This uses a new template. See mailers/spree/order_mailer_decorator.rb.
def resend
@@ -37,9 +65,7 @@ Spree::Admin::OrdersController.class_eval do
end
def invoice
pdf = render_to_string pdf: "invoice-#{@order.number}.pdf",
template: invoice_template,
formats: [:html], encoding: "UTF-8"
pdf = InvoiceRenderer.new.render_to_string(@order)
Spree::OrderMailer.invoice_email(@order.id, pdf).deliver
flash[:success] = t('admin.orders.invoice_email_sent')
@@ -48,7 +74,7 @@ Spree::Admin::OrdersController.class_eval do
end
def print
render pdf: "invoice-#{@order.number}", template: invoice_template, encoding: "UTF-8"
render InvoiceRenderer.new.args(@order)
end
def print_ticket
@@ -61,10 +87,6 @@ Spree::Admin::OrdersController.class_eval do
private
def invoice_template
Spree::Config.invoice_style2? ? "spree/admin/orders/invoice2" : "spree/admin/orders/invoice"
end
def require_distributor_abn
unless @order.distributor.abn.present?
flash[:error] = t(:must_have_valid_business_number, enterprise_name: @order.distributor.name)

View File

@@ -1,6 +1,35 @@
Spree::Admin::PaymentsController.class_eval do
append_before_filter :filter_payment_methods
def create
@payment = @order.payments.build(object_params)
if @payment.payment_method.is_a?(Spree::Gateway) && @payment.payment_method.payment_profiles_supported? && params[:card].present? and params[:card] != 'new'
@payment.source = CreditCard.find_by_id(params[:card])
end
begin
unless @payment.save
redirect_to admin_order_payments_path(@order)
return
end
if @order.completed?
@payment.process!
flash[:success] = flash_message_for(@payment, :successfully_created)
redirect_to admin_order_payments_path(@order)
else
AdvanceOrderService.new(@order).call!
flash[:success] = Spree.t(:new_order_completed)
redirect_to edit_admin_order_url(@order)
end
rescue Spree::Core::GatewayError => e
flash[:error] = "#{e.message}"
redirect_to new_admin_order_payment_path(@order)
end
end
# When a user fires an event, take them back to where they came from
# (we can't use respond_override because Spree no longer uses respond_with)

View File

@@ -23,14 +23,23 @@ Spree::Admin::ProductsController.class_eval do
render :new
} } }
def product_distributions
end
def index
@current_user = spree_current_user
@show_latest_import = params[:latest_import] || false
end
def create
delete_stock_params_and_set_after do
super
end
end
def update
delete_stock_params_and_set_after do
super
end
end
def bulk_update
collection_hash = Hash[params[:products].each_with_index.map { |p,i| [i,p] }]
product_set = Spree::ProductSet.new({:collection_attributes => collection_hash})
@@ -66,8 +75,13 @@ Spree::Admin::ProductsController.class_eval do
params[:q][:deleted_at_null] ||= "1"
params[:q][:s] ||= "name asc"
@search = Spree::Product.ransack(params[:q]) # this line is modified - hit Spree::Product instead of super, avoiding cancan error for fetching records with block permissions via accessible_by
# The next line is modified.
# Hit Spree::Product instead of super, avoiding cancan error for fetching
# records with block permissions via accessible_by.
@collection = Spree::Product
@collection = @collection.with_deleted if params[:q].delete(:deleted_at_null).blank?
# @search needs to be defined as this is passed to search_form_for
@search = @collection.ransack(params[:q])
@collection = @search.result.
managed_by(spree_current_user). # this line is added to the original spree code!!!!!
group_by_products_id.
@@ -119,4 +133,22 @@ Spree::Admin::ProductsController.class_eval do
end
end
end
def delete_stock_params_and_set_after
on_demand = params[:product].delete(:on_demand)
on_hand = params[:product].delete(:on_hand)
yield
set_stock_levels(@product, on_hand, on_demand) if @product.valid?
end
def set_stock_levels(product, on_hand, on_demand)
variant = product.master
if product.variants.any?
variant = product.variants.first
end
variant.on_demand = on_demand if on_demand.present?
variant.on_hand = on_hand.to_i if on_hand.present?
end
end

View File

@@ -0,0 +1,66 @@
module Spree
module Admin
module Reports
class EnterpriseFeeSummariesController < BaseController
before_filter :load_report_parameters
before_filter :load_permissions
def new; end
def create
return respond_to_invalid_parameters unless @report_parameters.valid?
@report_parameters.authorize!(@permissions)
@report = report_klass::ReportService.new(@permissions, @report_parameters)
renderer.render(self)
rescue ::Reports::Authorizer::ParameterNotAllowedError => e
flash[:error] = e.message
render_report_form
end
private
def respond_to_invalid_parameters
flash[:error] = I18n.t("invalid_filter_parameters", scope: i18n_scope)
render_report_form
end
def i18n_scope
"order_management.reports.enterprise_fee_summary"
end
def render_report_form
render action: :new
end
def report_klass
OrderManagement::Reports::EnterpriseFeeSummary
end
def load_report_parameters
@report_parameters = report_klass::Parameters.new(params[:report] || {})
end
def load_permissions
@permissions = report_klass::Permissions.new(spree_current_user)
end
def report_renderer_klass
case params[:report_format]
when "csv"
report_klass::Renderers::CsvRenderer
when nil, "", "html"
report_klass::Renderers::HtmlRenderer
else
raise Reports::UnsupportedReportFormatException
end
end
def renderer
@renderer ||= report_renderer_klass.new(@report)
end
end
end
end
end

View File

@@ -1,4 +1,6 @@
require 'csv'
require 'open_food_network/reports/list'
require 'open_food_network/order_and_distributor_report'
require 'open_food_network/products_and_inventory_report'
require 'open_food_network/lettuce_share_report'
@@ -24,35 +26,7 @@ Spree::Admin::ReportsController.class_eval do
before_filter :load_data, only: [:customers, :products_and_inventory, :order_cycle_management, :packing]
def report_types
{
orders_and_fulfillment: [
[I18n.t('admin.reports.supplier_totals'), :order_cycle_supplier_totals],
[I18n.t('admin.reports.supplier_totals_by_distributor'), :order_cycle_supplier_totals_by_distributor],
[I18n.t('admin.reports.totals_by_supplier'), :order_cycle_distributor_totals_by_supplier],
[I18n.t('admin.reports.customer_totals'), :order_cycle_customer_totals]
],
products_and_inventory: [
[I18n.t('admin.reports.all_products'), :all_products],
[I18n.t('admin.reports.inventory'), :inventory],
[I18n.t('admin.reports.lettuce_share'), :lettuce_share]
],
customers: [
[I18n.t('admin.reports.mailing_list'), :mailing_list],
[I18n.t('admin.reports.addresses'), :addresses]
],
order_cycle_management: [
[I18n.t('admin.reports.payment_methods'), :payment_methods],
[I18n.t('admin.reports.delivery'), :delivery]
],
sales_tax: [
[I18n.t('admin.reports.tax_types'), :tax_types],
[I18n.t('admin.reports.tax_rates'), :tax_rates]
],
packing: [
[I18n.t('admin.reports.pack_by_customer'), :pack_by_customer],
[I18n.t('admin.reports.pack_by_supplier'), :pack_by_supplier]
]
}
OpenFoodNetwork::Reports::List.all
end
# Override spree reports list.
@@ -71,16 +45,6 @@ Spree::Admin::ReportsController.class_eval do
def order_cycle_management
params[:q] ||= {}
# -- Prepare form options
my_distributors = Enterprise.is_distributor.managed_by(spree_current_user)
my_suppliers = Enterprise.is_primary_producer.managed_by(spree_current_user)
# My distributors and any distributors distributing products I supply
@distributors = my_distributors | Enterprise.with_distributed_products_outer.merge(Spree::Product.in_any_supplier(my_suppliers))
# My suppliers and any suppliers supplying products I distribute
@suppliers = my_suppliers | my_distributors.map { |d| Spree::Product.in_distributor(d) }.flatten.map(&:supplier).uniq
@order_cycles = OrderCycle.active_or_complete.accessible_by(spree_current_user).order('orders_close_at DESC')
@report_types = report_types[:order_cycle_management]
@report_type = params[:report_type]
@@ -94,22 +58,12 @@ Spree::Admin::ReportsController.class_eval do
def packing
params[:q] ||= {}
# -- Prepare form options
my_distributors = Enterprise.is_distributor.managed_by(spree_current_user)
my_suppliers = Enterprise.is_primary_producer.managed_by(spree_current_user)
# My distributors and any distributors distributing products I supply
@distributors = my_distributors | Enterprise.with_distributed_products_outer.merge(Spree::Product.in_any_supplier(my_suppliers))
# My suppliers and any suppliers supplying products I distribute
@suppliers = my_suppliers | my_distributors.map { |d| Spree::Product.in_distributor(d) }.flatten.map(&:supplier).uniq
@order_cycles = OrderCycle.active_or_complete.accessible_by(spree_current_user).order('orders_close_at DESC')
@report_types = report_types[:packing]
@report_type = params[:report_type]
# -- Build Report with Order Grouper
@report = OpenFoodNetwork::PackingReport.new spree_current_user, params, render_content?
order_grouper = OpenFoodNetwork::OrderGrouper.new @report.rules, @report.columns
@table = order_grouper.table(@report.table_items)
@table = order_grouper_table
render_report(@report.header, @table, params[:csv], "packing_#{timestamp}.csv")
end
@@ -122,7 +76,7 @@ Spree::Admin::ReportsController.class_eval do
end
def sales_tax
@distributors = Enterprise.is_distributor.managed_by(spree_current_user)
@distributors = my_distributors
@report_type = params[:report_type]
@report = OpenFoodNetwork::SalesTaxReport.new spree_current_user, params, render_content?
render_report(@report.header, @report.table, params[:csv], "sales_tax.csv")
@@ -130,13 +84,12 @@ Spree::Admin::ReportsController.class_eval do
def bulk_coop
# -- Prepare form options
@distributors = Enterprise.is_distributor.managed_by(spree_current_user)
@distributors = my_distributors
@report_type = params[:report_type]
# -- Build Report with Order Grouper
@report = OpenFoodNetwork::BulkCoopReport.new spree_current_user, params, render_content?
order_grouper = OpenFoodNetwork::OrderGrouper.new @report.rules, @report.columns
@table = order_grouper.table(@report.table_items)
@table = order_grouper_table
csv_file_name = "bulk_coop_#{params[:report_type]}_#{timestamp}.csv"
render_report(@report.header, @table, params[:csv], csv_file_name)
@@ -144,13 +97,12 @@ Spree::Admin::ReportsController.class_eval do
def payments
# -- Prepare Form Options
@distributors = Enterprise.is_distributor.managed_by(spree_current_user)
@distributors = my_distributors
@report_type = params[:report_type]
# -- Build Report with Order Grouper
@report = OpenFoodNetwork::PaymentsReport.new spree_current_user, params, render_content?
order_grouper = OpenFoodNetwork::OrderGrouper.new @report.rules, @report.columns
@table = order_grouper.table(@report.table_items)
@table = order_grouper_table
csv_file_name = "payments_#{timestamp}.csv"
render_report(@report.header, @table, params[:csv], csv_file_name)
@@ -166,7 +118,7 @@ Spree::Admin::ReportsController.class_eval do
# My suppliers and any suppliers supplying products I distribute
@suppliers = permissions.visible_enterprises_for_order_reports.is_primary_producer
@order_cycles = OrderCycle.active_or_complete.accessible_by(spree_current_user).order('orders_close_at DESC')
@order_cycles = my_order_cycles
@report_types = report_types[:orders_and_fulfillment]
@report_type = params[:report_type]
@@ -175,8 +127,7 @@ Spree::Admin::ReportsController.class_eval do
# -- Build Report with Order Grouper
@report = OpenFoodNetwork::OrdersAndFulfillmentsReport.new spree_current_user, params, render_content?
order_grouper = OpenFoodNetwork::OrderGrouper.new @report.rules, @report.columns
@table = order_grouper.table(@report.table_items)
@table = order_grouper_table
csv_file_name = "#{params[:report_type]}_#{timestamp}.csv"
render_report(@report.header, @table, params[:csv], csv_file_name)
@@ -200,8 +151,8 @@ Spree::Admin::ReportsController.class_eval do
def xero_invoices
params[:q] ||= {}
@distributors = Enterprise.is_distributor.managed_by(spree_current_user)
@order_cycles = OrderCycle.active_or_complete.accessible_by(spree_current_user).order('orders_close_at DESC')
@distributors = my_distributors
@order_cycles = my_order_cycles
@report = OpenFoodNetwork::XeroInvoicesReport.new spree_current_user, params, render_content?
render_report(@report.header, @report.table, params[:csv], "xero_invoices_#{timestamp}.csv")
@@ -254,15 +205,33 @@ Spree::Admin::ReportsController.class_eval do
end
def load_data
# Load distributors either owned by the user or selling their enterprises products.
my_distributors = Enterprise.is_distributor.managed_by(spree_current_user)
my_suppliers = Enterprise.is_primary_producer.managed_by(spree_current_user)
distributors_of_my_products = Enterprise.with_distributed_products_outer.merge(Spree::Product.in_any_supplier(my_suppliers))
@distributors = my_distributors | distributors_of_my_products
# Load suppliers either owned by the user or supplying products their enterprises distribute.
suppliers_of_products_i_distribute = my_distributors.map { |d| Spree::Product.in_distributor(d) }.flatten.map(&:supplier).uniq
@suppliers = my_suppliers | suppliers_of_products_i_distribute
@order_cycles = OrderCycle.active_or_complete.accessible_by(spree_current_user).order('orders_close_at DESC')
@distributors = my_distributors
@suppliers = my_suppliers | suppliers_of_products_distributed_by(@distributors)
@order_cycles = my_order_cycles
end
# Load managed distributor enterprises of current user
def my_distributors
Enterprise.is_distributor.managed_by(spree_current_user)
end
# Load managed producer enterprises of current user
def my_suppliers
Enterprise.is_primary_producer.managed_by(spree_current_user)
end
def suppliers_of_products_distributed_by(distributors)
distributors.map { |d| Spree::Product.in_distributor(d) }.flatten.map(&:supplier).uniq
end
# Load order cycles the current user has access to
def my_order_cycles
OrderCycle.active_or_complete.accessible_by(spree_current_user).order('orders_close_at DESC')
end
def order_grouper_table
order_grouper = OpenFoodNetwork::OrderGrouper.new @report.rules, @report.columns
order_grouper.table(@report.table_items)
end
def authorized_reports
@@ -275,12 +244,13 @@ Spree::Admin::ReportsController.class_eval do
:products_and_inventory,
:sales_total,
:users_and_enterprises,
:enterprise_fee_summary,
:order_cycle_management,
:sales_tax,
:xero_invoices,
:packing
]
reports = all_reports.select { |action| can? action, :report }
reports = all_reports.select { |action| can? action, Spree::Admin::ReportsController }
reports.map { |report| [report, describe_report(report)] }.to_h
end
@@ -295,7 +265,13 @@ Spree::Admin::ReportsController.class_eval do
locals: { report_types: report_types[report] }
).html_safe
end
{ name: name, description: description }
{ name: name, url: url_for_report(report), description: description }
end
def url_for_report(report)
public_send("#{report}_admin_reports_url".to_sym)
rescue NoMethodError
url_for([:new, :admin, :reports, report.to_s.singularize])
end
def timestamp

View File

@@ -5,22 +5,10 @@ module Spree
before_filter :load_hubs, only: [:new, :edit, :create, :update]
# Sort shipping methods by distributor name
# ! Code copied from Spree::Admin::ResourceController with two added lines
def collection
return parent.public_send(controller_name) if parent_data.present?
collection = super
collection = collection.managed_by(spree_current_user).by_name
collection = if model_class.respond_to?(:accessible_by) &&
!current_ability.has_block?(params[:action], model_class)
model_class.accessible_by(current_ability, action)
else
model_class.scoped
end
collection = collection.managed_by(spree_current_user).by_name # This line added
# This block added
if params.key? :enterprise_id
distributor = Enterprise.find params[:enterprise_id]
collection = collection.for_distributor(distributor)
@@ -29,14 +17,10 @@ module Spree
collection
end
# This method was originally written because ProductDistributions referenced shipping
# methods, and deleting a referenced shipping method would break all the reports that
# queried it.
# This has changed, and now all we're protecting is Orders, which is a spree resource.
# Do we really need to protect it ourselves? Does spree do this, or provide some means
# of preserving the shipping method information for past orders?
# Spree allows soft deletes of shipping_methods but our reports are not adapted to that.
# So, this method prevents the deletion (even soft) of shipping_methods that are referenced in orders.
def do_not_destroy_referenced_shipping_methods
order = Order.where(:shipping_method_id => @object).first
order = Order.joins(shipments: :shipping_rates).where( spree_shipping_rates: { :shipping_method_id => @object } ).first
if order
flash[:error] = I18n.t(:shipping_method_destroy_error, number: order.number)
redirect_to collection_url and return

View File

@@ -3,6 +3,18 @@ require 'open_food_network/scope_variants_for_search'
Spree::Admin::VariantsController.class_eval do
helper 'spree/products'
def create
on_demand = params[:variant].delete(:on_demand)
on_hand = params[:variant].delete(:on_hand)
super
if @object.present? && @object.valid?
@object.on_demand = on_demand if on_demand.present?
@object.on_hand = on_hand.to_i if on_hand.present?
end
end
def search
scoper = OpenFoodNetwork::ScopeVariantsForSearch.new(params)
@variants = scoper.search
@@ -10,12 +22,15 @@ Spree::Admin::VariantsController.class_eval do
def destroy
@variant = Spree::Variant.find(params[:id])
@variant.delete # This line changed, as well as removal of following conditional
flash[:success] = I18n.t('notice_messages.variant_deleted')
if VariantDeleter.new.delete(@variant) # This line changed
flash[:success] = Spree.t('notice_messages.variant_deleted')
else
flash[:success] = Spree.t('notice_messages.variant_not_deleted')
end
respond_with(@variant) do |format|
format.html { redirect_to admin_product_variants_url(params[:product_id]) }
format.js { render_js_for_destroy }
format.js { render_js_for_destroy }
end
end

View File

@@ -1,7 +0,0 @@
Spree::Api::OrdersController.class_eval do
# We need to add expections for collection actions other than :index here
# because Spree's API controller causes authorize_read! to be called, which
# results in an ActiveRecord::NotFound Exception as the order object is not
# defined for collection actions
end

View File

@@ -33,7 +33,7 @@ Spree::Api::ProductsController.class_eval do
authorize! :delete, Spree::Product
@product = find_product(params[:product_id])
authorize! :delete, @product
@product.delete
@product.destroy
respond_with(@product, :status => 204)
end
@@ -56,8 +56,8 @@ Spree::Api::ProductsController.class_eval do
def product_scope
if current_api_user.has_spree_role?("admin") || current_api_user.enterprises.present? # This line modified
scope = Spree::Product
unless params[:show_deleted]
scope = scope.not_deleted
if params[:show_deleted]
scope = scope.with_deleted
end
else
scope = Spree::Product.active

View File

@@ -0,0 +1,47 @@
require 'open_food_network/scope_variant_to_hub'
Spree::Api::ShipmentsController.class_eval do
def create
variant = scoped_variant(params[:variant_id])
quantity = params[:quantity].to_i
@shipment = get_or_create_shipment(params[:stock_location_id])
@order.contents.add(variant, quantity, nil, @shipment)
@shipment.refresh_rates
@shipment.save!
respond_with(@shipment.reload, default_template: :show)
end
def add
variant = scoped_variant(params[:variant_id])
quantity = params[:quantity].to_i
@order.contents.add(variant, quantity, nil, @shipment)
respond_with(@shipment, default_template: :show)
end
def remove
variant = scoped_variant(params[:variant_id])
quantity = params[:quantity].to_i
@order.contents.remove(variant, quantity, @shipment)
@shipment.reload if @shipment.persisted?
respond_with(@shipment, default_template: :show)
end
private
def scoped_variant(variant_id)
variant = Spree::Variant.find(variant_id)
OpenFoodNetwork::ScopeVariantToHub.new(@order.distributor).scope(variant)
variant
end
def get_or_create_shipment(stock_location_id)
@order.shipment || @order.shipments.create(stock_location_id: stock_location_id)
end
end

View File

@@ -3,7 +3,7 @@ Spree::Api::VariantsController.class_eval do
@variant = scope.find(params[:variant_id])
authorize! :delete, @variant
@variant.delete
VariantDeleter.new.delete(@variant)
respond_with @variant, status: 204
end
end

View File

@@ -10,10 +10,10 @@ module Spree
render json: @credit_card, serializer: ::Api::CreditCardSerializer, status: :ok
else
message = t(:card_could_not_be_saved)
render json: { flash: { error: I18n.t(:spree_gateway_error_flash_for_checkout, error: message) } }, status: 400
render json: { flash: { error: I18n.t(:spree_gateway_error_flash_for_checkout, error: message) } }, status: :bad_request
end
rescue Stripe::CardError => e
return render json: { flash: { error: I18n.t(:spree_gateway_error_flash_for_checkout, error: e.message) } }, status: 400
render json: { flash: { error: I18n.t(:spree_gateway_error_flash_for_checkout, error: e.message) } }, status: :bad_request
end
def update
@@ -26,6 +26,8 @@ module Spree
else
update_failed
end
rescue ArgumentError
update_failed
end
def destroy
@@ -79,7 +81,7 @@ module Spree
end
def update_failed
render json: { flash: { error: t(:card_could_not_be_updated) } }, status: 400
render json: { flash: { error: t(:card_could_not_be_updated) } }, status: :bad_request
end
end
end

View File

@@ -21,14 +21,15 @@ Spree::OrdersController.class_eval do
def edit
@order = current_order(true)
@insufficient_stock_lines = @order.insufficient_stock_lines
@unavailable_order_variants = OrderCycleDistributedVariants.new(current_order_cycle, current_distributor).unavailable_order_variants(@order)
if @order.line_items.empty?
redirect_to main_app.shop_path
else
associate_user
if @order.insufficient_stock_lines.present?
flash[:error] = t(:spree_inventory_error_flash_for_insufficient_quantity)
if @order.insufficient_stock_lines.present? || @unavailable_order_variants.present?
flash[:error] = t("spree.orders.error_flash_for_unavailable_items")
end
end
end
@@ -42,7 +43,8 @@ Spree::OrdersController.class_eval do
end
if @order.update_attributes(params[:order])
@order.line_items = @order.line_items.select {|li| li.quantity > 0 }
discard_empty_line_items
with_open_adjustments { update_totals_and_taxes }
render :edit and return unless apply_coupon_code
@@ -130,6 +132,34 @@ Spree::OrdersController.class_eval do
private
# Updates the various denormalized total attributes of the order and
# recalculates the shipment taxes
def update_totals_and_taxes
@order.updater.update_totals
@order.shipment.ensure_correct_adjustment_with_included_tax if @order.shipment
end
# Sets the adjustments to open to perform the block's action and restores
# their state to whatever the they had. Note that it does not change any new
# adjustments that might get created in the yielded block.
def with_open_adjustments
previous_states = @order.adjustments.each_with_object({}) do |adjustment, hash|
hash[adjustment.id] = adjustment.state
end
@order.adjustments.each(&:open)
yield
@order.adjustments.each do |adjustment|
previous_state = previous_states[adjustment.id]
adjustment.update_attribute(:state, previous_state) if previous_state
end
end
def discard_empty_line_items
@order.line_items = @order.line_items.select { |li| li.quantity > 0 }
end
def require_order_authentication
return if session[:access_token] || params[:token] || spree_current_user

View File

@@ -10,10 +10,6 @@ Spree::UsersController.class_eval do
def show
@orders = @user.orders.where(state: 'complete').order('completed_at desc')
@unconfirmed_email = spree_current_user.unconfirmed_email
return unless Spree::Config.accounts_distributor_id
@orders = @orders.where('distributor_id != ?', Spree::Config.accounts_distributor_id)
end
# Endpoint for queries to check if a user is already registered

View File

@@ -1,21 +0,0 @@
module AddToCartHelper
def product_out_of_stock
!@product.has_stock? && !Spree::Config[:allow_backorders]
end
def distributor_available_for?(order, product)
DistributionChangeValidator.new(order).distributor_available_for?(product)
end
def order_cycle_available_for?(order, product)
DistributionChangeValidator.new(order).order_cycle_available_for?(product)
end
def available_distributors_for(order, product)
DistributionChangeValidator.new(order).available_distributors_for(product)
end
def available_order_cycles_for(order, product)
DistributionChangeValidator.new(order).available_order_cycles_for(product)
end
end

View File

@@ -1,14 +0,0 @@
module Admin
module AccountHelper
def invoice_description_for(invoice)
month = t(:abbr_month_names, :scope => :date)[invoice.month]
year = invoice.year
star = invoice.order.nil? || invoice.order.completed? ? "" : "*"
"#{month} #{year}#{star}"
end
def invoice_total_for(invoice)
invoice.order.andand.display_total || Spree::Money.new(0, { :currency => Spree::Config[:currency] })
end
end
end

View File

@@ -1,71 +0,0 @@
module Admin
module BusinessModelConfigurationHelper
def monthly_bill_description
plus = monthly_bill_includes_fixed? && monthly_bill_includes_rate? ? " + " : ""
ts = trial_description.empty? ? "": " "
ms = minimum_description.empty? ? "": " "
if fixed_description.empty? && rate_description.empty?
t(:free).upcase
elsif monthly_bill_includes_rate_limits? && monthly_bill_includes_rate? # only care about cap/min-bill-to if there is a rate too
"#{trial_description}#{ts}#{fixed_description}#{plus}#{rate_description}#{ms}#{minimum_description}#{cap_description} #{t(:per_month).upcase}#{tax_description.upcase}"
else
"#{trial_description}#{ts}#{fixed_description}#{plus}#{rate_description} #{t(:per_month).upcase}#{tax_description.upcase}"
end
end
private
def free_use?
Spree::Config[:account_invoices_monthly_fixed] == 0 && Spree::Config[:account_invoices_monthly_rate] == 0
end
def fixed_description
fixed_amount = Spree::Money.new(Spree::Config[:account_invoices_monthly_fixed], {currency: Spree::Config[:currency]} ).rounded
monthly_bill_includes_fixed? ? "#{fixed_amount}" : ""
end
def rate_description
percentage = (Spree::Config[:account_invoices_monthly_rate]*100).round(2)
monthly_bill_includes_rate? ? t(:percentage_of_sales, percentage: "#{percentage}%").upcase : ""
end
def cap_description
cap_amount = Spree::Money.new(Spree::Config[:account_invoices_monthly_cap], { currency: Spree::Config[:currency] }).rounded
monthly_bill_includes_cap? ? ", #{t(:capped_at_cap, cap: cap_amount).upcase}" : ""
end
def tax_description
Spree::Config[:account_invoices_tax_rate] > 0 ? ", #{t(:plus_tax).upcase}" : ""
end
def trial_description
Spree::Config[:shop_trial_length_days] > 0 ? "#{t(:free_trial).upcase} #{t(:then).upcase}" : ""
end
def minimum_description
mbt_amount = Spree::Money.new(Spree::Config[:minimum_billable_turnover], { currency: Spree::Config[:currency] }).rounded
monthly_bill_includes_min_turnover? ? "#{t(:min_bill_turnover_desc, mbt_amount: mbt_amount).upcase}" : ""
end
def monthly_bill_includes_fixed?
Spree::Config[:account_invoices_monthly_fixed] > 0
end
def monthly_bill_includes_rate?
Spree::Config[:account_invoices_monthly_rate] > 0
end
def monthly_bill_includes_cap?
Spree::Config[:account_invoices_monthly_cap] > 0
end
def monthly_bill_includes_min_turnover?
Spree::Config[:minimum_billable_turnover] > 1
end
def monthly_bill_includes_rate_limits?
monthly_bill_includes_min_turnover? || monthly_bill_includes_cap?
end
end
end

View File

@@ -1,7 +1,5 @@
module Admin
module InjectionHelper
include BusinessModelConfigurationHelper
def admin_inject_enterprise
admin_inject_json_ams "admin.enterprises", "enterprise", @enterprise, Api::Admin::EnterpriseSerializer
end
@@ -65,6 +63,10 @@ module Admin
admin_inject_json_ams_array opts[:module], "columns", column_preferences, Api::Admin::ColumnPreferenceSerializer
end
def admin_inject_currency_config
admin_inject_json_ams 'admin.utils', "currencyConfig", {}, Api::CurrencyConfigSerializer
end
def admin_inject_enterprise_permissions
permissions =
{can_manage_shipping_methods: can?(:manage_shipping_methods, @enterprise),
@@ -106,10 +108,6 @@ module Admin
admin_inject_json_ams_array "admin.orders", "orderCycles", @order_cycles, Api::Admin::BasicOrderCycleSerializer, current_user: spree_current_user
end
def admin_inject_monthly_bill_description
render partial: "admin/json/injection_ams", locals: {ngModule: "admin.enterprises", name: "monthlyBillDescription", json: monthly_bill_description.to_json}
end
def admin_inject_spree_api_key
render partial: "admin/json/injection_ams", locals: {ngModule: 'admin.indexUtils', name: 'SpreeApiKey', json: "'#{@spree_api_key.to_s}'"}
end

View File

@@ -0,0 +1,13 @@
module Admin
module OrdersHelper
# Adjustments to display under "Order adjustments".
#
# We exclude shipping method adjustments because they are displayed in a
# separate table together with the order line items.
def order_adjustments_for_display(order)
order.adjustments.eligible.select do |adjustment|
adjustment.originator_type != "Spree::ShippingMethod"
end
end
end
end

View File

@@ -78,22 +78,6 @@ module EnterprisesHelper
link_to_with_icon 'icon-trash', name, url, options
end
def shop_trial_in_progress?(enterprise)
!!enterprise.shop_trial_start_date &&
(enterprise.shop_trial_start_date + Spree::Config[:shop_trial_length_days].days > Time.zone.now) &&
%w(own any).include?(enterprise.sells)
end
def shop_trial_expired?(enterprise)
!!enterprise.shop_trial_start_date &&
(enterprise.shop_trial_start_date + Spree::Config[:shop_trial_length_days].days <= Time.zone.now) &&
%w(own any).include?(enterprise.sells)
end
def remaining_trial_days(enterprise)
distance_of_time_in_words(Time.zone.now, enterprise.shop_trial_start_date + Spree::Config[:shop_trial_length_days].days)
end
def order_changes_allowed?
current_order.andand.distributor.andand.allow_order_changes?
end

View File

@@ -65,7 +65,7 @@ module InjectionHelper
end
def inject_shops
customers = spree_current_user.customers.of_regular_shops
customers = spree_current_user.customers
shops = Enterprise.where(id: @orders.pluck(:distributor_id).uniq | customers.pluck(:enterprise_id))
inject_json_ams "shops", shops.all, Api::ShopForOrdersSerializer
end

View File

@@ -20,6 +20,7 @@ module Spree
klass = Spree::Order if klass == :bulk_order_management
klass = EnterpriseGroup if klass == :group
klass = VariantOverride if klass == :Inventory
klass = Spree::Admin::ReportsController if klass == :report
klass
end
alias_method_chain :klass_for, :sym_fallback

View File

@@ -3,7 +3,6 @@ module Spree
module OrdersHelper
def order_links(order)
links = []
links << { name: t(:view_order), url: admin_order_path(order), icon: 'icon-eye-open' } unless action_name == "show"
links << { name: t(:edit_order), url: edit_admin_order_path(order), icon: 'icon-edit' } unless action_name == "edit"
if @order.complete?
links << { name: t(:resend_confirmation), url: resend_admin_order_path(order), icon: 'icon-email', method: 'post', confirm: t(:confirm_resend_order_confirmation) }

View File

@@ -5,10 +5,6 @@ module Spree
order.nil? || order.line_items.empty?
end
def alternative_available_distributors(order)
DistributionChangeValidator.new(order).available_distributors(Enterprise.all) - [order.distributor]
end
def last_completed_order
spree_current_user.orders.complete.last
end

View File

@@ -1,110 +0,0 @@
# This class is part of the system that charges hubs for using OFN. It does so
# by creating orders. These are not orders for food that customers place, but
# instead are orders for OFN usage, so to speak. Thus, they're technically not
# "shipped" anywhere, so they're just given a default shipping method.
#
# The "orders" used by this class are not real orders, they are basically
# "invoices" that enterprise owners need to pay for use of an open food network
# instance. The amount that the enterprise owner is charged is configurable by
# the instance, and can be based on a combination of a percentage of their
# turnover, fixed fees, caps and floors and trial periods. This "orders" hold
# the billing information for a particular enterprise owner for a given month.
#
# We assign them also a default shipping method because there is a validation
# on Spree::Shipment that requires it.
class FinalizeAccountInvoices
attr_reader :year, :month, :start_date, :end_date
def initialize(year = nil, month = nil)
ref_point = Time.zone.now - 1.month
@year = year || ref_point.year
@month = month || ref_point.month
@start_date = Time.zone.local(@year, @month)
@end_date = Time.zone.local(@year, @month) + 1.month
end
def before(job)
UpdateBillablePeriods.new(year, month).perform
UpdateAccountInvoices.new(year, month).perform
end
def perform
return unless settings_are_valid?
invoice_orders = AccountInvoice.where(year: year, month: month).map(&:order)
invoice_orders.select{ |order| order.present? && order.completed_at.nil? }.each{ |order| finalize(order) }
end
def finalize(invoice_order)
# TODO: When we implement per-customer and/or per-user preferences around shipping and payment methods
# we can update these to read from those preferences
invoice_order.payments.create(payment_method_id: Spree::Config.default_accounts_payment_method_id, amount: invoice_order.total)
invoice_order.update_attribute(:shipping_method_id, Spree::Config.default_accounts_shipping_method_id)
while invoice_order.state != "complete"
if invoice_order.errors.any?
Bugsnag.notify(RuntimeError.new("FinalizeInvoiceError"), {
job: "FinalizeAccountInvoices",
error: "Cannot finalize invoice due to errors",
data: {
errors: invoice_order.errors.full_messages
}
})
break
else
invoice_order.next
end
end
end
private
def settings_are_valid?
unless end_date <= Time.zone.now
Bugsnag.notify(RuntimeError.new("InvalidJobSettings"), {
job: "FinalizeAccountInvoices",
error: "end_date is in the future",
data: {
end_date: end_date.in_time_zone.strftime("%F %T"),
now: Time.zone.now.strftime("%F %T")
}
})
return false
end
unless @accounts_distributor = Enterprise.find_by_id(Spree::Config.accounts_distributor_id)
Bugsnag.notify(RuntimeError.new("InvalidJobSettings"), {
job: "FinalizeAccountInvoices",
error: "accounts_distributor_id is invalid",
data: {
accounts_distributor_id: Spree::Config.accounts_distributor_id
}
})
return false
end
unless @accounts_distributor.payment_methods.find_by_id(Spree::Config.default_accounts_payment_method_id)
Bugsnag.notify(RuntimeError.new("InvalidJobSettings"), {
job: "FinalizeAccountInvoices",
error: "default_accounts_payment_method_id is invalid",
data: {
default_accounts_payment_method_id: Spree::Config.default_accounts_payment_method_id
}
})
return false
end
unless @accounts_distributor.shipping_methods.find_by_id(Spree::Config.default_accounts_shipping_method_id)
Bugsnag.notify(RuntimeError.new("InvalidJobSettings"), {
job: "FinalizeAccountInvoices",
error: "default_accounts_shipping_method_id is invalid",
data: {
default_accounts_shipping_method_id: Spree::Config.default_accounts_shipping_method_id
}
})
return false
end
true
end
end

View File

@@ -3,7 +3,14 @@ require 'open_food_network/products_cache_integrity_checker'
ProductsCacheIntegrityCheckerJob = Struct.new(:distributor_id, :order_cycle_id) do
def perform
unless checker.ok?
Bugsnag.notify RuntimeError.new("Products JSON differs from cached version for distributor: #{distributor_id}, order cycle: #{order_cycle_id}"), diff: checker.diff.to_s(:text)
exception = RuntimeError.new(
"Products JSON differs from cached version for distributor: #{distributor_id}, " \
"order cycle: #{order_cycle_id}"
)
Bugsnag.notify(exception) do |report|
report.add_tab(:products_cache, diff: checker.diff.to_s(:text))
end
end
end

View File

@@ -2,12 +2,17 @@ require 'open_food_network/products_renderer'
RefreshProductsCacheJob = Struct.new(:distributor_id, :order_cycle_id) do
def perform
Rails.cache.write "products-json-#{distributor_id}-#{order_cycle_id}", products_json
Rails.cache.write(key, products_json)
rescue ActiveRecord::RecordNotFound
true
end
private
def key
"products-json-#{distributor_id}-#{order_cycle_id}"
end
def products_json
distributor = Enterprise.find distributor_id
order_cycle = OrderCycle.find order_cycle_id

View File

@@ -25,7 +25,7 @@ class SubscriptionConfirmJob
def proxy_orders
ProxyOrder.not_canceled.where('confirmed_at IS NULL AND placed_at IS NOT NULL')
.joins(:order_cycle).merge(recently_closed_order_cycles)
.joins(:order).merge(Spree::Order.complete)
.joins(:order).merge(Spree::Order.complete.not_state('canceled'))
end
def recently_closed_order_cycles

View File

@@ -67,7 +67,7 @@ class SubscriptionPlacementJob
end
def available_variants_for(order)
DistributionChangeValidator.new(order).variants_available_for_distribution(order.distributor, order.order_cycle)
OrderCycleDistributedVariants.new(order.order_cycle, order.distributor).available_variants
end
def send_placement_email(order, changes)

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