Fix #39604 - Update header avatar after user changes avatar
This commit is contained in:
parent
2bac2918b2
commit
6cfc5c6a5e
|
@ -61,7 +61,13 @@ export default class Profile {
|
||||||
url: this.form.attr('action'),
|
url: this.form.attr('action'),
|
||||||
data: formData,
|
data: formData,
|
||||||
})
|
})
|
||||||
.then(({ data }) => flash(data.message, 'notice'))
|
.then(({ data }) => {
|
||||||
|
if (avatarBlob != null) {
|
||||||
|
this.updateHeaderAvatar();
|
||||||
|
}
|
||||||
|
|
||||||
|
flash(data.message, 'notice');
|
||||||
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
// Enable submit button after requests ends
|
// Enable submit button after requests ends
|
||||||
|
@ -70,6 +76,10 @@ export default class Profile {
|
||||||
.catch(error => flash(error.message));
|
.catch(error => flash(error.message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateHeaderAvatar() {
|
||||||
|
$('.header-user-avatar').attr('src', this.avatarGlCrop.dataURL);
|
||||||
|
}
|
||||||
|
|
||||||
setRepoRadio() {
|
setRepoRadio() {
|
||||||
const multiEditRadios = $('input[name="user[multi_file]"]');
|
const multiEditRadios = $('input[name="user[multi_file]"]');
|
||||||
if (this.newRepoActivated || this.newRepoActivated === 'true') {
|
if (this.newRepoActivated || this.newRepoActivated === 'true') {
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Change avatar image in the header when user updates their avatar.
|
||||||
|
merge_request: 20119
|
||||||
|
author: Jamie Schembri
|
||||||
|
type: added
|
|
@ -1,17 +1,16 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
feature 'User uploads avatar to profile' do
|
feature 'User uploads avatar to profile' do
|
||||||
scenario 'they see their new avatar' do
|
let!(:user) { create(:user) }
|
||||||
user = create(:user)
|
let(:avatar_file_path) { Rails.root.join('spec', 'fixtures', 'dk.png') }
|
||||||
sign_in(user)
|
|
||||||
|
|
||||||
|
before do
|
||||||
|
sign_in user
|
||||||
visit profile_path
|
visit profile_path
|
||||||
attach_file(
|
end
|
||||||
'user_avatar',
|
|
||||||
Rails.root.join('spec', 'fixtures', 'dk.png'),
|
|
||||||
visible: false
|
|
||||||
)
|
|
||||||
|
|
||||||
|
scenario 'they see their new avatar on their profile' do
|
||||||
|
attach_file('user_avatar', avatar_file_path, visible: false)
|
||||||
click_button 'Update profile settings'
|
click_button 'Update profile settings'
|
||||||
|
|
||||||
visit user_path(user)
|
visit user_path(user)
|
||||||
|
@ -21,4 +20,16 @@ feature 'User uploads avatar to profile' do
|
||||||
# Cheating here to verify something that isn't user-facing, but is important
|
# Cheating here to verify something that isn't user-facing, but is important
|
||||||
expect(user.reload.avatar.file).to exist
|
expect(user.reload.avatar.file).to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario 'their new avatar is immediately visible in the header', :js do
|
||||||
|
find('.js-user-avatar-input', visible: false).set(avatar_file_path)
|
||||||
|
|
||||||
|
click_button 'Set new profile picture'
|
||||||
|
click_button 'Update profile settings'
|
||||||
|
|
||||||
|
wait_for_all_requests
|
||||||
|
|
||||||
|
data_uri = find('.avatar-image .avatar')['src']
|
||||||
|
expect(page.find('.header-user-avatar')['src']).to eq data_uri
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue