From e6eb9412d9739daa71da4a5dd6df5177b7db4a41 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 24 Feb 2023 14:39:35 +1100 Subject: [PATCH] Simplify owner selection in spec Instead of knowing the input id generated by select2, we now rely on the fact that the owner is in the fifth column. Both could change but this is less code. --- spec/system/admin/enterprises/index_spec.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/spec/system/admin/enterprises/index_spec.rb b/spec/system/admin/enterprises/index_spec.rb index c06b4540b8..a2b5c47901 100644 --- a/spec/system/admin/enterprises/index_spec.rb +++ b/spec/system/admin/enterprises/index_spec.rb @@ -87,12 +87,9 @@ describe 'Enterprises Index' do end def select_new_owner(user, enterprise) - enterprise_row_number = all('tr').index { |tr| tr.text.include? enterprise.name } - enterprise_row_number -= 1 - - within("tr.enterprise-#{enterprise.id}") do - select user.email, - from: "sets_enterprise_set_collection_attributes_#{enterprise_row_number}_owner_id" + # The fifth table column contains the owner field. + within("tr.enterprise-#{enterprise.id} td:nth-child(5)") do + select user.email end end end