From c7ab3e1fe2238299e9bd5f59a9669387fd782a0f Mon Sep 17 00:00:00 2001 From: Mantas Masalskis Date: Wed, 19 Feb 2020 12:43:58 +0100 Subject: [PATCH] Github PR #2935 - Fixes #2781 - Users can't remove their Sessions from Device list. --- .../app/controllers/_profile/devices.coffee | 2 +- spec/system/profile/devices_spec.rb | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 spec/system/profile/devices_spec.rb 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