Permalink
Browse files

Fix bug with return authorizations not creating refund adjustment

The Adjustment#source & Adjustment#adjustable attributes aren't marked as attr_accessible, so adjustments are being created that are not attached to the order

Fixes #1509
  • Loading branch information...
cyu authored and radar committed May 7, 2012
1 parent a68f06f commit 8a8d80e4a5d86c4ed4b3dec7d9d314bc90976b04
Showing with 9 additions and 3 deletions.
  1. +4 −2 core/app/models/spree/return_authorization.rb
  2. +5 −1 core/spec/models/return_authorization_spec.rb
@@ -67,8 +67,10 @@ def generate_number
def process_return
inventory_units.each &:return!
- credit = Adjustment.create(:source => self, :adjustable => order, :amount => amount.abs * -1, :label => I18n.t(:rma_credit))
- order.update!
+ credit = Adjustment.new(:amount => amount.abs * -1, :label => I18n.t(:rma_credit))
+ credit.source = self
+ credit.adjustable = order
+ credit.save
end
def allow_receive?
@@ -80,7 +80,11 @@
end
it "should add credit for specified amount" do
- Spree::Adjustment.should_receive(:create).with(:source => return_authorization, :adjustable => order, :amount => -20, :label => I18n.t(:rma_credit))
+ mock_adjustment = mock
+ mock_adjustment.should_receive(:source=).with(return_authorization)
+ mock_adjustment.should_receive(:adjustable=).with(order)
+ mock_adjustment.should_receive(:save)
+ Spree::Adjustment.should_receive(:new).with(:amount => -20, :label => I18n.t(:rma_credit)).and_return(mock_adjustment)
return_authorization.receive!
end

0 comments on commit 8a8d80e

Please sign in to comment.