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

fix rubocop Rails/ResponseParseBody #13112

Conversation

Yassir4
Copy link
Contributor

@Yassir4 Yassir4 commented Jan 31, 2025

What? Why?

Note

I disabled the RuboCop check on the spec/controllers/user_registrations_controller_spec.rb because the response is returned using format.js not format.json which doesn't work well with the parsed_body method.

What should we test?

  • Manual test for successful user registration/signup. Check JS console in case of any errors/warnings.
  • Test should pass for the spec file changed

Release notes

Changelog Category (reviewers may add a label for the release notes):

  • User facing changes
  • API changes (V0, V1, DFC or Webhook)
  • Technical changes only
  • Feature toggled

Copy link
Collaborator

@rioug rioug left a comment

Choose a reason for hiding this comment

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

Thanks @Yassir4 🙏 !

I disabled the RuboCop check on the spec/controllers/user_registrations_controller_spec.rb because the response is returned using format.js not format.json which doesn't work well with the parsed_body method.

It looks like something that should be using format.json and that we should fix, Would you want to give this a go ?

@@ -2,6 +2,7 @@

require 'spec_helper'

# rubocop:disable Rails/ResponseParsedBody
RSpec.describe UserRegistrationsController, type: :controller do
Copy link
Member

Choose a reason for hiding this comment

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

It looks like something that should be using format.json and that we should fix

Agreed, this should be fixed if possible.

Alternatively, we shouldn't disable the rubocop rule here. It's a violation that is still "to do"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rioug @dacook

I will tackle it.

The UserRegistrationsController#create is not yet used for signup, I saw an open issue for merging Spree::UserRegistrationsController into UserRegistrationsController, so changing the format won't break anything

@Yassir4 Yassir4 force-pushed the 12620-fix-rubocop-rails-response-parse-body branch from 14737a9 to 8f0c3c9 Compare February 3, 2025 17:26
@Yassir4 Yassir4 requested review from rioug and dacook February 3, 2025 17:45
@Yassir4 Yassir4 force-pushed the 12620-fix-rubocop-rails-response-parse-body branch from 8f0c3c9 to 69f3f9f Compare February 3, 2025 18:02
Copy link
Collaborator

@rioug rioug left a comment

Choose a reason for hiding this comment

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

Awesome ! thank you @Yassir4 🙏
FYI for next time, we tend to prefer rebasing the branch on master, rather than merging master.

Copy link
Member

@dacook dacook left a comment

Choose a reason for hiding this comment

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

Thank you! I've added a testing note to check the user registration.

@filipefurtad0 filipefurtad0 self-assigned this Feb 7, 2025
@filipefurtad0 filipefurtad0 added pr-staged-fr staging.coopcircuits.fr and removed pr-staged-fr staging.coopcircuits.fr labels Feb 7, 2025
@filipefurtad0
Copy link
Contributor

Hey @Yassir4,

Thanks for this PR as well. (Thank you @dacook for the notes on what to test).
I have not spotted any new errors on the console, when registering a new user - those on the picture are pre-existent (those appearing on Stripe are intermittent and I don't think relate to this PR):

Before this PR

image

After this PR

image

All working as before. Merging.

@filipefurtad0 filipefurtad0 merged commit da58566 into openfoodfoundation:master Feb 7, 2025
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Rubocop Rails/ResponseParsedBody
4 participants