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

Add scope to routes, to unify url with frontend #570

Merged
merged 11 commits into from
Dec 6, 2022

Conversation

wjwitek
Copy link
Contributor

@wjwitek wjwitek commented Nov 23, 2022

Change locale from being in url as param, to being part of url, using scope in routes.
It will break locale for legacy_frontend however (they'll be lost while clicking log out etc.), without this fix spree/spree_rails_frontend#31.

config/routes.rb Outdated
resource :account, controller: :account, only: %i[show create update]
resources :account_confirmations, only: %i[show]
resources :passwords, controller: :passwords, only: %i[create update]
namespace :api, defaults: { format: 'json' } do
Copy link
Member

Choose a reason for hiding this comment

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

The API in Spree is not locale-scoped, so these routes should go outside of the scope :locale thing

Copy link
Member

Choose a reason for hiding this comment

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

For them, locale is always passed as a query param

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, that makes sense. I've fixed it.

@nciemniak
Copy link
Contributor

@wjwitek , I think I found a place where the locale is still not persisting, can you check it out?

Steps:

  1. Set locale to fr
  2. Login
  3. Click "Ajouter une nouvelle adresse" (add new address), or update an existing address
  4. Enter a new address and click save button
    At this point, when it redirects back to the account page, the locale does not propagate and defaults back to english.

Hopefully I've correctly replicated your setup :P

Copy link
Contributor

@nciemniak nciemniak left a comment

Choose a reason for hiding this comment

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

Left some feedback on a couple tests, I'll take a look at the rest today as well 😎

spec/controllers/spree/user_sessions_controller_spec.rb Outdated Show resolved Hide resolved
spec/controllers/spree/user_sessions_controller_spec.rb Outdated Show resolved Hide resolved
spec/controllers/spree/user_sessions_controller_spec.rb Outdated Show resolved Hide resolved
spec/controllers/spree/user_sessions_controller_spec.rb Outdated Show resolved Hide resolved
spec/controllers/spree/user_sessions_controller_spec.rb Outdated Show resolved Hide resolved
@nciemniak
Copy link
Contributor

Great so far on covering the various test cases, this'll really help us make sure we're not breaking locale in the future. I feel like this'll be good to go once the tests are ironed out 💪

wjwitek and others added 3 commits December 6, 2022 08:26
Co-authored-by: nciemniak <nciemniak@gmail.com>
Co-authored-by: nciemniak <nciemniak@gmail.com>
Co-authored-by: nciemniak <nciemniak@gmail.com>
wjwitek and others added 3 commits December 6, 2022 08:28
@nciemniak nciemniak merged commit b6d3411 into spree:main Dec 6, 2022
@wjwitek wjwitek deleted the locale_scope_in_routes branch December 6, 2022 10:35
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