-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Added avatar support when passed through Keycloak #5998
Conversation
user = create(:user, email: OmniAuth.config.mock_auth[:openid_connect][:info][:email]) | ||
user.avatar.attach(io: fixture_file_upload('default-avatar.png'), filename:, content_type: 'image/png') | ||
|
||
expect(User.find_by(email: OmniAuth.config.mock_auth[:openid_connect][:info][:email]).avatar).not_to receive(:attach) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is :attach
defined by us anywhere in greenlight?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its part of Active Storage - the rails extension that handles file attachements
https://guides.rubyonrails.org/active_storage_overview.html#has-one-attached
|
||
it 'does not re-attach the avatar if it hasnt changed' do | ||
reg_method = instance_double(SettingGetter) | ||
allow(SettingGetter).to receive(:new).with(setting_name: 'ResyncOnLogin', provider: 'greenlight').and_return(reg_method) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need the ReSynvOnLogin
registration method in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default, ResyncOnLogin in tests is set to false. This specific case tests that a user that has already logged in wont have the same image reattached.
So, by mocking it to true, it ensures that handle_avatar
method actually runs again the second time the user logs in
|
Added support for avatars that are passed through under the
image
keyFor keycloak, there's some mapping changes that will need to be made to add support (atleast for Google, likely for others as well)
fixes #5987