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:
Maikel Linke
2019-03-18 17:29:58 +11:00
parent 130ba64f2f
commit 1ea2f37c18
2 changed files with 6 additions and 0 deletions

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')

View File

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