Compare commits

..

841 Commits

Author SHA1 Message Date
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
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
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
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
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
c5720bede5 Merge pull request #3697 from coopdevs/add-delayed-job-web
Add delayed job web
2019-04-16 15:33:59 +01: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
Pau Pérez Fabregat
ffbea7d3fd Merge pull request #3712 from openfoodfoundation/transifex
Transifex
2019-04-15 12:58:30 +02: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
Pau Pérez Fabregat
e0fd2fbaa9 Merge pull request #3726 from Matt-Yorkley/db2fog_patch
Db2fog patch
2019-04-12 14:26:46 +02: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
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
Transifex-Openfoodnetwork
029e8eb848 Updating translations for config/locales/de_DE.yml 2019-04-09 20:50:31 +10: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
Transifex-Openfoodnetwork
f5ab89eb03 Updating translations for config/locales/it.yml 2019-04-06 07:38:45 +11: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
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
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
Matt-Yorkley
7522594b85 Fix outdated db2fog initializer 2019-04-04 12:02:57 +01: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
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
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
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
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
Maikel
fed2b60743 Merge pull request #3644 from kevinchristianson/master
Fixed producer profile translation bug
2019-03-28 15:51:45 +11: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
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
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
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
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
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
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 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
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
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
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
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
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
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
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
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
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
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 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
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
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
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
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
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
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
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
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
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
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
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
Matt-Yorkley
6e77afbf35 Adjust expectations in flaky spec 2019-02-25 11:08:10 +00: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
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
Transifex-Openfoodnetwork
4b21c9cb70 Updating translations for config/locales/en_CA.yml 2019-02-21 07:32:50 +11: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
Transifex-Openfoodnetwork
aba4d742f6 Updating translations for config/locales/fr_CA.yml 2019-02-20 12:55:33 +11:00
Maikel
e7e2d1d870 Merge pull request #3516 from openfoodfoundation/transifex
Transifex
2019-02-20 10:39:55 +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
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
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
Matt-Yorkley
9705c249ac Sanitize no-parsable BOM characters inserted by Excel 2019-02-18 13:13:37 +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
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
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
Kristina Lim
af95e3871f Move check for table presence out of helper 2019-02-15 01:15:58 +08: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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Isaac Haseley
09d3cea830 Lazy-load one more translation 2019-02-01 09:22:26 -06: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
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
Luis Ramos
cf744bb663 Merge pull request #3407 from openfoodfoundation/transifex
Transifex
2019-01-30 13:58:26 +00:00
Transifex-Openfoodnetwork
2b13516d3d Updating translations for config/locales/nb.yml 2019-01-30 19:20:56 +11:00
Transifex-Openfoodnetwork
1b50ba2729 Updating translations for config/locales/fr.yml 2019-01-30 19:16:54 +11:00
Maikel
e8ac0e4a9f Merge pull request #3402 from openfoodfoundation/transifex
Transifex
2019-01-30 14:45:39 +11:00
Maikel
bef7684505 Merge pull request #3399 from kristinalim/fix/3381-address_failing_tests
3381 [Flaky Spec] Load enterprise users tab before inspecting table
2019-01-30 14:29:16 +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
Transifex-Openfoodnetwork
f7b7e98fec Updating translations for config/locales/en_GB.yml 2019-01-30 05:12:58 +11:00
luisramos0
c07b90ffb0 Update all locales with the latest Transifex translations 2019-01-29 12:45:28 +00:00
Pau Pérez Fabregat
2b3ffd8c82 Merge pull request #2833 from kristinalim/fix-variant_override_permissions
Add tests for permissions for variant overrides
2019-01-29 09:51:41 +01:00
Pau Pérez Fabregat
a5ed17f0f5 Merge pull request #3390 from openfoodfoundation/dependabot/bundler/oj-3.7.8
Bump oj from 3.7.4 to 3.7.8
2019-01-29 09:50:25 +01:00
Pau Pérez Fabregat
c9a8ec84c0 Merge pull request #3359 from kevinchristianson/ready
Convert sass files to scss
2019-01-28 20:02:37 +01:00
Kristina Lim
2129ab991b Load enterprise users tab before inspecting table 2019-01-26 12:11:41 +08: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]
33ee46b224 Bump oj from 3.7.4 to 3.7.8
Bumps [oj](https://github.com/ohler55/oj) from 3.7.4 to 3.7.8.
- [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.4...v3.7.8)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-01-24 19:16:56 +00: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
Maikel
4cc6a8c966 Merge pull request #3350 from openfoodfoundation/dependabot/bundler/delayed_job_active_record-4.1.3
Bump delayed_job_active_record from 4.1.2 to 4.1.3
2019-01-24 11:58:32 +11:00
Maikel
66cb0e6a91 Merge pull request #3352 from openfoodfoundation/dependabot/bundler/foundation-rails-5.5.2.1
Bump foundation-rails from 5.5.0.0 to 5.5.2.1
2019-01-24 10:29:17 +11:00
Maikel
a3cd1dc945 Merge pull request #3344 from mkllnk/3279-moment-upgrade
Avoid deprecation warnings of momentjs
2019-01-24 10:28:41 +11:00
Kristina Lim
cf7f8b887f Add tests for permissions for variant overrides 2019-01-24 07:08:54 +11:00
Pau Pérez Fabregat
7881f96cac Merge pull request #3341 from openfoodfoundation/dependabot/bundler/daemons-1.3.1
Bump daemons from 1.2.2 to 1.3.1
2019-01-23 16:09:28 +01:00
Pau Pérez Fabregat
8320dc75e8 Merge pull request #3002 from kevinchristianson/margin-fix
Fix bad spacing on account settings error page
2019-01-23 16:09:14 +01:00
Pau Pérez Fabregat
77fd0b228e Merge pull request #3360 from brases/wording_order_cofirmation
Fix wording in email template for orders confirmation
2019-01-23 13:35:00 +01:00
Maikel
2064ffe548 Merge pull request #3354 from luisramos0/knapsack
New Knapsack report
2019-01-22 10:58:13 +11:00
Maikel
06af79d1b0 Merge pull request #3339 from Matt-Yorkley/headless4
[Headless Chrome] Fix embedded_shopfront_spec unhandled alert
2019-01-22 10:46:42 +11: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
8b1c1881f7 Merge pull request #3351 from openfoodfoundation/dependabot/bundler/diffy-3.3.0
Bump diffy from 3.1.0 to 3.3.0
2019-01-21 15:08:24 +01:00
Kevin Christianson
6b7273f685 Convert sass files to scss 2019-01-19 22:40:41 -06:00
nozakis
972bfd5e62 Fixed bad margins on the account settings error page. 2019-01-19 16:23:13 -06:00
Brases
3437257515 Fix wording in order confirmation email template
Fixes issue #3063 "Repeated translation in Order Confirmation Screen and Email".
Now "Ready for" (collection time) is not repeated in place of "Collection
details" (collection instructions)
2019-01-19 20:37:21 +00:00
luisramos0
d155bb142c Make proxy order spec a bit more resilient by allowing two secs diff in timestamps 2019-01-19 15:53:05 +00:00
luisramos0
6f7a351ffa Update knapsack report to get build jobs more balanced 2019-01-18 23:46:09 +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
Matt-Yorkley
3929689d48 Ensure login via modal is completed 2019-01-18 19:06:42 +00:00
dependabot[bot]
49e3aa5070 Bump daemons from 1.2.2 to 1.3.1
Bumps [daemons](https://github.com/thuehlinger/daemons) from 1.2.2 to 1.3.1.
- [Release notes](https://github.com/thuehlinger/daemons/releases)
- [Changelog](https://github.com/thuehlinger/daemons/blob/master/Releases)
- [Commits](https://github.com/thuehlinger/daemons/compare/v1.2.2...v1.3.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-01-18 16:52:13 +00:00
dependabot[bot]
1e01cf81ec Bump diffy from 3.1.0 to 3.3.0
Bumps [diffy](https://github.com/samg/diffy) from 3.1.0 to 3.3.0.
- [Release notes](https://github.com/samg/diffy/releases)
- [Changelog](https://github.com/samg/diffy/blob/master/CHANGELOG)
- [Commits](https://github.com/samg/diffy/compare/3.1.0...3.3.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-01-18 16:51:42 +00:00
Pau Pérez Fabregat
a95dd98ed6 Merge pull request #2869 from Matt-Yorkley/bi/bulk_invoices
[Bulk Invoice Printing] Bulk invoices
2019-01-18 17:49:34 +01:00
Pau Pérez Fabregat
ee28cc5a29 Merge pull request #3323 from openfoodfoundation/dependabot/bundler/paper_trail-5.2.3
Bump paper_trail from 3.0.9 to 5.2.3
2019-01-18 17:48:56 +01:00
dependabot[bot]
2e993542a7 Bump foundation-rails from 5.5.0.0 to 5.5.2.1
Bumps [foundation-rails](http://foundation.zurb.com) from 5.5.0.0 to 5.5.2.1.

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-01-17 19:20:09 +00:00
dependabot[bot]
560e52a0ce Bump delayed_job_active_record from 4.1.2 to 4.1.3
Bumps [delayed_job_active_record](https://github.com/collectiveidea/delayed_job_active_record) from 4.1.2 to 4.1.3.
- [Release notes](https://github.com/collectiveidea/delayed_job_active_record/releases)
- [Commits](https://github.com/collectiveidea/delayed_job_active_record/compare/v4.1.2...v4.1.3)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-01-17 19:17:20 +00:00
dependabot[bot]
adfa6b306c Bump paper_trail from 3.0.9 to 5.2.3
Bumps [paper_trail](https://github.com/airblade/paper_trail) from 3.0.9 to 5.2.3.
- [Release notes](https://github.com/airblade/paper_trail/releases)
- [Changelog](https://github.com/paper-trail-gem/paper_trail/blob/master/CHANGELOG.md)
- [Commits](https://github.com/airblade/paper_trail/compare/v3.0.9...v5.2.3)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-01-17 19:08:33 +00:00
Pau Pérez Fabregat
c178478a4f Merge pull request #3346 from luisramos0/headless-chrome
Merge Headless Chrome to master
2019-01-17 20:04:27 +01:00
Pau Pérez Fabregat
29990f25c1 Merge pull request #3325 from mkllnk/2469-fix-async-js-requests
2469 Fix async js requests
2019-01-17 20:03:54 +01:00
Pau Pérez Fabregat
e8dd6e9ce7 Merge pull request #3322 from luisramos0/delete_archive_spec
Delete dead code and unused folders
2019-01-17 20:01:49 +01:00
Luis Ramos
a8998fad79 Merge branch 'master' into headless-chrome 2019-01-17 18:22:25 +00:00
Pau Pérez Fabregat
fd00ad4e94 Merge pull request #3342 from openfoodfoundation/dependabot/bundler/letter_opener-1.7.0
Bump letter_opener from 1.6.0 to 1.7.0
2019-01-17 16:55:46 +01:00
Pau Pérez Fabregat
c51aa0f3b8 Merge pull request #3340 from openfoodfoundation/dependabot/bundler/whenever-0.10.0
Bump whenever from 0.9.2 to 0.10.0
2019-01-17 16:52:21 +01:00
Matt-Yorkley
e7e208061f Assign polling numbers to variables and add comments 2019-01-17 09:37:32 +00:00
Matt-Yorkley
a3b9936f37 Improve matching inventory using 'items' unit type 2019-01-17 09:33:39 +00:00
Maikel Linke
4d3aed8467 Avoid deprecation warnings of momentjs 2019-01-17 14:49:43 +11:00
Maikel
9322c3f0c8 Merge pull request #3343 from Matt-Yorkley/headless5
[Headless Chrome] Fix datepicker interactions in bulk_order_management_spec
2019-01-17 14:19:00 +11:00
Maikel Linke
520ec5d047 Fix whenever upgrade by declaring dependency
Whenever doesn't depend on ActiveSupport any more. So we can't rely on
YAML being automatically loaded for us. We have to require it.
2019-01-17 10:41:11 +11:00
Maikel
7272ec8738 Merge pull request #3333 from Matt-Yorkley/headless3
[Headless Chrome] Fix shipping method tests
2019-01-17 09:18:12 +11:00
Matt-Yorkley
b3849778fa Fix datepicker interactions in bulk_order_management_spec 2019-01-16 21:51:15 +00:00
dependabot[bot]
d884be54f9 Bump letter_opener from 1.6.0 to 1.7.0
Bumps [letter_opener](https://github.com/ryanb/letter_opener) from 1.6.0 to 1.7.0.
- [Release notes](https://github.com/ryanb/letter_opener/releases)
- [Changelog](https://github.com/ryanb/letter_opener/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ryanb/letter_opener/compare/v1.6.0...v1.7.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-01-16 19:22:19 +00:00
dependabot[bot]
483d8893f2 Bump whenever from 0.9.2 to 0.10.0
Bumps [whenever](https://github.com/javan/whenever) from 0.9.2 to 0.10.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.9.2...v0.10.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-01-16 19:18:32 +00:00
Matt-Yorkley
07dff0af7f Check tag js has finished executing before submitting form 2019-01-16 17:46:56 +00:00
Matt-Yorkley
7487a6da3c Fix shipping method tests 2019-01-16 17:17:10 +00:00
Matt-Yorkley
5caa958db0 Merge pull request #3336 from luisramos0/chrome-helper-fix
Fix Gemfile.lock by running bundle install. Adds missing chromedriver-helper.
2019-01-16 17:16:22 +00:00
Pau Pérez Fabregat
e557e06a7b Merge pull request #3324 from openfoodfoundation/dependabot/bundler/spring-1.7.2
Bump spring from 1.1.3 to 1.7.2
2019-01-16 17:50:08 +01:00
luisramos0
41cd8c7ed3 Fix Gemfile.lock by running bundle install. Adds missing chromedriver-helper. 2019-01-16 16:29:55 +00:00
Matt-Yorkley
21bdaf9960 Fix enterprise images spec 2019-01-16 16:24:01 +00:00
Matt-Yorkley
0589516368 Add chromedriver-helper to Gemfile for test and development 2019-01-16 16:24:01 +00:00
Matt-Yorkley
40ccabc2b4 Fix broken product import spec 2019-01-16 16:24:01 +00:00
Maikel Linke
f391eab5b0 Revert "Temporarily move 2 broken specs to pending (shops and producers search by url) due to google maps api changes"
This reverts commit 7dc208fb8c.
2019-01-16 16:24:01 +00:00
Maikel Linke
6a53e5fd3d Avoid alert by waiting until shop loaded 2019-01-16 16:24:01 +00:00
Maikel Linke
dd5bd5b616 Remove js_errors = false from specs because it is not available in Selenium ChromeDriver
If the js errors this line was hidding become a problem we will need to address them
2019-01-16 16:24:01 +00:00
luisramos0
fce56776f6 Make embedded_shopfronts_spec work with selenium 2019-01-16 16:24:01 +00:00
luisramos0
5fb4faac91 Make features/admin/subscriptions_spec and shopworkflow work with selenium
Also, remove a test support method, dead code
2019-01-16 16:24:01 +00:00
Maikel Linke
e49eb42af6 Make Chrome accepting alerts 2019-01-16 16:21:30 +00:00
Maikel Linke
843ec2c08f Wait for table rows before testing them
Unfortunately, the exact table row matcher doesn't wait correctly for
changes on the page. Waiting correctly would mean to assemble a very
complicated xpath similar to this gem:

https://github.com/jnicklas/capybara_table
2019-01-16 16:21:30 +00:00
Maikel Linke
1407ae7778 Make TableMatcher match exactly, not part of row
Reverts dbf3a7aaaf9d458f99e14983ca9db2d4cbe4b564.

The reverted commit tried to avoid a 30 second delay by using
have_selector. While that was successful in reducing test time, it made
the matcher find rows that where not exactly the wanted row, but contained
text of the wanted row. This wasn't a problem until we experimented with
Chrome as test browser returns text on select boxes.

This commit makes the matcher precise again. We still have to deal with
the 30 second delay.
2019-01-16 16:21:30 +00:00
Rob Harrington
ef68bd1b43 Replace unnecessary perform_and_ensure* type helpers with standard actions and expectations 2019-01-16 16:21:30 +00:00
Rob Harrington
98f4ae9b60 Change screen size back to large after authentication_spec 2019-01-16 16:21:30 +00:00
Rob Harrington
a988fad2db Update orders_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
98a5b40aec Ensure multiligual switcher specs run in large screen 2019-01-16 16:21:30 +00:00
Rob Harrington
3a781049ed Update orders_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
3b40ede0b8 Fix table row matchers
The matcher was silently failing on the check step (adding ~30 seconds to out specs each time it was used!), so I changed it to fail if the basic step does not succeed
2019-01-16 16:21:30 +00:00
Rob Harrington
56c07aac5c Don't run ticket printing spec 2019-01-16 16:21:30 +00:00
Rob Harrington
4951863e9b Update enterprises_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
eccf874f03 Update shopping_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
2b48b4ee18 Update cart_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
bba8b2020c Replace use of 'trigger' in ui_component helper 2019-01-16 16:21:30 +00:00
Rob Harrington
23fa57ff6d Update multilingual_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
bbaf6359f3 Update shopping_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
1923c0dbc6 Update enterprise_fees_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
c2432fab0b Use all_options_absent method instead of poorly written no_options_present
SAVES 30 SECONDS FOR EVERY SPEC THAT IS IT USED IN!
2019-01-16 16:21:30 +00:00
Rob Harrington
3e90f9aa1d Update customers_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
189856a92a Reimplement resize helper methods to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
1bad08c1c0 Update checkout_workflow and spec_helper to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
3ab7a3d62b Update order_cycles_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
50a8554b55 Update enterprises_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
69e44bdeb3 Update enterprise_roles_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
5ae33747ea Update enterprise_relationships_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
7dc792b6fe Update enterprise_groups_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
e97f5e36a6 Update bulk_order_management_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
2ece6bfb49 Update subscriptions_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
8416af4995 Update variants_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
8413c5f60a Update variant_overrides_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
5c268e9359 Update schedules_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
708e308b7c Update products_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
c6a383aafd Update bulk_product_update_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
cc55f59b00 Update tag_rules_spec to work with Selenium 2019-01-16 16:21:30 +00:00
Rob Harrington
118d26b2ff Add aynchronous select2 search helper
select2_search from spree times out after 1 second, so this new method just waits for a result to be returned before attempting to select it
2019-01-16 16:21:30 +00:00
Rob Harrington
70502a7a32 Switch to using selenium as js driver for capybara specs
PhantomJS is no longer being maintained
2019-01-16 16:21:30 +00:00
Rob Harrington
6608655e9a Use headless chrome for karma specs instead of PhantomJS
PhantomJS is no longer being maintained
2019-01-16 16:21:30 +00:00
Pau Pérez Fabregat
d2325fc7dd Merge pull request #3230 from luisramos0/stock_levels
3222 Improve stock levels calculation code on cart populate and add specs to test handling of variant overrides
2019-01-16 12:54:25 +01:00
Pau Pérez Fabregat
5bb327efbd Merge pull request #3234 from openfoodfoundation/dependabot/bundler/oauth2-1.4.1
Bump oauth2 from 1.2.0 to 1.4.1
2019-01-16 12:33:39 +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
Maikel
54311c2d1b Merge pull request #3304 from HugsDaniel/3288-3291-translation-issues
Add I18n keys for order state and order firstname and lastname filters
2019-01-16 09:43:28 +11:00
Maikel
2c197d40bb Merge pull request #3326 from mkllnk/cleanup-specs
Cleanup specs
2019-01-16 09:23:06 +11:00
luisramos0
ea61e415e1 Add bugsnag notifications to detect potential dead code scenarios in variants_stock_levels and cart_service 2019-01-15 13:42:51 +00:00
luisramos0
d926f7c776 Reorganize and improve cart controller spec 2019-01-15 13:42:51 +00:00
luisramos0
aa603c9a84 Make rubocop happy on cart controller, cart service and stock levels service 2019-01-15 13:42:51 +00:00
luisramos0
b0449be302 Add spec to test cart controller handling of variant overrides on cart populate 2019-01-15 13:38:58 +00:00
luisramos0
c0473a4505 Extract variants_stock_levels from cart_controller and refactor some names 2019-01-15 13:38:58 +00:00
Maikel
e56915e65a Merge pull request #3303 from openfoodfoundation/transifex
Transifex
2019-01-15 17:19:21 +11:00
Maikel Linke
5a5db3c458 Fix state of RequestMonitor
`@loading` was set to false when the request with the last id finished.
But another request started earlier (having a lower id) could take
longer. `@loading` was set to false even though these long requests were
still active.
2019-01-15 15:45:49 +11:00
Maikel Linke
ca9673f562 Fix Dereferencer service
It failed when `object[attr]` was `undefined` instead of `null`.
2019-01-15 15:43:00 +11:00
Maikel
8ba0e3b474 Merge pull request #3302 from mkllnk/74-bundler-version
Add script to install required bundler version
2019-01-15 09:36:18 +11:00
dependabot[bot]
22c225968a Bump spring from 1.1.3 to 1.7.2
Bumps [spring](https://github.com/rails/spring) from 1.1.3 to 1.7.2.
- [Release notes](https://github.com/rails/spring/releases)
- [Changelog](https://github.com/rails/spring/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rails/spring/compare/v1.1.3...v1.7.2)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-01-14 19:18:25 +00:00
luisramos0
90240f1802 Delete unused folders under /vendor 2019-01-14 14:38:51 +00:00
luisramos0
497974db74 Delete outdated archived version of checkout spec 2019-01-14 14:32:51 +00:00
luisramos0
e2c966244a Delete /doc.
The list of specs is outdated and the images were transfered to the wiki itself

The project docs should be in the wiki
2019-01-14 14:31:31 +00:00
Pau Pérez Fabregat
ccc0a2cf96 Merge pull request #3280 from openfoodfoundation/dependabot/bundler/uglifier-4.1.20
Bump uglifier from 4.1.19 to 4.1.20
2019-01-11 19:46:04 +01:00
Matt-Yorkley
3f62d82afc Add more inventory testing for visibility in the inventory UI 2019-01-11 11:26:38 +00:00
Maikel Linke
4abacb3691 Remove unused spec helpers
They all seem to have been used in the past. People forgot to remove
them after removing the using spec code.
2019-01-11 18:04:24 +11:00
Maikel Linke
e89a836e72 Remove forgotten code from spec
Commit e4ebeb8a29 forgot to remove this
code.
2019-01-11 18:04:24 +11:00
Maikel Linke
223982f571 Prepare spec for Chrome testing 2019-01-11 18:04:24 +11:00
Maikel Linke
cbdda54989 DRY specs with new helper 2019-01-11 18:04:24 +11:00
Maikel
4920782742 Merge pull request #3072 from luisramos0/2-0-calc-line-items-for-take-2
Fix bug on calculator_decorator line_items_for where input is line_item with a nil order
2019-01-11 14:49:25 +11:00
dependabot[bot]
1548c7c25a Bump oauth2 from 1.2.0 to 1.4.1
Bumps [oauth2](https://github.com/oauth-xx/oauth2) from 1.2.0 to 1.4.1.
- [Release notes](https://github.com/oauth-xx/oauth2/releases)
- [Changelog](https://github.com/oauth-xx/oauth2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/oauth-xx/oauth2/compare/v1.2.0...v1.4.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-01-10 23:46:45 +00:00
dependabot[bot]
7f09112d7b Bump uglifier from 4.1.19 to 4.1.20
Bumps [uglifier](https://github.com/lautis/uglifier) from 4.1.19 to 4.1.20.
- [Release notes](https://github.com/lautis/uglifier/releases)
- [Changelog](https://github.com/lautis/uglifier/blob/master/CHANGELOG.md)
- [Commits](https://github.com/lautis/uglifier/compare/v4.1.19...v4.1.20)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-01-10 23:45:22 +00:00
Maikel
ab14b73e17 Merge pull request #3211 from openfoodfoundation/dependabot/bundler/blockenspiel-0.5.0
Bump blockenspiel from 0.4.5 to 0.5.0
2019-01-11 10:42:40 +11:00
Maikel
fff054efc1 Merge pull request #3169 from luisramos0/hubPermissions
Add guard clause on variant overrides filter in case hub id is not present in the hubPermissions
2019-01-11 10:41:57 +11:00
Maikel
6c3d769121 Merge pull request #3229 from mkllnk/3127-tax-rates-report
3127 More robust tax rates report
2019-01-11 10:41:12 +11:00
Maikel
935e233605 Merge pull request #3244 from luisramos0/ruby-racer
Revert to the ruby racer
2019-01-11 10:40:02 +11:00
Hugo Daniel
026fe55f1d Add I18n keys for order state and order firstname and lastname filters 2019-01-10 15:32:23 +01:00
Transifex-Openfoodnetwork
e70b8c03ce Updating translations for config/locales/nb.yml 2019-01-10 22:18:58 +11:00
Matt-Yorkley
e624faaacb Add 'please wait' message to bulk invoice modal 2019-01-10 09:57:06 +00:00
Matt-Yorkley
0e478ff501 Increase polling to 150 seconds maximum before showing error message. 2019-01-10 09:57:06 +00:00
Matt-Yorkley
66ac61f591 Rename background processing method 2019-01-10 09:57:06 +00:00
Matt-Yorkley
4f9f8adcd6 Add Service and remove Job 2019-01-10 09:57:06 +00:00
Matt-Yorkley
003014daf8 Extract invoice methods from ordersCtrl 2019-01-10 09:57:06 +00:00
Matt-Yorkley
bb814f91ef Extract timeout to named function 2019-01-10 09:57:06 +00:00
Matt-Yorkley
6b6a41cfbc Update CSS 2019-01-10 09:57:06 +00:00
Matt-Yorkley
638dc6eada Add polling and show action 2019-01-10 09:57:06 +00:00
Matt-Yorkley
b0f75162ac Add delayed job for create bulk invoice 2019-01-10 09:57:06 +00:00
Matt-Yorkley
7d82020657 Move bulk invoice to new RESTful route 2019-01-10 09:57:06 +00:00
Matt-Yorkley
4a88fb0626 Use simpler array for selected ids 2019-01-10 09:57:06 +00:00
Matt-Yorkley
5279210254 Improve invoice order querying 2019-01-10 09:57:06 +00:00
Matt-Yorkley
f3585befff Fix customer missing from some order records - guest checkout? 2019-01-10 09:57:06 +00:00
Matt-Yorkley
24207053e4 Reset selected orders on filter change 2019-01-10 09:57:06 +00:00
Matt-Yorkley
5cc8bad42b Improve UI layout for select all option 2019-01-10 09:57:06 +00:00
Matt-Yorkley
42cf96e635 Disable button unless orders selected 2019-01-10 09:57:06 +00:00
Matt-Yorkley
4ec0f0ff73 Add bulk invoices printing 2019-01-10 09:57:06 +00:00
Matt-Yorkley
96d530b473 Tidy up invoice template selection 2019-01-10 09:57:06 +00:00
Matt-Yorkley
9a71236abd Add combine_pdf gem 2019-01-10 09:57:06 +00:00
Matt-Yorkley
f263ef7dc0 Add selectable checkboxes 2019-01-10 09:57:06 +00:00
Maikel
4f5bb96484 Merge pull request #3300 from openfoodfoundation/transifex
Transifex
2019-01-10 17:52:28 +11:00
Maikel Linke
199dee3f64 Use install-bundler in setup script 2019-01-10 17:44:13 +11:00
Maikel Linke
dafa433788 Add script to install required bundler version
The newest version of bundler is not compatible with our current version
of Ruby. This script helps to install the bundler version defined in
Gemfile.lock.
2019-01-10 17:44:09 +11:00
Transifex-Openfoodnetwork
15e197b3b0 Updating translations for config/locales/en_GB.yml 2019-01-10 07:31:46 +11:00
Pau Pérez Fabregat
399cc5f796 Merge pull request #3224 from alvaro-chalar/footer-message
Add custom footer message in reports section
2019-01-09 16:01:02 +01:00
Pau Pérez Fabregat
1815a2116d Merge pull request #3257 from coopdevs/refactor-enterprise-controller-shop-injection
Refactor to reveal how we load enterprises in shop
2019-01-09 13:21:56 +01:00
Maikel
abe4f78e5c Merge pull request #2988 from Matt-Yorkley/pi/utf8
Pi/utf8
2019-01-09 15:39:05 +11:00
Pau Pérez Fabregat
57267ab4a4 Merge pull request #3297 from openfoodfoundation/transifex
Transifex
2019-01-08 22:45:55 +01:00
Transifex-Openfoodnetwork
f05f4ce0b1 Updating translations for config/locales/en_GB.yml 2019-01-09 07:06:27 +11:00
Pau Pérez Fabregat
bd10400457 Merge pull request #3295 from coopdevs/pull-translations
Update all locales with the latest Transifex translations
2019-01-08 17:58:51 +01:00
Pau Perez
f1f1ab9daf Update all locales with the latest Transifex translations 2019-01-08 17:17:35 +01:00
luisramos0
364f9f9abd Improve variable names in cart spec 2019-01-07 11:40:42 +00:00
Pau Pérez Fabregat
34876cc255 Merge pull request #3275 from openfoodfoundation/transifex
Transifex
2019-01-07 11:43:06 +01:00
Pau Pérez Fabregat
ed8f719769 Merge pull request #3245 from luisramos0/spring
Add spring, a rails preloader alternative to zeus, to our gemfile
2019-01-07 11:07:34 +01:00
luisramos0
2893f1c141 Add test to cover weight calculation bug #3072 2019-01-07 01:18:40 +00:00
Maikel Linke
d2ba305ce6 Fix context data for tax rate finder spec
The spec was accidentally finding an exact tax rate match. The new test
data provides only close matches to choose from.

The naming of variables has been simplified as well.
2019-01-04 18:31:46 +11:00
Maikel Linke
a8ccb9b818 Explain why we look for the closest tax rate of a fee 2019-01-04 17:24:45 +11:00
Maikel
1024fc1f34 Merge pull request #3273 from coopdevs/fix-fr-BE-link
Fix menu_1_url translation for fr_BE
2019-01-04 09:52:44 +11:00
Transifex-Openfoodnetwork
9da7ff5698 Updating translations for config/locales/fr.yml 2019-01-04 02:15:57 +11:00
Pau Pérez Fabregat
9f0c6a6bac Merge pull request #3251 from openfoodfoundation/dependabot/bundler/webmock-3.5.1
Bump webmock from 3.4.2 to 3.5.1
2019-01-03 11:18:59 +01:00
Pau Perez
edffbd72fe Update rubocop_manual_todo 2019-01-03 11:17:10 +01:00
Pau Perez
ddf916814f Reduce complexity of EnterprisesController#shop
As asked by Rubocop.
2019-01-03 11:17:10 +01:00
Pau Perez
e3edb51d3e Update rubocop_todo 2019-01-03 11:17:10 +01:00
Pau Perez
51da607ab1 Fix too long line 2019-01-03 11:17:10 +01:00
Pau Perez
46760ce28c Do not double-render when there is no stock 2019-01-03 11:17:10 +01:00
Pau Perez
cca15e75a6 Refactor to reveal how we load enterprises in shop
By sticking to Rails conventions we make it more obvious how (badly) we
are loading enterprises in EnterprisesController#shop and shed some
light on the obscure InjectionHelper.

This will also make it easier to improve its performance in the future as
it's among the top offenders. See https://www.skylight.io/app/applications/ibo3NOqCYMnq/1545851520/1d/endpoints/EnterprisesController%23shop?responseType=html
2019-01-03 11:17:10 +01:00
Maikel
ac76580932 Merge pull request #3274 from openfoodfoundation/transifex
Transifex
2019-01-03 11:35:47 +11:00
Transifex-Openfoodnetwork
89bf819b37 Updating translations for config/locales/en_US.yml 2019-01-03 00:33:56 +11:00
Pau Perez
112080d8c6 Fix menu_1_url translation for fr_BE
The first menu item in OFN BE is currently broken.
2019-01-02 13:10:33 +01:00
dependabot[bot]
8170937708 Bump webmock from 3.4.2 to 3.5.1
Bumps [webmock](https://github.com/bblimke/webmock) from 3.4.2 to 3.5.1.
- [Release notes](https://github.com/bblimke/webmock/releases)
- [Changelog](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bblimke/webmock/compare/v3.4.2...v3.5.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-12-27 19:16:35 +00:00
Pau Pérez Fabregat
d88be202a6 Merge pull request #3223 from kristinalim/fix-rubocop_block_length_ignore_rake_routes_dsl
Ignore Rake and routes DSL methods in Rubocop BlockLength
2018-12-27 17:14:57 +01:00
Pau Pérez Fabregat
755eca5abe Merge pull request #3236 from openfoodfoundation/dependabot/bundler/guard-2.15.0
Bump guard from 2.14.1 to 2.15.0
2018-12-27 17:14:32 +01:00
Alvaro Chalar
6dccbeca70 Add custom footer message in reports section 2018-12-27 12:22:48 +01:00
luisramos0
fd21914a15 Add spring, a rails preloader alternative to zeus, to our gemfile
Add /bin to gitignore, bin is used by spring, rails preloader
2018-12-26 13:36:48 +00:00
luisramos0
4eaaeb37c9 Reverting to therubyracer because mini racer is causing trouble to some developers using osx.
We will probably be able to move back to the faster mini racer when we upgrade to newer rails versions
2018-12-26 13:07:52 +00:00
Pau Pérez Fabregat
1ab50798fe Merge pull request #3189 from luisramos0/3043-i18n-emails
Make all mailers use appropriate locale when sending emails
2018-12-24 14:59:04 +01:00
albarnaz
5d515712ed Fix for instagram links (#2849)
* Add new attribute instagram_placeholder to local yml

* Add placeholder to instagram link input

* Add migration to fix wrong instagram links

* Add new attribute facebook_placeholder to local yml

* Add placeholder to facebook link input

* Add new attribute linkedin_placeholder to local yml

* Add placeholder to linkedin link input

* Change each for find_each in migration

* Add new attribute instagram_placeholder to local yml

* Add migration to fix wrong instagram links

* Add new attribute linkedin_placeholder to local yml

* Add placeholder to linkedin link input
2018-12-21 14:42:28 +11:00
Maikel
9557457ec2 Merge pull request #3088 from kristinalim/cleanup-test_scripts
Run RSpec tests in custom engines (and some fixes, cleanup)
2018-12-21 14:32:56 +11:00
dependabot[bot]
e680559169 Bump guard from 2.14.1 to 2.15.0
Bumps [guard](https://github.com/guard/guard) from 2.14.1 to 2.15.0.
- [Release notes](https://github.com/guard/guard/releases)
- [Changelog](https://github.com/guard/guard/blob/master/CHANGELOG.md)
- [Commits](https://github.com/guard/guard/compare/v2.14.1...v2.15.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-12-20 19:18:59 +00:00
Pau Pérez Fabregat
e61b7139cc Merge pull request #3212 from openfoodfoundation/dependabot/bundler/wkhtmltopdf-binary-0.12.4
Bump wkhtmltopdf-binary from 0.12.3.1 to 0.12.4
2018-12-20 16:43:24 +01:00
Pau Pérez Fabregat
0876986215 Merge pull request #3227 from openfoodfoundation/dependabot/bundler/momentjs-rails-2.20.1
Bump momentjs-rails from 2.5.1 to 2.20.1
2018-12-20 16:36:40 +01:00
dependabot[bot]
aac8706f9a Bump blockenspiel from 0.4.5 to 0.5.0
Bumps [blockenspiel](https://github.com/dazuma/blockenspiel) from 0.4.5 to 0.5.0.
- [Release notes](https://github.com/dazuma/blockenspiel/releases)
- [Changelog](https://github.com/dazuma/blockenspiel/blob/master/History.rdoc)
- [Commits](https://github.com/dazuma/blockenspiel/commits/v0.5.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-12-20 08:35:01 +00:00
Pau Pérez Fabregat
2a759a9c0d Merge pull request #3196 from openfoodfoundation/dependabot/bundler/angularjs-file-upload-rails-2.4.1
Bump angularjs-file-upload-rails from 1.1.6 to 2.4.1
2018-12-20 09:31:49 +01:00
Maikel
073f88b1c2 Merge pull request #3198 from kristinalim/fix-variant_override_stock_settings_validation
Validation and others for keeping variant override "On Demand" and "Count on Hand" compatible
2018-12-20 14:05:20 +11:00
Kristina Lim
4adae0a1e8 Disable Knapsack when running engine RSpec tests 2018-12-19 17:50:52 +08:00
Kristina Lim
a460e9d35f Allow disabling Knapsack when running RSpec tests 2018-12-19 17:50:29 +08:00
Kristina Lim
abcb71f8b3 Document running app engine RSpec tests 2018-12-19 17:11:03 +08:00
Kristina Lim
12780b722e Make Travis CI run RSpec tests in app engines 2018-12-19 17:08:27 +08:00
Kristina Lim
74ea1eee6b Add description for Rake tasks 2018-12-19 17:08:24 +08:00
Kristina Lim
571ad37c3e Add Rake task openfoodnetwork:specs:engines:rspec 2018-12-19 17:06:33 +08:00
Kristina Lim
f7e03ca60e Add Rake tasks openfoodnetwork:specs:engines:NAME:rspec
The task name follows the directory name under engines/. For example,
for the Web engine in engines/web, run:

    bundle exec rake openfoodnetwork:specs:engines:web:rspec
2018-12-19 17:02:19 +08:00
Maikel Linke
a978e992bf Remove tax_rates shortcut from adjustment
Becoming less dependent on Spree, using our own namespace, keeping
decorators small.
2018-12-19 14:42:38 +11:00
Maikel Linke
fc1b182275 Simplify method complexity and comply with rubocop 2018-12-19 14:31:29 +11:00
Maikel Linke
3169a384ba Find approximate tax rate if no other is found
There are several cases in which a tax rate is not associated with an
adjustment. We find the closest one for reporting here. It is not a good
solution, but a workaround introduced for reporting:
https://github.com/openfoodfoundation/openfoodnetwork/pull/1496
2018-12-19 14:31:29 +11:00
Maikel Linke
a341561446 Move tax rate finding into service and spec it
The `#tax_rates` method is actually not present in Spree. We encapsulate
the logic in this commit and enable better unit testing. The new tests
cover a current bug: https://github.com/openfoodfoundation/openfoodnetwork/issues/3127
2018-12-19 14:31:29 +11:00
Maikel
84f2f9af3c Merge pull request #3156 from HugsDaniel/3121-deface-payment-methods-new
[Defacepocalypse] De-deface payment methods new and form
2018-12-19 09:44:57 +11:00
dependabot[bot]
6de1844b7c Bump momentjs-rails from 2.5.1 to 2.20.1
Bumps [momentjs-rails](https://github.com/derekprior/momentjs-rails) from 2.5.1 to 2.20.1.
- [Release notes](https://github.com/derekprior/momentjs-rails/releases)
- [Changelog](https://github.com/derekprior/momentjs-rails/blob/master/news.md)
- [Commits](https://github.com/derekprior/momentjs-rails/compare/v2.5.1...v2.20.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-12-18 19:14:54 +00:00
luisramos0
5e960512ac Set user locale on user registrations #create
This is done so that user.locale is used in the first confirmation email. This also stores user.locale in the DB from registration.
2018-12-18 15:30:01 +00:00
luisramos0
a9222665b8 Refactor user registrations controller, early return to reduce indentation 2018-12-18 15:26:49 +00:00
Maikel
f36c045425 Merge pull request #3213 from kristinalim/fix-rubocop_block_length_ignore_it
Ignore `it` in Rubocop BlockLength
2018-12-18 11:42:14 +11:00
Matt-Yorkley
d34b8c52b8 Update all locales with the latest Transifex translations 2018-12-17 11:17:54 +00:00
Pau Pérez Fabregat
54775f6b6a Merge pull request #3221 from zvkemp/skylight-1.7.2
update Skylight to 1.7.2
2018-12-17 10:44:16 +01:00
Pau Pérez Fabregat
1876ec42dc Merge pull request #3201 from kevinchristianson/add-missing-stars
Add missing 'required field' stars in new product form
2018-12-17 10:36:51 +01:00
Pau Pérez Fabregat
554d650b8c Merge pull request #3176 from kevinchristianson/button-translation-fix
Fix untranslated buttons at image step of registration modal
2018-12-17 10:36:07 +01:00
Pau Pérez Fabregat
2deffb9c9f Merge pull request #3076 from Matt-Yorkley/orders_checkboxes
Fix checkbox values on orders page
2018-12-17 10:35:46 +01:00
Kristina Lim
216c598e74 Ignore more methods in Metrics/BlockLength cop
Ignore these additional methods:

* collection
* member
* namespace
* resource
* resources
2018-12-17 05:21:20 +08:00
Kristina Lim
fb5a9356dc Fix spec_helper.rb of web engine
This fixes the tests of the web engine when running the following from
its root: bundle exec rspec

An engine is meant to have some independence from the main application,
and its tests should be run independently.

This should be using the engine's own dummy application, actually, or
the dummy application of a dependency.
2018-12-15 16:11:15 +08:00
Kristina Lim
93940ced3a Remove outdated comment recommending knapsack
We are already using this.
2018-12-15 16:11:12 +08:00
zvkemp
d3d43c8808 update Skylight to 1.7.2 2018-12-14 12:25:41 -08:00
Pau Pérez Fabregat
fe0c56c800 Merge pull request #3174 from kevinchristianson/footer-url-fix
Fix broken registration link in footer
2018-12-14 15:42:08 +01:00
dependabot[bot]
2f19b37b54 Bump angularjs-file-upload-rails from 1.1.6 to 2.4.1
Bumps [angularjs-file-upload-rails](https://github.com/marthyn/angularjs-file-upload-rails) from 1.1.6 to 2.4.1.
- [Release notes](https://github.com/marthyn/angularjs-file-upload-rails/releases)
- [Commits](https://github.com/marthyn/angularjs-file-upload-rails/commits/v2.4.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-12-14 14:29:42 +00:00
Pau Pérez Fabregat
34a42cc592 Merge pull request #3181 from luisramos0/roadie-rails-upgrade
Bump roadie-rails from 1.0.3 to 1.1.1
2018-12-14 15:26:25 +01:00
Kristina Lim
d0d10eba4b Ignore it method in Rubocop BlockLength 2018-12-14 17:44:19 +08:00
Kristina Lim
77a6562762 Make DB migration generate summary by distributor 2018-12-14 13:02:43 +08:00
Kristina Lim
a6664d0ac6 Move report generated by migration to subdirectory
This is in preparation of an upcoming change to split the main CSV file
by distributor.
2018-12-14 13:00:42 +08:00
Kristina Lim
91e5a523f0 Add /reports/ to .gitignore but ignore README
Using the first slash to make sure that other reports/ directories are
not ignored.
2018-12-14 10:25:23 +08:00
Kristina Lim
d859939c79 Add README.md to reports/ directory 2018-12-14 10:24:26 +08:00
Kristina Lim
6458127892 Add undo logic for DB migration script 2018-12-14 10:09:09 +08:00
Kristina Lim
5a98acd101 Log changes from DB migration to CSV file 2018-12-14 10:09:09 +08:00
Kristina Lim
842a11b564 Refactor DB migration script 2018-12-14 10:09:08 +08:00
dependabot[bot]
2ecec93514 Bump wkhtmltopdf-binary from 0.12.3.1 to 0.12.4
Bumps [wkhtmltopdf-binary](https://github.com/zakird/wkhtmltopdf_binary_gem) from 0.12.3.1 to 0.12.4.
- [Release notes](https://github.com/zakird/wkhtmltopdf_binary_gem/releases)
- [Changelog](https://github.com/zakird/wkhtmltopdf_binary_gem/blob/master/CHANGELOG)
- [Commits](https://github.com/zakird/wkhtmltopdf_binary_gem/compare/0.12.3.1...0.12.4)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-12-13 19:19:36 +00:00
Pau Pérez Fabregat
2eb6d0a047 Merge pull request #3185 from openfoodfoundation/dependabot/bundler/oj-3.7.4
Bump oj from 3.6.10 to 3.7.4
2018-12-13 18:10:55 +01:00
Kristina Lim
aa92dd8771 Declare VariantOverride in migration for safe use 2018-12-13 23:29:05 +08:00
Kristina Lim
9e3332ba2a Rename DB migration file 2018-12-13 23:25:48 +08:00
Maikel
eb016c0471 Merge pull request #3145 from openfoodfoundation/dependabot/bundler/i18n-js-3.1.0
Bump i18n-js from 3.0.11 to 3.1.0
2018-12-13 10:58:22 +11:00
Pau Pérez Fabregat
d317603872 Merge pull request #3187 from openfoodfoundation/dependabot/bundler/rspec-rails-3.8.1
Bump rspec-rails from 3.7.2 to 3.8.1
2018-12-12 17:14:05 +01:00
Pau Pérez Fabregat
64e41712c6 Merge pull request #3130 from coopdevs/extract-restart-checkout
Extract restart checkout
2018-12-12 17:12:53 +01:00
luisramos0
e274442d77 Cover i18nhelper.valid_locale and user mailer with tests related to localized emails 2018-12-11 11:16:50 +00:00
haseleyi
835617159e Add missing 'required field' stars in new product form 2018-12-10 18:02:39 -08:00
Matt-Yorkley
0c5ac99e0f Fix multiple results with 'inventory_items_shipment_id_null' ransack query
The q['inventory_items_shipment_id_null'] search element was generating duplicates where there were multiple line items on an order that were ready to be shipped, with id = null
2018-12-10 20:48:53 +00:00
Matt-Yorkley
e711c5ed03 Add spec for search filters 2018-12-10 20:48:53 +00:00
Matt-Yorkley
d48774e3a2 Add comment 2018-12-10 20:48:53 +00:00
Matt-Yorkley
997169b974 Fix checkbox values on orders page 2018-12-10 20:48:53 +00:00
luisramos0
38ff99717a Fix bug on calculator_decorator line_items_for where input is line_item with an nil order. Adapted line_items_for so that weight_calculator.line_items_for could be removed. 2018-12-09 19:37:11 +00:00
Kristina Lim
df51d137dc Update some code style for product import 2018-12-10 03:30:52 +08:00
Kristina Lim
cec50e81f5 Make product import set correct VO stock settings 2018-12-10 03:30:46 +08:00
Kristina Lim
0de829017a Refactor finding or initializing VO for product import 2018-12-10 03:30:39 +08:00
Kristina Lim
c873a7b8e3 Move stock settings override validation to concern 2018-12-09 23:29:36 +08:00
Kristina Lim
1bfdb708c1 Add app/models/concerns to autoload path 2018-12-09 23:29:36 +08:00
Kristina Lim
d67b3faf01 Address affected specs from new VO validations 2018-12-09 21:48:08 +08:00
Kristina Lim
34313c94ca Make reset stock settings for VO force limited stock 2018-12-09 21:47:05 +08:00
Kristina Lim
ad35ea1102 Add factory stock traits for variant overrides 2018-12-09 21:47:05 +08:00
Kristina Lim
210a11783c Test that saving invalid variant override provides error 2018-12-09 21:43:57 +08:00
Kristina Lim
4c0c0bbfd0 Simplify stock configuration in existing variant overrides 2018-12-07 14:40:15 +08:00
Kristina Lim
83b6973bc2 Require compatible VO on_demand and count_on_hand 2018-12-07 14:39:36 +08:00
Maikel
046ba14da4 Merge pull request #3191 from openfoodfoundation/dependabot/bundler/knapsack-1.17.1
Bump knapsack from 1.16.0 to 1.17.1
2018-12-07 15:18:25 +11:00
haseleyi
3f6e96dd5d Fix comment 2018-12-06 14:07:45 -08:00
haseleyi
4a0744dd94 Add comment to explain hard-coded link 2018-12-06 11:49:39 -08:00
dependabot[bot]
6ae2df7b92 Bump knapsack from 1.16.0 to 1.17.1
Bumps [knapsack](https://github.com/ArturT/knapsack) from 1.16.0 to 1.17.1.
- [Release notes](https://github.com/ArturT/knapsack/releases)
- [Changelog](https://github.com/ArturT/knapsack/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ArturT/knapsack/compare/v1.16.0...v1.17.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-12-06 19:16:09 +00:00
luisramos0
b9b91231ae Fix rubocop issues in mailers 2018-12-06 14:18:24 +00:00
luisramos0
0f442a911e Improve I18nHelper.valid_locale to handle empty objects 2018-12-06 12:48:48 +00:00
luisramos0
feea499298 Make all mailers use appropriate locale when sending emails 2018-12-06 11:45:44 +00:00
Kristina Lim
71db9f5289 Import CSS variables in admin/components/input 2018-12-06 14:08:06 +08:00
luisramos0
c33ca508f7 Add guard clause on variant overrides filter in case hub id is not present in the hubPermissions 2018-12-06 15:35:44 +11:00
Maikel
3a3c9f3847 Merge pull request #3177 from coopdevs/dont-clean-db-twice-in-feature-specs
Do not clean DB twice on feature specs
2018-12-06 12:36:34 +11:00
haseleyi
75277e92e4 Lazy-load the translations for images step of registration 2018-12-05 11:36:27 -08:00
dependabot[bot]
727cc9d578 Bump rspec-rails from 3.7.2 to 3.8.1
Bumps [rspec-rails](https://github.com/rspec/rspec-rails) from 3.7.2 to 3.8.1.
- [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.7.2...v3.8.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-12-05 19:19:50 +00:00
dependabot[bot]
ebff8be996 Bump oj from 3.6.10 to 3.7.4
Bumps [oj](https://github.com/ohler55/oj) from 3.6.10 to 3.7.4.
- [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.6.10...v3.7.4)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-12-05 19:16:55 +00:00
luisramos0
bbc61b4eda Bump roadie-rails to 1.1.1 2018-12-05 15:11:45 +00:00
Pau Pérez Fabregat
1052d98255 Merge pull request #3175 from haseleyi/patch-1
Fix link to Mac setup guide in Getting Started
2018-12-05 12:52:08 +01:00
Kristina Lim
842a8e3654 Move null option for VO use_producer_settings to JS 2018-12-05 17:40:32 +08:00
Kristina Lim
802e3bb447 Refactor choosing VO on_demand in feature specs
We are still using the Rails view I18n scope for :use_producer_settings.
Angular requires this replacement of the default blank option, which we
use for nil on_demand, to be in the template itself.

If we eventually move this template to a JS template, we can move it to
the same I18n scope as the :yes and :no options.
2018-12-05 17:40:31 +08:00
Kristina Lim
d8908bdf4b Remove unused translation keys js.yes and js.no 2018-12-05 17:40:31 +08:00
Kristina Lim
47d51ca525 Prefer guard clause in updateCountOnHand for VOs 2018-12-05 17:40:31 +08:00
Kristina Lim
34c34b94d1 Describe method countOnHandPlaceholder for VOs 2018-12-05 17:40:30 +08:00
Kristina Lim
cff4eb0005 Improve and simplify VO count on hand suggestions
Set variant override count_on_hand in UI to variant count_on_hand value
if on_demand is changed and both specify limited stock.
2018-12-05 17:40:30 +08:00
Kristina Lim
4f2d96d763 Use correct placeholders for VO count_on_hand 2018-12-05 17:40:29 +08:00
Kristina Lim
f5dc03e118 Style disabled text fields in admin pages 2018-12-05 17:40:29 +08:00
Kristina Lim
09b9f968b7 Make VO count on hand readonly unless limited stock 2018-12-05 17:40:29 +08:00
Kristina Lim
cc003c99d5 Ensure in UI compatible VO count and on demand 2018-12-05 17:40:28 +08:00
Kristina Lim
a32bb0445f Change translation for variant override use_producer_settings 2018-12-05 17:40:28 +08:00
Kristina Lim
7ae555cd9c Translate variant override on_demand yes and no 2018-12-05 17:40:27 +08:00
Kristina Lim
4b3198a2b4 Allow reset of "on demand" for variant overrides
Change the UI control for "on demand" in the Inventory page from a
checkbox to a SELECT field with three options: nil, true, and false.

This resolves the following issues:
* There is no way to tell between nil and false - both are represented
by an unticked checkbox.
* There is no way to go back to nil.
2018-12-05 17:40:24 +08:00
Pau Perez
25567d6bd6 Do not clean DB twice on feature specs
It turns out that we were executing `DatabaseCleaner.clean` on two
`after(:each)` blocks. One for all specs and another one for `js: true`
specs. As a result feature specs were hitting both which slows them down
considerably.

On my machine this changes consistently saves 2sec on
`spec/features/consumer/shops_spec.rb` but chances are it has an
accumulative effect when run on the whole test suite.
2018-12-05 09:58:14 +01:00
Pau Pérez Fabregat
3b56212290 Merge pull request #3151 from coopdevs/remove-frontoffice-enterprises-n+1
Remove frontoffice enterprises n+1
2018-12-05 08:12:19 +01:00
Pau Pérez Fabregat
e5a267f4c2 Merge pull request #2735 from luisramos0/cookies_colors
Moved definition of colors in the cookies modal and banner colors to common darkswarm/base/colors
2018-12-05 08:06:58 +01:00
haseleyi
94d12217de Fix untranslated buttons at image step of registration modal 2018-12-04 21:30:42 -08:00
Isaac Haseley
76e5d281bf Fix link for Mac setup guide 2018-12-04 20:37:23 -08:00
Maikel
609a4fde4d Merge pull request #3173 from openfoodfoundation/transifex
Transifex
2018-12-05 11:55:29 +11:00
Transifex-Openfoodnetwork
18a5f53330 Updating translations for config/locales/fr.yml 2018-12-05 09:17:00 +11:00
haseleyi
e863c3dec8 Fix broken link in register call partial 2018-12-04 10:23:46 -08:00
Transifex-Openfoodnetwork
9bedc69df8 Updating translations for config/locales/en_GB.yml 2018-12-05 04:52:44 +11:00
Hugo Daniel
24dab58de7 Lazy load translations and add keys 2018-11-30 10:49:36 +01:00
luisramos0
1c5d94472f Make colors.css relative reference to branding.css an absolute reference so that colors can be imported in engines 2018-11-29 18:39:58 +00:00
Hugo Daniel
aa948552e1 Import payment_methods edit view and apply overrides 2018-11-29 14:58:14 +01:00
Hugo Daniel
34bc79c7f6 Import payment_methods form partial and apply overrides 2018-11-29 14:58:06 +01:00
Hugo Daniel
29bc4c52a5 Import payment_methods#new view and apply overrides 2018-11-29 14:56:28 +01:00
luisramos0
93e1310deb Fixed bug in cookies css, import colors, not branding 2018-11-29 11:47:51 +00:00
luisramos0
cdc5899791 Moved cookies policy modal and cookies banner colors to darkswarm/base/colors.scss 2018-11-29 11:47:51 +00:00
Pau Perez
96202ab00d Fix Rubocop violations 2018-11-28 16:23:56 +01:00
Pau Perez
e0f43191e2 Make helper methods private
Otherwise next dev might think these are attributes of the resulting
JSON serialized object.

They just made the refactoring a bit easier.
2018-11-28 16:21:40 +01:00
Pau Perez
c330d931ce Eager load product properties to avoid N+1
This totally removes the following N+1 query from the GET /shops request

```sql
SELECT "spree_properties".* FROM "spree_properties"
  INNER JOIN "spree_product_properties"
    ON "spree_product_properties"."property_id" = "spree_properties"."id"
  INNER JOIN "spree_products"
    ON "spree_products"."id" = "spree_product_properties"."product_id"
  INNER JOIN "enterprises"
    ON "enterprises"."id" = "spree_products"."supplier_id"
  WHERE "spree_products"."supplier_id" = 24;
```

The product properties of the corresponding enterprises are now loaded
in a single query fired from the controller.
2018-11-28 16:21:40 +01:00
Pau Perez
4608c434b4 Eager load producer properties to avoid N+1
This totally removes the following N+1 query from the GET /shops request

```sql
SELECT "spree_properties".* FROM "spree_properties"
  INNER JOIN "producer_properties"
    ON "spree_properties"."id" = "producer_properties"."property_id"
  WHERE "producer_properties"."producer_id" = 17
  ORDER BY producer_properties.position;
```

The producer properties of the corresponding enterprises are now loaded
in a single query fired from the controller.
2018-11-28 16:21:40 +01:00
Pau Perez
e40c1c08ca Refactor spec to not stub the class under test
This also relies on ActiveRecord which will come in handy as we move on
the refactor.
2018-11-28 16:21:40 +01:00
Pau Perez
149fc1ac6f Inline PropertyMerge's #merge into serializer
Now that it has become a plain Ruby #uniq, there's no point on having
the abstraction and indirection.
2018-11-28 16:21:40 +01:00
Pau Perez
faac5f4b2d Refactor PropertyMerge to use Ruby's #uniq instead 2018-11-28 16:21:40 +01:00
Pau Perez
1363a2a17d Improve readability of spec 2018-11-28 16:21:40 +01:00
Pau Perez
8e1f9a1ba3 Refactor #product_properties not to fetch ids 2018-11-28 16:21:40 +01:00
Pau Perez
bc7258d43b Test #supplied_properties helper methods 2018-11-28 16:21:40 +01:00
Pau Perez
23f629cfd6 Autofix all Rubocop violations in serializer 2018-11-28 13:54:42 +01:00
Pau Perez
c6ab5feb81 Move cached & uncached serializers to their files 2018-11-28 13:54:42 +01:00
Pau Perez
41d988176c Pass enterprises to inject method from controller 2018-11-28 13:54:42 +01:00
Pau Perez
5a85d7a77b RSpec3-ize controller spec 2018-11-28 13:54:42 +01:00
dependabot[bot]
7b95e3a8d7 Bump i18n-js from 3.0.11 to 3.1.0
Bumps [i18n-js](https://github.com/fnando/i18n-js) from 3.0.11 to 3.1.0.
- [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.0.11...v3.1.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-11-27 19:17:57 +00:00
Pau Perez
453b2a99de Rename redundant #restart_checkout to #call 2018-11-23 12:05:39 +01:00
Pau Perez
88afa70f37 Simplify and speed up service tests 2018-11-23 12:04:42 +01:00
Pau Perez
2c8a1f5e78 Check for value and not object identity in spec 2018-11-23 12:04:42 +01:00
Pau Perez
99463427ce Refactor RestartCheckout service just extracted 2018-11-23 12:04:42 +01:00
Pau Perez
3b681a59ba Move controller tests to service class tests 2018-11-23 12:04:42 +01:00
Pau Perez
a62a2cb52f Extract #restart_checkout to a service 2018-11-23 12:04:42 +01:00
Matt-Yorkley
9011f5d9a2 Rescue ArgumentError and give user feedback 2018-11-07 18:48:08 +00:00
Matt-Yorkley
b5c6ecb45a Explicitly use UTF-8 encoding when opening spreadsheet files 2018-11-07 16:50:24 +00:00
479 changed files with 30843 additions and 10240 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. -->

4
.gitignore vendored
View File

@@ -33,7 +33,6 @@ public/images
public/spree
config/abr.yml
config/initializers/feature_toggle.rb
config/initializers/db2fog.rb
NERD_tree*
coverage
libpeerconnection.log
@@ -41,3 +40,6 @@ libpeerconnection.log
node_modules
vendor/bundle/
coverage
/reports/
!/reports/README.md
bin/

View File

@@ -25,7 +25,6 @@ Metrics/LineLength:
- 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
@@ -47,7 +46,6 @@ Metrics/LineLength:
- app/controllers/base_controller.rb
- app/controllers/cart_controller.rb
- app/controllers/checkout_controller.rb
- app/controllers/enterprises_controller.rb
- app/controllers/shop_controller.rb
- app/controllers/spree/admin/adjustments_controller_decorator.rb
- app/controllers/spree/admin/base_controller_decorator.rb
@@ -100,7 +98,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
@@ -320,7 +317,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
@@ -350,7 +346,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
@@ -413,7 +408,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
@@ -435,7 +429,6 @@ Metrics/AbcSize:
- app/controllers/cart_controller.rb
- app/controllers/checkout_controller.rb
- app/controllers/discourse_sso_controller.rb
- app/controllers/enterprises_controller.rb
- app/controllers/spree/admin/adjustments_controller_decorator.rb
- app/controllers/spree/admin/line_items_controller_decorator.rb
- app/controllers/spree/admin/orders_controller_decorator.rb

View File

@@ -187,13 +187,15 @@ Metrics/AbcSize:
Max: 15
Metrics/BlockLength:
ExcludedMethods: ["describe", "context"]
ExcludedMethods: ["collection", "context", "describe", "it", "member", "namespace", "resource", "resources"]
Metrics/BlockNesting:
Max: 3
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

@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --exclude-limit 1400`
# on 2018-10-25 13:57:32 +1100 using RuboCop version 0.57.2.
# on 2019-01-02 13:44:41 +0100 using RuboCop version 0.57.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
@@ -20,14 +20,11 @@ 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/controllers/cart_controller_spec.rb'
- 'spec/lib/open_food_network/order_grouper_spec.rb'
- 'spec/services/cart_service_spec.rb'
# Offense count: 121
# Offense count: 122
# Cop supports --auto-correct.
# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
# SupportedHashRocketStyles: key, separator, table
@@ -56,8 +53,9 @@ Layout/AlignHash:
- 'spec/models/order_cycle_spec.rb'
- 'spec/models/spree/shipping_method_spec.rb'
- 'spec/models/spree/variant_spec.rb'
- 'spec/models/variant_override_spec.rb'
# Offense count: 60
# Offense count: 49
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: with_first_parameter, with_fixed_indentation
@@ -68,7 +66,6 @@ Layout/AlignParameters:
- 'app/models/enterprise_group.rb'
- 'app/models/enterprise_relationship.rb'
- 'app/serializers/api/address_serializer.rb'
- 'app/serializers/api/enterprise_serializer.rb'
- 'app/serializers/api/shipping_method_serializer.rb'
- 'lib/spree/product_filters.rb'
- 'spec/controllers/enterprises_controller_spec.rb'
@@ -94,11 +91,12 @@ Layout/BlockAlignment:
- 'spec/models/spree/line_item_spec.rb'
- 'spec/models/spree/product_spec.rb'
# Offense count: 1
# Offense count: 2
# Cop supports --auto-correct.
Layout/BlockEndNewline:
Exclude:
- 'spec/features/consumer/shopping/cart_spec.rb'
- 'spec/models/variant_override_spec.rb'
# Offense count: 1
# Cop supports --auto-correct.
@@ -124,7 +122,7 @@ Layout/ElseAlignment:
- 'app/serializers/api/admin/order_cycle_serializer.rb'
- 'lib/open_food_network/sales_tax_report.rb'
# Offense count: 197
# Offense count: 187
# Cop supports --auto-correct.
Layout/EmptyLines:
Exclude:
@@ -137,7 +135,6 @@ Layout/EmptyLines:
- 'app/controllers/spree/admin/adjustments_controller_decorator.rb'
- 'app/controllers/spree/admin/base_controller_decorator.rb'
- 'app/controllers/spree/admin/general_settings_controller_decorator.rb'
- 'app/controllers/spree/admin/orders_controller_decorator.rb'
- 'app/controllers/spree/admin/payments_controller_decorator.rb'
- 'app/controllers/spree/admin/products_controller_decorator.rb'
- 'app/controllers/spree/admin/variants_controller_decorator.rb'
@@ -148,16 +145,12 @@ Layout/EmptyLines:
- 'app/jobs/finalize_account_invoices.rb'
- 'app/jobs/products_cache_integrity_checker_job.rb'
- 'app/jobs/refresh_products_cache_job.rb'
- 'app/mailers/producer_mailer.rb'
- 'app/models/coordinator_fee.rb'
- 'app/models/enterprise_fee.rb'
- 'app/models/enterprise_relationship.rb'
- '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'
@@ -176,7 +169,6 @@ Layout/EmptyLines:
- 'app/models/spree/shipping_method_decorator.rb'
- 'app/models/spree/tax_rate_decorator.rb'
- 'app/models/spree/taxon_decorator.rb'
- 'app/serializers/api/enterprise_serializer.rb'
- 'lib/open_food_network/cached_products_renderer.rb'
- 'lib/open_food_network/enterprise_fee_applicator.rb'
- 'lib/open_food_network/enterprise_issue_validator.rb'
@@ -188,7 +180,6 @@ Layout/EmptyLines:
- 'lib/open_food_network/products_cache.rb'
- 'lib/open_food_network/products_cache_integrity_checker.rb'
- 'lib/open_food_network/products_renderer.rb'
- 'lib/open_food_network/property_merge.rb'
- 'lib/open_food_network/reports/bulk_coop_report.rb'
- 'lib/open_food_network/sales_tax_report.rb'
- 'lib/open_food_network/scope_product_to_hub.rb'
@@ -239,19 +230,16 @@ 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'
- 'spec/models/spree/product_spec.rb'
- 'spec/models/spree/shipping_method_spec.rb'
- 'spec/models/spree/variant_spec.rb'
- 'spec/models/variant_override_spec.rb'
- 'spec/serializers/admin/exchange_serializer_spec.rb'
- 'spec/serializers/admin/for_order_cycle/enterprise_serializer_spec.rb'
- 'spec/serializers/admin/for_order_cycle/supplied_product_serializer_spec.rb'
- 'spec/serializers/credit_card_serializer_spec.rb'
- 'spec/services/cart_service_spec.rb'
- 'spec/support/delayed_job_helper.rb'
- 'spec/support/matchers/table_matchers.rb'
@@ -261,15 +249,13 @@ Layout/EmptyLinesAroundArguments:
Exclude:
- 'spec/archive/features/consumer/checkout_spec.rb'
# Offense count: 59
# Offense count: 51
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, no_empty_lines
Layout/EmptyLinesAroundBlockBody:
Exclude:
- 'app/controllers/spree/admin/orders_controller_decorator.rb'
- 'app/controllers/spree/api/orders_controller_decorator.rb'
- 'app/controllers/spree/api/products_controller_decorator.rb'
- 'app/controllers/spree/checkout_controller_decorator.rb'
- 'app/models/spree/calculator/default_tax_decorator.rb'
- 'app/models/spree/calculator_decorator.rb'
@@ -279,21 +265,17 @@ Layout/EmptyLinesAroundBlockBody:
- 'lib/spree/money_decorator.rb'
- 'spec/controllers/admin/order_cycles_controller_spec.rb'
- 'spec/controllers/admin/tag_rules_controller_spec.rb'
- 'spec/controllers/spree/admin/orders_controller_spec.rb'
- 'spec/controllers/spree/admin/reports_controller_spec.rb'
- 'spec/controllers/spree/api/orders_controller_spec.rb'
- 'spec/controllers/spree/orders_controller_spec.rb'
- 'spec/controllers/user_confirmations_controller_spec.rb'
- 'spec/controllers/user_registrations_controller_spec.rb'
- 'spec/features/admin/caching_spec.rb'
- 'spec/features/admin/orders_spec.rb'
- 'spec/features/admin/reports_spec.rb'
- 'spec/features/admin/variant_overrides_spec.rb'
- 'spec/features/consumer/cookies_spec.rb'
- 'spec/features/consumer/shopping/embedded_groups_spec.rb'
- 'spec/features/consumer/shopping/embedded_shopfronts_spec.rb'
- 'spec/features/consumer/shopping/shopping_spec.rb'
- 'spec/features/consumer/shopping/variant_overrides_spec.rb'
- 'spec/helpers/admin/business_model_configuration_helper_spec.rb'
- 'spec/helpers/shared_helper_spec.rb'
- 'spec/helpers/shop_helper_spec.rb'
@@ -305,7 +287,6 @@ Layout/EmptyLinesAroundBlockBody:
- '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'
@@ -317,21 +298,19 @@ Layout/EmptyLinesAroundBlockBody:
- 'spec/support/matchers/select2_matchers.rb'
- 'spec/support/matchers/table_matchers.rb'
# Offense count: 24
# Offense count: 23
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# 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'
- 'app/controllers/api/enterprises_controller.rb'
- 'app/controllers/application_controller.rb'
- 'app/controllers/home_controller.rb'
- 'app/mailers/producer_mailer.rb'
- 'app/models/coordinator_fee.rb'
- 'app/models/producer_property.rb'
- 'app/models/spree/preferences/file_configuration.rb'
@@ -358,7 +337,7 @@ Layout/EndAlignment:
- 'app/serializers/api/admin/for_order_cycle/supplied_product_serializer.rb'
- 'app/serializers/api/admin/order_cycle_serializer.rb'
# Offense count: 47
# Offense count: 45
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
Layout/ExtraSpacing:
@@ -368,7 +347,6 @@ Layout/ExtraSpacing:
- 'app/helpers/admin/injection_helper.rb'
- 'app/models/enterprise.rb'
- 'app/models/spree/classification_decorator.rb'
- 'app/serializers/api/enterprise_serializer.rb'
- 'config.ru'
- 'lib/open_food_network/bulk_coop_report.rb'
- 'lib/open_food_network/option_value_namer.rb'
@@ -453,7 +431,7 @@ Layout/IndentationWidth:
- 'spec/models/enterprise_spec.rb'
- 'spec/models/spree/calculator/flexi_rate_spec.rb'
# Offense count: 44
# Offense count: 43
# Cop supports --auto-correct.
Layout/LeadingCommentSpace:
Exclude:
@@ -463,7 +441,6 @@ Layout/LeadingCommentSpace:
- 'app/models/spree/inventory_unit_decorator.rb'
- 'app/models/spree/taxon_decorator.rb'
- 'app/serializers/api/address_serializer.rb'
- 'app/serializers/api/enterprise_serializer.rb'
- 'app/serializers/api/product_serializer.rb'
- 'spec/archive/features/consumer/checkout_spec.rb'
- 'spec/controllers/spree/api/line_items_controller_spec.rb'
@@ -479,7 +456,7 @@ Layout/LeadingCommentSpace:
- 'spec/support/matchers/select2_matchers.rb'
- 'spec/support/request/authentication_workflow.rb'
# Offense count: 44
# Offense count: 45
# Cop supports --auto-correct.
Layout/MultilineBlockLayout:
Exclude:
@@ -499,6 +476,7 @@ Layout/MultilineBlockLayout:
- 'spec/models/order_cycle_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'
# Offense count: 4
@@ -645,7 +623,7 @@ Layout/SpaceAroundEqualsInParameterDefault:
- 'spec/support/request/distribution_helper.rb'
- 'spec/support/request/web_helper.rb'
# Offense count: 55
# Offense count: 50
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Layout/SpaceAroundOperators:
@@ -656,11 +634,9 @@ Layout/SpaceAroundOperators:
- 'app/overrides/remove_search_bar.rb'
- 'app/overrides/remove_side_bar.rb'
- 'app/overrides/replace_shipping_address_form_with_distributor_details.rb'
- 'app/serializers/api/enterprise_serializer.rb'
- 'lib/open_food_network/xero_invoices_report.rb'
- 'lib/spree/product_filters.rb'
- 'spec/controllers/admin/enterprises_controller_spec.rb'
- 'spec/controllers/cart_controller_spec.rb'
- 'spec/features/admin/bulk_order_management_spec.rb'
- 'spec/features/admin/bulk_product_update_spec.rb'
- 'spec/features/consumer/shopping/checkout_spec.rb'
@@ -721,7 +697,7 @@ Layout/SpaceInsideArrayLiteralBrackets:
- 'spec/lib/open_food_network/users_and_enterprises_report_spec.rb'
- 'spec/models/spree/order_spec.rb'
# Offense count: 194
# Offense count: 192
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
# SupportedStyles: space, no_space
@@ -759,7 +735,6 @@ Layout/SpaceInsideBlockBraces:
- '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'
@@ -774,14 +749,13 @@ Layout/SpaceInsideBlockBraces:
- 'spec/spec_helper.rb'
- 'spec/support/cancan_helper.rb'
# Offense count: 728
# Offense count: 702
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
# SupportedStyles: space, no_space, compact
# 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'
@@ -825,7 +799,6 @@ Layout/SpaceInsideHashLiteralBraces:
- 'spec/controllers/admin/order_cycles_controller_spec.rb'
- 'spec/controllers/admin/subscriptions_controller_spec.rb'
- 'spec/controllers/api/statuses_controller_spec.rb'
- 'spec/controllers/cart_controller_spec.rb'
- 'spec/controllers/checkout_controller_spec.rb'
- 'spec/controllers/enterprises_controller_spec.rb'
- 'spec/controllers/shop_controller_spec.rb'
@@ -845,7 +818,6 @@ Layout/SpaceInsideHashLiteralBraces:
- 'spec/features/admin/reports_spec.rb'
- 'spec/features/consumer/shopping/checkout_spec.rb'
- 'spec/helpers/checkout_helper_spec.rb'
- 'spec/helpers/i18n_helper_spec.rb'
- 'spec/helpers/order_cycles_helper_spec.rb'
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
- 'spec/lib/open_food_network/feature_toggle_spec.rb'
@@ -861,7 +833,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'
@@ -877,7 +848,6 @@ Layout/SpaceInsideHashLiteralBraces:
- 'spec/requests/checkout/failed_checkout_spec.rb'
- 'spec/requests/checkout/stripe_connect_spec.rb'
- 'spec/serializers/enterprise_serializer_spec.rb'
- 'spec/services/cart_service_spec.rb'
- 'spec/services/order_syncer_spec.rb'
- 'spec/services/subscription_form_spec.rb'
- 'spec/spec_helper.rb'
@@ -915,15 +885,7 @@ Layout/Tab:
- 'spec/lib/spree/product_filters_spec.rb'
- 'spec/models/spree/line_item_spec.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: final_newline, final_blank_line
Layout/TrailingBlankLines:
Exclude:
- 'spec/controllers/cart_controller_spec.rb'
# Offense count: 60
# Offense count: 57
# Cop supports --auto-correct.
# Configuration parameters: AllowInHeredoc.
Layout/TrailingWhitespace:
@@ -939,7 +901,6 @@ Layout/TrailingWhitespace:
- 'app/views/json/partials/_producer.rabl'
- 'spec/controllers/admin/column_preferences_controller_spec.rb'
- 'spec/features/admin/customers_spec.rb'
- 'spec/features/admin/variant_overrides_spec.rb'
- 'spec/features/consumer/cookies_spec.rb'
- 'spec/helpers/enterprises_helper_spec.rb'
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
@@ -952,9 +913,10 @@ Layout/TrailingWhitespace:
- 'spec/serializers/enterprise_serializer_spec.rb'
- 'spec/support/request/menu_helper.rb'
# Offense count: 1
# Offense count: 2
Lint/AmbiguousOperator:
Exclude:
- 'spec/controllers/api/enterprise_fees_controller_spec.rb'
- 'spec/controllers/spree/admin/payments_controller_spec.rb'
# Offense count: 4
@@ -963,14 +925,13 @@ Lint/DuplicateMethods:
- 'lib/discourse/single_sign_on.rb'
- 'lib/open_food_network/subscription_summary.rb'
# Offense count: 16
# Offense count: 15
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'
- 'lib/open_food_network/property_merge.rb'
- 'spec/lib/open_food_network/reports/report_spec.rb'
# Offense count: 2
@@ -1070,18 +1031,17 @@ Lint/UnusedMethodArgument:
- 'lib/open_food_network/paperclippable.rb'
- 'lib/open_food_network/rack_request_blocker.rb'
# Offense count: 6
# Offense count: 5
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
Lint/UselessAccessModifier:
Exclude:
- 'app/models/column_preference.rb'
- 'lib/open_food_network/feature_toggle.rb'
- 'lib/open_food_network/products_cache.rb'
- 'lib/open_food_network/property_merge.rb'
- 'lib/open_food_network/reports/bulk_coop_report.rb'
- 'spec/lib/open_food_network/reports/report_spec.rb'
# Offense count: 242
# Offense count: 240
# Configuration parameters: CheckForMethodsWithNoSideEffects.
Lint/Void:
Exclude:
@@ -1092,7 +1052,6 @@ Lint/Void:
- 'spec/controllers/enterprises_controller_spec.rb'
- 'spec/controllers/shop_controller_spec.rb'
- 'spec/controllers/spree/admin/adjustments_controller_spec.rb'
- 'spec/controllers/spree/admin/orders_controller_spec.rb'
- 'spec/controllers/spree/admin/variants_controller_spec.rb'
- 'spec/controllers/spree/api/products_controller_spec.rb'
- 'spec/controllers/spree/api/variants_controller_spec.rb'
@@ -1116,7 +1075,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'
@@ -1136,53 +1094,26 @@ Lint/Void:
- 'spec/serializers/enterprise_serializer_spec.rb'
- 'spec/support/request/web_helper.rb'
# Offense count: 192
Metrics/AbcSize:
Max: 293
# Offense count: 1039
# Offense count: 110
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 787
# Offense count: 1
# Configuration parameters: CountBlocks.
Metrics/BlockNesting:
Max: 4
# Offense count: 23
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 331
Max: 117
# Offense count: 36
Metrics/CyclomaticComplexity:
Max: 23
# Offense count: 2717
# Offense count: 1
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 619
Max: 141
# Offense count: 161
# Offense count: 1
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 95
# Offense count: 27
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 633
# Offense count: 6
# Configuration parameters: CountKeywordArgs.
Metrics/ParameterLists:
Max: 8
# Offense count: 28
Metrics/PerceivedComplexity:
Max: 21
Max: 14
# Offense count: 7
Naming/AccessorMethodName:
@@ -1237,7 +1168,7 @@ Naming/PredicateName:
- 'lib/open_food_network/packing_report.rb'
- 'lib/tasks/data.rake'
# Offense count: 13
# Offense count: 12
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: io, id, to, by, on, in, at
Naming/UncommunicativeMethodParamName:
@@ -1247,7 +1178,6 @@ Naming/UncommunicativeMethodParamName:
- 'app/helpers/spree/base_helper_decorator.rb'
- 'app/models/exchange.rb'
- 'app/services/subscription_validator.rb'
- 'lib/open_food_network/property_merge.rb'
- 'lib/open_food_network/reports/bulk_coop_report.rb'
- 'lib/open_food_network/xero_invoices_report.rb'
- 'spec/lib/open_food_network/reports/report_spec.rb'
@@ -1260,7 +1190,7 @@ Naming/VariableName:
Exclude:
- 'app/helpers/admin/injection_helper.rb'
# Offense count: 16
# Offense count: 10
# Configuration parameters: EnforcedStyle.
# SupportedStyles: snake_case, normalcase, non_integer
Naming/VariableNumber:
@@ -1418,7 +1348,7 @@ Rails/HasManyOrHasOneDependent:
- 'app/models/spree/variant_decorator.rb'
- 'app/models/subscription.rb'
# Offense count: 45
# Offense count: 46
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: numeric, symbolic
@@ -1427,16 +1357,15 @@ Rails/HttpStatus:
- 'app/controllers/admin/bulk_line_items_controller.rb'
- 'app/controllers/admin/column_preferences_controller.rb'
- 'app/controllers/admin/customers_controller.rb'
- 'app/controllers/admin/enterprise_fees_controller.rb'
- 'app/controllers/admin/enterprise_relationships_controller.rb'
- 'app/controllers/admin/enterprise_roles_controller.rb'
- 'app/controllers/admin/manager_invitations_controller.rb'
- 'app/controllers/admin/tag_rules_controller.rb'
- 'app/controllers/admin/variant_overrides_controller.rb'
- 'app/controllers/api/customers_controller.rb'
- 'app/controllers/api/enterprise_fees_controller.rb'
- 'app/controllers/api/enterprises_controller.rb'
- 'app/controllers/application_controller.rb'
- 'app/controllers/cart_controller.rb'
- 'app/controllers/checkout_controller.rb'
- 'app/controllers/enterprises_controller.rb'
- 'app/controllers/line_items_controller.rb'
@@ -1474,12 +1403,11 @@ Rails/Presence:
Exclude:
- 'app/serializers/api/admin/customer_serializer.rb'
# Offense count: 4
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: NotNilAndNotEmpty, NotBlank, UnlessBlank.
Rails/Present:
Exclude:
- 'app/controllers/spree/admin/orders_controller_decorator.rb'
- 'app/models/producer_property.rb'
- 'lib/open_food_network/products_and_inventory_report.rb'
@@ -1546,7 +1474,6 @@ 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'
@@ -1611,7 +1538,6 @@ Style/BracesAroundHashParameters:
- 'spec/controllers/admin/manager_invitations_controller_spec.rb'
- 'spec/controllers/admin/order_cycles_controller_spec.rb'
- 'spec/controllers/api/order_cycles_controller_spec.rb'
- 'spec/controllers/cart_controller_spec.rb'
- 'spec/controllers/enterprises_controller_spec.rb'
- 'spec/controllers/line_items_controller_spec.rb'
- 'spec/controllers/spree/admin/adjustments_controller_spec.rb'
@@ -1638,13 +1564,11 @@ Style/BracesAroundHashParameters:
- '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'
- 'spec/models/spree/taxon_spec.rb'
- 'spec/serializers/admin/customer_serializer_spec.rb'
- 'spec/services/cart_service_spec.rb'
- 'spec/spec_helper.rb'
- 'spec/support/cancan_helper.rb'
- 'spec/support/request/authentication_workflow.rb'
@@ -1656,7 +1580,7 @@ Style/CaseEquality:
- 'app/helpers/angular_form_helper.rb'
- 'spec/models/spree/payment_spec.rb'
# Offense count: 85
# Offense count: 82
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle.
# SupportedStyles: nested, compact
@@ -1665,7 +1589,6 @@ Style/ClassAndModuleChildren:
- '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'
@@ -1800,7 +1723,7 @@ Style/EmptyLiteral:
- 'app/helpers/checkout_helper.rb'
- 'app/models/spree/order_decorator.rb'
# Offense count: 6
# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: compact, expanded
@@ -1810,7 +1733,6 @@ Style/EmptyMethod:
- 'app/controllers/home_controller.rb'
- 'app/controllers/map_controller.rb'
- 'app/controllers/producers_controller.rb'
- 'app/controllers/shops_controller.rb'
- 'app/controllers/spree/admin/products_controller_decorator.rb'
# Offense count: 2
@@ -1829,19 +1751,17 @@ Style/FormatStringToken:
- 'lib/open_food_network/sales_tax_report.rb'
- 'spec/models/enterprise_spec.rb'
# Offense count: 80
# Offense count: 76
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'app/controllers/admin/accounts_and_billing_settings_controller.rb'
- 'app/controllers/admin/enterprise_fees_controller.rb'
- 'app/controllers/admin/enterprises_controller.rb'
- 'app/controllers/admin/order_cycles_controller.rb'
- 'app/controllers/admin/product_import_controller.rb'
- 'app/controllers/application_controller.rb'
- 'app/controllers/base_controller.rb'
- 'app/controllers/checkout_controller.rb'
- 'app/controllers/enterprises_controller.rb'
- 'app/controllers/home_controller.rb'
- 'app/controllers/spree/admin/adjustments_controller_decorator.rb'
- 'app/controllers/spree/admin/base_controller_decorator.rb'
@@ -1854,7 +1774,6 @@ Style/GuardClause:
- 'app/jobs/products_cache_integrity_checker_job.rb'
- 'app/jobs/update_account_invoices.rb'
- 'app/jobs/update_billable_periods.rb'
- 'app/mailers/producer_mailer.rb'
- 'app/models/enterprise.rb'
- 'app/models/enterprise_group.rb'
- 'app/models/producer_property.rb'
@@ -1877,7 +1796,7 @@ Style/GuardClause:
- 'spec/support/request/distribution_helper.rb'
- 'spec/support/request/shop_workflow.rb'
# Offense count: 924
# Offense count: 872
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
@@ -1909,7 +1828,6 @@ Style/HashSyntax:
- 'app/helpers/spree/admin/navigation_helper_decorator.rb'
- 'app/helpers/spree/admin/orders_helper_decorator.rb'
- 'app/mailers/enterprise_mailer.rb'
- 'app/mailers/spree/order_mailer_decorator.rb'
- 'app/mailers/spree/user_mailer_decorator.rb'
- 'app/models/billable_period.rb'
- 'app/models/calculator/flat_percent_per_item.rb'
@@ -1919,7 +1837,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'
@@ -1933,22 +1850,13 @@ 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'
- 'app/serializers/api/admin/enterprise_fee_serializer.rb'
- 'app/serializers/api/enterprise_serializer.rb'
- 'app/views/api/order_cycles/bulk_show.v1.rabl'
- 'app/views/json/_order_cycle.rabl'
- 'app/views/json/partials/_hub.rabl'
@@ -1972,8 +1880,6 @@ Style/HashSyntax:
- 'spec/controllers/admin/stripe_connect_settings_controller_spec.rb'
- 'spec/controllers/api/order_cycles_controller_spec.rb'
- 'spec/controllers/base_controller_spec.rb'
- 'spec/controllers/cart_controller_spec.rb'
- 'spec/controllers/spree/admin/orders_controller_spec.rb'
- 'spec/controllers/spree/admin/payment_methods_controller_spec.rb'
- 'spec/controllers/spree/admin/payments_controller_spec.rb'
- 'spec/controllers/spree/api/products_controller_spec.rb'
@@ -2011,7 +1917,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'
@@ -2061,7 +1966,6 @@ Style/MethodCallWithoutArgsParentheses:
Exclude:
- 'app/controllers/spree/admin/payment_methods_controller_decorator.rb'
- 'app/views/json/_groups.rabl'
- 'spec/controllers/cart_controller_spec.rb'
- 'spec/features/consumer/registration_spec.rb'
- 'spec/models/spree/payment_method_spec.rb'
- 'spec/support/request/ui_component_helper.rb'
@@ -2093,7 +1997,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
@@ -2162,7 +2065,7 @@ Style/NumericLiteralPrefix:
Exclude:
- 'spec/features/admin/order_cycles_spec.rb'
# Offense count: 13
# Offense count: 12
# Cop supports --auto-correct.
# Configuration parameters: Strict.
Style/NumericLiterals:
@@ -2199,14 +2102,13 @@ Style/ParenthesesAroundCondition:
Exclude:
- 'app/controllers/checkout_controller.rb'
# Offense count: 2
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: short, verbose
Style/PreferredHashMethods:
Exclude:
- 'app/controllers/spree/orders_controller_decorator.rb'
- 'spec/controllers/spree/admin/orders_controller_spec.rb'
# Offense count: 18
# Cop supports --auto-correct.
@@ -2264,7 +2166,7 @@ Style/RedundantReturn:
- 'app/models/spree/classification_decorator.rb'
- 'app/serializers/api/admin/enterprise_serializer.rb'
# Offense count: 96
# Offense count: 95
# Cop supports --auto-correct.
Style/RedundantSelf:
Exclude:
@@ -2311,15 +2213,14 @@ Style/RegexpLiteral:
- 'spec/mailers/subscription_mailer_spec.rb'
- 'spec/models/content_configuration_spec.rb'
# Offense count: 4
# Offense count: 2
# Cop supports --auto-correct.
Style/RescueModifier:
Exclude:
- 'app/controllers/application_controller.rb'
- 'app/controllers/spree/admin/orders_controller_decorator.rb'
- 'lib/tasks/data.rake'
# Offense count: 268
# Offense count: 266
Style/Send:
Exclude:
- 'spec/controllers/admin/subscriptions_controller_spec.rb'
@@ -2350,7 +2251,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'
@@ -2395,7 +2295,7 @@ Style/StructInheritance:
Exclude:
- 'lib/open_food_network/enterprise_fee_applicator.rb'
# Offense count: 93
# Offense count: 90
# Cop supports --auto-correct.
# Configuration parameters: IgnoredMethods.
# IgnoredMethods: respond_to, define_method
@@ -2419,7 +2319,6 @@ Style/SymbolProc:
- 'lib/open_food_network/reports/bulk_coop_supplier_report.rb'
- 'lib/spree/product_filters.rb'
- 'spec/controllers/api/order_cycles_controller_spec.rb'
- 'spec/controllers/spree/admin/orders_controller_spec.rb'
- 'spec/controllers/spree/api/products_controller_spec.rb'
- 'spec/controllers/spree/api/variants_controller_spec.rb'
- 'spec/features/admin/bulk_product_update_spec.rb'

View File

@@ -9,9 +9,6 @@ addons:
# Set the timezone for phantomjs with TZ
# Set the timezone for karma with TIMEZONE
#
# The test cases are roughly split according to their test times.
# It would be better to use https://github.com/ArturT/knapsack.
env:
global:
- TZ="Australia/Melbourne"
@@ -21,7 +18,7 @@ env:
- CI_NODE_INDEX=0
- CI_NODE_INDEX=1
- CI_NODE_INDEX=2
- CI_NODE_INDEX=3
- CI_NODE_INDEX=3 RSPEC_ENGINES="true"
- CI_NODE_INDEX=4 KARMA="true" GITHUB_DEPLOY="true"
before_script:
@@ -42,6 +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 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

@@ -69,10 +69,14 @@ Tests, both unit and integration, are based on RSpec. To run the test suite, fir
bundle exec rake db:test:prepare
Then the tests can be run with:
Then the main application tests can be run with:
bundle exec rspec spec
The tests of all custom engines can be run with:
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.
Note: The time zone on your machine should match the one defined in `config/application.yml`.
@@ -114,7 +118,7 @@ $ createdb open_food_network_test --owner=ofn
If these commands succeed, you should be able to [continue the setup process](#get-it-running).
[developer-wiki]: https://github.com/openfoodfoundation/openfoodnetwork/wiki
[sierra]: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Development-Environment-Setup:-macOS-(Sierra)
[sierra]: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Development-Environment-Setup%3A-macOS-%28Sierra%2C-HighSierra-and-Mojave%29
[el-capitan]: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Development-Environment-Setup:-OS-X-(El-Capitan)
[ubuntu]: https://github.com/openfoodfoundation/openfoodnetwork/wiki/Development-Environment-Setup:-Ubuntu
[wiki]: https://github.com/openfoodfoundation/openfoodnetwork/wiki

27
Gemfile
View File

@@ -5,11 +5,12 @@ 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.0.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'
@@ -22,16 +23,17 @@ gem 'spree_auth_devise', github: 'openfoodfoundation/spree_auth_devise', branch:
# - 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 '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.2.0' # Used for Stripe Connect
gem 'jwt', '~> 1.5'
gem 'oauth2', '~> 1.4.1' # Used for Stripe Connect
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
@@ -63,15 +65,16 @@ gem 'spinjs-rails'
gem 'rack-ssl', require: 'rack/ssl'
gem 'rack-rewrite'
gem 'custom_error_message', github: 'jeremydurham/custom-err-msg'
gem 'angularjs-file-upload-rails', '~> 1.1.6'
gem 'roadie-rails', '~> 1.0.3'
gem 'angularjs-file-upload-rails', '~> 2.4.1'
gem 'roadie-rails', '~> 1.1.1'
gem 'figaro'
gem 'blockenspiel'
gem 'acts-as-taggable-on', '~> 3.4'
gem 'paper_trail', '~> 3.0.8'
gem 'paper_trail', '~> 5.2.3'
gem 'diffy'
gem 'skylight', '< 2.0'
gem 'combine_pdf'
gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'
@@ -88,10 +91,7 @@ group :assets do
gem 'compass-rails'
gem 'coffee-rails', '~> 3.2.1'
gem 'mini_racer'
# We found that the following version of libv8 breaks the compilation of mini_racer.
# Nothing else depends on libv8.
gem 'libv8', '!= 6.7.288.46.1'
gem 'therubyracer', '=0.12.0'
gem 'uglifier', '>= 1.0.3'
@@ -120,7 +120,8 @@ group :test, :development do
gem 'awesome_print'
gem 'letter_opener', '>= 1.4.1'
gem 'timecop'
gem 'poltergeist', '>= 1.16.0'
gem 'selenium-webdriver'
gem 'chromedriver-helper'
gem 'rspec-retry'
gem 'json_spec', '~> 1.1.4'
gem 'unicorn-rails'
@@ -145,6 +146,8 @@ group :development do
gem 'guard-rails'
gem 'guard-rspec', '~> 4.7.3'
gem 'rubocop', '>= 0.49.1'
gem 'spring', '1.7.2'
gem 'spring-commands-rspec'
# 1.0.9 fixed openssl issues on macOS https://github.com/eventmachine/eventmachine/issues/602
# While we don't require this gem directly, no dependents forced the upgrade to a version

View File

@@ -133,6 +133,11 @@ GIT
activemodel (>= 3.0)
railties (>= 3.0)
PATH
remote: engines/order_management
specs:
order_management (0.0.1)
PATH
remote: engines/web
specs:
@@ -186,8 +191,10 @@ GEM
railties (>= 3.1)
sprockets (~> 2.0)
tilt
angularjs-file-upload-rails (1.1.6)
angularjs-file-upload-rails (2.4.1)
angularjs-rails (1.5.5)
archive-zip (0.7.0)
io-like (~> 0.3.0)
arel (3.0.3)
ast (2.4.0)
atomic (1.1.101)
@@ -201,8 +208,9 @@ GEM
bcrypt (3.1.11)
bcrypt-ruby (3.1.5)
bcrypt (>= 3.1.3)
blockenspiel (0.4.5)
bugsnag (4.1.0)
blockenspiel (0.5.0)
bugsnag (6.11.1)
concurrent-ruby (~> 1.0)
builder (3.0.4)
byebug (9.0.6)
cancan (1.6.8)
@@ -213,10 +221,14 @@ GEM
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (>= 2.0, < 4.0)
childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
chromedriver-helper (1.1.0)
archive-zip (~> 0.7.0)
nokogiri (~> 1.6)
chronic (0.10.2)
chunky_png (1.3.10)
climate_control (0.1.0)
cliver (0.3.2)
climate_control (0.2.0)
cocaine (0.5.8)
climate_control (>= 0.0.3, < 1.0)
coderay (1.1.2)
@@ -228,6 +240,8 @@ GEM
execjs
coffee-script-source (1.10.0)
colorize (0.8.1)
combine_pdf (1.0.16)
ruby-rc4 (>= 0.1.5)
compass (1.0.3)
chunky_png (~> 1.2)
compass-core (~> 1.0.2)
@@ -244,23 +258,30 @@ 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.3.5)
css_parser (1.6.0)
addressable
daemons (1.2.2)
dalli (2.7.2)
daemons (1.3.1)
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)
delayed_job (4.1.4)
activesupport (>= 3.0, < 5.2)
delayed_job_active_record (4.1.2)
activerecord (>= 3.0, < 5.2)
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)
@@ -269,7 +290,7 @@ GEM
devise-encryptable (0.1.2)
devise (>= 2.1.0)
diff-lcs (1.3)
diffy (3.1.0)
diffy (3.3.0)
docile (1.3.1)
dry-inflector (0.1.2)
em-websocket (0.5.1)
@@ -284,10 +305,10 @@ GEM
factory_bot_rails (4.8.2)
factory_bot (~> 4.8.2)
railties (>= 3.0.0)
faraday (0.9.2)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
ffaker (1.15.0)
ffi (1.9.25)
ffi (1.10.0)
figaro (1.1.1)
thor (~> 0.14)
fission (0.5.0)
@@ -444,18 +465,18 @@ GEM
foundation-icons-sass-rails (3.0.0)
railties (>= 3.1.1)
sass-rails (>= 3.1.1)
foundation-rails (5.5.0.0)
foundation-rails (5.5.2.1)
railties (>= 3.1.0)
sass (>= 3.2.0, < 3.4)
sass (>= 3.3.0, < 3.5)
fuubar (2.3.2)
rspec-core (~> 3.0)
ruby-progressbar (~> 1.4)
geocoder (1.1.8)
gmaps4rails (1.5.6)
guard (2.14.1)
guard (2.15.0)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (~> 1.0)
lumberjack (>= 1.0.12, < 2.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
@@ -484,10 +505,11 @@ GEM
multi_json (~> 1.0)
multi_xml
i18n (0.6.11)
i18n-js (3.0.11)
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)
ipaddress (0.8.3)
jaro_winkler (1.5.1)
journey (1.0.4)
@@ -499,33 +521,31 @@ GEM
json_spec (1.1.5)
multi_json (~> 1.0)
rspec (>= 2.0, < 4.0)
jwt (1.5.6)
jwt (2.1.0)
kaminari (0.13.0)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
railties (>= 3.0.0)
kgio (2.11.2)
knapsack (1.16.0)
knapsack (1.17.1)
rake
launchy (2.4.3)
addressable (~> 2.3)
letter_opener (1.6.0)
letter_opener (1.7.0)
launchy (~> 2.2)
libv8 (6.3.292.48.1)
libv8 (3.16.14.19)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
lumberjack (1.0.12)
lumberjack (1.0.13)
mail (2.5.5)
mime-types (~> 1.16)
treetop (~> 1.4.8)
method_source (0.9.0)
method_source (0.9.2)
mime-types (1.25.1)
mini_mime (1.0.1)
mini_portile2 (2.1.0)
mini_racer (0.1.15)
libv8 (~> 6.3)
momentjs-rails (2.5.1)
momentjs-rails (2.20.1)
railties (>= 3.1)
money (5.1.0)
i18n (~> 0.6.0)
@@ -533,22 +553,24 @@ GEM
multi_xml (0.6.0)
multipart-post (2.0.0)
nenv (0.3.0)
net-http-persistent (3.0.0)
connection_pool (~> 2.2)
nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0)
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
oauth2 (1.2.0)
faraday (>= 0.8, < 0.10)
jwt (~> 1.0)
oauth2 (1.4.1)
faraday (>= 0.8, < 0.16.0)
jwt (>= 1.0, < 3.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
oj (3.6.10)
oj (3.7.12)
orm_adapter (0.5.0)
paper_trail (3.0.9)
activerecord (>= 3.0, < 5.0)
activesupport (>= 3.0, < 5.0)
paper_trail (5.2.3)
activerecord (>= 3.0, < 6.0)
request_store (~> 1.1)
paperclip (3.5.4)
activemodel (>= 3.0.0)
activesupport (>= 3.0.0)
@@ -563,15 +585,11 @@ GEM
paypal-sdk-merchant (1.106.1)
paypal-sdk-core (~> 0.2.3)
pg (0.21.0)
poltergeist (1.18.1)
capybara (>= 2.1, < 4)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
polyamorous (0.5.0)
activerecord (~> 3.0)
polyglot (0.3.5)
powerpack (0.1.1)
pry (0.11.2)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
pry-byebug (3.4.3)
@@ -586,6 +604,8 @@ GEM
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
@@ -611,7 +631,7 @@ GEM
thor (>= 0.14.6, < 2.0)
rainbow (3.0.0)
raindrops (0.19.0)
rake (12.3.1)
rake (12.3.2)
ransack (0.7.2)
actionpack (~> 3.0)
activerecord (~> 3.0)
@@ -626,13 +646,16 @@ GEM
trollop (~> 2.1)
rdoc (3.12.2)
json (~> 1.4)
redcarpet (3.2.3)
roadie (3.0.1)
css_parser (~> 1.3.4)
nokogiri (~> 1.6.0)
roadie-rails (1.0.3)
rails (>= 3.0, < 4.2)
roadie (~> 3.0)
redcarpet (3.4.0)
ref (2.0.0)
request_store (1.4.1)
rack (>= 1.4)
roadie (3.4.0)
css_parser (~> 1.4)
nokogiri (~> 1.5)
roadie-rails (1.1.1)
railties (>= 3.0, < 5.1)
roadie (~> 3.1)
roo (2.7.1)
nokogiri (~> 1)
rubyzip (~> 1.1, < 2.0.0)
@@ -640,29 +663,29 @@ GEM
nokogiri
roo (>= 2.0.0beta1, < 3)
spreadsheet (> 0.9.0)
rspec (3.7.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-core (3.7.1)
rspec-support (~> 3.7.0)
rspec-expectations (3.7.0)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-mocks (3.7.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-rails (3.7.2)
rspec-support (~> 3.8.0)
rspec-rails (3.8.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-support (~> 3.7.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-support (~> 3.8.0)
rspec-retry (0.6.1)
rspec-core (> 3.3)
rspec-support (3.7.1)
rspec-support (3.8.0)
rubocop (0.57.2)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
@@ -673,6 +696,7 @@ GEM
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-ole (1.2.12.1)
ruby-progressbar (1.10.0)
ruby-rc4 (0.1.5)
rubyzip (1.2.2)
safe_yaml (1.0.4)
sass (3.3.14)
@@ -682,6 +706,9 @@ GEM
tilt (~> 1.3)
select2-rails (3.5.10)
thor (~> 0.14)
selenium-webdriver (3.141.0)
childprocess (~> 0.5)
rubyzip (~> 1.2, >= 1.2.2)
shellany (0.0.1)
shoulda-matchers (2.8.0)
activesupport (>= 3.0.0)
@@ -690,12 +717,19 @@ GEM
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
skylight (1.7.1)
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)
ruby-ole (>= 1.0)
spring (1.7.2)
spring-commands-rspec (1.0.4)
spring (>= 0.9.1)
sprockets (2.2.3)
hike (~> 1.2)
multi_json (~> 1.0)
@@ -703,8 +737,12 @@ GEM
tilt (~> 1.1, != 1.3.0)
state_machine (1.2.0)
stringex (1.3.3)
stripe (3.3.2)
faraday (~> 0.9)
stripe (4.11.0)
faraday (~> 0.13)
net-http-persistent (~> 3.0)
therubyracer (0.12.0)
libv8 (~> 3.16.14.0)
ref
thor (0.20.3)
tilt (1.4.1)
timecop (0.9.1)
@@ -716,11 +754,11 @@ GEM
turbo-sprockets-rails3 (0.3.14)
railties (> 3.2.8, < 4.0.0)
sprockets (>= 2.2.0)
tzinfo (0.3.54)
uglifier (4.1.19)
tzinfo (0.3.55)
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)
@@ -733,18 +771,14 @@ GEM
railties (>= 3.0)
warden (1.2.7)
rack (>= 1.0)
webmock (3.4.2)
webmock (3.5.1)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
whenever (0.9.2)
activesupport (>= 2.3.4)
whenever (0.11.0)
chronic (>= 0.6.3)
wicked_pdf (1.1.0)
wkhtmltopdf-binary (0.12.3.1)
wkhtmltopdf-binary (0.12.4)
xml-simple (1.1.5)
xpath (2.1.0)
nokogiri (~> 1.3)
@@ -758,7 +792,7 @@ DEPENDENCIES
acts-as-taggable-on (~> 3.4)
andand
angular-rails-templates (~> 0.3.0)
angularjs-file-upload-rails (~> 1.1.6)
angularjs-file-upload-rails (~> 2.4.1)
angularjs-rails (= 1.5.5)
atomic
awesome_print
@@ -767,7 +801,9 @@ DEPENDENCIES
bugsnag
byebug (~> 9.0.0)
capybara (>= 2.15.4)
chromedriver-helper
coffee-rails (~> 3.2.1)
combine_pdf
compass-rails
custom_error_message!
daemons
@@ -777,6 +813,7 @@ DEPENDENCIES
debugger-linecache
deface!
delayed_job_active_record
delayed_job_web
diffy
eventmachine (>= 1.2.3)
factory_bot_rails
@@ -794,26 +831,24 @@ DEPENDENCIES
guard-rspec (~> 4.7.3)
haml
i18n (~> 0.6.11)
i18n-js (~> 3.0.0)
i18n-js (~> 3.2.1)
immigrant
jquery-migrate-rails
jquery-rails
json_spec (~> 1.1.4)
jwt (~> 1.5)
jwt (~> 2.1)
knapsack
letter_opener (>= 1.4.1)
libv8 (!= 6.7.288.46.1)
listen (= 3.0.8)
mini_racer
momentjs-rails
nokogiri (>= 1.6.7.1)
oauth2 (~> 1.2.0)
oauth2 (~> 1.4.1)
ofn-qz!
oj
paper_trail (~> 3.0.8)
order_management!
paper_trail (~> 5.2.3)
paperclip
pg
poltergeist (>= 1.16.0)
pry-byebug (>= 3.4.3)
rabl
rack-mini-profiler (< 1.0.0)
@@ -822,7 +857,7 @@ DEPENDENCIES
rails (~> 3.2.22)
rails-i18n (~> 3.0.0)
redcarpet
roadie-rails (~> 1.0.3)
roadie-rails (~> 1.1.1)
roo (~> 2.7.0)
roo-xls (~> 1.1.0)
rspec-rails (>= 3.5.2)
@@ -830,6 +865,7 @@ DEPENDENCIES
rubocop (>= 0.49.1)
sass (~> 3.3)
sass-rails (~> 3.2.3)
selenium-webdriver
shoulda-matchers
simple_form!
simplecov
@@ -839,7 +875,10 @@ DEPENDENCIES
spree_auth_devise!
spree_i18n!
spree_paypal_express!
stripe (~> 3.3.2)
spring (= 1.7.2)
spring-commands-rspec
stripe
therubyracer (= 0.12.0)
timecop
truncate_html
turbo-sprockets-rails3
@@ -856,4 +895,4 @@ RUBY VERSION
ruby 2.1.5p273
BUNDLED WITH
1.16.4
1.17.2

View File

@@ -9,7 +9,7 @@
//= require jquery-migrate-min
//= require jquery_ujs
//= require jquery-ui
//= require shared/jquery-ui-timepicker-addon
//= require jquery-ui-timepicker-addon
//= require angular
//= require angular-resource
//= require angular-animate

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

@@ -9,4 +9,4 @@ angular.module("admin.indexUtils").factory 'Dereferencer', ->
dereferenceAttr: (array, attr, data)->
if array
for object in array
object[attr] = data[object[attr].id] unless object[attr] == null
object[attr] = data[object[attr].id] if object[attr]

View File

@@ -1,11 +1,12 @@
angular.module("admin.indexUtils").factory 'RequestMonitor', ($q) ->
new class RequestMonitor
loadQueue: $q.when([])
loadId: 0
requestCount: 0
loading: false
load: (promise) ->
loadId = (@loadId += 1)
@requestCount += 1
@loading = true
@loadQueue = $q.all([@loadQueue, promise]).then =>
@loading = false if @loadId == loadId
@requestCount -= 1
@loading = false if @requestCount == 0

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

@@ -0,0 +1,32 @@
angular.module("admin.orders").controller "bulkInvoiceCtrl", ($scope, $http, $timeout) ->
$scope.createBulkInvoice = ->
$scope.invoice_id = null
$scope.poll = 1
$scope.loading = true
$scope.message = null
$scope.error = null
$scope.poll_wait = 5 # 5 Seconds between each check
$scope.poll_retries = 80 # Maximum checks before stopping
$http.post('/admin/orders/invoices', {order_ids: $scope.selected_orders}).success (data) ->
$scope.invoice_id = data
$scope.pollBulkInvoice()
$scope.pollBulkInvoice = ->
$timeout($scope.nextPoll, $scope.poll_wait * 1000)
$scope.nextPoll = ->
$http.get('/admin/orders/invoices/'+$scope.invoice_id+'/poll').success (data) ->
$scope.loading = false
$scope.message = t('js.admin.orders.index.bulk_invoice_created')
.error (data) ->
$scope.poll++
if $scope.poll > $scope.poll_retries
$scope.loading = false
$scope.error = t('js.admin.orders.index.bulk_invoice_failed')
return
$scope.pollBulkInvoice()

View File

@@ -1,4 +1,4 @@
angular.module("admin.orders").controller "ordersCtrl", ($scope, RequestMonitor, Orders, SortOptions) ->
angular.module("admin.orders").controller "ordersCtrl", ($scope, RequestMonitor, Orders, SortOptions, $window, $filter) ->
$scope.RequestMonitor = RequestMonitor
$scope.pagination = Orders.pagination
$scope.orders = Orders.all
@@ -8,6 +8,11 @@ angular.module("admin.orders").controller "ordersCtrl", ($scope, RequestMonitor,
{id: 50, name: t('js.admin.orders.index.per_page', results: 50)},
{id: 100, name: t('js.admin.orders.index.per_page', results: 100)}
]
$scope.selected_orders = []
$scope.checkboxes = {}
$scope.selected = false
$scope.select_all = false
$scope.poll = 0
$scope.initialise = ->
$scope.per_page = 15
@@ -17,6 +22,7 @@ angular.module("admin.orders").controller "ordersCtrl", ($scope, RequestMonitor,
$scope.fetchResults()
$scope.fetchResults = (page=1) ->
$scope.resetSelected()
Orders.index({
'q[completed_at_lt]': $scope['q']['completed_at_lt'],
'q[completed_at_gt]': $scope['q']['completed_at_gt'],
@@ -25,8 +31,9 @@ angular.module("admin.orders").controller "ordersCtrl", ($scope, RequestMonitor,
'q[email_cont]': $scope['q']['email_cont'],
'q[bill_address_firstname_start]': $scope['q']['bill_address_firstname_start'],
'q[bill_address_lastname_start]': $scope['q']['bill_address_lastname_start'],
'q[completed_at_not_null]': $scope['q']['completed_at_not_null'],
'q[inventory_units_shipment_id_null]': $scope['q']['inventory_units_shipment_id_null'],
# 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'],
@@ -35,6 +42,26 @@ angular.module("admin.orders").controller "ordersCtrl", ($scope, RequestMonitor,
page: page
})
$scope.resetSelected = ->
$scope.selected_orders.length = 0
$scope.selected = false
$scope.select_all = false
$scope.checkboxes = {}
$scope.toggleSelection = (id) ->
index = $scope.selected_orders.indexOf(id)
if index == -1
$scope.selected_orders.push(id)
else
$scope.selected_orders.splice(index, 1)
$scope.toggleAll = ->
$scope.selected_orders.length = 0
$scope.orders.forEach (order) ->
$scope.checkboxes[order.id] = $scope.select_all
$scope.selected_orders.push order.id if $scope.select_all
$scope.$watch 'sortOptions', (sort) ->
if sort && sort.predicate != ""
$scope.sorting = sort.predicate + ' desc' if sort.reverse

View File

@@ -0,0 +1,5 @@
angular.module("admin.orders").directive "invoicesModal", ($modal) ->
restrict: 'C'
link: (scope, elem, attrs, ctrl) ->
elem.on "click", (ev) =>
scope.uploadModal = $modal.open(templateUrl: 'admin/modals/bulk_invoice.html', controller: ctrl, scope: scope, windowClass: 'simple-modal')

View File

@@ -1 +1 @@
angular.module("admin.orders", ['admin.indexUtils', 'ngResource'])
angular.module("admin.orders", ['admin.indexUtils', 'ngResource', 'mm.foundation'])

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

@@ -2,5 +2,5 @@ angular.module("ofn.admin").directive "imageModal", ($modal, ProductImageService
restrict: 'C'
link: (scope, elem, attrs, ctrl) ->
elem.on "click", (ev) =>
scope.uploadModal = $modal.open(templateUrl: 'admin/modals/image_upload.html', controller: ctrl, scope: scope, windowClass: 'product-image-upload')
scope.uploadModal = $modal.open(templateUrl: 'admin/modals/image_upload.html', controller: ctrl, scope: scope, windowClass: 'simple-modal')
ProductImageService.configure(scope.product)

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

@@ -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,6 +22,7 @@ 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) ->
results: data
formatResult: (variant) ->

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

@@ -13,6 +13,11 @@ angular.module("admin.variantOverrides").controller "AdminVariantOverridesCtrl",
$scope.RequestMonitor = RequestMonitor
$scope.selectView = Views.selectView
$scope.currentView = -> Views.currentView
$scope.onDemandOptions = [
{ description: t('js.variant_overrides.on_demand.use_producer_settings'), value: null },
{ description: t('js.variant_overrides.on_demand.yes'), value: true },
{ description: t('js.variant_overrides.on_demand.no'), value: false }
]
$scope.views = Views.setViews
inventory: { name: t('js.variant_overrides.inventory_products'), visible: true }
@@ -105,3 +110,35 @@ angular.module("admin.variantOverrides").controller "AdminVariantOverridesCtrl",
StatusMessage.display 'success', t('js.variant_overrides.stock_reset')
.error (data, status) ->
$timeout -> StatusMessage.display 'failure', $scope.updateError(data, status)
# Variant override count_on_hand field placeholder logic:
# on_demand true -- Show "On Demand"
# on_demand false -- Show empty value to be set by the user
# on_demand nil -- Show producer on_hand value
$scope.countOnHandPlaceholder = (variant, hubId) ->
variantOverride = $scope.variantOverrides[hubId][variant.id]
if variantOverride.on_demand
t('js.variants.on_demand.yes')
else if variantOverride.on_demand == false
''
else
variant.on_hand
# This method should only be used when the variant override on_demand is changed.
#
# Change the count_on_hand value to a suggested value.
$scope.updateCountOnHand = (variant, hubId) ->
variantOverride = $scope.variantOverrides[hubId][variant.id]
suggested = $scope.countOnHandSuggestion(variant, hubId)
return if suggested == variantOverride.count_on_hand
variantOverride.count_on_hand = suggested
DirtyVariantOverrides.set hubId, variant.id, variantOverride.id, 'count_on_hand', suggested
# Suggest producer count_on_hand if variant has limited stock and variant override forces limited
# stock. Otherwise, clear whatever value is set.
$scope.countOnHandSuggestion = (variant, hubId) ->
variantOverride = $scope.variantOverrides[hubId][variant.id]
return null unless !variant.on_demand && variantOverride.on_demand == false
variant.on_hand

View File

@@ -1,4 +1,5 @@
angular.module("admin.variantOverrides").filter "hubPermissions", ($filter) ->
return (products, hubPermissions, hub_id) ->
return [] if !hub_id
return [] if !hubPermissions[hub_id]
return $filter('filter')(products, ((product) -> hubPermissions[hub_id].indexOf(product.producer_id) > -1), true)

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)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,15 @@
%h4.modal-title
= t('js.admin.orders.index.compiling_invoices')
%p.message{ ng: { show: 'message' } }
{{message}}
%p.error{ ng: { show: 'error' } }
{{error}}
%img.spinner{ src: "/assets/spinning-circles.svg", ng: { show: "loading" } }
%p{ ng: { show: "loading" } }
= t('js.admin.orders.index.please_wait')
%a.button{ target: '_blank', ng: { click: 'showBulkInvoice()', href: '/admin/orders/invoices/{{invoice_id}}', show: "!loading && !error" } }
= t('js.admin.orders.index.view_file')

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

@@ -7,9 +7,10 @@
*= 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
*/
@@ -17,4 +18,3 @@
@import 'variables';
@import 'components/*';
@import '*';
@import 'pages/*';

View File

@@ -0,0 +1,10 @@
@import '../../darkswarm/branding';
.container {
input {
&[readonly] {
background-color: $disabled-light;
cursor: default;
}
}
}

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

@@ -1,6 +1,6 @@
@import '../variables';
.reveal-modal.product-image-upload {
.reveal-modal.simple-modal {
width: 300px;
.close-reveal-modal {

View File

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

View File

@@ -103,3 +103,34 @@ table.index td.actions {
font-size: 1.2em;
}
}
.index-controls {
button {
float: right;
&:disabled {
background-color: $disabled-button;
}
}
}
.simple-modal {
text-align: center;
.modal-title {
margin-bottom: 1.5em;
}
.message, .error {
margin-bottom: 1em;
}
.spinner {
margin-bottom: 1em;
}
.error {
color: $warning-red;
}
}

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,86 +0,0 @@
@import typography
.darkswarm
navigation
display: block
background: #f7f7f7
distributor.details
box-sizing: border-box
display: block
min-height: 150px
padding: 30px 0px 20px 0px
select
width: 200px
position: relative
img
display: block
height: 100px
width: 100px
margin-right: 12px
location
@include headingFont
@media all and (max-width: 768px)
location, location + small
display: block
#distributor_title h3
margin-top: 0
@media all and (max-width: 768px)
margin-bottom: 8px
ordercycle
text-align: right
p
max-width: 400px
h4 i
margin-right: 0.3rem
@media all and (max-width: 640px)
float: left
clear: left
text-align: left
padding: 12px 10px
width: 100%
margin-top: 10px
background: #e5e5e5
p
max-width: 100%
float: right
form.custom
text-align: right
& > strong
line-height: 2.5
font-size: 1.29em
padding-right: 14px
@media all and (max-width: 768px)
select
width: inherit
display: inline-block
border-width: 1px
border-color: #999
color: #666
font-size: 1em
margin-bottom: 0
padding: 8px 20px 8px 12px
@media all and (max-width: 768px)
font-size: 0.875em
@media screen and (-webkit-min-device-pixel-ratio:0)
font-size: 16px
closing
@include headingFont
@media all and (max-width: 768px)
font-size: 1.2em
padding-bottom: 10px
color: black
font-size: 1.5em
display: block
padding-bottom: 12px
span
@media all and (max-width: 768px)
font-size: 0.875em

View File

@@ -0,0 +1,103 @@
@import "typography";
.darkswarm navigation {
display: block;
background: #f7f7f7;
distributor.details {
box-sizing: border-box;
display: block;
min-height: 150px;
padding: 30px 0 20px 0;
position: relative;
select {
width: 200px;
}
img {
display: block;
height: 100px;
width: 100px;
margin-right: 12px;
}
location {
@include headingFont;
}
@media all and (max-width: 768px) {
location, location + small {
display: block;
}
}
#distributor_title h3 {
margin-top: 0;
@media all and (max-width: 768px) {
margin-bottom: 8px;
}
}
ordercycle {
text-align: right;
float: right;
p {
max-width: 400px;
}
h4 i {
margin-right: 0.3rem;
}
@media all and (max-width: 640px) {
float: left;
clear: left;
text-align: left;
padding: 12px 10px;
width: 100%;
margin-top: 10px;
background: #e5e5e5;
p {
max-width: 100%;
}
}
form.custom {
text-align: right;
& > strong {
line-height: 2.5;
font-size: 1.29em;
padding-right: 14px;
}
select {
width: inherit;
display: inline-block;
border: 1px #999;
color: #666;
font-size: 1em;
margin-bottom: 0;
padding: 8px 20px 8px 12px;
@media all and (max-width: 768px) {
font-size: 0.875em;
}
@media screen and (-webkit-min-device-pixel-ratio: 0) {
font-size: 16px;
}
}
}
closing {
@include headingFont;
color: black;
font-size: 1.5em;
display: block;
padding-bottom: 12px;
@media all and (max-width: 768px) {
font-size: 1.2em;
padding-bottom: 10px;
}
span {
@media all and (max-width: 768px) {
font-size: 0.875em;
}
}
}
}
}
}

View File

@@ -1,4 +1,13 @@
@import 'darkswarm/branding';
$modal-background-color: #efefef;
$modal-content-background-color: #fff;
$modal-alert-link-color: #fff;
$modal-alert-link-hover-color: rgba(255, 255, 255, .7);
$cookies-banner-background-color: $dark-grey;
$cookies-banner-button-background-color: $clr-turquoise;
$cookies-banner-text-color: $white;
$cookies-policy-modal-background-color: $disabled-light;
$cookies-policy-modal-border-bottom-color: $disabled-light;
$cookies-policy-modal-table-tr-even-background-color: $disabled-very-light;

View File

@@ -1,86 +0,0 @@
@import mixins
@import branding
@import animations
.order-summary
background-color: #e1f0f5
padding: 1em
width: 100%
border: none
color: inherit
checkout
display: block
@media all and (max-width: 640px)
&.row .row
margin-left: 0
margin-right: 0
orderdetails
.button, table
width: 100%
@media all and (max-width: 640px)
form.edit_order
border: 1px solid $disabled-bright
margin-bottom: 2rem
#details, #billing, #shipping, #payment
border: 0
margin: 1em 0
padding: 0
.content
border: 1px solid #efefef
h5
margin: 0
padding: 0.65em
background: #f7f7f7
.label
font-size: 1em
padding: 0.3rem 0.35rem 0.275rem
// Logic to turn on & off the alerts for success against each fieldset
label, label.alert, label.success, &.valid label.alert, &.dirty label.success
display: none
&.dirty label.alert
display: inline
&.dirty.valid label.alert
display: none
&.valid label.success
display: inline
h5.dirty
background: #f7ccc5
h5.valid, h5.dirty.valid
background: #bfefd1
orderdetails table tr th
text-align: left
// Logic to swap out up / down accordion icons
//Foundation overrides
dd > a
@include csstrans
background: $disabled-light !important
dd > a:hover
background: $disabled-v-dark !important
color: white
dd
span.accordion-up
display: none
span.accordion-down
display: inline
&.open
span.accordion-up
display: inline
span.accordion-down
display: none
.error
color: #c82020

View File

@@ -0,0 +1,117 @@
@import "mixins";
@import "branding";
@import "animations";
.order-summary {
background-color: #e1f0f5;
padding: 1em;
width: 100%;
border: none;
color: inherit;
}
checkout {
display: block;
@media all and (max-width: 640px) {
&.row .row {
margin-left: 0;
margin-right: 0;
}
}
orderdetails {
.button, table {
width: 100%;
}
@media all and (max-width: 640px) {
form.edit_order {
border: 1px solid $disabled-bright;
margin-bottom: 2rem;
}
}
}
#details, #billing, #shipping, #payment {
border: 0;
margin: 1em 0;
padding: 0;
.content {
border: 1px solid #efefef;
}
}
h5 {
margin: 0;
padding: 0.65em;
background: #f7f7f7;
.label {
font-size: 1em;
padding: 0.3rem 0.35rem 0.275rem;
}
// Logic to turn on & off the alerts for success against each fieldset
label, label.alert, label.success, &.valid label.alert, &.dirty label.success {
display: none;
}
&.dirty label.alert {
display: inline;
}
&.dirty.valid label.alert {
display: none;
}
&.valid label.success {
display: inline;
}
}
h5.dirty {
background: #f7ccc5;
}
h5.valid, h5.dirty.valid {
background: #bfefd1;
}
orderdetails table tr th {
text-align: left;
}
// Logic to swap out up / down accordion icons
//Foundation overrides
dd > a {
@include csstrans;
background: $disabled-light !important;
}
dd > a:hover {
background: $disabled-v-dark !important;
color: white;
}
dd {
span.accordion-up {
display: none;
}
span.accordion-down {
display: inline;
}
&.open {
span.accordion-up {
display: inline;
}
span.accordion-down {
display: none;
}
}
}
.error {
color: #c82020;
}
}

View File

@@ -4,3 +4,11 @@
fieldset {
border: 0;
}
.user-form {
margin-left: auto;
margin-right: auto;
max-width: 1184px;
padding-left: .9375rem;
padding-right: .9375rem;
}

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,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

@@ -16,8 +16,7 @@ module Admin
@original_filename = params[:file].try(:original_filename)
@non_updatable_fields = ProductImport::EntryValidator.non_updatable_fields
check_file_errors @importer
check_spreadsheet_has_data @importer
return if contains_errors? @importer
@ams_data = ams_data
end
@@ -63,25 +62,28 @@ module Admin
true
end
def check_file_errors(importer)
def contains_errors?(importer)
if importer.errors.present?
redirect_to '/admin/product_import', notice: @importer.errors.full_messages.to_sentence
return true
end
check_spreadsheet_has_data importer
end
def check_spreadsheet_has_data(importer)
unless importer.item_count
redirect_to '/admin/product_import', notice: I18n.t(:product_import_no_data_in_spreadsheet_notice)
true
end
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

@@ -20,28 +20,16 @@ class CartController < BaseController
variant_ids = variant_ids_in(cart_service.variants_h)
render json: { error: false, stock_levels: stock_levels(current_order, variant_ids) },
status: 200
render json: { error: false,
stock_levels: VariantsStockLevels.new.call(current_order, variant_ids) },
status: :ok
else
render json: { error: true }, status: 412
render json: { error: true }, status: :precondition_failed
end
end
populate_variant_attributes
end
# Report the stock levels in the order for all variant ids requested
def stock_levels(order, variant_ids)
stock_levels = li_stock_levels(order)
li_variant_ids = stock_levels.keys
(variant_ids - li_variant_ids).each do |variant_id|
stock_levels[variant_id] = { quantity: 0, max_quantity: 0, on_hand: Spree::Variant.find(variant_id).on_hand }
end
stock_levels
end
def variant_ids_in(variants_h)
variants_h.map { |v| v[:variant_id].to_i }
end
@@ -79,21 +67,4 @@ class CartController < BaseController
max_quantity: max_quantity)
end
end
def li_stock_levels(order)
Hash[
order.line_items.map do |li|
[li.variant.id,
{ quantity: li.quantity,
max_quantity: li.max_quantity,
on_hand: wrap_json_infinity(li.variant.on_hand) }]
end
]
end
# Rails to_json encodes Float::INFINITY as Infinity, which is not valid JSON
# Return it as a large integer (max 32 bit signed int)
def wrap_json_infinity(number)
number == Float::INFINITY ? 2147483647 : number
end
end

View File

@@ -18,7 +18,7 @@ class CheckoutController < Spree::CheckoutController
# This is only required because of spree_paypal_express. If we implement
# a version of paypal that uses this controller, and more specifically
# the #update_failed method, then we can remove this call
restart_checkout
RestartCheckout.new(@order).call
end
def update
@@ -139,7 +139,8 @@ class CheckoutController < Spree::CheckoutController
def update_failed
clear_ship_address
restart_checkout
RestartCheckout.new(@order).call
respond_to do |format|
format.html do
render :edit
@@ -158,15 +159,6 @@ class CheckoutController < Spree::CheckoutController
end
end
def restart_checkout
return if @order.state == 'cart'
@order.restart_checkout! # resets state to 'cart'
@order.update_attributes!(shipping_method_id: nil)
@order.shipments.with_state(:pending).destroy_all
@order.payments.with_state(:checkout).destroy_all
@order.reload
end
def skip_state_validation?
true
end

View File

@@ -7,13 +7,27 @@ class EnterprisesController < BaseController
# These prepended filters are in the reverse order of execution
prepend_before_filter :set_order_cycles, :require_distributor_chosen, :reset_order, only: :shop
before_filter :check_stock_levels, :set_noindex_meta_tag, only: :shop
before_filter :clean_permalink, only: :check_permalink
before_filter :enable_embedded_shopfront
respond_to :js, only: :permalink_checker
def shop
return redirect_to spree.cart_path unless enough_stock?
set_noindex_meta_tag
enterprises = current_distributor
.plus_relatives_and_oc_producers(shop_order_cycles)
.activated
.includes(address: :state)
.all
enterprises = inject_json_ams('enterprises', enterprises)
render locals: { enterprises: enterprises }
end
def relatives
set_enterprise
@@ -48,10 +62,8 @@ class EnterprisesController < BaseController
params[:permalink] = params[:permalink].parameterize
end
def check_stock_levels
if current_order(true).insufficient_stock_lines.present?
redirect_to spree.cart_path
end
def enough_stock?
current_order(true).insufficient_stock_lines.blank?
end
def reset_order
@@ -85,7 +97,25 @@ class EnterprisesController < BaseController
order.order_cycle = order_cycle_options.first if order_cycle_options.count == 1
end
def shop_order_cycles
if current_order_cycle
[current_order_cycle]
else
OrderCycle.not_closed.with_distributor(current_distributor)
end
end
def set_noindex_meta_tag
@noindex_meta_tag = true unless current_distributor.visible?
end
def inject_json_ams(name, object)
options = {
each_serializer: Api::EnterpriseSerializer,
data: OpenFoodNetwork::EnterpriseInjectionData.new
}
serializer_instance = ActiveModel::ArraySerializer.new(object, options)
{ name: name, json: serializer_instance.to_json }
end
end

View File

@@ -4,5 +4,11 @@ class ShopsController < BaseController
before_filter :enable_embedded_shopfront
def index
@enterprises = Enterprise
.activated
.includes(address: :state)
.includes(:properties)
.includes(supplied_products: :properties)
.all
end
end

View File

@@ -0,0 +1,32 @@
module Spree
module Admin
class InvoicesController < Spree::Admin::BaseController
respond_to :json
authorize_resource class: false
def create
invoice_service = BulkInvoiceService.new
invoice_service.start_pdf_job(params[:order_ids])
render json: invoice_service.id, status: :ok
end
def show
invoice_id = params[:id]
invoice_pdf = BulkInvoiceService.new.filepath(invoice_id)
send_file(invoice_pdf, type: 'application/pdf', disposition: :inline)
end
def poll
invoice_id = params[:invoice_id]
if BulkInvoiceService.new.invoice_created? invoice_id
render json: { created: true }, status: :ok
else
render json: { created: false }, status: :unprocessable_entity
end
end
end
end
end

View File

@@ -37,8 +37,8 @@ Spree::Admin::OrdersController.class_eval do
end
def invoice
template = if Spree::Config.invoice_style2? then "spree/admin/orders/invoice2" else "spree/admin/orders/invoice" end
pdf = render_to_string pdf: "invoice-#{@order.number}.pdf", template: 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')
@@ -46,8 +46,7 @@ Spree::Admin::OrdersController.class_eval do
end
def print
template = if Spree::Config.invoice_style2? then "spree/admin/orders/invoice2" else "spree/admin/orders/invoice" end
render pdf: "invoice-#{@order.number}", template: template, encoding: "UTF-8"
render InvoiceRenderer.new.args(@order)
end
def print_ticket

View File

@@ -23,9 +23,6 @@ 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

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,6 +244,7 @@ Spree::Admin::ReportsController.class_eval do
:products_and_inventory,
:sales_total,
:users_and_enterprises,
:enterprise_fee_summary,
:order_cycle_management,
:sales_tax,
:xero_invoices,
@@ -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

@@ -29,12 +29,8 @@ 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, here we prevent the deletion (even soft) of shipping_methods used in orders.
def do_not_destroy_referenced_shipping_methods
order = Order.where(:shipping_method_id => @object).first
if order

View File

@@ -10,12 +10,13 @@ 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
@variant.delete_and_refresh_cache
flash[:success] = I18n.t('notice_messages.variant_deleted')
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

@@ -5,25 +5,29 @@ class UserRegistrationsController < Spree::UserRegistrationsController
before_filter :set_checkout_redirect, only: :create
include I18nHelper
before_filter :set_locale
# POST /resource/sign_up
def create
@user = build_resource(params[:spree_user])
if resource.save
session[:spree_user_signup] = true
session[:confirmation_return_url] = params[:return_url]
associate_user
@user.locale = I18n.locale.to_s
unless resource.save
return render_error(@user.errors)
end
respond_to do |format|
format.html do
set_flash_message(:success, :signed_up_but_unconfirmed)
redirect_to after_sign_in_path_for(@user)
end
format.js do
render json: { email: @user.email }
end
session[:spree_user_signup] = true
session[:confirmation_return_url] = params[:return_url]
associate_user
respond_to do |format|
format.html do
set_flash_message(:success, :signed_up_but_unconfirmed)
redirect_to after_sign_in_path_for(@user)
end
format.js do
render json: { email: @user.email }
end
else
render_error(@user.errors)
end
rescue StandardError => error
OpenFoodNetwork::ErrorLogger.notify(error)

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

@@ -65,6 +65,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),

View File

@@ -54,7 +54,7 @@ module CheckoutHelper
end
def display_adjustment_tax_rates(adjustment)
tax_rates = adjustment.tax_rates
tax_rates = TaxRateFinder.tax_rates_of(adjustment)
tax_rates.map { |tr| number_to_percentage(tr.amount * 100, :precision => 1) }.join(", ")
end

View File

@@ -1,7 +1,7 @@
module I18nHelper
def set_locale
# Save a given locale
if params[:locale] && Rails.application.config.i18n.available_locales.include?(params[:locale])
if params[:locale] && available_locale?(params[:locale])
spree_current_user.update_attributes!(locale: params[:locale]) if spree_current_user
cookies[:locale] = params[:locale]
end
@@ -13,4 +13,20 @@ module I18nHelper
I18n.locale = spree_current_user.andand.locale || cookies[:locale] || I18n.default_locale
end
def valid_locale(user)
if user.present? &&
user.locale.present? &&
available_locale?(user.locale)
user.locale
else
I18n.default_locale
end
end
private
def available_locale?(locale)
Rails.application.config.i18n.available_locales.include?(locale)
end
end

View File

@@ -1,23 +1,19 @@
require 'open_food_network/enterprise_injection_data'
module InjectionHelper
def inject_enterprises
inject_json_ams "enterprises", Enterprise.activated.includes(address: :state).all, Api::EnterpriseSerializer, enterprise_injection_data
def inject_enterprises(enterprises = Enterprise.activated.includes(address: :state).all)
inject_json_ams(
'enterprises',
enterprises,
Api::EnterpriseSerializer,
enterprise_injection_data
)
end
def inject_enterprise_and_relatives
inject_json_ams "enterprises", current_distributor.relatives_including_self.activated.includes(address: :state).all, Api::EnterpriseSerializer, enterprise_injection_data
end
def inject_shop_enterprises
ocs = if current_order_cycle
[current_order_cycle]
else
OrderCycle.not_closed.with_distributor(current_distributor)
end
inject_json_ams "enterprises", current_distributor.plus_relatives_and_oc_producers(ocs).activated.includes(address: :state).all, Api::EnterpriseSerializer, enterprise_injection_data
end
def inject_group_enterprises
inject_json_ams "group_enterprises", @group.enterprises.activated.all, Api::EnterpriseSerializer, enterprise_injection_data
end

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

@@ -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

@@ -1,15 +1,18 @@
require 'devise/mailers/helpers'
class EnterpriseMailer < Spree::BaseMailer
include Devise::Mailers::Helpers
include I18nHelper
def welcome(enterprise)
@enterprise = enterprise
subject = t('enterprise_mailer.welcome.subject',
enterprise: @enterprise.name,
sitename: Spree::Config[:site_name])
mail(:to => enterprise.contact.email,
:from => from_address,
:subject => subject)
I18n.with_locale valid_locale(@enterprise.owner) do
subject = t('enterprise_mailer.welcome.subject',
enterprise: @enterprise.name,
sitename: Spree::Config[:site_name])
mail(:to => enterprise.contact.email,
:from => from_address,
:subject => subject)
end
end
def manager_invitation(enterprise, user)
@@ -17,11 +20,12 @@ class EnterpriseMailer < Spree::BaseMailer
@instance = Spree::Config[:site_name]
@instance_email = from_address
subject = t('enterprise_mailer.invite_manager.subject', enterprise: @enterprise.name)
mail(to: user.email,
from: from_address,
subject: subject)
I18n.with_locale valid_locale(@enterprise.owner) do
subject = t('enterprise_mailer.invite_manager.subject', enterprise: @enterprise.name)
mail(to: user.email,
from: from_address,
subject: subject)
end
end
private

View File

@@ -1,4 +1,5 @@
class ProducerMailer < Spree::BaseMailer
include I18nHelper
def order_cycle_report(producer, order_cycle)
@producer = producer
@@ -10,9 +11,11 @@ class ProducerMailer < Spree::BaseMailer
@total = total_from_line_items(line_items)
@tax_total = tax_total_from_line_items(line_items)
subject = "[#{Spree::Config.site_name}] #{I18n.t('producer_mailer.order_cycle.subject', producer: producer.name)}"
I18n.with_locale valid_locale(@producer.owner) do
order_cycle_subject = I18n.t('producer_mailer.order_cycle.subject', producer: producer.name)
subject = "[#{Spree::Config.site_name}] #{order_cycle_subject}"
if has_orders?(order_cycle, producer)
return unless has_orders?(order_cycle, producer)
mail(
to: @producer.contact.email,
from: from_address,
@@ -23,7 +26,6 @@ class ProducerMailer < Spree::BaseMailer
end
end
private
def has_orders?(order_cycle, producer)

View File

@@ -2,44 +2,59 @@ Spree::OrderMailer.class_eval do
helper HtmlHelper
helper CheckoutHelper
helper SpreeCurrencyHelper
include I18nHelper
def cancel_email(order, resend = false)
@order = find_order(order)
subject = (resend ? "[#{t(:resend).upcase}] " : '')
subject += "#{Spree::Config[:site_name]} #{t('order_mailer.cancel_email.subject')} ##{order.number}"
mail(to: order.email, from: from_address, subject: subject)
I18n.with_locale valid_locale(@order.user) do
mail(to: order.email,
from: from_address,
subject: mail_subject(t('order_mailer.cancel_email.subject'), resend))
end
end
def confirm_email_for_customer(order, resend = false)
find_order(order) # Finds an order instance from an id
subject = (resend ? "[#{t(:resend).upcase}] " : '')
subject += "#{Spree::Config[:site_name]} #{t('order_mailer.confirm_email.subject')} ##{@order.number}"
mail(:to => @order.email,
:from => from_address,
:subject => subject,
:reply_to => @order.distributor.contact.email)
I18n.with_locale valid_locale(@order.user) do
mail(to: @order.email,
from: from_address,
subject: mail_subject(t('order_mailer.confirm_email.subject'), resend),
reply_to: @order.distributor.contact.email)
end
end
def confirm_email_for_shop(order, resend = false)
find_order(order) # Finds an order instance from an id
subject = (resend ? "[#{t(:resend).upcase}] " : '')
subject += "#{Spree::Config[:site_name]} #{t('order_mailer.confirm_email.subject')} ##{@order.number}"
mail(:to => @order.distributor.contact.email,
:from => from_address,
:subject => subject)
I18n.with_locale valid_locale(@order.user) do
mail(to: @order.distributor.contact.email,
from: from_address,
subject: mail_subject(t('order_mailer.confirm_email.subject'), resend))
end
end
def invoice_email(order, pdf)
find_order(order) # Finds an order instance from an id
attachments["invoice-#{@order.number}.pdf"] = pdf if pdf.present?
subject = "#{Spree::Config[:site_name]} #{t(:invoice)} ##{@order.number}"
mail(:to => @order.email,
:from => from_address,
:subject => subject,
:reply_to => @order.distributor.contact.email)
attach_file("invoice-#{@order.number}.pdf", pdf)
I18n.with_locale valid_locale(@order.user) do
mail(to: @order.email,
from: from_address,
subject: mail_subject(t(:invoice), false),
reply_to: @order.distributor.contact.email)
end
end
def find_order(order)
@order = order.respond_to?(:id) ? order : Spree::Order.find(order)
end
private
def mail_subject(base_subject, resend)
resend_prefix = (resend ? "[#{t(:resend).upcase}] " : '')
"#{resend_prefix}#{Spree::Config[:site_name]} #{base_subject} ##{@order.number}"
end
def attach_file(filename, file)
attachments[filename] = file if file.present?
end
end

View File

@@ -1,8 +1,12 @@
Spree::UserMailer.class_eval do
include I18nHelper
def signup_confirmation(user)
@user = user
mail(:to => user.email, :from => from_address,
:subject => t(:welcome_to) + Spree::Config[:site_name])
I18n.with_locale valid_locale(@user) do
mail(:to => user.email, :from => from_address,
:subject => t(:welcome_to) + Spree::Config[:site_name])
end
end
# Overriding `Spree::UserMailer.confirmation_instructions` which is
@@ -12,10 +16,12 @@ Spree::UserMailer.class_eval do
@instance = Spree::Config[:site_name]
@contact = ContentConfig.footer_email
subject = t('spree.user_mailer.confirmation_instructions.subject')
mail(to: confirmation_email_address,
from: from_address,
subject: subject)
I18n.with_locale valid_locale(@user) do
subject = t('spree.user_mailer.confirmation_instructions.subject')
mail(to: confirmation_email_address,
from: from_address,
subject: subject)
end
end
private

View File

@@ -1,6 +1,7 @@
class SubscriptionMailer < Spree::BaseMailer
helper CheckoutHelper
helper ShopMailHelper
include I18nHelper
def confirmation_email(order)
@type = 'confirmation'
@@ -46,10 +47,13 @@ class SubscriptionMailer < Spree::BaseMailer
private
def send_mail(order)
subject = "#{Spree::Config[:site_name]} #{t('order_mailer.confirm_email.subject')} ##{order.number}"
mail(to: order.email,
from: from_address,
subject: subject,
reply_to: order.distributor.contact.email)
I18n.with_locale valid_locale(order.user) do
confirm_email_subject = t('order_mailer.confirm_email.subject')
subject = "#{Spree::Config[:site_name]} #{confirm_email_subject} ##{order.number}"
mail(to: order.email,
from: from_address,
subject: subject,
reply_to: order.distributor.contact.email)
end
end
end

View File

@@ -1,7 +1,11 @@
require 'spree/localized_number'
module Calculator
class Weight < Spree::Calculator
extend Spree::LocalizedNumber
preference :per_kg, :decimal, default: 0.0
attr_accessible :preferred_per_kg
localize_number :preferred_per_kg
def self.description
I18n.t('spree.weight')
@@ -12,19 +16,5 @@ module Calculator
total_weight = line_items.sum { |li| ((li.variant.andand.weight || 0) * li.quantity) }
total_weight * preferred_per_kg
end
private
def line_items_for(object)
if object.respond_to? :order
object.order.line_items
elsif object.respond_to? :line_items
object.line_items
elsif object.respond_to?(:variant) && object.respond_to?(:quantity)
[object]
else
raise "Unknown object type: #{object.inspect}"
end
end
end
end

View File

@@ -0,0 +1,5 @@
module AddressDisplay
def full_name_reverse
[lastname, firstname].reject(&:blank?).join(" ")
end
end

View File

@@ -0,0 +1,59 @@
# Validates the combination of on_demand and count_on_hand values.
#
# `on_demand` can have three values: true, false or nil
# `count_on_hand` can either be: nil or a number
#
# This means that a variant override can be in six different stock states
# but only three of them are valid.
#
# | on_demand | count_on_hand | stock_overridden? | use_producer_stock_settings? | valid? |
# |-----------|---------------|-------------------|------------------------------|--------|
# | 1 | nil | false | false | true |
# | 0 | x | true | false | true |
# | nil | nil | false | true | true |
# | 1 | x | ? | ? | false |
# | 0 | nil | ? | ? | false |
# | nil | x | ? | ? | false |
#
# This module has one method for each invalid case.
module StockSettingsOverrideValidation
extend ActiveSupport::Concern
included do
before_validation :require_compatible_on_demand_and_count_on_hand
end
def require_compatible_on_demand_and_count_on_hand
disallow_count_on_hand_if_using_producer_stock_settings
disallow_count_on_hand_if_on_demand
require_count_on_hand_if_limited_stock
end
def disallow_count_on_hand_if_using_producer_stock_settings
return unless on_demand.nil? && count_on_hand.present?
error_message = I18n.t("count_on_hand.using_producer_stock_settings_but_count_on_hand_set",
scope: i18n_scope_for_stock_settings_override_validation_error)
errors.add(:count_on_hand, error_message)
end
def disallow_count_on_hand_if_on_demand
return unless on_demand? && count_on_hand.present?
error_message = I18n.t("count_on_hand.on_demand_but_count_on_hand_set",
scope: i18n_scope_for_stock_settings_override_validation_error)
errors.add(:count_on_hand, error_message)
end
def require_count_on_hand_if_limited_stock
return unless on_demand == false && count_on_hand.blank?
error_message = I18n.t("count_on_hand.limited_stock_but_no_count_on_hand",
scope: i18n_scope_for_stock_settings_override_validation_error)
errors.add(:count_on_hand, error_message)
end
def i18n_scope_for_stock_settings_override_validation_error
"activerecord.errors.models.#{self.class.name.underscore}"
end
end

View File

@@ -27,8 +27,6 @@ class Enterprise < ActiveRecord::Base
has_many :supplied_products, :class_name => 'Spree::Product', :foreign_key => 'supplier_id', :dependent => :destroy
has_many :distributed_orders, :class_name => 'Spree::Order', :foreign_key => 'distributor_id'
belongs_to :address, :class_name => 'Spree::Address'
has_many :product_distributions, :foreign_key => 'distributor_id', :dependent => :destroy
has_many :distributed_products, :through => :product_distributions, :source => :product
has_many :enterprise_fees
has_many :enterprise_roles, :dependent => :destroy
has_many :users, through: :enterprise_roles
@@ -109,17 +107,20 @@ class Enterprise < ActiveRecord::Base
scope :is_primary_producer, where(:is_primary_producer => true)
scope :is_distributor, where('sells != ?', 'none')
scope :is_hub, where(sells: 'any')
scope :supplying_variant_in, lambda { |variants| joins(:supplied_products => :variants_including_master).where('spree_variants.id IN (?)', variants).select('DISTINCT enterprises.*') }
scope :supplying_variant_in, lambda { |variants|
joins(:supplied_products => :variants_including_master).
where('spree_variants.id IN (?)', variants).
select('DISTINCT enterprises.*')
}
scope :with_distributed_products_outer,
joins('LEFT OUTER JOIN product_distributions ON product_distributions.distributor_id = enterprises.id').
joins('LEFT OUTER JOIN spree_products ON spree_products.id = product_distributions.product_id')
scope :with_order_cycles_as_supplier_outer,
joins("LEFT OUTER JOIN exchanges ON (exchanges.sender_id = enterprises.id AND exchanges.incoming = 't')").
joins('LEFT OUTER JOIN order_cycles ON (order_cycles.id = exchanges.order_cycle_id)')
scope :with_order_cycles_as_distributor_outer,
joins("LEFT OUTER JOIN exchanges ON (exchanges.receiver_id = enterprises.id AND exchanges.incoming = 'f')").
joins('LEFT OUTER JOIN order_cycles ON (order_cycles.id = exchanges.order_cycle_id)')
scope :with_order_cycles_outer,
joins("LEFT OUTER JOIN exchanges ON (exchanges.receiver_id = enterprises.id OR exchanges.sender_id = enterprises.id)").
joins('LEFT OUTER JOIN order_cycles ON (order_cycles.id = exchanges.order_cycle_id)')
@@ -136,16 +137,15 @@ class Enterprise < ActiveRecord::Base
}
scope :distributing_products, lambda { |products|
# TODO: remove this when we pull out product distributions
pds = joins("INNER JOIN product_distributions ON product_distributions.distributor_id = enterprises.id").
where("product_distributions.product_id IN (?)", products).select('DISTINCT enterprises.id')
exs = joins("INNER JOIN exchanges ON (exchanges.receiver_id = enterprises.id AND exchanges.incoming = 'f')").
exchanges = joins("
INNER JOIN exchanges
ON (exchanges.receiver_id = enterprises.id AND exchanges.incoming = 'f')
").
joins('INNER JOIN exchange_variants ON (exchange_variants.exchange_id = exchanges.id)').
joins('INNER JOIN spree_variants ON (spree_variants.id = exchange_variants.variant_id)').
where('spree_variants.product_id IN (?)', products).select('DISTINCT enterprises.id')
where(id: pds | exs)
where(id: exchanges)
}
scope :managed_by, lambda { |user|
@@ -247,14 +247,6 @@ class Enterprise < ActiveRecord::Base
Spree::Variant.joins(:product).merge(Spree::Product.in_distributor(self)).select('spree_variants.*')
end
def product_distribution_variants
Spree::Variant.joins(:product).merge(Spree::Product.in_product_distribution_by(self)).select('spree_variants.*')
end
def available_variants
Spree::Variant.joins(:product => :product_distributions).where('product_distributions.distributor_id=?', self.id)
end
def is_distributor
self.sells != "none"
end

View File

@@ -26,7 +26,6 @@ class EnterpriseFee < ActiveRecord::Base
validates_presence_of :name
before_save :ensure_valid_tax_category_settings
before_destroy :ensure_no_product_distributions
scope :for_enterprise, lambda { |enterprise| where(enterprise_id: enterprise) }
scope :for_enterprises, lambda { |enterprises| where(enterprise_id: enterprises) }
@@ -46,10 +45,6 @@ class EnterpriseFee < ActiveRecord::Base
joins(:calculator).where('spree_calculators.type IN (?)', PER_ORDER_CALCULATORS)
}
def self.clear_all_adjustments_for(line_item)
line_item.order.adjustments.where(originator_type: 'EnterpriseFee', source_id: line_item, source_type: 'Spree::LineItem').destroy_all
end
def self.clear_all_adjustments_on_order(order)
order.adjustments.where(originator_type: 'EnterpriseFee').destroy_all
end
@@ -69,15 +64,6 @@ class EnterpriseFee < ActiveRecord::Base
return true
end
def ensure_no_product_distributions
dependent_distribution = ProductDistribution.where(enterprise_fee_id: self).first
return unless dependent_distribution
product = dependent_distribution.product
error = I18n.t(:enterprise_fees_destroy_error, id: product.id, name: product.name)
errors.add(:base, error)
false
end
def refresh_products_cache
OpenFoodNetwork::ProductsCache.enterprise_fee_changed self
end

View File

@@ -11,18 +11,17 @@ class FeatureFlags
#
# @return [Boolean]
def product_import_enabled?
superadmin?
user.superadmin?
end
# Checks whether the "Enterprise Fee Summary" is enabled for the specified user
#
# @return [Boolean]
def enterprise_fee_summary_enabled?
user.superadmin?
end
private
attr_reader :user
# Checks whether the specified user is a superadmin, with full control of the
# instance
#
# @return [Boolean]
def superadmin?
user.has_spree_role?('admin')
end
end

View File

@@ -39,18 +39,10 @@ class OrderCycle < ActiveRecord::Base
scope :by_name, order('name')
scope :distributing_product, lambda { |product|
joins(:exchanges).
merge(Exchange.outgoing).
merge(Exchange.with_product(product)).
select('DISTINCT order_cycles.*')
}
scope :with_distributor, lambda { |distributor|
joins(:exchanges).merge(Exchange.outgoing).merge(Exchange.to_enterprise(distributor))
}
scope :managed_by, lambda { |user|
if user.has_spree_role?('admin')
scoped
@@ -156,7 +148,6 @@ class OrderCycle < ActiveRecord::Base
end
def distributed_variants
# TODO: only used in DistributionChangeValidator, can we remove?
self.exchanges.outgoing.map(&:variants).flatten.uniq.reject(&:deleted?)
end
@@ -175,17 +166,6 @@ class OrderCycle < ActiveRecord::Base
variants_distributed_by(distributor).map(&:product).uniq
end
# If a product without variants is added to an order cycle, and then some variants are added
# to that product, but not the order cycle, then the master variant should not available for customers
# to purchase.
# This method filters out such products so that the customer cannot purchase them.
def valid_products_distributed_by(distributor)
variants = variants_distributed_by(distributor)
products = variants.map(&:product).uniq
product_ids = products.reject{ |p| product_has_only_obsolete_master_in_distribution?(p, variants) }.map(&:id)
Spree::Product.where(id: product_ids)
end
def products
self.variants.map(&:product).uniq
end
@@ -265,17 +245,6 @@ class OrderCycle < ActiveRecord::Base
private
# If a product without variants is added to an order cycle, and then some variants are added
# to that product, but not the order cycle, then the master variant should not available for customers
# to purchase.
# This method is used by #valid_products_distributed_by to filter out such products so that
# the customer cannot purchase them.
def product_has_only_obsolete_master_in_distribution?(product, distributed_variants)
product.has_variants? &&
distributed_variants.include?(product.master) &&
(product.variants & distributed_variants).empty?
end
def orders_close_at_after_orders_open_at?
return if orders_open_at.blank? || orders_close_at.blank?
return if orders_close_at > orders_open_at

View File

@@ -1,27 +0,0 @@
class ProductDistribution < ActiveRecord::Base
belongs_to :product, :class_name => 'Spree::Product'
belongs_to :distributor, :class_name => 'Enterprise'
belongs_to :enterprise_fee
validates_presence_of :product_id, :on => :update
validates_presence_of :distributor_id, :enterprise_fee_id
validates_uniqueness_of :product_id, :scope => :distributor_id
def adjustment_for(line_item)
adjustments = line_item.order.adjustments.enterprise_fee.where(originator_id: enterprise_fee)
raise "Multiple adjustments for this enterprise fee on this line item. This method is not designed to deal with this scenario." if adjustments.count > 1
adjustments.first
end
def create_adjustment_for(line_item)
a = enterprise_fee.create_adjustment(adjustment_label_for(line_item), line_item.order, line_item, true)
AdjustmentMetadata.create! adjustment: a, enterprise: enterprise_fee.enterprise, fee_name: enterprise_fee.name, fee_type: enterprise_fee.fee_type, enterprise_role: 'distributor'
end
def adjustment_label_for(line_item)
I18n.t(:products_distribution_adjustment_label, distributor: distributor.name, product: line_item.product.name )
end
end

View File

@@ -175,7 +175,7 @@ module ProductImport
assign_errors product.errors.full_messages, entry.line_number
end
@already_created[entry.enterprise_id] = { entry.name => product.id }
@already_created.deep_merge! entry.enterprise_id => { entry.name => product.id }
end
def save_variant(entry)
@@ -212,12 +212,20 @@ module ProductImport
case setting['mode']
when 'overwrite_all'
object.assign_attributes(attribute => setting['value'])
# In case of new products, some attributes are saved on the variant.
# We write them to the entry here to be copied to the variant later.
if entry.respond_to? "#{attribute}="
entry.public_send("#{attribute}=", setting['value'])
end
when 'overwrite_empty'
if object.public_send(attribute).blank? ||
((attribute == 'on_hand' || attribute == 'count_on_hand') &&
entry.on_hand_nil)
object.assign_attributes(attribute => setting['value'])
if entry.respond_to? "#{attribute}="
entry.public_send("#{attribute}=", setting['value'])
end
end
end
end

View File

@@ -68,6 +68,18 @@ module ProductImport
private
def find_or_initialize_variant_override(entry, existing_variant)
existing_variant_override = VariantOverride.where(
variant_id: existing_variant.id,
hub_id: entry.enterprise_id
).first
existing_variant_override || VariantOverride.new(
variant_id: existing_variant.id,
hub_id: entry.enterprise_id
)
end
def enterprise_validation(entry)
return if name_presence_error entry
return if enterprise_not_found_error entry
@@ -177,7 +189,7 @@ module ProductImport
products.flat_map(&:variants).each do |existing_variant|
unit_scale = existing_variant.product.variant_unit_scale
unscaled_units = entry.unscaled_units || 0
entry.unit_value = unscaled_units * unit_scale
entry.unit_value = unscaled_units * unit_scale unless unit_scale.nil?
if entry_matches_existing_variant?(entry, existing_variant)
variant_override = create_inventory_item(entry, existing_variant)
@@ -242,6 +254,7 @@ module ProductImport
new_product = Spree::Product.new
new_product.assign_attributes(entry.attributes.except('id'))
new_product.supplier_id = entry.producer_id
entry.on_hand = 0 if entry.on_hand.nil?
if new_product.valid?
entry.validates_as = 'new_product' unless entry.errors?
@@ -310,21 +323,12 @@ module ProductImport
end
def create_inventory_item(entry, existing_variant)
existing_variant_override = VariantOverride.where(
variant_id: existing_variant.id,
hub_id: entry.enterprise_id
).first
find_or_initialize_variant_override(entry, existing_variant).tap do |variant_override|
check_variant_override_stock_settings(entry, variant_override)
variant_override = existing_variant_override || VariantOverride.new(
variant_id: existing_variant.id,
hub_id: entry.enterprise_id
)
variant_override.assign_attributes(count_on_hand: entry.on_hand, import_date: @import_time)
check_on_hand_nil(entry, variant_override)
variant_override.assign_attributes(entry.attributes.slice('price', 'on_demand'))
variant_override
variant_override.assign_attributes(import_date: @import_time)
variant_override.assign_attributes(entry.attributes.slice('price', 'on_demand'))
end
end
def mark_as_inventory_item(entry, variant_override)
@@ -355,5 +359,11 @@ module ProductImport
object.count_on_hand = 0 if object.respond_to?(:count_on_hand)
entry.on_hand_nil = true
end
def check_variant_override_stock_settings(entry, object)
object.count_on_hand = entry.on_hand.presence
object.on_demand = object.count_on_hand.blank? if entry.on_demand.blank?
entry.on_hand_nil = object.count_on_hand.blank?
end
end
end

View File

@@ -206,7 +206,7 @@ module ProductImport
def open_spreadsheet
if accepted_mimetype
Roo::Spreadsheet.open(@file, extension: accepted_mimetype)
Roo::Spreadsheet.open(@file, extension: accepted_mimetype, encoding: Encoding::UTF_8)
else
errors.add(:importer, I18n.t(:product_importer_spreadsheet_error))
delete_uploaded_file
@@ -227,6 +227,14 @@ module ProductImport
(2..@sheet.last_row).map do |i|
@sheet.row(i)
end
rescue ArgumentError => e
if e.message.include? 'invalid byte sequence'
errors.add(:importer, I18n.t('admin.product_import.model.encoding_error'))
else
errors.add(:importer, I18n.t('admin.product_import.model.unexpected_error',
error_message: e.message))
end
[]
end
def build_entries_in_range

View File

@@ -138,7 +138,10 @@ class AbilityDecorator
def add_product_management_abilities(user)
# Enterprise User can only access products that they are a supplier for
can [:create], Spree::Product
can [:admin, :read, :index, :update, :product_distributions, :seo, :group_buy_options, :bulk_update, :clone, :delete, :destroy], Spree::Product do |product|
can [:admin, :read, :index, :update,
:seo, :group_buy_options,
:bulk_update, :clone, :delete,
:destroy], Spree::Product do |product|
OpenFoodNetwork::Permissions.new(user).managed_product_enterprises.include? product.supplier
end
@@ -184,7 +187,10 @@ class AbilityDecorator
can [:admin, :index, :guide, :import, :save, :save_data, :validate_data, :reset_absent_products], ProductImport::ProductImporter
# Reports page
can [:admin, :index, :customers, :orders_and_distributors, :group_buys, :bulk_coop, :payments, :orders_and_fulfillment, :products_and_inventory, :order_cycle_management, :packing], :report
can [:admin, :index, :customers, :orders_and_distributors, :group_buys, :bulk_coop, :payments,
:orders_and_fulfillment, :products_and_inventory, :order_cycle_management, :packing],
:report
add_enterprise_fee_summary_abilities(user)
end
def add_order_cycle_management_abilities(user)
@@ -210,7 +216,10 @@ class AbilityDecorator
# during the order creation process from the admin backend
order.distributor.nil? || user.enterprises.include?(order.distributor) || order.order_cycle.andand.coordinated_by?(user)
end
can [:admin, :bulk_management, :managed], Spree::Order if user.admin? || user.enterprises.any?(&:is_distributor)
can [:admin, :bulk_management, :managed], Spree::Order do
user.admin? || user.enterprises.any?(&:is_distributor)
end
can [:admin, :create, :show, :poll], :invoice
can [:admin, :visible], Enterprise
can [:admin, :index, :create, :update, :destroy], :line_item
can [:admin, :index, :create], Spree::LineItem
@@ -254,7 +263,10 @@ class AbilityDecorator
end
# Reports page
can [:admin, :index, :customers, :group_buys, :bulk_coop, :sales_tax, :payments, :orders_and_distributors, :orders_and_fulfillment, :products_and_inventory, :order_cycle_management, :xero_invoices], :report
can [:admin, :index, :customers, :group_buys, :bulk_coop, :sales_tax, :payments,
:orders_and_distributors, :orders_and_fulfillment, :products_and_inventory,
:order_cycle_management, :xero_invoices], :report
add_enterprise_fee_summary_abilities(user)
can [:create], Customer
can [:admin, :index, :update, :destroy, :show], Customer, enterprise_id: Enterprise.managed_by(user).pluck(:id)
@@ -277,6 +289,16 @@ class AbilityDecorator
user.enterprises.include? enterprise_relationship.parent
end
end
def add_enterprise_fee_summary_abilities(user)
feature_enabled = FeatureFlags.new(user).enterprise_fee_summary_enabled?
return unless feature_enabled
# Reveal the report link in spree/admin/reports#index
can [:enterprise_fee_summary], :report
# Allow direct access to the report resource
can [:admin, :new, :create], :enterprise_fee_summary
end
end
Spree::Ability.register_ability(AbilityDecorator)

View File

@@ -1,4 +1,6 @@
Spree::Address.class_eval do
include AddressDisplay
has_one :enterprise, dependent: :restrict
belongs_to :country, class_name: "Spree::Country"

View File

@@ -40,33 +40,6 @@ module Spree
included_tax > 0
end
# @return [Array<Spree::TaxRate>]
def tax_rates
case originator
when Spree::TaxRate
[originator]
when EnterpriseFee
case source
when Spree::LineItem
tax_category = originator.inherits_tax_category? ? source.product.tax_category : originator.tax_category
return tax_category ? tax_category.tax_rates.match(source.order) : []
when Spree::Order
return originator.tax_category ? originator.tax_category.tax_rates.match(source) : []
end
else
find_closest_tax_rates_from_included_tax
end
end
# shipping fees and adjustments created from the admin panel have
# taxes set at creation in the included_tax field without relation
# to the corresponding TaxRate, so we look for the closest one
def find_closest_tax_rates_from_included_tax
approximation = (included_tax / (amount - included_tax))
return [] if approximation.infinite? or approximation.zero?
[Spree::TaxRate.order("ABS(amount - #{approximation})").first]
end
def self.without_callbacks
skip_callback :save, :after, :update_adjustable
skip_callback :destroy, :after, :update_adjustable

View File

@@ -52,4 +52,7 @@ Spree::AppConfiguration.class_eval do
# Number localization
preference :enable_localized_number?, :boolean, default: false
# Enable cache
preference :enable_products_cache?, :boolean, default: !Rails.env.development?
end

View File

@@ -1,18 +1,20 @@
module Spree
Calculator.class_eval do
private
# Given an object which might be an Order or a LineItem (amongst
# others), return a collection of line items.
def line_items_for(object)
if object.respond_to? :line_items
if object.is_a?(Spree::LineItem)
[object]
elsif object.respond_to? :line_items
object.line_items
elsif object.order.present?
object.order.line_items
else
[object]
end
end
end
end

View File

@@ -218,10 +218,6 @@ Spree::Order.class_eval do
line_items.each do |line_item|
if provided_by_order_cycle? line_item
OpenFoodNetwork::EnterpriseFeeCalculator.new.create_line_item_adjustments_for line_item
else
pd = product_distribution_for line_item
pd.create_adjustment_for line_item if pd
end
end
@@ -293,7 +289,7 @@ Spree::Order.class_eval do
def tax_adjustment_totals
tax_adjustments.each_with_object(Hash.new) do |adjustment, hash|
tax_rates = adjustment.tax_rates
tax_rates = TaxRateFinder.tax_rates_of(adjustment)
tax_rates_hash = Hash[tax_rates.collect do |tax_rate|
tax_amount = tax_rates.one? ? adjustment.included_tax : tax_rate.compute_tax(adjustment.amount)
[tax_rate, tax_amount]
@@ -383,10 +379,6 @@ Spree::Order.class_eval do
order_cycle_variants.include? line_item.variant
end
def product_distribution_for(line_item)
line_item.variant.product.product_distribution_for distributor
end
def require_customer?
return true unless new_record? || state == 'cart'
end

View File

@@ -4,6 +4,8 @@ module Spree
Payment.class_eval do
extend Spree::LocalizedNumber
delegate :line_items, to: :order
has_one :adjustment, as: :source, dependent: :destroy
after_save :ensure_correct_adjustment, :update_order
@@ -30,15 +32,6 @@ module Spree
I18n.t('payment_method_fee')
end
# This is called by the calculator of a payment method
def line_items
if order.complete? && Spree::Config[:track_inventory_levels]
order.line_items.select { |li| inventory_units.pluck(:variant_id).include?(li.variant_id) }
else
order.line_items
end
end
# Pin payments lacks void and credit methods, but it does have refund
# Here we swap credit out for refund and remove void as a possible action
def actions_with_pin_payment_adaptations

View File

@@ -23,6 +23,11 @@ Spree::PaymentMethod.class_eval do
end
}
scope :for_distributors, ->(distributors) {
non_unique_matches = unscoped.joins(:distributors).where(enterprises: { id: distributors })
where(id: non_unique_matches.map(&:id))
}
scope :for_distributor, lambda { |distributor|
joins(:distributors).
where('enterprises.id = ?', distributor)

View File

@@ -11,22 +11,17 @@ Spree::Product.class_eval do
belongs_to :supplier, :class_name => 'Enterprise', touch: true
belongs_to :primary_taxon, class_name: 'Spree::Taxon'
has_many :product_distributions, :dependent => :destroy
has_many :distributors, :through => :product_distributions
accepts_nested_attributes_for :product_distributions, :allow_destroy => true
delegate_belongs_to :master, :unit_value, :unit_description
delegate :images_attributes=, :display_as=, to: :master
attr_accessible :supplier_id, :primary_taxon_id, :distributor_ids, :product_distributions_attributes
attr_accessible :supplier_id, :primary_taxon_id, :distributor_ids
attr_accessible :group_buy, :group_buy_unit_size, :unit_description, :notes, :images_attributes, :display_as
attr_accessible :variant_unit, :variant_unit_scale, :variant_unit_name, :unit_value
attr_accessible :inherits_properties, :sku
# validates_presence_of :variants, unless: :new_record?, message: "Product must have at least one variant"
validates_presence_of :supplier
validates :primary_taxon, presence: { message: I18n.t("validation_msg_product_category_cant_be_blank") }
validates :tax_category_id, presence: { message: I18n.t("validation_msg_tax") }, if: "Spree::Config.products_require_tax_category"
validates :primary_taxon, presence: true
validates :tax_category_id, presence: true, if: "Spree::Config.products_require_tax_category"
validates_presence_of :variant_unit
validates_presence_of :variant_unit_scale,
@@ -37,7 +32,6 @@ Spree::Product.class_eval do
after_initialize :set_available_on_to_now, :if => :new_record?
before_validation :sanitize_permalink
before_save :add_primary_taxon_to_taxons
after_touch :touch_distributors
after_save :remove_previous_primary_taxon_from_taxons
after_save :ensure_standard_variant
after_save :update_units
@@ -45,8 +39,6 @@ Spree::Product.class_eval do
# -- Joins
scope :with_product_distributions_outer, joins('LEFT OUTER JOIN product_distributions ON product_distributions.product_id = spree_products.id')
scope :with_order_cycles_outer, joins('LEFT OUTER JOIN spree_variants AS o_spree_variants ON (o_spree_variants.product_id = spree_products.id)').
joins('LEFT OUTER JOIN exchange_variants AS o_exchange_variants ON (o_exchange_variants.variant_id = o_spree_variants.id)').
joins('LEFT OUTER JOIN exchanges AS o_exchanges ON (o_exchanges.id = o_exchange_variants.exchange_id)').
@@ -65,37 +57,28 @@ Spree::Product.class_eval do
# -- Scopes
scope :in_supplier, lambda { |supplier| where(:supplier_id => supplier) }
scope :in_any_supplier, lambda { |suppliers|
where('supplier_id IN (?)', suppliers.map(&:id))
}
# Find products that are distributed via the given distributor EITHER through a product distribution OR through an order cycle
# Products distributed via the given distributor through an OC
scope :in_distributor, lambda { |distributor|
distributor = distributor.respond_to?(:id) ? distributor.id : distributor.to_i
with_product_distributions_outer.with_order_cycles_outer.
where('product_distributions.distributor_id = ? OR (o_exchanges.incoming = ? AND o_exchanges.receiver_id = ?)', distributor, false, distributor).
with_order_cycles_outer.
where('(o_exchanges.incoming = ? AND o_exchanges.receiver_id = ?)', false, distributor).
select('distinct spree_products.*')
}
scope :in_product_distribution_by, lambda { |distributor|
distributor = distributor.respond_to?(:id) ? distributor.id : distributor.to_i
with_product_distributions_outer.
where('product_distributions.distributor_id = ?', distributor).
select('distinct spree_products.*')
}
# Find products that are supplied by a given enterprise or distributed via that enterprise EITHER through a product distribution OR through an order cycle
# Products supplied by a given enterprise or distributed via that enterprise through an OC
scope :in_supplier_or_distributor, lambda { |enterprise|
enterprise = enterprise.respond_to?(:id) ? enterprise.id : enterprise.to_i
with_product_distributions_outer.with_order_cycles_outer.
where('spree_products.supplier_id = ? OR product_distributions.distributor_id = ? OR (o_exchanges.incoming = ? AND o_exchanges.receiver_id = ?)', enterprise, enterprise, false, enterprise).
with_order_cycles_outer.
where("
spree_products.supplier_id = ?
OR (o_exchanges.incoming = ? AND o_exchanges.receiver_id = ?)
", enterprise, false, enterprise).
select('distinct spree_products.*')
}
# Find products that are distributed by the given order cycle
# Products distributed by the given order cycle
scope :in_order_cycle, lambda { |order_cycle| with_order_cycles_inner.
merge(Exchange.outgoing).
where('order_cycles.id = ?', order_cycle)
@@ -155,10 +138,6 @@ Spree::Product.class_eval do
self.class.in_order_cycle(order_cycle).include? self
end
def product_distribution_for(distributor)
self.product_distributions.find_by_distributor_id(distributor)
end
# overriding to check self.on_demand as well
def has_stock?
has_variants? ? variants.any?(&:in_stock?) : (on_demand || master.in_stock?)
@@ -180,15 +159,6 @@ Spree::Product.class_eval do
variants.map(&:import_date).compact.max
end
# Build a product distribution for each distributor
def build_product_distributions_for_user user
Enterprise.is_distributor.managed_by(user).each do |distributor|
unless self.product_distributions.find_by_distributor_id distributor.id
self.product_distributions.build(:distributor => distributor)
end
end
end
def variant_unit_option_type
if variant_unit.present?
option_type_name = "unit_#{variant_unit}"

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