mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Rubocop fixes
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
# Encapsulates the concept of default stock location in creation of a product or a shipping method.
|
||||
|
||||
class DefaultShippingCategory
|
||||
NAME = 'Default'.freeze
|
||||
NAME = 'Default'.freeze
|
||||
|
||||
def self.create!
|
||||
Spree::ShippingCategory.create!(name: NAME)
|
||||
end
|
||||
def self.create!
|
||||
Spree::ShippingCategory.create!(name: NAME)
|
||||
end
|
||||
|
||||
def self.find_or_create
|
||||
Spree::ShippingCategory.find_or_create_by_name(NAME)
|
||||
end
|
||||
end
|
||||
def self.find_or_create
|
||||
Spree::ShippingCategory.find_or_create_by_name(NAME)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -52,4 +52,4 @@ end
|
||||
require File.join(File.dirname(__FILE__), 'default', 'users')
|
||||
|
||||
DefaultStockLocation.find_or_create
|
||||
DefaultShippingCategory.find_or_create
|
||||
DefaultShippingCategory.find_or_create
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe DefaultShippingCategory do
|
||||
describe '.create!' do
|
||||
it "names the location 'Default'" do
|
||||
shipping_category = described_class.create!
|
||||
expect(shipping_category.name).to eq('Default')
|
||||
end
|
||||
end
|
||||
describe '.create!' do
|
||||
it "names the location 'Default'" do
|
||||
shipping_category = described_class.create!
|
||||
expect(shipping_category.name).to eq('Default')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'find_or_create' do
|
||||
context 'when a Default category already exists' do
|
||||
let!(:category) do
|
||||
Spree::ShippingCategory.create!(name: 'Default')
|
||||
end
|
||||
describe 'find_or_create' do
|
||||
context 'when a Default category already exists' do
|
||||
let!(:category) do
|
||||
Spree::ShippingCategory.create!(name: 'Default')
|
||||
end
|
||||
|
||||
it 'returns the category' do
|
||||
expect(described_class.find_or_create).to eq(category)
|
||||
@@ -21,19 +21,18 @@ describe DefaultShippingCategory do
|
||||
it 'does not create another category' do
|
||||
expect { described_class.find_or_create }.not_to change(Spree::ShippingCategory, :count)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a Default category does not exist' do
|
||||
it 'returns the category' do
|
||||
category = described_class.find_or_create
|
||||
expect(category.name).to eq('Default')
|
||||
end
|
||||
context 'when a Default category does not exist' do
|
||||
it 'returns the category' do
|
||||
category = described_class.find_or_create
|
||||
expect(category.name).to eq('Default')
|
||||
end
|
||||
|
||||
it 'does not create another category' do
|
||||
expect { described_class.find_or_create }
|
||||
.to change(Spree::ShippingCategory, :count).from(0).to(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
it 'does not create another category' do
|
||||
expect { described_class.find_or_create }
|
||||
.to change(Spree::ShippingCategory, :count).from(0).to(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user