Remove stock location from specs

This commit is contained in:
Maikel Linke
2025-01-22 11:51:42 +11:00
parent 33ed0998a9
commit 70ebe7b964
11 changed files with 4 additions and 53 deletions

View File

@@ -339,7 +339,6 @@ Naming/VariableNumber:
- 'app/models/preference_sections/main_links_section.rb'
- 'lib/spree/core/controller_helpers/common.rb'
- 'spec/controllers/spree/admin/search_controller_spec.rb'
- 'spec/factories/stock_location_factory.rb'
- 'spec/models/spree/stock_item_spec.rb'
- 'spec/models/spree/tax_rate_spec.rb'
- 'spec/requests/api/orders_spec.rb'

View File

@@ -142,7 +142,6 @@ RSpec.describe Spree::Admin::ProductsController, type: :controller do
before do
controller_login_as_admin
create(:stock_location)
end
it "redirects to products when the user hits 'create'" do

View File

@@ -1,33 +0,0 @@
# frozen_string_literal: true
FactoryBot.define do
factory :stock_location, class: Spree::StockLocation do
# keeps the test stock_location unique
initialize_with { Spree::StockLocation.first || DefaultStockLocation.find_or_create }
address1 { '1600 Pennsylvania Ave NW' }
city { 'Washington' }
zipcode { '20500' }
phone { '(202) 456-1111' }
country { |stock_location| Spree::Country.first || stock_location.association(:country) }
state do |stock_location|
stock_location.country.states.first ||
stock_location.association(:state, country: stock_location.country)
end
factory :stock_location_with_items do
after(:create) do |_stock_location, _evaluator|
# variant will add itself to all stock_locations in an after_create
# creating a product will automatically create a master variant
product_1 = create(:product)
product_2 = create(:product)
Spree::StockItem.where(variant_id: product_1.variants.first.id)
.first.adjust_count_on_hand(10)
Spree::StockItem.where(variant_id: product_2.variants.first.id)
.first.adjust_count_on_hand(20)
end
end
end
end

View File

@@ -3,8 +3,8 @@
require 'spec_helper'
RSpec.describe Spree::InventoryUnit do
let!(:stock_location) { create(:stock_location_with_items) }
let(:stock_item) { Spree::StockItem.order(:id).first }
let(:variant) { create(:variant) }
let(:stock_item) { variant.stock_item }
context "variants deleted" do
let!(:unit) do
@@ -18,8 +18,6 @@ RSpec.describe Spree::InventoryUnit do
end
context "#finalize_units!" do
let!(:stock_location) { create(:stock_location) }
let(:variant) { create(:variant) }
let(:inventory_units) {
[
create(:inventory_unit, variant:),

View File

@@ -130,10 +130,6 @@ module Spree
let!(:taxon){ create(:taxon) }
let(:supplier){ create(:enterprise) }
before do
create(:stock_location)
end
it "copies properties to the first standard variant" do
product.primary_taxon_id = taxon.id
product.name = "Product1"

View File

@@ -3,9 +3,7 @@
require 'spec_helper'
RSpec.describe Spree::StockItem do
let!(:stock_location) { create(:stock_location_with_items) }
subject(:stock_item) { Spree::StockItem.order(:id).first }
subject(:stock_item) { create(:variant, on_hand: 15).stock_item }
describe "validation" do
it "requires count_on_hand to be positive if not backorderable" do

View File

@@ -3,8 +3,7 @@
require 'spec_helper'
RSpec.describe Spree::StockMovement do
let!(:stock_location) { create(:stock_location_with_items) }
let(:stock_item) { Spree::StockItem.order(:id).first }
let(:stock_item) { create(:variant, on_hand: 15).stock_item }
subject { build(:stock_movement, stock_item:) }
it 'should belong to a stock item' do

View File

@@ -10,7 +10,6 @@ RSpec.describe Sets::ProductSet do
subject{ product_set.save }
context 'when the product does not exist yet' do
let!(:stock_location) { create(:stock_location) }
let(:collection_hash) do
{
0 => {

View File

@@ -11,7 +11,6 @@ RSpec.describe '
include FileHelper
let!(:taxon) { create(:taxon) }
let!(:stock_location) { create(:stock_location) }
let!(:shipping_category) { DefaultShippingCategory.find_or_create }
let!(:supplier) { create(:supplier_enterprise, name: 'New supplier') }

View File

@@ -13,7 +13,6 @@ RSpec.describe 'As an enterprise user, I can manage my products' do
let!(:taxon) { create(:taxon) }
describe "creating a new product" do
let!(:stock_location) { create(:stock_location) }
let!(:distributor) { create(:distributor_enterprise) }
let!(:shipping_category) { create(:shipping_category) }

View File

@@ -9,8 +9,6 @@ RSpec.describe '
include AuthenticationHelper
include WebHelper
let!(:stock_location) { create(:stock_location) }
describe "product" do
it "creating a new product" do
login_as_admin