Files
openfoodnetwork/spec/services/default_stock_location_spec.rb
Maikel Linke 392aeb7321 Remove unused method loading default country
And another unused method.
2022-11-02 16:21:15 +11:00

40 lines
1.1 KiB
Ruby

# frozen_string_literal: true
require 'spec_helper'
describe DefaultStockLocation do
describe '.find_or_create' do
context 'when a location named default already exists' do
let!(:location) do
country = create(:country)
state = Spree::State.create(name: 'Alabama', country: country)
Spree::StockLocation.create!(
name: 'default',
country_id: country.id,
state_id: state.id
)
end
it 'returns the location' do
expect(described_class.find_or_create).to eq(location)
end
it 'does not create any other location' do
expect { described_class.find_or_create }.not_to change(Spree::StockLocation, :count)
end
end
context 'when a location named default does not exist' do
it 'returns the location' do
location = described_class.find_or_create
expect(location.name).to eq('default')
end
it 'does not create any other location' do
expect { described_class.find_or_create }
.to change(Spree::StockLocation, :count).from(0).to(1)
end
end
end
end