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

Add inverse_of to order.payments #1406

Merged

Conversation

jordan-brough
Copy link
Contributor

@jordan-brough jordan-brough commented Aug 25, 2016

This doesn't seem to happen automatically and is more important now
that we're using cached association objects in OrderUpdater (see
#1389). Solidus 1.4 broke some functionality in our app without it. This

after_save in Payment triggers order.update! if the Order or the
Payment is complete. That update needs to operate on the in-memory order
object or things can get out of sync.

It seems like this would be worth getting into Solidus 1.4.

In a Solidus sandbox without this patch:

>> o = Spree::Order.create!
>> p = o.payments.create!
>> puts p.order.object_id, o.object_id
70240633410460
70240634674300

With this patch:

>> o = Spree::Order.create!
>> p = o.payments.create!
>> puts p.order.object_id, o.object_id
70145793491740
70145793491740

There is some important history around this particular inverse_of --
see #407 and spree/spree_gateway#132.

Commit d7b8c73 removed part of the specs around this,
assuming that the inverse_of was automatically added, but it doesn't
actually seem to be (see above). The remaining tests around the issue
still pass.

I think I need to look further into the details of the prior issues to ensure
that we won't bring back bugs with this. Any extra eyes or thoughts are
appreciated. Any ideas on specs to add with this are also welcome.

This doesn't seem to happen automatically and is more important now
that we're using cached association objects in OrderUpdater (see
Solidus PR 1389).  Solidus 1.4 broke some of our specs without it.

In a Solidus sandbox without this patch:

    >> o = Spree::Order.create!
    >> p = o.payments.create!
    >> puts p.order.object_id, o.object_id
    70240633410460
    70240634674300

With this patch:

    >> o = Spree::Order.create!
    >> p = o.payments.create!
    >> puts p.order.object_id, o.object_id
    70145793491740
    70145793491740

There is some important history around this particular `inverse_of` --
see solidusio/solidus PR 407 and spree/spree_gateway PR 132.

Commit d7b8c73 in Solidus removed part of the specs around this,
assuming that the `inverse_of` was automatically added, but it doesn't
actually seem to be (see above). The remaining tests around the issue
still pass.
@jordan-brough jordan-brough added this to the 1.4.0 milestone Aug 25, 2016
@jhawthorn
Copy link
Contributor

👍 it's time to do this.

We probably can also drop the order.reload added in #407, as I believe that was required due to rails 4.2's awkward behaviour for changed? when update_columns was being used.

@cbrunsdon
Copy link
Contributor

I'm good on this too, thanks jordan 👍

See code comments in spec.
@jordan-brough
Copy link
Contributor Author

jordan-brough commented Aug 26, 2016

I've gone ahead and removed the reload mentioned by @jhawthorn and added some more comments on the specs for that. Assuming specs go green I'll merge this.

Shall we backport this to 1.4 as well?

@jordan-brough jordan-brough merged commit 68b425f into solidusio:master Aug 29, 2016
bbuchalter pushed a commit to TommyJohnWear/solidus that referenced this pull request Nov 15, 2016
…t-inverse-of

Add `inverse_of` to order.payments
gmacdougall added a commit to TommyJohnWear/solidus that referenced this pull request Nov 16, 2016
Merge pull request solidusio#1406 from jordan-brough/add-order-payment-inverse-of
@bbuchalter
Copy link
Contributor

For those who are investigating this issue be sure to also look at what impact this PR had by reviewing #1416

bbuchalter pushed a commit to TommyJohnWear/solidus that referenced this pull request May 26, 2017
…t-inverse-of

Add `inverse_of` to order.payments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants