gitlab-org--gitlab-foss/spec/support/wait_for_ajax.rb
Dmitriy Zaporozhets 82033e2edc
Wait for ajax for every merge request spinach test
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-10-18 18:55:11 +03:00

15 lines
358 B
Ruby

module WaitForAjax
def wait_for_ajax
Timeout.timeout(Capybara.default_max_wait_time) do
loop until finished_all_ajax_requests?
end
end
def finished_all_ajax_requests?
page.evaluate_script('jQuery.active').zero?
end
def javascript_test?
[:selenium, :webkit, :chrome, :poltergeist].include?(Capybara.current_driver)
end
end