Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-12-08 01:08:22 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-12-08 01:40:17 +0300
commitbdb4945dcf3c899c6a88fd42657a1b3f04baced1 (patch)
treec200dd2911336dd64575835e59f83368afc98736 /spec
parent2928e19d4356683119cf0d2bb269752253ea5d50 (diff)
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>
Diffstat (limited to 'spec')
-rw-r--r--spec/features/notes_on_merge_requests_spec.rb5
-rw-r--r--spec/support/wait_for_ajax.rb11
2 files changed, 14 insertions, 2 deletions
diff --git a/spec/features/notes_on_merge_requests_spec.rb b/spec/features/notes_on_merge_requests_spec.rb
index d7cb3b2e86e..f0fc6916c4d 100644
--- a/spec/features/notes_on_merge_requests_spec.rb
+++ b/spec/features/notes_on_merge_requests_spec.rb
@@ -2,6 +2,7 @@ require 'spec_helper'
describe 'Comments', feature: true do
include RepoHelpers
+ include WaitForAjax
describe 'On a merge request', js: true, feature: true do
let!(:merge_request) { create(:merge_request) }
@@ -123,8 +124,8 @@ describe 'Comments', feature: true do
it 'removes the attachment div and resets the edit form' do
find('.js-note-attachment-delete').click
is_expected.not_to have_css('.note-attachment')
- expect(find('.current-note-edit-form', visible: false)).
- not_to be_visible
+ is_expected.not_to have_css('.current-note-edit-form')
+ wait_for_ajax
end
end
end
diff --git a/spec/support/wait_for_ajax.rb b/spec/support/wait_for_ajax.rb
new file mode 100644
index 00000000000..692d219e9f1
--- /dev/null
+++ b/spec/support/wait_for_ajax.rb
@@ -0,0 +1,11 @@
+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