mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-30 21:27:17 +00:00
Delete dead code
This commit is contained in:
@@ -6,12 +6,6 @@ module Spree
|
||||
|
||||
validates :name, :iso_name, presence: true
|
||||
|
||||
def self.states_required_by_country_id
|
||||
states_required = Hash.new(true)
|
||||
all.find_each { |country| states_required[country.id.to_s] = country.states_required }
|
||||
states_required
|
||||
end
|
||||
|
||||
def <=>(other)
|
||||
name <=> other.name
|
||||
end
|
||||
|
||||
@@ -10,16 +10,6 @@ module Spree
|
||||
where('name = ? OR abbr = ?', name_or_abbr, name_or_abbr)
|
||||
end
|
||||
|
||||
# table of { country.id => [ state.id , state.name ] }, arrays sorted by name
|
||||
# blank is added elsewhere, if needed
|
||||
def self.states_group_by_country_id
|
||||
state_info = Hash.new { |h, k| h[k] = [] }
|
||||
order('name ASC').each { |state|
|
||||
state_info[state.country_id.to_s].push [state.id, state.name]
|
||||
}
|
||||
state_info
|
||||
end
|
||||
|
||||
def <=>(other)
|
||||
name <=> other.name
|
||||
end
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Spree::Country do
|
||||
it "can find all countries group by states required" do
|
||||
country_states_required = Spree::Country.create({ name: "Canada",
|
||||
iso_name: "CAN",
|
||||
states_required: true })
|
||||
country_states_not_required = Spree::Country.create({ name: "France",
|
||||
iso_name: "FR",
|
||||
states_required: false })
|
||||
states_required = Spree::Country.states_required_by_country_id
|
||||
expect(states_required[country_states_required.id.to_s]).to be_truthy
|
||||
expect(states_required[country_states_not_required.id.to_s]).to be_falsy
|
||||
end
|
||||
|
||||
it "returns that the states are required for an invalid country" do
|
||||
expect(Spree::Country.states_required_by_country_id['i do not exit']).to be_truthy
|
||||
end
|
||||
end
|
||||
@@ -12,10 +12,4 @@ describe Spree::State do
|
||||
expect(Spree::State.find_all_by_name_or_abbr("California")).to include(state)
|
||||
expect(Spree::State.find_all_by_name_or_abbr("CA")).to include(state)
|
||||
end
|
||||
|
||||
it "can find all states group by country id" do
|
||||
state = create(:state)
|
||||
country_hash = { state.country_id.to_s => [[state.id, state.name]] }
|
||||
expect(Spree::State.states_group_by_country_id).to eq country_hash
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user