Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix state_changes to be destroyed when the associated order is destroyed #4

Merged
merged 1 commit into from
Oct 13, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion core/app/models/spree/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class Order < ActiveRecord::Base

alias_attribute :ship_total, :shipment_total

has_many :state_changes, as: :stateful
belongs_to :store, class_name: 'Spree::Store'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This addition was part of a merge conflict I had to resolve when cherry-picking. I'm a little perplexed on why it's actually an addition as it was present in the parent branch.

has_many :state_changes, as: :stateful, dependent: :destroy
has_many :line_items, -> { order("#{LineItem.table_name}.created_at ASC") }, dependent: :destroy, inverse_of: :order
has_many :payments, dependent: :destroy
has_many :return_authorizations, dependent: :destroy, inverse_of: :order
Expand Down Expand Up @@ -460,6 +461,7 @@ def empty!
updater.update_item_count
adjustments.destroy_all
shipments.destroy_all
state_changes.destroy_all

update_totals
persist_totals
Expand Down