fix variable hoisting issue and brittle spec

gravatar now proxies fallback urls, meaning they don't work for private
hosts/ips (e.g. dev or test). the profile pic ui tries to remove broken
images, so depending on gravatar's behavior the number of images in the
dom could vary. so we remove that check, since we don't really need it.

also fix a related issue where if one of the images is missing, the last
one in the list will get removed (variable hoisting). incidentally this
fixes a sporadic failure

test plan:
1. run specs, they should pass
2. run canvas locally
3. upload a profile pic and click "Select Image"
4. reload the page and go to edit profile pics again
5. the uploaded pic should not get removed (the broken gravatar one should)

Change-Id: I31c82a983ba6451d7abc4465e7ca345ddaa5697f
Reviewed-on: https://gerrit.instructure.com/13975
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jake Sorce <jake@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
This commit is contained in:
Jon Jensen 2012-09-27 08:48:28 -06:00 committed by Bryan Madsen
parent ecae448a0e
commit 841aed6063
2 changed files with 1 additions and 5 deletions

View File

@ -496,9 +496,7 @@ define([
.attr('title', image.display_name || image.type)
.attr('data-type', image.type);
$img[0].onerror = function() {
$span.remove();
}
$img[0].onerror = $span.remove.bind($span, null);
$dialog.find(".profile_pic_list div").before($span);
}
if (pollThumbnails) thumbnailPoller.start();

View File

@ -304,7 +304,6 @@ shared_examples_for "profile pictures selenium tests" do
keep_trying_until { f(".profile_pic_link") }.click
dialog = f("#profile_pic_dialog")
dialog.should be_displayed
dialog.find_elements(:css, ".profile_pic_list span.img").length.should == 2
dialog.find_element(:css, ".add_pic_link").click
filename, fullpath, data = get_file("graded.png")
dialog.find_element(:id, 'attachment_uploaded_data').send_keys(fullpath)
@ -320,7 +319,6 @@ shared_examples_for "profile pictures selenium tests" do
keep_trying_until do
spans = ffj("#profile_pic_dialog .profile_pic_list span.img")
spans.length.should == 3
spans.last.attribute('class') =~ /selected/
uploaded_image = ffj("#profile_pic_dialog .profile_pic_list span.img img").last
image_src = uploaded_image.attribute('src')