Skip to content

Commit

Permalink
set_position conflicts with acts_as_list
Browse files Browse the repository at this point in the history
  • Loading branch information
tkimi committed Nov 12, 2023
1 parent 378ed49 commit 9b6448f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 13 deletions.
5 changes: 0 additions & 5 deletions core/app/models/spree/variant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class Variant < Spree::Base
validates_uniqueness_of :sku, allow_blank: true, case_sensitive: true, conditions: -> { where(deleted_at: nil) }, if: :enforce_unique_sku?

after_create :create_stock_items
after_create :set_position
after_create :set_master_out_of_stock, unless: :is_master?

after_save :clear_in_stock_cache
Expand Down Expand Up @@ -406,10 +405,6 @@ def build_vat_prices
Spree::Config.variant_vat_prices_generator_class.new(self).run
end

def set_position
update_column(:position, product.variants.maximum(:position).to_i + 1)
end

def in_stock_cache_key
"variant-#{id}-in_stock"
end
Expand Down
8 changes: 0 additions & 8 deletions core/spec/models/spree/variant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -574,14 +574,6 @@
end
end

# Regression test for https://github.com/spree/spree/issues/2744
describe "set_position" do
it "sets variant position after creation" do
variant = create(:variant)
expect(variant.position).to_not be_nil
end
end

describe '#in_stock?' do
before do
stub_spree_preferences(track_inventory_levels: true)
Expand Down

0 comments on commit 9b6448f

Please sign in to comment.