2020-08-20 11:10:18 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe 'Upload a user avatar', :js do
|
|
|
|
let_it_be(:user, reload: true) { create(:user) }
|
2021-06-28 23:07:32 -04:00
|
|
|
|
2020-08-20 11:10:18 -04:00
|
|
|
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-03-03 10:16:42 -05:00
|
|
|
expect(page).to have_current_path(profile_path, ignore_query: true)
|
2020-08-20 11:10:18 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'handling file uploads', 'for a user avatar'
|
|
|
|
end
|