MountainRoseHerbs/spree — pull request #37 by mbj (2014-11-28 01:18:30+00:00)
Title: Fix processing of invalid line items

This PR fixes cases where `OrderContents#add` triggered adjustments of line items that could not be persisted.

The change makes sure that invalid line items get returned unsaved to the call side within the `OrderPopulator` that will recheck `#valid?` to steer its UI flow on.

Before invalid line items created by `OrderContents#add` got adjusted and can cause all sorts of errors like violation of foreign reference / adjustable lookup errors etc.

The specs added kill all mutations of changed call subjects before and after the change. I admit they are not very beautifully written. But without tearing them apart and rewriting the whole spec suite for `OrderContents` I could not think about a better way to cover the big holes in the specs.

My spec additions are style wise in line with the present ones.