mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Remove unused method loading default country
And another unused method.
This commit is contained in:
@@ -5,17 +5,6 @@
|
||||
class DefaultStockLocation
|
||||
NAME = 'default'
|
||||
|
||||
def self.create!
|
||||
country = Spree::Country.find_by(iso: ENV['DEFAULT_COUNTRY_CODE'])
|
||||
state = country.states.first
|
||||
Spree::StockLocation.create!(name: NAME, country_id: country.id, state_id: state.id,
|
||||
backorderable_default: false)
|
||||
end
|
||||
|
||||
def self.destroy_all
|
||||
Spree::StockLocation.where(name: NAME).destroy_all
|
||||
end
|
||||
|
||||
def self.find_or_create
|
||||
Spree::StockLocation.find_or_create_by(name: NAME)
|
||||
end
|
||||
|
||||
@@ -3,34 +3,6 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe DefaultStockLocation do
|
||||
describe '.create!' do
|
||||
it "names the location 'OFN default'" do
|
||||
stock_location = described_class.create!
|
||||
expect(stock_location.name).to eq('default')
|
||||
end
|
||||
|
||||
it 'sets the location in the default country' do
|
||||
default_country = Spree::Country.find_by(iso: ENV['DEFAULT_COUNTRY_CODE'])
|
||||
stock_location = described_class.create!
|
||||
expect(stock_location.country).to eq(default_country)
|
||||
end
|
||||
|
||||
it 'sets the first state in the country' do
|
||||
default_country = Spree::Country.find_by(iso: ENV['DEFAULT_COUNTRY_CODE'])
|
||||
stock_location = described_class.create!
|
||||
expect(stock_location.state).to eq(default_country.states.first)
|
||||
end
|
||||
end
|
||||
|
||||
describe '.destroy_all' do
|
||||
it "removes all stock locations named 'default'" do
|
||||
create(:stock_location)
|
||||
|
||||
expect { described_class.destroy_all }
|
||||
.to change { Spree::StockLocation.count }.to(0)
|
||||
end
|
||||
end
|
||||
|
||||
describe '.find_or_create' do
|
||||
context 'when a location named default already exists' do
|
||||
let!(:location) do
|
||||
|
||||
Reference in New Issue
Block a user