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

Convert product, variant, stock item, prices to discard #2396

Merged
merged 6 commits into from
Jan 3, 2018

Conversation

jhawthorn
Copy link
Contributor

@jhawthorn jhawthorn commented Nov 23, 2017

This deprecates the #paranoia_destroy (and therefore also #destroy) method on these models in favour of using #discard.

after_discard callbacks have been added to these models to duplicate the exact current behaviour of calling #destroy (before_destroy callbacks and destroying of dependent: :destroy associations). In the future we probably want to change this behaviour (why do we delete images when soft-deleting variants?), but that isn't being done here.

@jhawthorn jhawthorn added the WIP label Nov 23, 2017
def paranoia_destroy
Spree::Deprecation.warn <<-WARN.strip_heredoc
Calling #destroy (or #paranoia_destroy) on a Product currently performs a soft-destroy using the paranoia gem.
In Solidus 3.0, paranoia will be removed, and this will perform a HARD destoy instead. To continue soft-deleting, use #discard instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

"...perform a HARD destoy". All three of the deprecation warnings have this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This also prompted me to move these warnings to a common ParanoiaDeprecations module.

@jhawthorn jhawthorn changed the title [WIP] Convert product, variant, stock item to discard Convert product, variant, stock item to discard Nov 24, 2017
@jhawthorn jhawthorn changed the title Convert product, variant, stock item to discard Convert product, variant, stock item, prices to discard Nov 24, 2017
@jhawthorn jhawthorn removed the WIP label Nov 24, 2017
Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

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

Great! Just left a comment on a possible mistake.


it "should keep its price if deleted" do
expect(variant.display_price).to eq(previous_variant_price)
variant.destroy
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't be variant.discard?

@jhawthorn jhawthorn force-pushed the discard_products branch 2 times, most recently from 0796699 to cc59d0e Compare December 12, 2017 20:08
@jhawthorn jhawthorn added this to the 2.5.0 milestone Dec 22, 2017
This deprecates the #paranoia_destroy (and therefore also #destroy)
method on these models in favour of using #discard.

after_discard callbacks have been added to these models to duplicate the
current behaviour of calling #destroy (before_destroy callbacks and
destroying of dependent: :destroy associations).
@jhawthorn jhawthorn merged commit f1ffcc7 into solidusio:master Jan 3, 2018
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