Skip to content

Not updating dynamic weight when attribute is changed #195

Open
@ghost

Description

I have the following setup:

class SalesAd
  has_one :district, through: :wine
  counter_culture :district, column_name: :active_sales_ads_count, delta_magnitude: proc { |model| model.state == "active" ? 1 : 0 }
end

I am then speccing it like this:

sales_ad
expect(district.reload.active_sales_ads_count).to eq 0
sales_ad.update!(state: "active")
expect(district.reload.active_sales_ads_count).to eq 1

Which fails with expected: 1 got: 0.

I would expect counter culture to notice the change and change the weight from 0 to 1 and add the change in weight to the active_sales_ads_count column on the district.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions