File: user_avatar_spec.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (35 lines) | stat: -rw-r--r-- 1,049 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Upload a user avatar', :js, feature_category: :user_profile do
  let_it_be(:user, reload: true) { create(:user) }

  let(:file) { fixture_file_upload('spec/fixtures/banana_sample.gif') }

  before do
    stub_feature_flags(edit_user_profile_vue: false)
    sign_in(user)
    visit(user_settings_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
      expect(page).to have_current_path(user_settings_profile_path, ignore_query: true)
    end
  end

  it_behaves_like 'handling file uploads', 'for a user avatar'
end