Joseph Johansen
5086f2d8b5
Fix rubocop Style/Send group
2024-07-23 14:18:26 +01:00
Maikel Linke
6317fe1b71
Disable RSpec monkey patching
2024-05-09 12:24:41 +10:00
Neal Chambers
fe88a88206
Fix Style/HashSyntax
2023-09-22 09:08:50 +09:00
Neal Chambers
7ecd4a149b
Fix Style/HashSyntax
2023-09-21 22:58:42 +09:00
David Cook
c0c123a92a
Remove localized number logic from weight calculator
...
Follow-on from a46eef291c
2023-05-17 14:10:58 +02:00
David Cook
918425fd93
Remove customised error message
...
We're now handling these values on the frontend, so can keep this simple.
fixes up:
Add numericality validation for *
Add translation for Active Record error message
2023-04-28 14:02:12 +10:00
David Cook
a46eef291c
Remove localized number logic from calculators
...
The browser is now responsible for dealing with the decimal separator, for all numeric preferences (as input[type=number]; see Spree::Admin::BaseHelper::preference_field_tag). Calculators are the only place that numeric preferences are used.
It will enforce that only one comma or dot (depending on user's locale) is entered, thus avoiding any ambiguity, and mis-interpretation (eg 100,001 could be interpreted as more than 100 thousand or 100 with a decimal place).
2023-04-28 13:54:16 +10:00
James Wu
29ddc68d20
Fix duplicate validation error message
2023-04-18 09:39:39 +10:00
James Wu
6b1426d0c6
Add numericality validation for PriceSack
2023-04-18 09:39:39 +10:00
James Wu
c68987c0f2
Add numericality validation for PerItem
2023-04-18 09:39:39 +10:00
James Wu
2cb25e6366
Add numericality validation for FlexiRate
2023-04-18 09:39:39 +10:00
James Wu
073f46e590
Add numericality validation for FlatRate
2023-04-18 09:39:39 +10:00
James Wu
23beea8a13
Add numericality validation for FlatPercentPerItem
2023-04-18 09:39:39 +10:00
James Wu
096e388fdf
Add numericality validation for FlatPercentItemTotal
2023-04-18 09:39:39 +10:00
Luis Ramos
23627c5453
Run rubocop -a (safe corrections) removing all exceptions so all possible fixes are applied
...
9290 issues fixed
2021-06-17 22:19:26 +01:00
Luis Ramos
2b8f0abe49
Try some mass auto-correct adding frozen-string-literal to all specs
2020-12-03 06:38:24 -08:00
Maikel
8c65498661
Merge pull request #5998 from andrewpbrett/shipping-per-pound
...
Per-pound shipping calculator
2020-10-16 15:27:57 +11:00
Luis Ramos
e04b85e900
Merge pull request #6078 from arku/perf/per-item-flexi-rate-specs
...
Replace `build` with `build_stubbed` in flexi rate and per item model specs
2020-09-24 18:41:29 +01:00
Luis Ramos
b8fae8e3a3
Merge pull request #6077 from arku/perf/calculator-price-sack-specs
...
Replace `build` with `build_stubbed` in price sack model specs
2020-09-24 18:41:19 +01:00
Luis Ramos
01fdee9dba
Merge pull request #6076 from arku/perf/calculator-flat-percent-item-total-specs
...
Replace `build` with `build_stubbed` in flat percent item total specs
2020-09-24 18:40:55 +01:00
Andy Brett
84eb8e964d
add specs for weight calculators using lbs
2020-09-24 07:03:57 -07:00
Arun Kumar Mohan
bc77b8bcb2
Replace build with build_stubbed in per item model specs
2020-09-21 21:24:38 -05:00
Arun Kumar Mohan
38ab95a9a4
Replace build with build_stubbed in flexi rate model specs
2020-09-21 21:22:59 -05:00
Arun Kumar Mohan
698d8b35fa
Replace build with build_stubbed in price sack model specs
2020-09-21 21:18:36 -05:00
Arun Kumar Mohan
a257a9e9d2
Replace build with build_stubbed in calculator weight model specs
2020-09-21 21:12:30 -05:00
Arun Kumar Mohan
231fbcd11a
Replace build with build_stubbed in flat percent item total specs
2020-09-21 21:04:16 -05:00
Arun Kumar Mohan
c098ba0ce3
Replace create with build_stubbed in calculator weight model specs
2020-09-21 20:46:50 -05:00
Andy Brett
4123eb7c10
update specs; add specs to validate weight calculator preference is kg or lb
2020-09-12 11:53:45 -07:00
Andy Brett
adb29a9c8f
add preferred_unit to weight shipping calculator
2020-09-07 08:41:48 -07:00
Andy Brett
4bc3101f4d
Add specs for shipping weight calculations using lbs and oz
2020-09-03 09:11:00 -07:00
Luis Ramos
9c7cb23262
Move calculator specs out of the spree namespace
2020-07-07 17:26:24 +01:00
Maikel Linke
4bcd665379
Handle all line items without unit_value in weight calculation
2020-03-26 17:13:29 +11:00
Luis Ramos
24c8f38111
Restructure spec to avoid variable names with numbers
2020-03-25 15:48:57 +01:00
Luis Ramos
9af4bb9757
Use create instead of build so that we test with callbacks
2020-03-25 11:22:40 +00:00
Matt-Yorkley
ef0fb18fda
Fix calculations for weight when variant.unit_value is zero
2020-03-24 22:05:55 +01:00
Matt-Yorkley
87ee4bbebc
Add spec for current problematic behaviour
2020-03-24 20:09:54 +01:00
Matt-Yorkley
54c3c73ed2
Fix duplicate key in hash
2020-03-24 12:46:21 +01:00
luisramos0
e9e6aa77d8
Make weight calculator work for SubscriptionLineItems by making it test if line_item responds to final_weight_volume field (final_weight_volume_present?)
...
We also add logic to weight_per_variant so that we use variant.unit_value if final_weight_volume is not available but variant_unit is weight
Adapt some test case to test unit_value (in grams) instead of weight (in kgs)
2019-12-08 17:36:21 +00:00
luisramos0
0e8f167ab9
Fix spec in weight calculator tests
2019-08-02 20:44:11 +01:00
Kristina Lim
e1fce8304d
Update weight calculator and add specs
2019-07-23 23:24:00 +08:00
luisramos0
160b535e2f
Make weight calculator compute 0 for variants with unit different from weight
2019-06-18 15:21:13 +01:00
luisramos0
82955b9fe5
Make weight calculator use line_item.final_weight_volume rather than variant.weight for cases where the final weight is set manually in the BOM
2019-05-31 19:55:17 +01: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
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
luisramos0
9490da329a
Move Calculator::Weight from models/open_food_network/calculator to models/calculator
2018-11-07 09:54:30 +00:00
luisramos0
bf55f50a7e
Fix rubocop warnings on weight and weight_spec
2018-11-07 09:54:30 +00:00
luisramos0
275a192270
Convert specs to RSpec 3.7.1 syntax with Transpec
...
This conversion is done by Transpec 3.3.0 with the following command:
transpec spec/models/calculator/weight_spec.rb
* 3 conversions
from: == expected
to: eq(expected)
* 3 conversions
from: obj.should
to: expect(obj).to
For more details: https://github.com/yujinakayama/transpec#supported-conversions
2018-11-07 09:54:30 +00:00
luisramos0
1ef04354fd
Add capacity to weight calculator to calculate based on any object with an order (needed in spree 2 to calculate based on package)
2018-11-07 09:54:30 +00:00
Pierre de Lacroix
f67a8c1f2d
Add tests
2017-12-01 13:37:24 +11:00
Rohan Mitchell
701c047a0a
Move our customisations of FlatPercentItemTotal calculator to a new calc: FlatPercentPerItem
2016-08-26 09:28:29 +10:00