debian-mirror-gitlab/spec/features/file_uploads/user_avatar_spec.rb

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

35 lines
968 B
Ruby
Raw Normal View History

2020-11-24 15:15:51 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-04-23 21:23:45 +05:30
RSpec.describe 'Upload a user avatar', :js, feature_category: :user_profile do
2020-11-24 15:15:51 +05:30
let_it_be(:user, reload: true) { create(:user) }
2021-09-30 23:02:18 +05:30
2020-11-24 15:15:51 +05:30
let(:file) { fixture_file_upload('spec/fixtures/banana_sample.gif') }
before do
sign_in(user)
visit(profile_path)
attach_file('user_avatar-trigger', file.path, make_visible: true)
click_button 'Set new profile picture'
end
subject do
click_button 'Update profile settings'
end
RSpec.shared_examples 'for a user avatar' do
it 'uploads successfully' do
expect(user.avatar.file).to eq nil
subject
expect(page).to have_content 'Profile was successfully updated'
expect(user.reload.avatar.file).to be_present
expect(user.avatar).to be_instance_of AvatarUploader
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path(profile_path, ignore_query: true)
2020-11-24 15:15:51 +05:30
end
end
it_behaves_like 'handling file uploads', 'for a user avatar'
end