Sha256: 75c7995acfefab37bf2c759a721fdf83adf758739d5647f0bb7fe77bc7d1fc26
Contents?: true
Size: 1.12 KB
Versions: 3
Compression:
Stored size: 1.12 KB
Contents
require 'spec_helper' describe 'Users', js: true, type: :feature do let!(:user) do User.create(avatar: File.open("#{Rails.root}/spec/fixtures/avatar.jpg")) end let(:created_user) { User.last } describe '#new + #create' do it 'functions properly' do visit new_user_path attach_file 'user[avatar]', "#{Rails.root}/spec/fixtures/avatar2.jpg" expect do click_button 'Submit' sleep 1 end.to change { User.count }.by(1) expect(created_user.avatar.file.filename).to eq 'avatar2.jpg' end end describe '#edit + #update' do it 'uploads via AJAX' do user.update(remove_avatar: true) expect(user.avatar).to be_blank visit edit_user_path(user) find('input[type=file]').set "#{Rails.root}/spec/fixtures/avatar2.jpg" sleep 1 expect(user.reload.avatar).to_not be_blank expect(user.avatar.file.filename).to eq 'avatar2.jpg' end it 'removes via AJAX' do expect(user.avatar).to_not be_blank visit edit_user_path(user) find('a', text: 'Remove').click expect(user.reload.avatar).to be_blank end end end
Version data entries
3 entries across 3 versions & 1 rubygems