Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features/uploads/user_uploads_avatar_to_profile_spec.rb')
-rw-r--r--spec/features/uploads/user_uploads_avatar_to_profile_spec.rb69
1 files changed, 49 insertions, 20 deletions
diff --git a/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb b/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb
index cc296259b80..cd181f73473 100644
--- a/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb
+++ b/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb
@@ -6,34 +6,63 @@ RSpec.describe 'User uploads avatar to profile', feature_category: :user_profile
let!(:user) { create(:user) }
let(:avatar_file_path) { Rails.root.join('spec', 'fixtures', 'dk.png') }
- before do
- stub_feature_flags(edit_user_profile_vue: false)
- sign_in user
- visit profile_path
- end
+ shared_examples 'upload avatar' do
+ it 'shows the new avatar immediately in the header and setting sidebar', :js do
+ expect(page.find('.avatar-image .gl-avatar')['src']).not_to include(
+ "/uploads/-/system/user/avatar/#{user.id}/avatar.png"
+ )
+ find('.js-user-avatar-input', visible: false).set(avatar_file_path)
+
+ click_button 'Set new profile picture'
+ click_button 'Update profile settings'
- it 'they see their new avatar on their profile' do
- attach_file('user_avatar', avatar_file_path, visible: false)
- click_button 'Update profile settings'
+ wait_for_all_requests
- visit user_path(user)
+ data_uri = find('.avatar-image .gl-avatar')['src']
+ expect(page.find('.header-user-avatar')['src']).to eq data_uri
+ expect(page.find('[data-testid="sidebar-user-avatar"]')['src']).to eq data_uri
+
+ visit profile_path
+
+ expect(page.find('.avatar-image .gl-avatar')['src']).to include(
+ "/uploads/-/system/user/avatar/#{user.id}/avatar.png"
+ )
+ end
+ end
- expect(page).to have_selector(%(img[src$="/uploads/-/system/user/avatar/#{user.id}/dk.png?width=96"]))
+ context 'with "edit_user_profile_vue" turned on' do
+ before do
+ sign_in_and_visit_profile
+ end
- # Cheating here to verify something that isn't user-facing, but is important
- expect(user.reload.avatar.file).to exist
+ it_behaves_like 'upload avatar'
end
- it 'their new avatar is immediately visible in the header and setting sidebar', :js do
- find('.js-user-avatar-input', visible: false).set(avatar_file_path)
+ context 'with "edit_user_profile_vue" turned off' do
+ before do
+ stub_feature_flags(edit_user_profile_vue: false)
+ sign_in_and_visit_profile
+ end
- click_button 'Set new profile picture'
- click_button 'Update profile settings'
+ it 'they see their new avatar on their profile' do
+ attach_file('user_avatar', avatar_file_path, visible: false)
+ click_button 'Update profile settings'
- wait_for_all_requests
+ visit user_path(user)
- data_uri = find('.avatar-image .gl-avatar')['src']
- expect(page.find('.header-user-avatar')['src']).to eq data_uri
- expect(page.find('[data-testid="sidebar-user-avatar"]')['src']).to eq data_uri
+ expect(page).to have_selector(%(img[src$="/uploads/-/system/user/avatar/#{user.id}/dk.png?width=96"]))
+
+ # Cheating here to verify something that isn't user-facing, but is important
+ expect(user.reload.avatar.file).to exist
+ end
+
+ it_behaves_like 'upload avatar'
+ end
+
+ private
+
+ def sign_in_and_visit_profile
+ sign_in user
+ visit profile_path
end
end