summaryrefslogtreecommitdiff
path: root/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb
blob: 0dfd29045e55242989758482d14a1dc001170635 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require 'rails_helper'

feature 'User uploads avatar to profile', feature: true do
  scenario 'they see their new avatar' do
    user = create(:user)
    login_as(user)

    visit profile_path
    attach_file(
      'user_avatar',
      Rails.root.join('spec', 'fixtures', 'dk.png'),
      visible: false
    )

    click_button 'Update profile settings'

    visit user_path(user)

    expect(page).to have_selector(%Q(img[src$="/uploads/user/avatar/#{user.id}/dk.png"]))

    # Cheating here to verify something that isn't user-facing, but is important
    expect(user.reload.avatar.file).to exist
  end
end