Skip to content

Commit

Permalink
Change migration to avoid tiggering callback and use private send:
Browse files Browse the repository at this point in the history
* Skip :after callbacks on StockLocation and StockItem when creating
intitial instances. Regression due to 0ba60a0 and 630afbb
* Use private send to set StockItem.count_on_hand
because :count_on_hand= is now private. Regression due to 9acf57f

[Closes solidusio#2789]
  • Loading branch information
sohara authored and Trung Lê committed Apr 1, 2013
1 parent 42b5569 commit e700fd1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/db/migrate/20130213191427_create_default_stock.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
class CreateDefaultStock < ActiveRecord::Migration
def up
Spree::StockLocation.skip_callback(:create, :after, :create_stock_items)
Spree::StockItem.skip_callback(:save, :after, :process_backorders)
location = Spree::StockLocation.create(name: 'default')
Spree::Variant.all.each do |variant|
location.stock_items.create(variant: variant, count_on_hand: variant.count_on_hand)
stock_item = location.stock_items.build(variant: variant)
stock_item.send(:count_on_hand=, variant.count_on_hand)
stock_item.save!
end

remove_column :spree_variants, :count_on_hand
Expand Down

0 comments on commit e700fd1

Please sign in to comment.