diff --git a/app/assets/javascripts/darkswarm/services/cart.js.coffee b/app/assets/javascripts/darkswarm/services/cart.js.coffee
index 849af562b8..b0311cb402 100644
--- a/app/assets/javascripts/darkswarm/services/cart.js.coffee
+++ b/app/assets/javascripts/darkswarm/services/cart.js.coffee
@@ -62,12 +62,12 @@ Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http, $modal, $roo
for li in @line_items when li.quantity > 0
if stockLevels[li.variant.id]?
- li.variant.count_on_hand = stockLevels[li.variant.id].on_hand
- if li.quantity > li.variant.count_on_hand
- li.quantity = li.variant.count_on_hand
+ li.variant.on_hand = stockLevels[li.variant.id].on_hand
+ if li.quantity > li.variant.on_hand
+ li.quantity = li.variant.on_hand
scope.variants.push li.variant
- if li.variant.count_on_hand == 0 && li.max_quantity > li.variant.count_on_hand
- li.max_quantity = li.variant.count_on_hand
+ if li.variant.on_hand == 0 && li.max_quantity > li.variant.on_hand
+ li.max_quantity = li.variant.on_hand
scope.variants.push(li.variant) unless li.variant in scope.variants
if scope.variants.length > 0
diff --git a/app/assets/javascripts/templates/out_of_stock.html.haml b/app/assets/javascripts/templates/out_of_stock.html.haml
index a92c721c25..4ee27e7aa1 100644
--- a/app/assets/javascripts/templates/out_of_stock.html.haml
+++ b/app/assets/javascripts/templates/out_of_stock.html.haml
@@ -9,7 +9,7 @@
%p{'ng-repeat' => "v in variants"}
%em {{ v.name_to_display }} - {{ v.unit_to_display }}
- %span{'ng-if' => "v.count_on_hand == 0"}
+ %span{'ng-if' => "v.on_hand == 0"}
{{ 'js.out_of_stock.now_out_of_stock' | t }}
- %span{'ng-if' => "v.count_on_hand > 0"}
- {{ 'js.out_of_stock.only_n_remainging' | t:{ num: v.count_on_hand } }}
+ %span{'ng-if' => "v.on_hand > 0"}
+ {{ 'js.out_of_stock.only_n_remainging' | t:{ num: v.on_hand } }}
diff --git a/app/assets/javascripts/templates/partials/shop_variant_no_group_buy.html.haml b/app/assets/javascripts/templates/partials/shop_variant_no_group_buy.html.haml
index 0441156c2c..2e7e49a0ca 100644
--- a/app/assets/javascripts/templates/partials/shop_variant_no_group_buy.html.haml
+++ b/app/assets/javascripts/templates/partials/shop_variant_no_group_buy.html.haml
@@ -7,6 +7,6 @@
placeholder: "0",
"ofn-disable-scroll" => true,
"ng-model" => "variant.line_item.quantity",
- "ofn-on-hand" => "{{variant.on_demand && 9999 || variant.count_on_hand }}",
- "ng-disabled" => "!variant.on_demand && variant.count_on_hand == 0",
+ "ofn-on-hand" => "{{variant.on_demand && 9999 || variant.on_hand }}",
+ "ng-disabled" => "!variant.on_demand && variant.on_hand == 0",
name: "variants[{{::variant.id}}]", id: "variants_{{::variant.id}}"}
diff --git a/app/assets/javascripts/templates/partials/shop_variant_with_group_buy.html.haml b/app/assets/javascripts/templates/partials/shop_variant_with_group_buy.html.haml
index 05bdf468b4..169b33391c 100644
--- a/app/assets/javascripts/templates/partials/shop_variant_with_group_buy.html.haml
+++ b/app/assets/javascripts/templates/partials/shop_variant_with_group_buy.html.haml
@@ -9,7 +9,7 @@
"ng-model" => "variant.line_item.quantity",
placeholder: "{{::'shop_variant_quantity_min' | t}}",
"ofn-disable-scroll" => true,
- "ofn-on-hand" => "{{variant.on_demand && 9999 || variant.count_on_hand }}",
+ "ofn-on-hand" => "{{variant.on_demand && 9999 || variant.on_hand }}",
name: "variants[{{::variant.id}}]", id: "variants_{{::variant.id}}"}
%span.bulk-input
%input.bulk.second{type: :number,
diff --git a/app/models/product_import/entry_processor.rb b/app/models/product_import/entry_processor.rb
index bd9ef94d45..b7aecee078 100644
--- a/app/models/product_import/entry_processor.rb
+++ b/app/models/product_import/entry_processor.rb
@@ -214,7 +214,7 @@ module ProductImport
object.assign_attributes(attribute => setting['value'])
when 'overwrite_empty'
if object.public_send(attribute).blank? ||
- ((attribute == 'on_hand' || attribute == 'count_on_hand') &&
+ ((attribute == 'on_hand') &&
entry.on_hand_nil)
object.assign_attributes(attribute => setting['value'])
diff --git a/app/models/product_import/entry_validator.rb b/app/models/product_import/entry_validator.rb
index 090c55e01d..39e3d761f9 100644
--- a/app/models/product_import/entry_validator.rb
+++ b/app/models/product_import/entry_validator.rb
@@ -372,7 +372,6 @@ module ProductImport
return if entry.on_hand.present?
object.on_hand = 0 if object.respond_to?(:on_hand)
- object.count_on_hand = 0 if object.respond_to?(:count_on_hand)
entry.on_hand_nil = true
end
diff --git a/app/models/product_import/products_reset_strategy.rb b/app/models/product_import/products_reset_strategy.rb
index 0dc005af82..989f5a275c 100644
--- a/app/models/product_import/products_reset_strategy.rb
+++ b/app/models/product_import/products_reset_strategy.rb
@@ -9,7 +9,7 @@ module ProductImport
return 0 if enterprise_ids.blank?
- reset_variants_count_on_hand(enterprise_variants_relation)
+ reset_variants_on_hand(enterprise_variants_relation)
end
private
@@ -29,17 +29,17 @@ module ProductImport
relation.where('spree_variants.id NOT IN (?)', excluded_items_ids)
end
- def reset_variants_count_on_hand(variants)
+ def reset_variants_on_hand(variants)
updated_records_count = 0
variants.each do |variant|
- updated_records_count += 1 if reset_variant_count_on_hand(variant)
+ updated_records_count += 1 if reset_variant_on_hand(variant)
end
updated_records_count
end
- def reset_variant_count_on_hand(variant)
- variant.count_on_hand = 0
- variant.count_on_hand.zero?
+ def reset_variant_on_hand(variant)
+ variant.on_hand = 0
+ variant.on_hand.zero?
end
end
end
diff --git a/app/models/product_import/spreadsheet_entry.rb b/app/models/product_import/spreadsheet_entry.rb
index c87f46ec0e..990124e24b 100644
--- a/app/models/product_import/spreadsheet_entry.rb
+++ b/app/models/product_import/spreadsheet_entry.rb
@@ -16,7 +16,7 @@ module ProductImport
:distributor_id, :name, :display_name, :sku, :unit_value,
:unit_description, :variant_unit, :variant_unit_scale,
:variant_unit_name, :display_as, :category, :primary_taxon_id,
- :price, :on_hand, :count_on_hand, :on_demand,
+ :price, :on_hand, :on_demand,
:tax_category_id, :shipping_category_id, :description,
:import_date, :enterprise, :enterprise_id
diff --git a/app/serializers/api/variant_serializer.rb b/app/serializers/api/variant_serializer.rb
index 59600b6ab3..f4845dc6af 100644
--- a/app/serializers/api/variant_serializer.rb
+++ b/app/serializers/api/variant_serializer.rb
@@ -1,5 +1,5 @@
class Api::VariantSerializer < ActiveModel::Serializer
- attributes :id, :is_master, :count_on_hand, :name_to_display, :unit_to_display, :unit_value
+ attributes :id, :is_master, :on_hand, :name_to_display, :unit_to_display, :unit_value
attributes :options_text, :on_demand, :price, :fees, :price_with_fees, :product_name
attributes :tag_list
diff --git a/app/services/order_factory.rb b/app/services/order_factory.rb
index e920719384..85c887411a 100644
--- a/app/services/order_factory.rb
+++ b/app/services/order_factory.rb
@@ -45,7 +45,7 @@ class OrderFactory
attrs[:line_items].each do |li|
next unless variant = Spree::Variant.find_by_id(li[:variant_id])
scoper.scope(variant)
- li[:quantity] = stock_limited_quantity(variant.count_on_hand, li[:quantity])
+ li[:quantity] = stock_limited_quantity(variant.on_hand, li[:quantity])
li[:price] = variant.price
build_item_from(li)
end
diff --git a/app/views/shop/products/_form.html.haml b/app/views/shop/products/_form.html.haml
index 8bf8f8dcbb..98fb49501d 100644
--- a/app/views/shop/products/_form.html.haml
+++ b/app/views/shop/products/_form.html.haml
@@ -31,7 +31,7 @@
%div.pad-top{ "infinite-scroll" => "incrementLimit()", "infinite-scroll-distance" => "1", "infinite-scroll-disabled" => 'filteredProducts.length <= limit' }
%product.animate-repeat{"ng-controller" => "ProductNodeCtrl", "ng-repeat" => "product in visibleProducts track by product.id", "id" => "product-{{ product.id }}"}
= render "shop/products/summary"
- %shop-variant{variant: 'variant', "ng-repeat" => "variant in product.variants | orderBy: ['name_to_display','unit_value'] track by variant.id", "id" => "variant-{{ variant.id }}", "ng-class" => "{'out-of-stock': !variant.on_demand && variant.count_on_hand == 0}"}
+ %shop-variant{variant: 'variant', "ng-repeat" => "variant in product.variants | orderBy: ['name_to_display','unit_value'] track by variant.id", "id" => "variant-{{ variant.id }}", "ng-class" => "{'out-of-stock': !variant.on_demand && variant.on_hand == 0}"}
%product{"ng-show" => "Products.loading"}
.row.summary
diff --git a/app/views/spree/admin/variants/_autocomplete.js.erb b/app/views/spree/admin/variants/_autocomplete.js.erb
index 4cecb1f61d..c4c6d101bf 100644
--- a/app/views/spree/admin/variants/_autocomplete.js.erb
+++ b/app/views/spree/admin/variants/_autocomplete.js.erb
@@ -16,7 +16,7 @@
- <%= t('admin.sku') %>: {{variant.sku}}
- - <%= t('on_hand') %>: {{variant.count_on_hand}}
+ - <%= t('on_hand') %>: {{variant.on_hand}}
{{#if variant.option_values}}
@@ -41,7 +41,7 @@
<%= Spree.t(:location) %> |
- <%= Spree.t(:count_on_hand) %> |
+ <%= Spree.t(:on_hand) %> |
<%= Spree.t(:quantity) %> |
|
@@ -53,7 +53,7 @@
Spree.t(:on_demand) |
{{else}}
- {{variant.count_on_hand}}
+ {{variant.on_hand}}
|
{{/if}}
diff --git a/app/views/spree/admin/variants/search.rabl b/app/views/spree/admin/variants/search.rabl
index 8206932c5f..b65ef4d768 100644
--- a/app/views/spree/admin/variants/search.rabl
+++ b/app/views/spree/admin/variants/search.rabl
@@ -2,7 +2,7 @@
# overriding spree/core/app/views/spree/admin/variants/search.rabl
#
collection @variants
-attributes :sku, :options_text, :in_stock?, :on_demand, :count_on_hand, :id, :cost_price
+attributes :sku, :options_text, :in_stock?, :on_demand, :on_hand, :id, :cost_price
node(:name) do |v|
# TODO: when products must have a unit, full_name will always be present
diff --git a/spec/controllers/cart_controller_spec.rb b/spec/controllers/cart_controller_spec.rb
index 8a7ad16dd8..5630429d6d 100644
--- a/spec/controllers/cart_controller_spec.rb
+++ b/spec/controllers/cart_controller_spec.rb
@@ -63,8 +63,8 @@ describe CartController, type: :controller do
let!(:line_item) { create(:line_item, order: order, variant: variant_in_the_order, quantity: 2, max_quantity: 3) }
before do
- variant_in_the_order.count_on_hand = 4
- variant_not_in_the_order.count_on_hand = 2
+ variant_in_the_order.on_hand = 4
+ variant_not_in_the_order.on_hand = 2
order_cycle.exchanges.outgoing.first.variants = [variant_in_the_order, variant_not_in_the_order]
order.order_cycle = order_cycle
order.distributor = hub
diff --git a/spec/controllers/spree/admin/variants_controller_spec.rb b/spec/controllers/spree/admin/variants_controller_spec.rb
index 36fd0463a2..d8178fa3a1 100644
--- a/spec/controllers/spree/admin/variants_controller_spec.rb
+++ b/spec/controllers/spree/admin/variants_controller_spec.rb
@@ -22,7 +22,7 @@ module Spree
it "applies variant overrides" do
spree_get :search, q: 'Prod', distributor_id: d.id.to_s
assigns(:variants).should == [v1]
- assigns(:variants).first.count_on_hand.should == 44
+ assigns(:variants).first.on_hand.should == 44
end
it "filters by order cycle" do
diff --git a/spec/factories.rb b/spec/factories.rb
index d21d1143fd..2582de3fb6 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -602,7 +602,7 @@ FactoryBot.modify do
after(:create) do |variant, evaluator|
variant.on_demand = evaluator.on_demand
- variant.count_on_hand = evaluator.on_hand
+ variant.on_hand = evaluator.on_hand
variant.save
end
end
diff --git a/spec/features/admin/reports_spec.rb b/spec/features/admin/reports_spec.rb
index f34d2ef28e..08e01a4159 100644
--- a/spec/features/admin/reports_spec.rb
+++ b/spec/features/admin/reports_spec.rb
@@ -308,11 +308,11 @@ xfeature %q{
product2.set_property 'Organic', 'NASAA 12345'
product1.taxons = [taxon]
product2.taxons = [taxon]
- variant1.count_on_hand = 10
+ variant1.on_hand = 10
variant1.update_column(:sku, "sku1")
- variant2.count_on_hand = 20
+ variant2.on_hand = 20
variant2.update_column(:sku, "sku2")
- variant3.count_on_hand = 9
+ variant3.on_hand = 9
variant3.update_column(:sku, "")
variant1.option_values = [create(:option_value, :presentation => "Test")]
variant2.option_values = [create(:option_value, :presentation => "Something")]
diff --git a/spec/features/consumer/shopping/variant_overrides_spec.rb b/spec/features/consumer/shopping/variant_overrides_spec.rb
index 8638616872..5aaa0d1ac9 100644
--- a/spec/features/consumer/shopping/variant_overrides_spec.rb
+++ b/spec/features/consumer/shopping/variant_overrides_spec.rb
@@ -123,7 +123,7 @@ feature "shopping with variant overrides defined", js: true, retry: 3 do
expect do
expect do
complete_checkout
- end.to change { product1_variant3.reload.count_on_hand }.by(0)
+ end.to change { product1_variant3.reload.on_hand }.by(0)
end.to change { product1_variant3_override.reload.count_on_hand }.by(-2)
end
@@ -134,7 +134,7 @@ feature "shopping with variant overrides defined", js: true, retry: 3 do
expect do
expect do
complete_checkout
- end.to change { product3_variant2.reload.count_on_hand }.by(0)
+ end.to change { product3_variant2.reload.on_hand }.by(0)
end.to change { product3_variant2_override.reload.count_on_hand }.by(-2)
end
@@ -143,12 +143,12 @@ feature "shopping with variant overrides defined", js: true, retry: 3 do
click_checkout
expect do
complete_checkout
- end.to change { product1_variant1.reload.count_on_hand }.by(-2)
+ end.to change { product1_variant1.reload.on_hand }.by(-2)
product1_variant1_override.reload.count_on_hand.should be_nil
end
it "does not show out of stock flags on order confirmation page" do
- product1_variant3.count_on_hand = 0
+ product1_variant3.on_hand = 0
fill_in "variants[#{product1_variant3.id}]", with: "2"
click_checkout
diff --git a/spec/javascripts/unit/admin/controllers/variant_overrides_controller_spec.js.coffee b/spec/javascripts/unit/admin/controllers/variant_overrides_controller_spec.js.coffee
index 3ff397eb18..5724fe1353 100644
--- a/spec/javascripts/unit/admin/controllers/variant_overrides_controller_spec.js.coffee
+++ b/spec/javascripts/unit/admin/controllers/variant_overrides_controller_spec.js.coffee
@@ -98,7 +98,7 @@ describe "VariantOverridesCtrl", ->
beforeEach ->
# Ideally, count_on_hand is blank when the variant is on demand. However, this rule is not
# enforced.
- variant = {id: 2, on_demand: true, count_on_hand: 20, on_hand: "On demand"}
+ variant = {id: 2, on_demand: true, on_hand: 20, on_hand: "On demand"}
it "clears count_on_hand when variant override uses producer stock settings", ->
scope.variantOverrides[123][2] = {on_demand: null, count_on_hand: 1}
@@ -162,7 +162,7 @@ describe "VariantOverridesCtrl", ->
beforeEach ->
# Ideally, count_on_hand is blank when the variant is on demand. However, this rule is not
# enforced.
- variant = {id: 2, on_demand: true, count_on_hand: 20, on_hand: t("on_demand")}
+ variant = {id: 2, on_demand: true, on_hand: 20, on_hand: t("on_demand")}
it "is 'On demand' when variant override uses producer stock settings", ->
scope.variantOverrides[123][2] = {on_demand: null, count_on_hand: 1}
@@ -183,7 +183,7 @@ describe "VariantOverridesCtrl", ->
variant = null
beforeEach ->
- variant = {id: 2, on_demand: false, count_on_hand: 20, on_hand: 20}
+ variant = {id: 2, on_demand: false, on_hand: 20, on_hand: 20}
it "is variant count on hand when variant override uses producer stock settings", ->
scope.variantOverrides[123][2] = {on_demand: null, count_on_hand: 1}
diff --git a/spec/javascripts/unit/bulk_product_update_spec.js.coffee b/spec/javascripts/unit/bulk_product_update_spec.js.coffee
index c1c34cbe6b..466253885f 100644
--- a/spec/javascripts/unit/bulk_product_update_spec.js.coffee
+++ b/spec/javascripts/unit/bulk_product_update_spec.js.coffee
@@ -183,7 +183,7 @@ describe "filtering products for submission to database", ->
shipping_category_id: null
created_at: null
updated_at: null
- count_on_hand: 0
+ on_hand: 0
producer_id: 5
group_buy: null
diff --git a/spec/javascripts/unit/darkswarm/services/cart_spec.js.coffee b/spec/javascripts/unit/darkswarm/services/cart_spec.js.coffee
index 131880ddc7..f8d124c110 100644
--- a/spec/javascripts/unit/darkswarm/services/cart_spec.js.coffee
+++ b/spec/javascripts/unit/darkswarm/services/cart_spec.js.coffee
@@ -145,11 +145,11 @@ describe 'Cart service', ->
expect(li.max_quantity).toEqual 0
it "resets the count on hand available", ->
- li = {variant: {id: 1, count_on_hand: 10}, quantity: 5}
+ li = {variant: {id: 1, on_hand: 10}, quantity: 5}
Cart.line_items = [li]
stockLevels = {1: {quantity: 0, max_quantity: 0, on_hand: 0}}
Cart.compareAndNotifyStockLevels stockLevels
- expect(li.variant.count_on_hand).toEqual 0
+ expect(li.variant.on_hand).toEqual 0
describe "when the quantity available is less than that requested", ->
it "reduces the quantity in the cart", ->
@@ -172,7 +172,7 @@ describe 'Cart service', ->
Cart.line_items = [li]
stockLevels = {1: {quantity: 5, on_hand: 6}}
Cart.compareAndNotifyStockLevels stockLevels
- expect(li.variant.count_on_hand).toEqual 6
+ expect(li.variant.on_hand).toEqual 6
describe "when the client-side quantity has been increased during the request", ->
it "does not reset the quantity", ->
diff --git a/spec/jobs/subscription_placement_job_spec.rb b/spec/jobs/subscription_placement_job_spec.rb
index 685d6f4ded..a55bce0d00 100644
--- a/spec/jobs/subscription_placement_job_spec.rb
+++ b/spec/jobs/subscription_placement_job_spec.rb
@@ -76,9 +76,9 @@ describe SubscriptionPlacementJob do
context "and insufficient stock exists to fulfil the order for some items" do
before do
- variant1.update_attribute(:count_on_hand, 5)
- variant2.update_attribute(:count_on_hand, 2)
- variant3.update_attribute(:count_on_hand, 0)
+ variant1.update_attribute(:on_hand, 5)
+ variant2.update_attribute(:on_hand, 2)
+ variant3.update_attribute(:on_hand, 0)
end
xit "caps quantity at the stock level for stock-limited items, and reports the change" do
@@ -98,9 +98,9 @@ describe SubscriptionPlacementJob do
context "and insufficient stock exists to fulfil the order for some items" do
before do
- variant1.update_attribute(:count_on_hand, 5)
- variant2.update_attribute(:count_on_hand, 2)
- variant3.update_attribute(:count_on_hand, 0)
+ variant1.update_attribute(:on_hand, 5)
+ variant2.update_attribute(:on_hand, 2)
+ variant3.update_attribute(:on_hand, 0)
end
xit "sets quantity to 0 for unavailable items, and reports the change" do
diff --git a/spec/lib/open_food_network/lettuce_share_report_spec.rb b/spec/lib/open_food_network/lettuce_share_report_spec.rb
index eb912f58c2..0ca330251c 100644
--- a/spec/lib/open_food_network/lettuce_share_report_spec.rb
+++ b/spec/lib/open_food_network/lettuce_share_report_spec.rb
@@ -50,7 +50,7 @@ module OpenFoodNetwork
end
it "only available items" do
- variant.count_on_hand = 0
+ variant.on_hand = 0
report.stub(:child_variants) { Spree::Variant.where(id: [variant, variant2, variant3, variant4]) }
report.table.count.should eq 3
end
diff --git a/spec/lib/open_food_network/products_renderer_spec.rb b/spec/lib/open_food_network/products_renderer_spec.rb
index a845dfecf5..330ad57062 100644
--- a/spec/lib/open_food_network/products_renderer_spec.rb
+++ b/spec/lib/open_food_network/products_renderer_spec.rb
@@ -50,7 +50,7 @@ module OpenFoodNetwork
it "doesn't return products not in stock" do
variant.update_attribute(:on_demand, false)
- variant.update_attribute(:count_on_hand, 0)
+ variant.update_attribute(:on_hand, 0)
pr.products_json.should_not include product.name
end
diff --git a/spec/lib/open_food_network/scope_variant_to_hub_spec.rb b/spec/lib/open_food_network/scope_variant_to_hub_spec.rb
index 11bf218a1d..4daaa05c6c 100644
--- a/spec/lib/open_food_network/scope_variant_to_hub_spec.rb
+++ b/spec/lib/open_food_network/scope_variant_to_hub_spec.rb
@@ -39,12 +39,12 @@ module OpenFoodNetwork
it "returns the overridden stock level when one is present" do
vo
scoper.scope v
- v.count_on_hand.should == 2
+ v.on_hand.should == 2
end
it "returns the variant's stock level otherwise" do
scoper.scope v
- v.count_on_hand.should == 1
+ v.on_hand.should == 1
end
describe "overriding stock on an on_demand variant" do
@@ -131,7 +131,7 @@ module OpenFoodNetwork
end
context "when variant out of stock" do
- before { v.count_on_hand = 0 }
+ before { v.on_hand = 0 }
it "returns true if VO in stock" do
scoper.scope v
@@ -153,7 +153,7 @@ module OpenFoodNetwork
end
it "returns false if variant out of stock" do
- v.count_on_hand = 0
+ v.on_hand = 0
scoper.scope v
expect(v.in_stock?).to eq(false)
end
diff --git a/spec/models/product_import/products_reset_strategy_spec.rb b/spec/models/product_import/products_reset_strategy_spec.rb
index c3aa64a00b..e44249e8a3 100644
--- a/spec/models/product_import/products_reset_strategy_spec.rb
+++ b/spec/models/product_import/products_reset_strategy_spec.rb
@@ -9,7 +9,7 @@ describe ProductImport::ProductsResetStrategy do
let(:enterprise) { product.supplier }
let(:variant) { product.variants.first }
- before { variant.count_on_hand = 2 }
+ before { variant.on_hand = 2 }
context 'when there are excluded_items_ids' do
let(:excluded_items_ids) { [variant.id] }
@@ -17,35 +17,35 @@ describe ProductImport::ProductsResetStrategy do
context 'and supplier_ids is []' do
let(:supplier_ids) { [] }
- it 'does not reset the variant.count_on_hand' do
+ it 'does not reset the variant.on_hand' do
products_reset.reset(supplier_ids)
- expect(variant.reload.count_on_hand).to eq(2)
+ expect(variant.reload.on_hand).to eq(2)
end
end
context 'and supplier_ids is nil' do
let(:supplier_ids) { nil }
- it 'does not reset the variant.count_on_hand' do
+ it 'does not reset the variant.on_hand' do
products_reset.reset(supplier_ids)
- expect(variant.reload.count_on_hand).to eq(2)
+ expect(variant.reload.on_hand).to eq(2)
end
end
context 'and supplier_ids is set' do
- it 'does not update the count_on_hand of the excluded items' do
+ it 'does not update the on_hand of the excluded items' do
products_reset.reset(supplier_ids)
- expect(variant.reload.count_on_hand).to eq(2)
+ expect(variant.reload.on_hand).to eq(2)
end
- it 'updates the count_on_hand of the non-excluded items' do
+ it 'updates the on_hand of the non-excluded items' do
non_excluded_variant = create(
:variant,
product: variant.product
)
- non_excluded_variant.count_on_hand = 3
+ non_excluded_variant.on_hand = 3
products_reset.reset(supplier_ids)
- expect(non_excluded_variant.reload.count_on_hand).to eq(0)
+ expect(non_excluded_variant.reload.on_hand).to eq(0)
end
end
end
@@ -56,31 +56,31 @@ describe ProductImport::ProductsResetStrategy do
context 'and supplier_ids is []' do
let(:supplier_ids) { [] }
- it 'does not reset the variant.count_on_hand' do
+ it 'does not reset the variant.on_hand' do
products_reset.reset(supplier_ids)
- expect(variant.reload.count_on_hand).to eq(2)
+ expect(variant.reload.on_hand).to eq(2)
end
end
context 'and supplier_ids is nil' do
let(:supplier_ids) { nil }
- it 'does not reset the variant.count_on_hand' do
+ it 'does not reset the variant.on_hand' do
products_reset.reset(supplier_ids)
- expect(variant.reload.count_on_hand).to eq(2)
+ expect(variant.reload.on_hand).to eq(2)
end
end
context 'and supplier_ids is not nil' do
- it 'sets all count_on_hand to 0' do
+ it 'sets all on_hand to 0' do
updated_records_count = products_reset.reset(supplier_ids)
- expect(variant.reload.count_on_hand).to eq(0)
+ expect(variant.reload.on_hand).to eq(0)
expect(updated_records_count).to eq(1)
end
context 'and there is an unresetable variant' do
before do
- variant.stock_items = [] # this makes variant.count_on_hand raise an error
+ variant.stock_items = [] # this makes variant.on_hand raise an error
end
it 'returns correct number of resetted variants' do
@@ -96,24 +96,24 @@ describe ProductImport::ProductsResetStrategy do
context 'and supplier_ids is []' do
let(:supplier_ids) { [] }
- it 'does not reset the variant.count_on_hand' do
+ it 'does not reset the variant.on_hand' do
products_reset.reset(supplier_ids)
- expect(variant.reload.count_on_hand).to eq(2)
+ expect(variant.reload.on_hand).to eq(2)
end
end
context 'and supplier_ids is nil' do
let(:supplier_ids) { nil }
- it 'does not reset the variant.count_on_hand' do
+ it 'does not reset the variant.on_hand' do
products_reset.reset(supplier_ids)
- expect(variant.reload.count_on_hand).to eq(2)
+ expect(variant.reload.on_hand).to eq(2)
end
end
context 'and supplier_ids is nil' do
- it 'sets all count_on_hand to 0' do
+ it 'sets all on_hand to 0' do
products_reset.reset(supplier_ids)
- expect(variant.reload.count_on_hand).to eq(0)
+ expect(variant.reload.on_hand).to eq(0)
end
end
end
diff --git a/spec/models/spree/product_spec.rb b/spec/models/spree/product_spec.rb
index 6f04f97a0c..0499b0a38c 100644
--- a/spec/models/spree/product_spec.rb
+++ b/spec/models/spree/product_spec.rb
@@ -634,14 +634,14 @@ module Spree
describe "stock filtering" do
it "considers products that are on_demand as being in stock" do
product = create(:simple_product, on_demand: true)
- product.master.update_attribute(:count_on_hand, 0)
+ product.master.update_attribute(:on_hand, 0)
product.has_stock?.should == true
end
describe "finding products in stock for a particular distribution" do
it "returns on-demand products" do
p = create(:simple_product, on_demand: true)
- p.variants.first.update_attributes!(count_on_hand: 0, on_demand: true)
+ p.variants.first.update_attributes!(on_hand: 0, on_demand: true)
d = create(:distributor_enterprise)
oc = create(:simple_order_cycle, distributors: [d])
oc.exchanges.outgoing.first.variants << p.variants.first
@@ -652,7 +652,7 @@ module Spree
it "returns products with in-stock variants" do
p = create(:simple_product)
v = create(:variant, product: p)
- v.update_attribute(:count_on_hand, 1)
+ v.update_attribute(:on_hand, 1)
d = create(:distributor_enterprise)
oc = create(:simple_order_cycle, distributors: [d])
oc.exchanges.outgoing.first.variants << v
@@ -663,7 +663,7 @@ module Spree
it "returns products with on-demand variants" do
p = create(:simple_product)
v = create(:variant, product: p, on_demand: true)
- v.update_attribute(:count_on_hand, 0)
+ v.update_attribute(:on_hand, 0)
d = create(:distributor_enterprise)
oc = create(:simple_order_cycle, distributors: [d])
oc.exchanges.outgoing.first.variants << v
@@ -673,7 +673,7 @@ module Spree
it "does not return products that have stock not in the distribution" do
p = create(:simple_product)
- p.master.update_attribute(:count_on_hand, 1)
+ p.master.update_attribute(:on_hand, 1)
d = create(:distributor_enterprise)
oc = create(:simple_order_cycle, distributors: [d])
diff --git a/spec/requests/shop_spec.rb b/spec/requests/shop_spec.rb
index 1b15c08a7f..3058a47c89 100644
--- a/spec/requests/shop_spec.rb
+++ b/spec/requests/shop_spec.rb
@@ -23,15 +23,15 @@ describe "Shop API", type: :request do
before do
set_order order
- v61.update_attribute(:count_on_hand, 1)
+ v61.update_attribute(:on_hand, 1)
p6.delete
- v71.update_attribute(:count_on_hand, 1)
- v41.update_attribute(:count_on_hand, 1)
- v42.update_attribute(:count_on_hand, 0)
- v43.update_attribute(:count_on_hand, 0)
- v51.update_attribute(:count_on_hand, 1)
- v52.update_attribute(:count_on_hand, 0)
- v71.update_attribute(:count_on_hand, 1)
+ v71.update_attribute(:on_hand, 1)
+ v41.update_attribute(:on_hand, 1)
+ v42.update_attribute(:on_hand, 0)
+ v43.update_attribute(:on_hand, 0)
+ v51.update_attribute(:on_hand, 1)
+ v52.update_attribute(:on_hand, 0)
+ v71.update_attribute(:on_hand, 1)
v71.update_attribute(:deleted_at, Time.zone.now)
exchange = Exchange.find(oc1.exchanges.to_enterprises(distributor).outgoing.first.id)
exchange.update_attribute :pickup_time, "frogs"
diff --git a/spec/serializers/variant_serializer_spec.rb b/spec/serializers/variant_serializer_spec.rb
index 3c6aebf6a9..583412ff56 100644
--- a/spec/serializers/variant_serializer_spec.rb
+++ b/spec/serializers/variant_serializer_spec.rb
@@ -10,7 +10,7 @@ describe Api::VariantSerializer do
:id,
:name_to_display,
:is_master,
- :count_on_hand,
+ :on_hand,
:name_to_display,
:unit_to_display,
:unit_value,
diff --git a/spec/services/order_factory_spec.rb b/spec/services/order_factory_spec.rb
index 3755f69e8e..672ac0a780 100644
--- a/spec/services/order_factory_spec.rb
+++ b/spec/services/order_factory_spec.rb
@@ -55,7 +55,7 @@ describe OrderFactory do
context "when requested quantity is greater than available stock" do
context "when no override is present" do
before do
- variant1.update_attribute(:count_on_hand, 2)
+ variant1.update_attribute(:on_hand, 2)
attrs[:line_items].first[:quantity] = 5
end
diff --git a/spec/services/order_syncer_spec.rb b/spec/services/order_syncer_spec.rb
index e1ee400fc8..8645eb674e 100644
--- a/spec/services/order_syncer_spec.rb
+++ b/spec/services/order_syncer_spec.rb
@@ -292,7 +292,7 @@ describe OrderSyncer do
let(:sli) { subscription.subscription_line_items.first }
let(:variant) { sli.variant }
- before { variant.update_attribute(:count_on_hand, 2) }
+ before { variant.update_attribute(:on_hand, 2) }
context "when quantity is within available stock" do
let(:params) { { subscription_line_items_attributes: [{ id: sli.id, quantity: 2}] } }
@@ -327,7 +327,7 @@ describe OrderSyncer do
let(:syncer) { OrderSyncer.new(subscription) }
let(:changed_line_item) { order.line_items.find_by_variant_id(sli.variant_id) }
- before { variant.update_attribute(:count_on_hand, 3) }
+ before { variant.update_attribute(:on_hand, 3) }
context "when the changed line_item quantity matches the new quantity on the subscription line item" do
before { changed_line_item.update_attributes(quantity: 3) }
diff --git a/spec/services/variants_stock_levels_spec.rb b/spec/services/variants_stock_levels_spec.rb
index a7e788d657..48088a6fce 100644
--- a/spec/services/variants_stock_levels_spec.rb
+++ b/spec/services/variants_stock_levels_spec.rb
@@ -12,8 +12,8 @@ describe VariantsStockLevels do
let(:variant_stock_levels) { VariantsStockLevels.new }
before do
- variant_in_the_order.count_on_hand = 4
- variant_not_in_the_order.count_on_hand = 2
+ variant_in_the_order.on_hand = 4
+ variant_not_in_the_order.on_hand = 2
order.reload
end
@@ -40,7 +40,7 @@ describe VariantsStockLevels do
describe "encoding Infinity" do
let!(:variant_in_the_order) { create(:variant, on_demand: true) }
- before { variant_in_the_order.count_on_hand = 0 }
+ before { variant_in_the_order.on_hand = 0 }
it "encodes Infinity as a large, finite integer" do
expect(variant_stock_levels.call(order, [variant_in_the_order.id])).to eq(
|