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

Borrar usos de OpenStruct #651

Merged
merged 3 commits into from
Feb 12, 2025
Merged

Conversation

santiagorodriguez96
Copy link
Collaborator

Al intentar actualizar rollbar a la versión v3.6.1 se rompen los tests con el siguiente error:

NameError: uninitialized constant UserTest::OpenStruct

El problema es que nuestra aplicación usa OpenStruct pero nunca la requerimos directamente – de todas formas funcionaba dado que rollbar la requería en su código.

Sin embargo, la versión v3.6.1 de rollbar deja de requerir OpenStruct por lo que al actualizar a esa versión empiezan a fallar los tests.

Para solucionarlo simplemente nos definimos dos clases Auth y Auth::Info usando Struct que nos proveen la misma funcionalidad que estaba ofreciendo el OpenStruct.

test 'User.from_omniauth of a user that doesn\'t exist, should create a new user' do
auth = OpenStruct.new(
auth = Auth.new(
Copy link
Collaborator

Choose a reason for hiding this comment

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

otra opción puede ser usar OmniAuth::AuthHash y OmniAuth::AuthHash::InfoHash que parecería que es lo que usa internamente omniauth, y por lo tanto lo que se le termina pasando en nuestro caso a este método

Copy link
Collaborator Author

@santiagorodriguez96 santiagorodriguez96 Feb 12, 2025

Choose a reason for hiding this comment

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

Ahh no es mala! Lo único que me preocupa es que podría darnos problemas si después la gema omniauth decide, por ejemplo, cambiar los nombres de esas clases – lo cual resultaría en que fallen nuevamente estos tests 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

Me da igual cualquiera de las dos opciones.
Pero no me parece mal que se rompa so omniauth cambia algo, porque de hecho eso puede causarnos problemas en producción

Copy link
Collaborator Author

@santiagorodriguez96 santiagorodriguez96 Feb 12, 2025

Choose a reason for hiding this comment

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

Actualicé con esos cambios en ac31a90

This commits changes from defining our own custom classes in favor of
`OmniAuth::AuthHash` and `OmniAuth::AuthHash::InfoHash` which are
`OmniAuth` internal classes. Instances of those classes end up being
passed to our `User.from_omniauth` method in production.
@santiagorodriguez96 santiagorodriguez96 merged commit b492a08 into master Feb 12, 2025
5 checks passed
@santiagorodriguez96 santiagorodriguez96 deleted the sr--remove-openstruct branch February 12, 2025 18:43
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.

2 participants