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

Adds configuration flag for the deprecation of associate_user #3677

Conversation

carlosep
Copy link

@carlosep carlosep commented Jun 22, 2020

Description
This Pull Request solves the issue #3559, and it is done after #3667, which was closed due to a better solution on this one.

Based on this discussion the associate_user method is deprecated due to changes during the creation or building of an order via current_order where before the creation and association of an user were made in different places now it is done immediately. After discussing on the issue we came to the conclusion that a good solution would be to add a configuration flag and enter a deprecation cycle starting at 2.11. For that I added the flag :associate_user_in_authentication_extension which will allow clients to safely move their customization on associate_user

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)
  • I have attached screenshots to this PR for visual changes (if needed)

Copy link
Member

@elia elia left a comment

Choose a reason for hiding this comment

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

Looks great, just a couple of tweaks and I think we're good to go!

@@ -52,6 +52,8 @@ def current_order(options = {})
end

def associate_user
return if Spree::Config.manually_associate_user
warn "Order#associate_user is deprecated and will be removed in 2.11"
Copy link
Member

Choose a reason for hiding this comment

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

Great! All deprecation in Solidus are managed via Spree::Deprecation.warn (see examples around the code) and would also be better to have a spec ensuring the deprecation is displayed (there are numerous examples of that in spec/ as well).

@@ -173,6 +173,10 @@ class AppConfiguration < Preferences::Configuration
# @return [String] Email address used as +From:+ field in transactional emails.
preference :mails_from, :string, default: '[email protected]'

# @!attribute [rw] manually_associate_user
# @return [Boolean] manually call associate_user instead of relying on current_order
preference :manually_associate_user, :boolean, default: true
Copy link
Member

Choose a reason for hiding this comment

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

Can you add something to the pref name that makes it clear that the association is responsibility of the authentication system? Like manually_associate_user_in_authentication_extension, or even without the initial manually_.

Copy link
Member

Choose a reason for hiding this comment

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

Also the default (contrary to what I initially said 😅) should be false, to maintain the current behavior.

@spaghetticode
Copy link
Member

@carlosep can you please review the commit message? It does not conform to the other ones on this project as it's very long and it does not read very nicely on github:

Screen Shot 2020-06-24 at 12 55 36 PM

I would keep the title at around 60 chars and add a description body with some details. Thanks 🙏

@carlosep carlosep force-pushed the add_configuration_flag_deprecated_associated_user branch from 1712b3b to 7a3e461 Compare July 12, 2020 20:39
@carlosep
Copy link
Author

@elia and @spaghetticode, all of the mentioned points were addressed, if something else is needed please reach out
🙂

@elia
Copy link
Member

elia commented Jul 14, 2020

@carlosep great job! I see the CI is failing because it treats deprecations as errors, I'm not sure how to deal with such a pervasive one, maybe @kennyadsl or @spaghetticode have handled similar ones in the past

@spaghetticode
Copy link
Member

@carlosep you can remove the deprecations (and consequently their errors) by overriding the default configuration value for the new preference in dummy_app.rb:

Spree.config do |config|
  # ...
  config.use_combined_first_and_last_name_in_address = true
  config.use_legacy_order_state_machine = false
  # add your preference here:
  config.associate_user_in_authentication_extension = true
end

This way, when the test suite runs the preference value will be set to true instead of false.

A configuration flag was needed to start a cycle of deprecation of the
Spree::Core::ControllerHelpers::Order#associate_user method.

This method is deprecated because now this association is done immediately
by the authentication system when needed.
@carlosep carlosep force-pushed the add_configuration_flag_deprecated_associated_user branch from 7a3e461 to 428617d Compare August 7, 2020 13:06
@carlosep
Copy link
Author

carlosep commented Aug 7, 2020

@spaghetticode, I added this configuration and still the CI broke. Is there some other place that requires this flag besides dummy_app.rb?

@kennyadsl
Copy link
Member

Hey @carlosep, you can see another PR (like #3749) as a reference for setting a "deprecation preference". Thanks!

@dborovsky
Copy link

Hi @elia, @carlosep @kennyadsl Is still actual to check CI errors, fix and merge this PR?

@elia
Copy link
Member

elia commented Nov 4, 2021

@dborovsky yes, this needs to be done, and IIRC this PR just lack the proper boilerplate for a smooth deprecation, interested in picking this up?

@dborovsky
Copy link

@elia yea, I want to help with this PR.

@elia
Copy link
Member

elia commented Nov 4, 2021

That's great, if you have any question about the comments we left above just ask and I'll try to help 👍
Also feel free to ping me on the solidus slack: http:https://slack.solidus.io/

dborovsky pushed a commit to dborovsky/solidus that referenced this pull request Nov 4, 2021
@dborovsky
Copy link

@elia @spaghetticode please review my PR #4201

@waiting-for-dev
Copy link
Contributor

Closing in favor of #4201

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.

None yet

7 participants