Make enterprises/index_spec a bit more resilient

This commit is contained in:
luisramos0
2019-09-03 13:55:41 +01:00
parent f0586af1c7
commit b4de8ef899

View File

@@ -76,12 +76,20 @@ feature 'Enterprises Index' do
visit admin_enterprises_path
end
def enterprise_row_index(enterprise_name)
enterprise_row_number = all('tr').index { |tr| tr.text.include? enterprise_name }
enterprise_row_number - 1
end
it "does not update the enterprises and displays errors" do
d_row_index = enterprise_row_index(d.name)
within("tr.enterprise-#{d.id}") do
select d_manager.email, from: 'enterprise_set_collection_attributes_0_owner_id'
select d_manager.email, from: "enterprise_set_collection_attributes_#{d_row_index}_owner_id"
end
second_distributor_row_index = enterprise_row_index(second_distributor.name)
within("tr.enterprise-#{second_distributor.id}") do
select d_manager.email, from: 'enterprise_set_collection_attributes_1_owner_id'
select d_manager.email, from: "enterprise_set_collection_attributes_#{second_distributor_row_index}_owner_id"
end
click_button "Update"
expect(flash_message).to eq('Update failed')