gitlab-org--gitlab-foss/spec/support/wait_for_ajax.rb
Dmitriy Zaporozhets bdb4945dcf Fix random failing test - delete attachment
Make sure we wait for AJAX request to finish before end test and cleanup
database

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-12-07 23:40:17 +01:00

11 lines
242 B
Ruby

module WaitForAjax
def wait_for_ajax
Timeout.timeout(Capybara.default_wait_time) do
loop until finished_all_ajax_requests?
end
end
def finished_all_ajax_requests?
page.evaluate_script('jQuery.active').zero?
end
end