From 605e2925893fd34f24427b228c8fcbdfa1e1dd2e Mon Sep 17 00:00:00 2001
From: Benjamin Neff <benjamin@coding4coffee.ch>
Date: Fri, 11 Aug 2017 02:14:32 +0200
Subject: [PATCH] Wait for image to be uploaded

---
 app/assets/javascripts/mobile/mobile_file_uploader.js | 1 -
 features/step_definitions/web_steps.rb                | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/app/assets/javascripts/mobile/mobile_file_uploader.js b/app/assets/javascripts/mobile/mobile_file_uploader.js
index 86c7848188..3a33ef5ee6 100644
--- a/app/assets/javascripts/mobile/mobile_file_uploader.js
+++ b/app/assets/javascripts/mobile/mobile_file_uploader.js
@@ -33,7 +33,6 @@ function createUploader(){
         $("#fileInfo-publisher").text(fileName + " " + progress + "%");
       },
       onSubmit: function() {
-        $("#file-upload-publisher").addClass("loading");
         $("#publisher_textarea_wrapper").addClass("with_attachments");
         $("#photodropzone").append(
           "<li class='publisher_photo loading' style='position:relative;'>" +
diff --git a/features/step_definitions/web_steps.rb b/features/step_definitions/web_steps.rb
index 36092716fe..2ffdd48296 100644
--- a/features/step_definitions/web_steps.rb
+++ b/features/step_definitions/web_steps.rb
@@ -93,6 +93,8 @@ When /^(?:|I )attach the file "([^"]*)" to (?:hidden )?"([^"]*)"(?: within "([^"
     page.execute_script("$(\"input[name='#{field}']\").css('opacity', '1');")
     attach_file(field, Rails.root.join(path).to_s)
   end
+  # wait for the image to be ready
+  page.assert_selector(".loading", count: 0)
 end
 
 Then /^(?:|I )should see (\".+?\"[\s]*)(?:[\s]+within[\s]* "([^"]*)")?$/ do |vars, selector|
-- 
GitLab