diff --git a/app/assets/javascripts/app/controllers/_profile/devices.coffee b/app/assets/javascripts/app/controllers/_profile/devices.coffee index de387907c..bbe33021c 100644 --- a/app/assets/javascripts/app/controllers/_profile/devices.coffee +++ b/app/assets/javascripts/app/controllers/_profile/devices.coffee @@ -36,7 +36,7 @@ class Index extends App.ControllerSubContent delete: (e) => e.preventDefault() - id = $(e.target).closest('a').data('device-id') + id = $(e.target).closest('div').data('device-id') @ajax( id: 'user_devices_delete' diff --git a/spec/system/profile/devices_spec.rb b/spec/system/profile/devices_spec.rb new file mode 100644 index 000000000..bac516fd2 --- /dev/null +++ b/spec/system/profile/devices_spec.rb @@ -0,0 +1,18 @@ +require 'rails_helper' + +RSpec.describe 'Profile > Devices', type: :system, authenticated: true do + subject!(:device) { create(:user_device, user_id: User.find_by(login: 'master@example.com').id) } + + it 'allows to remove device' do + visit 'profile/devices' + + within(:active_content) do + find('td', text: device.name) + .ancestor('tr') + .find('.settings-list-control') + .click + end + + wait(5).until { expect(page).to have_no_css('td', text: device.name) } + end +end