Skip to content

fix transient failure in path_locks_spec.rb

Simon Knox requested to merge path-locks-spec-fix into master

What does this MR do?

wait for Lock request to be finished before navigating away from that page

Are there points in the code the reviewer needs to double check?

Why was this MR needed?

this failed a few times on 9-5-stable-ee

Testing

Added artificial delay to Lock button, and ran test a bunch of times

for i in `seq 20` ; do bin/rspec spec/features/projects/path_locks_spec.rb ; [[ ! $? = 0 ]] && break ; done
diff --git a/app/assets/javascripts/path_locks.js b/app/assets/javascripts/path_locks.js
index 8b22b412f14..a074b4764ff 100644
--- a/app/assets/javascripts/path_locks.js
+++ b/app/assets/javascripts/path_locks.js
@@ -11,11 +11,13 @@
         $lockBtn = $(this);
         currentState = $lockBtn.data('state');
         toggleAction = currentState === 'lock' ? 'unlock' : 'lock';
-        return $.post(url, {
-          path: path
-        }, function() {
-          location.reload();
-        });
+        setTimeout(() => {
+          return $.post(url, {
+            path: path
+          }, function() {
+            location.reload();
+          });
+        }, 4500);
       });
     };
 

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Merge request reports