diff --git a/public/javascripts/aspect-edit.js b/public/javascripts/aspect-edit.js index 8edaa1853..134d661f4 100644 --- a/public/javascripts/aspect-edit.js +++ b/public/javascripts/aspect-edit.js @@ -54,7 +54,8 @@ var AspectEdit = { }); } - if (dropzone.attr('data-aspect_id') != person.attr('data-aspect_id')) { + if (person.attr('data-aspect_id') != undefined && // request doesn't have an aspect ID yet + dropzone.attr('data-aspect_id') != person.attr('data-aspect_id')) { $.ajax({ url: "/aspects/move_friend/", data: { diff --git a/spec/javascripts/aspect-edit-spec.js b/spec/javascripts/aspect-edit-spec.js index d5eea139a..b65ae396a 100644 --- a/spec/javascripts/aspect-edit-spec.js +++ b/spec/javascripts/aspect-edit-spec.js @@ -92,19 +92,18 @@ describe("AspectEdit", function() { }); describe("onDropMove", function() { - beforeEach(function() { - $('#jasmine_content').html( - '
  • ' + - ' Alexander Hamiltom' + - '
  • ' + - '' - ); - }); describe("when dragging a friend request", function() { + beforeEach(function() { + $('#jasmine_content').html( +'
  • ' + +' Alexander Hamiltom' + +'
  • ' + +'' + ); + }); it("deletes the request object", function() { spyOn($, "ajax"); - AspectEdit.initialize(); $.proxy(AspectEdit.onDropMove, $('.dropzone.ui-droppable'))(null, {draggable: $('.person.ui-draggable')}); expect($.ajax).toHaveBeenCalled(); var args = $.ajax.calls[0].args[0]; @@ -112,6 +111,11 @@ describe("AspectEdit", function() { expect(args["url"]).toEqual("/requests/4cae42d32367bca44e000003"); expect(args["data"]).toEqual({"accept" : true, "aspect_id" : "4cdae5ed2367bc30aa000007" }); }); + it("doesn't call move_friend", function() { + spyOn($, "ajax"); + $.proxy(AspectEdit.onDropMove, $('.dropzone.ui-droppable'))(null, {draggable: $('.person.ui-draggable')}); + expect($.ajax.calls.length).toEqual(1); + }); }); });