mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-08 22:56:06 +00:00
load GeneralSettingsHelper#all_units from WeightsAndMeasures::UNITS
This commit is contained in:
@@ -5,11 +5,9 @@ module Spree
|
||||
module GeneralSettingsHelper
|
||||
def all_units
|
||||
[
|
||||
"mg", "g", "kg", "T",
|
||||
"oz", "lb",
|
||||
"mL", "cL", "dL", "L", "kL",
|
||||
"gal"
|
||||
]
|
||||
WeightsAndMeasures::UNITS['weight'].values.pluck('name'),
|
||||
WeightsAndMeasures::UNITS['volume'].values.pluck('name')
|
||||
].flatten.uniq
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
12
spec/helpers/spree/admin/general_settings_helper_spec.rb
Normal file
12
spec/helpers/spree/admin/general_settings_helper_spec.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Spree::Admin::GeneralSettingsHelper, type: :helper do
|
||||
describe "#all_units" do
|
||||
it "returns all units" do
|
||||
expect(helper.all_units).to eq(["mg", "g", "kg", "T", "oz", "lb", "mL", "cL", "dL", "L",
|
||||
"kL", "gal"])
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -90,12 +90,4 @@ describe WeightsAndMeasures do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "UNITS" do
|
||||
include Spree::Admin::GeneralSettingsHelper
|
||||
it "should include all the available untis" do
|
||||
units = WeightsAndMeasures::UNITS.values.flat_map(&:values).pluck("name").sort.uniq
|
||||
expect(units).to eq(all_units.sort.uniq)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user