From 43e64f35559d6680cdc32284ce44e09d76ec98ef Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Thu, 6 Aug 2020 01:38:40 +0100 Subject: [PATCH] Delete dead code --- app/models/spree/country.rb | 6 ------ app/models/spree/state.rb | 10 ---------- spec/models/spree/country_spec.rb | 21 --------------------- spec/models/spree/state_spec.rb | 6 ------ 4 files changed, 43 deletions(-) delete mode 100644 spec/models/spree/country_spec.rb diff --git a/app/models/spree/country.rb b/app/models/spree/country.rb index 2f69cd75d5..e0a69f3ae6 100644 --- a/app/models/spree/country.rb +++ b/app/models/spree/country.rb @@ -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 diff --git a/app/models/spree/state.rb b/app/models/spree/state.rb index 1342feb4cb..7b3c5ff057 100644 --- a/app/models/spree/state.rb +++ b/app/models/spree/state.rb @@ -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 diff --git a/spec/models/spree/country_spec.rb b/spec/models/spree/country_spec.rb deleted file mode 100644 index a70d341436..0000000000 --- a/spec/models/spree/country_spec.rb +++ /dev/null @@ -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 diff --git a/spec/models/spree/state_spec.rb b/spec/models/spree/state_spec.rb index 6730fc773b..47a3b8552d 100644 --- a/spec/models/spree/state_spec.rb +++ b/spec/models/spree/state_spec.rb @@ -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