solidus icon indicating copy to clipboard operation
solidus copied to clipboard

updating adjustment eligibility does not expire API cache

Open loicginoux opened this issue 6 years ago • 0 comments

Steps to reproduce

  • I have a free shipping promo if the total amount is > 50 $
  • my order total is at 55 $
  • I apply a coupon code that gives - 10$. my new order total is at 45.
  • requesting the order via API gives the shipment adjustment is still eligible
  • the attribute in DB for the adjustment is eligible = false

Expected behavior

the API response for the adjustment should reflect the DB change when requesting the order response.

What's happening ?

When changing eligible column both in the PromotionChooser#update and in Spree::Adjustment#recalculate we do it via the method update_columns, a method which does not fire the touch event on the adjustable association:

class Adjustment < Spree::Base
    belongs_to :adjustable, polymorphic: true, touch: true

Changing the update_columns by update_attributes will fire the touch event and invalidate the shipment api result cache.

System configuration

Solidus Version: 2.4

loicginoux avatar Dec 14 '17 11:12 loicginoux