Retry setting single attributes in AbstractWorkPackage

pull/4945/head
Oliver Günther 8 years ago
parent d0311d8f28
commit e4511ec3a7
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 30
      spec/support/pages/abstract_work_package.rb
  2. 2
      spec/support/work_packages/work_package_field.rb

@ -122,16 +122,36 @@ module Pages
def set_attributes(key_value_map, save: true)
key_value_map.each_with_index.map do |(key, value), index|
field = work_package_field key
field.activate!
set_attribute(key, value, save: save)
unless index == key_value_map.length - 1
ensure_no_conflicting_modifications
end
end
end
##
# Set a single attribute while retrying to open the field
# if unsuccessful at first.
def set_attribute(key, value, save: true)
field = work_package_field key
# Retry to set attributes due to reloading the page after setting
# an attribute, which may cause an input not to open properly.
retried = false
begin
field.activate_edition
field.set_value value
# select fields are saved on change
field.save! if save && field.input_element.tag_name != 'select'
unless index == key_value_map.length - 1
ensure_no_conflicting_modifications
rescue => e
if retried
raise e
end
$stderr.puts "Failed to set attribute #{key}: #{e.message}. Retrying"
retried = true
sleep 1
retry
end
end

@ -90,7 +90,7 @@ class WorkPackageField
end
def activate_edition
element.find("#{trigger_link_selector}").click
element.find(trigger_link_selector).click
end
def input_element

Loading…
Cancel
Save