Skip to content

Commit

Permalink
Change from simple_product to base_product in specs related to Spree'…
Browse files Browse the repository at this point in the history
…s product_factory
  • Loading branch information
HugsDaniel committed Jul 20, 2018
1 parent 7707df3 commit 7ab57b7
Show file tree
Hide file tree
Showing 58 changed files with 242 additions and 242 deletions.
2 changes: 1 addition & 1 deletion doc/outstanding_shopping_tests
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ scenario "order cycle expires mid-order" do
d = create(:distributor_enterprise,
name: 'Green Grass', email: '[email protected]', phone: '1029 3847')
create_enterprise_group_for d
p = create(:simple_product)
p = create(:base_product)
oc = create(:simple_order_cycle, name: 'oc', distributors: [d], variants: [p.master])

# When I select an order cycle and add a product to my cart
Expand Down
6 changes: 3 additions & 3 deletions spec/archive/features/consumer/checkout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
# Given some products, one with product distribution only, (@product1)
# one with order cycle distribution only, (@product_oc)
supplier = create(:supplier_enterprise)
product_oc = create(:simple_product, name: 'Feijoas')
product_oc = create(:base_product, name: 'Feijoas')
@order_cycle = create(:simple_order_cycle, suppliers: [supplier], distributors: [@distributor], variants: [product_oc.master], orders_close_at: Time.zone.now + 2.weeks)
@order_cycle.coordinator_fees << create(:enterprise_fee, enterprise: @order_cycle.coordinator)

Expand Down Expand Up @@ -509,12 +509,12 @@ def make_order_cycle
# Products
@distributor_oc = distributor1

@product_3 = create(:simple_product, name: 'Bananas', supplier: supplier1)
@product_3 = create(:base_product, name: 'Bananas', supplier: supplier1)
ex1.variants << @product_3.master
ex3.variants << @product_3.master
ex4.variants << @product_3.master

@product_4 = create(:simple_product, name: 'Zucchini', supplier: supplier2)
@product_4 = create(:base_product, name: 'Zucchini', supplier: supplier2)
ex2.variants << @product_4.master
ex3.variants << @product_4.master
ex4.variants << @product_4.master
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/spree/admin/products_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
describe "updating a product we do not have access to" do
let(:s_managed) { create(:enterprise) }
let(:s_unmanaged) { create(:enterprise) }
let(:p) { create(:simple_product, supplier: s_unmanaged, name: 'Peas') }
let(:p) { create(:base_product, supplier: s_unmanaged, name: 'Peas') }

before do
login_as_enterprise_user [s_managed]
Expand Down Expand Up @@ -68,7 +68,7 @@
describe "product properties" do
context "as an enterprise user" do
let(:producer) { create(:enterprise) }
let!(:product) { create(:simple_product, supplier: producer) }
let!(:product) { create(:base_product, supplier: producer) }
let!(:property) { create(:property, name: "A nice name") }

before do
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/spree/admin/variants_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ module Admin
before { login_as_admin }

describe "search action" do
let!(:p1) { create(:simple_product, name: 'Product 1') }
let!(:p2) { create(:simple_product, name: 'Product 2') }
let!(:p1) { create(:base_product, name: 'Product 1') }
let!(:p2) { create(:base_product, name: 'Product 2') }
let!(:v1) { p1.variants.first }
let!(:v2) { p2.variants.first }
let!(:vo) { create(:variant_override, variant: v1, hub: d, count_on_hand: 44) }
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/spree/orders_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
end

describe "returning stock levels in JSON on success" do
let(:product) { create(:simple_product) }
let(:product) { create(:base_product) }

it "returns stock levels as JSON" do
controller.stub(:variant_ids_in) { [123] }
Expand Down Expand Up @@ -165,7 +165,7 @@
describe "when I pass params that includes a line item no longer in our cart" do
it "should silently ignore the missing line item" do
order = subject.current_order(true)
li = order.add_variant(create(:simple_product, on_hand: 110).variants.first)
li = order.add_variant(create(:base_product, on_hand: 110).variants.first)
spree_get :update, order: { line_items_attributes: {
"0" => {quantity: "0", id: "9999"},
"1" => {quantity: "99", id: li.id}
Expand All @@ -177,7 +177,7 @@

it "filters line items that are missing from params" do
order = subject.current_order(true)
li = order.add_variant(create(:simple_product).master)
li = order.add_variant(create(:base_product).master)

attrs = {
"0" => {quantity: "0", id: "9999"},
Expand Down
2 changes: 1 addition & 1 deletion spec/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@
order_cycle { create(:simple_order_cycle) }

after(:create) do |order|
p = create(:simple_product, :distributors => [order.distributor])
p = create(:base_product, :distributors => [order.distributor])
FactoryBot.create(:line_item, :order => order, :product => p)
order.reload
end
Expand Down
12 changes: 6 additions & 6 deletions spec/features/admin/bulk_product_update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,8 @@
scenario "updating when a filter has been applied" do
s1 = create(:supplier_enterprise)
s2 = create(:supplier_enterprise)
p1 = FactoryBot.create(:simple_product, :name => "product1", supplier: s1)
p2 = FactoryBot.create(:simple_product, :name => "product2", supplier: s2)
p1 = FactoryBot.create(:base_product, :name => "product1", supplier: s1)
p2 = FactoryBot.create(:base_product, :name => "product2", supplier: s2)
login_to_admin_section

visit spree.admin_products_path
Expand Down Expand Up @@ -566,7 +566,7 @@
describe "using the page" do
describe "using column display dropdown" do
it "shows a column display dropdown, which shows a list of columns when clicked" do
FactoryBot.create(:simple_product)
FactoryBot.create(:base_product)
login_to_admin_section

visit spree.admin_products_path
Expand Down Expand Up @@ -597,8 +597,8 @@
it "displays basic filtering controls which filter the product list" do
s1 = create(:supplier_enterprise)
s2 = create(:supplier_enterprise)
p1 = FactoryBot.create(:simple_product, :name => "product1", supplier: s1)
p2 = FactoryBot.create(:simple_product, :name => "product2", supplier: s2)
p1 = FactoryBot.create(:base_product, :name => "product1", supplier: s1)
p2 = FactoryBot.create(:base_product, :name => "product2", supplier: s2)
login_to_admin_section

visit spree.admin_products_path
Expand Down Expand Up @@ -746,7 +746,7 @@
end

describe "Updating product image with new upload interface" do
let!(:product) { create(:simple_product, name: "Carrots") }
let!(:product) { create(:base_product, name: "Carrots") }

it "displays product images and image upload modal" do
quick_login_as_admin
Expand Down
2 changes: 1 addition & 1 deletion spec/features/admin/enterprises_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@

describe "inventory settings", js: true do
let!(:enterprise) { create(:distributor_enterprise) }
let!(:product) { create(:simple_product) }
let!(:product) { create(:base_product) }
let!(:order_cycle) { create(:simple_order_cycle, distributors: [enterprise], variants: [product.variants.first]) }

before do
Expand Down
8 changes: 4 additions & 4 deletions spec/features/admin/order_cycles_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@
# (this usually happens when a product is added to an order cycle, then variants are added
# to the product after the fact)
s = create(:supplier_enterprise)
p = create(:simple_product, supplier: s)
p = create(:base_product, supplier: s)
v = create(:variant, product: p)
d = create(:distributor_enterprise)
oc = create(:simple_order_cycle, suppliers: [s], distributors: [d], variants: [p.master])
Expand Down Expand Up @@ -979,9 +979,9 @@
describe "simplified interface for enterprise users selling only their own produce" do
let(:user) { create_enterprise_user }
let(:enterprise) { create(:enterprise, is_primary_producer: true, sells: 'own') }
let!(:p1) { create(:simple_product, supplier: enterprise) }
let!(:p2) { create(:simple_product, supplier: enterprise) }
let!(:p3) { create(:simple_product, supplier: enterprise) }
let!(:p1) { create(:base_product, supplier: enterprise) }
let!(:p2) { create(:base_product, supplier: enterprise) }
let!(:p3) { create(:base_product, supplier: enterprise) }
let!(:v1) { p1.variants.first }
let!(:v2) { p2.variants.first }
let!(:v3) { p3.variants.first }
Expand Down
4 changes: 2 additions & 2 deletions spec/features/admin/orders_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

background do
@user = create(:user)
@product = create(:simple_product)
@product = create(:base_product)
@distributor = create(:distributor_enterprise, owner: @user, charges_sales_tax: true)
@order_cycle = create(:simple_order_cycle, name: 'One', distributors: [@distributor], variants: [@product.variants.first])

Expand Down Expand Up @@ -122,7 +122,7 @@ def new_order_with_distribution(distributor, order_cycle)


scenario "can't add products to an order outside the order's hub and order cycle" do
product = create(:simple_product)
product = create(:base_product)

login_to_admin_section
visit '/admin/orders'
Expand Down
10 changes: 5 additions & 5 deletions spec/features/admin/product_import_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
let!(:tax_category2) { create(:tax_category) }
let!(:shipping_category) { create(:shipping_category) }

let!(:product) { create(:simple_product, supplier: enterprise2, name: 'Hypothetical Cake') }
let!(:product) { create(:base_product, supplier: enterprise2, name: 'Hypothetical Cake') }
let!(:variant) { create(:variant, product_id: product.id, price: '8.50', on_hand: '100', unit_value: '500', display_name: 'Preexisting Banana') }
let!(:product2) { create(:simple_product, supplier: enterprise, on_hand: '100', name: 'Beans', unit_value: '500') }
let!(:product3) { create(:simple_product, supplier: enterprise, on_hand: '100', name: 'Sprouts', unit_value: '500') }
let!(:product4) { create(:simple_product, supplier: enterprise, on_hand: '100', name: 'Cabbage', unit_value: '500') }
let!(:product5) { create(:simple_product, supplier: enterprise2, on_hand: '100', name: 'Lettuce', unit_value: '500') }
let!(:product2) { create(:base_product, supplier: enterprise, on_hand: '100', name: 'Beans', unit_value: '500') }
let!(:product3) { create(:base_product, supplier: enterprise, on_hand: '100', name: 'Sprouts', unit_value: '500') }
let!(:product4) { create(:base_product, supplier: enterprise, on_hand: '100', name: 'Cabbage', unit_value: '500') }
let!(:product5) { create(:base_product, supplier: enterprise2, on_hand: '100', name: 'Lettuce', unit_value: '500') }
let!(:variant_override) { create(:variant_override, variant_id: product4.variants.first.id, hub: enterprise2, count_on_hand: 42) }
let!(:variant_override2) { create(:variant_override, variant_id: product5.variants.first.id, hub: enterprise, count_on_hand: 96) }

Expand Down
12 changes: 6 additions & 6 deletions spec/features/admin/products_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
end

scenario "editing a product" do
product = create(:simple_product, name: 'a product', supplier: @supplier2)
product = create(:base_product, name: 'a product', supplier: @supplier2)

visit spree.edit_admin_product_path product

Expand All @@ -148,7 +148,7 @@
end

scenario "editing product group buy options" do
product = product = create(:simple_product, supplier: @supplier2)
product = product = create(:base_product, supplier: @supplier2)

visit spree.edit_admin_product_path product
within('#sidebar') { click_link 'Group Buy Options' }
Expand All @@ -164,7 +164,7 @@
end

scenario "editing product distributions" do
product = create(:simple_product, supplier: @supplier2)
product = create(:base_product, supplier: @supplier2)

visit spree.edit_admin_product_path product
within('#sidebar') { click_link 'Product Distributions' }
Expand All @@ -185,7 +185,7 @@
end

scenario "editing product Search" do
product = product = create(:simple_product, supplier: @supplier2)
product = product = create(:base_product, supplier: @supplier2)
visit spree.edit_admin_product_path product
within('#sidebar') { click_link 'Search' }
fill_in 'Product Search Keywords', :with => 'Product Search Keywords'
Expand All @@ -199,7 +199,7 @@

scenario "deleting product properties", js: true do
# Given a product with a property
p = create(:simple_product, supplier: @supplier2)
p = create(:base_product, supplier: @supplier2)
p.set_property('fooprop', 'fooval')

# When I navigate to the product properties page
Expand All @@ -219,7 +219,7 @@


scenario "deleting product images", js: true do
product = create(:simple_product, supplier: @supplier2)
product = create(:base_product, supplier: @supplier2)
image = File.open(File.expand_path('../../../../app/assets/images/logo-white.png', __FILE__))
Spree::Image.create({:viewable_id => product.master.id, :viewable_type => 'Spree::Variant', :alt => "position 1", :attachment => image, :position => 1})

Expand Down
8 changes: 4 additions & 4 deletions spec/features/admin/reports_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@
let(:order1) { create(:order, distributor: distributor, bill_address: bill_address1) }
let(:order2) { create(:order, distributor: distributor, bill_address: bill_address2) }
let(:supplier) { create(:supplier_enterprise, name: "Supplier") }
let(:product_1) { create(:simple_product, name: "Product 1", supplier: supplier ) }
let(:product_1) { create(:base_product, name: "Product 1", supplier: supplier ) }
let(:variant_1) { create(:variant, product: product_1, unit_description: "Big") }
let(:variant_2) { create(:variant, product: product_1, unit_description: "Small") }
let(:product_2) { create(:simple_product, name: "Product 2", supplier: supplier) }
let(:product_2) { create(:base_product, name: "Product 2", supplier: supplier) }

before do
Timecop.travel(Time.zone.local(2013, 4, 25, 14, 0, 0)) { order1.finalize! }
Expand Down Expand Up @@ -294,8 +294,8 @@
describe "products and inventory report", js: true do
let(:supplier) { create(:supplier_enterprise, name: 'Supplier Name') }
let(:taxon) { create(:taxon, name: 'Taxon Name') }
let(:product1) { create(:simple_product, name: "Product Name", price: 100, supplier: supplier, primary_taxon: taxon) }
let(:product2) { create(:simple_product, name: "Product 2", price: 99.0, variant_unit: 'weight', variant_unit_scale: 1, unit_value: '100', supplier: supplier, primary_taxon: taxon, sku: "product_sku") }
let(:product1) { create(:base_product, name: "Product Name", price: 100, supplier: supplier, primary_taxon: taxon) }
let(:product2) { create(:base_product, name: "Product 2", price: 99.0, variant_unit: 'weight', variant_unit_scale: 1, unit_value: '100', supplier: supplier, primary_taxon: taxon, sku: "product_sku") }
let(:variant1) { product1.variants.first }
let(:variant2) { create(:variant, product: product1, price: 80.0) }
let(:variant3) { product2.variants.first }
Expand Down
18 changes: 9 additions & 9 deletions spec/features/admin/variant_overrides_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
let!(:producer_related) { create(:supplier_enterprise) }
let!(:producer_unrelated) { create(:supplier_enterprise) }
let!(:er1) { create(:enterprise_relationship, parent: producer, child: hub,
permissions_list: [:create_variant_overrides])
permissions_list: [:create_variant_overrides])
}
let!(:er2) { create(:enterprise_relationship, parent: producer_related, child: hub,
permissions_list: [:create_variant_overrides])
permissions_list: [:create_variant_overrides])
}

context "as an enterprise user" do
Expand All @@ -28,7 +28,7 @@

describe "selecting a hub" do
let!(:er1) { create(:enterprise_relationship, parent: hub2, child: producer_managed,
permissions_list: [:add_to_order_cycle])
permissions_list: [:add_to_order_cycle])
} # This er should not confer ability to create VOs for hub2

it "displays a list of hub choices (ie. only those managed by the user)" do
Expand All @@ -41,19 +41,19 @@
end

context "when inventory_items exist for variants" do
let!(:product) { create(:simple_product, supplier: producer, variant_unit: 'weight', variant_unit_scale: 1) }
let!(:product) { create(:base_product, supplier: producer, variant_unit: 'weight', variant_unit_scale: 1) }
let!(:variant) { create(:variant, product: product, unit_value: 1, price: 1.23, on_hand: 12) }
let!(:inventory_item) { create(:inventory_item, enterprise: hub, variant: variant ) }

let!(:product_managed) { create(:simple_product, supplier: producer_managed, variant_unit: 'weight', variant_unit_scale: 1) }
let!(:product_managed) { create(:base_product, supplier: producer_managed, variant_unit: 'weight', variant_unit_scale: 1) }
let!(:variant_managed) { create(:variant, product: product_managed, unit_value: 3, price: 3.65, on_hand: 2) }
let!(:inventory_item_managed) { create(:inventory_item, enterprise: hub, variant: variant_managed ) }

let!(:product_related) { create(:simple_product, supplier: producer_related) }
let!(:product_related) { create(:base_product, supplier: producer_related) }
let!(:variant_related) { create(:variant, product: product_related, unit_value: 2, price: 2.34, on_hand: 23) }
let!(:inventory_item_related) { create(:inventory_item, enterprise: hub, variant: variant_related ) }

let!(:product_unrelated) { create(:simple_product, supplier: producer_unrelated) }
let!(:product_unrelated) { create(:base_product, supplier: producer_unrelated) }


before do
Expand Down Expand Up @@ -220,7 +220,7 @@
context "with overrides" do
let!(:vo) { create(:variant_override, variant: variant, hub: hub, price: 77.77, count_on_hand: 11111, default_stock: 1000, resettable: true, tag_list: ["tag1","tag2","tag3"]) }
let!(:vo_no_auth) { create(:variant_override, variant: variant, hub: hub2, price: 1, count_on_hand: 2) }
let!(:product2) { create(:simple_product, supplier: producer, variant_unit: 'weight', variant_unit_scale: 1) }
let!(:product2) { create(:base_product, supplier: producer, variant_unit: 'weight', variant_unit_scale: 1) }
let!(:variant2) { create(:variant, product: product2, unit_value: 8, price: 1.00, on_hand: 12) }
let!(:inventory_item2) { create(:inventory_item, enterprise: hub, variant: variant2) }
let!(:vo_no_reset) { create(:variant_override, variant: variant2, hub: hub, price: 3.99, count_on_hand: 40, default_stock: 100, resettable: false) }
Expand Down Expand Up @@ -344,7 +344,7 @@
end

describe "when inventory_items do not exist for variants" do
let!(:product) { create(:simple_product, supplier: producer, variant_unit: 'weight', variant_unit_scale: 1) }
let!(:product) { create(:base_product, supplier: producer, variant_unit: 'weight', variant_unit_scale: 1) }
let!(:variant1) { create(:variant, product: product, unit_value: 1, price: 1.23, on_hand: 12) }
let!(:variant2) { create(:variant, product: product, unit_value: 2, price: 4.56, on_hand: 3) }

Expand Down
6 changes: 3 additions & 3 deletions spec/features/admin/variants_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

scenario "creating a new variant" do
# Given a product with a unit-related option type
p = create(:simple_product, variant_unit: "weight", variant_unit_scale: "1")
p = create(:base_product, variant_unit: "weight", variant_unit_scale: "1")

# When I create a variant on the product
login_to_admin_section
Expand All @@ -27,7 +27,7 @@

scenario "editing unit value and description for a variant", js:true do
# Given a product with unit-related option types, with a variant
p = create(:simple_product, variant_unit: "weight", variant_unit_scale: "1")
p = create(:base_product, variant_unit: "weight", variant_unit_scale: "1")
v = p.variants.first
v.update_attributes( unit_value: 1, unit_description: 'foo' )

Expand Down Expand Up @@ -59,7 +59,7 @@
end

it "soft-deletes variants", js: true do
p = create(:simple_product)
p = create(:base_product)
v = create(:variant, product: p)

login_to_admin_section
Expand Down
Loading

0 comments on commit 7ab57b7

Please sign in to comment.