debian-mirror-gitlab/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
1.2 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2019-12-04 20:38:33 +05:30
require 'spec_helper'
2017-08-17 22:00:37 +05:30
2020-06-23 00:09:42 +05:30
RSpec.describe 'User uploads avatar to profile' do
2018-11-08 19:23:39 +05:30
let!(:user) { create(:user) }
let(:avatar_file_path) { Rails.root.join('spec', 'fixtures', 'dk.png') }
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
before do
sign_in user
2017-08-17 22:00:37 +05:30
visit profile_path
2018-11-08 19:23:39 +05:30
end
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
it 'they see their new avatar on their profile' do
attach_file('user_avatar', avatar_file_path, visible: false)
2017-08-17 22:00:37 +05:30
click_button 'Update profile settings'
visit user_path(user)
2022-08-27 11:52:29 +05:30
expect(page).to have_selector(%Q(img[src$="/uploads/-/system/user/avatar/#{user.id}/dk.png?width=96"]))
2017-08-17 22:00:37 +05:30
# Cheating here to verify something that isn't user-facing, but is important
expect(user.reload.avatar.file).to exist
end
2018-11-08 19:23:39 +05:30
2021-04-17 20:07:23 +05:30
it 'their new avatar is immediately visible in the header and setting sidebar', :js do
2018-11-08 19:23:39 +05:30
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
2022-11-25 23:54:43 +05:30
data_uri = find('.avatar-image .gl-avatar')['src']
2018-11-08 19:23:39 +05:30
expect(page.find('.header-user-avatar')['src']).to eq data_uri
2021-04-17 20:07:23 +05:30
expect(page.find('[data-testid="sidebar-user-avatar"]')['src']).to eq data_uri
2018-11-08 19:23:39 +05:30
end
2017-08-17 22:00:37 +05:30
end