mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-17 00:07:24 +00:00
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.
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Calculator::Weight do
|
||||
it_behaves_like "a model using the LocalizedNumber module", [:preferred_per_kg]
|
||||
|
||||
it "computes shipping cost for an order by total weight" do
|
||||
variant1 = build(:variant, weight: 10)
|
||||
variant2 = build(:variant, weight: 20)
|
||||
|
||||
Reference in New Issue
Block a user