From 82033e2edc43b34823625f886f229e5ae944d4d6 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 18 Oct 2016 18:55:11 +0300 Subject: [PATCH] Wait for ajax for every merge request spinach test Signed-off-by: Dmitriy Zaporozhets --- features/steps/project/merge_requests.rb | 4 ++++ features/steps/shared/note.rb | 2 -- features/support/env.rb | 2 +- features/support/wait_for_ajax.rb | 11 ----------- spec/support/wait_for_ajax.rb | 4 ++++ 5 files changed, 9 insertions(+), 14 deletions(-) delete mode 100644 features/support/wait_for_ajax.rb diff --git a/features/steps/project/merge_requests.rb b/features/steps/project/merge_requests.rb index 44346d99f44..2ccab4334eb 100644 --- a/features/steps/project/merge_requests.rb +++ b/features/steps/project/merge_requests.rb @@ -9,6 +9,10 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps include SharedUser include WaitForAjax + after do + wait_for_ajax if javascript_test? + end + step 'I click link "New Merge Request"' do click_link "New Merge Request" end diff --git a/features/steps/shared/note.rb b/features/steps/shared/note.rb index d3b5b0bdebe..9dc1fc41b3b 100644 --- a/features/steps/shared/note.rb +++ b/features/steps/shared/note.rb @@ -1,5 +1,3 @@ -require Rails.root.join('features/support/wait_for_ajax') - module SharedNote include Spinach::DSL include WaitForAjax diff --git a/features/support/env.rb b/features/support/env.rb index 569fd444e86..8dbe3624410 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -15,7 +15,7 @@ if ENV['CI'] Knapsack::Adapters::SpinachAdapter.bind end -%w(select2_helper test_env repo_helpers).each do |f| +%w(select2_helper test_env repo_helpers wait_for_ajax).each do |f| require Rails.root.join('spec', 'support', f) end diff --git a/features/support/wait_for_ajax.rb b/features/support/wait_for_ajax.rb deleted file mode 100644 index b90fc112671..00000000000 --- a/features/support/wait_for_ajax.rb +++ /dev/null @@ -1,11 +0,0 @@ -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 -end diff --git a/spec/support/wait_for_ajax.rb b/spec/support/wait_for_ajax.rb index b90fc112671..0f9dc2dee75 100644 --- a/spec/support/wait_for_ajax.rb +++ b/spec/support/wait_for_ajax.rb @@ -8,4 +8,8 @@ module WaitForAjax 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