diff --git a/app/assets/javascripts/app/views/publisher/uploader_view.js b/app/assets/javascripts/app/views/publisher/uploader_view.js index bd5c8ed3b..538946fbc 100644 --- a/app/assets/javascripts/app/views/publisher/uploader_view.js +++ b/app/assets/javascripts/app/views/publisher/uploader_view.js @@ -72,11 +72,19 @@ app.views.PublisherUploader = Backbone.View.extend({ ); // replace placeholder var placeholder = publisher.photozoneEl.find("li.loading#upload-" + id); + + var imgElement = document.createElement("img"); + imgElement.src = image.thumb_medium.url; + imgElement.classList.add("hidden"); + imgElement.dataset.id = photoId; + imgElement.dataset.small = image.thumb_small.url; + imgElement.dataset.scaled = image.scaled_full.url; + placeholder .prepend( - "
" + - "
" + - "\"\"" + '
' + + '
' + + imgElement.outerHTML ).removeClass("loading"); placeholder.find("div.progress").remove(); placeholder.find("img").on("load", function(ev) { diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb index c5caf120c..ef9743694 100644 --- a/features/step_definitions/custom_web_steps.rb +++ b/features/step_definitions/custom_web_steps.rb @@ -127,7 +127,9 @@ end When /^I click to delete the first uploaded photo$/ do page.execute_script("$('#photodropzone .x').css('display', 'block');") + image_count = all(".publisher_photo img").count find("#photodropzone .x", match: :first).trigger "click" + page.assert_selector(".publisher_photo img", count: image_count - 1) end And /^I click on selector "([^"]*)"$/ do |selector| diff --git a/features/support/publishing_cuke_helpers.rb b/features/support/publishing_cuke_helpers.rb index 3fe3e4b59..2b78f8e97 100644 --- a/features/support/publishing_cuke_helpers.rb +++ b/features/support/publishing_cuke_helpers.rb @@ -14,10 +14,13 @@ module PublishingCukeHelpers def upload_file_with_publisher(path) page.execute_script(%q{$("input[name='qqfile']").css("opacity", '1');}) + image_count = all(".publisher_photo img").count with_scope("#publisher-textarea-wrapper") do attach_file("qqfile", Rails.root.join(path).to_s) # wait for the image to be ready page.assert_selector(".publisher_photo.loading", count: 0) + page.assert_selector(".publisher_photo img", count: image_count + 1) + page.assert_selector(".publisher_photo img.hidden", count: 0) end end diff --git a/spec/javascripts/app/views/publisher_view_spec.js b/spec/javascripts/app/views/publisher_view_spec.js index 85ebea854..f389f4125 100644 --- a/spec/javascripts/app/views/publisher_view_spec.js +++ b/spec/javascripts/app/views/publisher_view_spec.js @@ -624,7 +624,9 @@ describe("app.views.Publisher", function() { var img = li.find('img'); expect(li).not.toHaveClass("loading"); - expect(img.attr("src")).toBe("/uploads/images/test.jpg"); + expect(img.attr("src")).toBe("/uploads/images/thumb_medium_test.jpg"); + expect(img.attr("data-small")).toBe("/uploads/images/thumb_small_test.jpg"); + expect(img.attr("data-scaled")).toBe("/uploads/images/scaled_full_test.jpg"); expect(img.attr("data-id")).toBe("987"); });