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.
This commit is contained in:
Maikel Linke
2023-02-24 14:39:35 +11:00
parent 401210ef44
commit e6eb9412d9

View File

@@ -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