Skip to content

Add inverse_of to promotion actions and rules#1420

Merged
jordan-brough merged 1 commit intosolidusio:masterfrom
jordan-brough:add-inverse-ofs-to-promotion
Sep 17, 2016
Merged

Add inverse_of to promotion actions and rules#1420
jordan-brough merged 1 commit intosolidusio:masterfrom
jordan-brough:add-inverse-ofs-to-promotion

Conversation

@jordan-brough
Copy link
Copy Markdown
Contributor

This isn't happening automatically.

Without this patch:

>> p = Spree::Promotion.create!(name: 'foo')
>> p.promotion_rules << Spree::Promotion::Rules::FirstOrder.new
>> p.promotion_actions << Spree::Promotion::Actions::FreeShipping.new

>> p.object_id == p.promotion_rules.to_a.first.promotion.object_id
=> false

>> p.object_id == p.promotion_actions.to_a.first.promotion.object_id
=> false

With this patch those queries return true.

It seems likely that there are a lot of other places where we should add this. Or else figure out why it's not happening automatically.

This isn't happening automatically.

Without this patch:

    >> p = Spree::Promotion.create!(name: 'foo')
    >> p.promotion_rules << Spree::Promotion::Rules::FirstOrder.new
    >> p.promotion_actions << Spree::Promotion::Actions::FreeShipping.new

    >> p.object_id == p.promotion_rules.to_a.first.promotion.object_id
    => false

    >> p.object_id == p.promotion_actions.to_a.first.promotion.object_id
    => false

With this patch those queries return true.
@jhawthorn
Copy link
Copy Markdown
Contributor

👍

I'd guess that rails doesn't understand our Spree:: namespace well enough to add inverses automatically. Definitely needs further investigation.

Copy link
Copy Markdown
Member

@gmacdougall gmacdougall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jordan-brough jordan-brough merged commit 054e4bd into solidusio:master Sep 17, 2016
@jordan-brough jordan-brough deleted the add-inverse-ofs-to-promotion branch September 17, 2016 14:51
@jordan-brough
Copy link
Copy Markdown
Contributor Author

FYI I added an issue to look into things further: #1452

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.

3 participants