diff --git a/chef/cookbooks/common/recipes/daemontools.rb b/chef/cookbooks/common/recipes/daemontools.rb index 3ce295c3a..84e4a4f10 100644 --- a/chef/cookbooks/common/recipes/daemontools.rb +++ b/chef/cookbooks/common/recipes/daemontools.rb @@ -16,7 +16,7 @@ end config = YAML.load_file("/usr/local/app/diaspora/chef/cookbooks/common/files/default/thins.yml") config.each do |thin| - id = thin["port"] + port = thin["port"] #socket = "/tmp/thin_#{id}.sock" dir = "/service/thin_#{port}" flags = [] diff --git a/public/javascripts/aspect-edit.js b/public/javascripts/aspect-edit.js index 134d661f4..e4a82a11f 100644 --- a/public/javascripts/aspect-edit.js +++ b/public/javascripts/aspect-edit.js @@ -54,7 +54,7 @@ var AspectEdit = { }); } - if (person.attr('data-aspect_id') != undefined && // request doesn't have an aspect ID yet + if (person.attr('data-aspect_id') != undefined && // a request doesn't have a data-aspect_id, but an existing friend does dropzone.attr('data-aspect_id') != person.attr('data-aspect_id')) { $.ajax({ url: "/aspects/move_friend/", diff --git a/spec/javascripts/aspect-edit-spec.js b/spec/javascripts/aspect-edit-spec.js index b65ae396a..94e3460fc 100644 --- a/spec/javascripts/aspect-edit-spec.js +++ b/spec/javascripts/aspect-edit-spec.js @@ -2,19 +2,26 @@ describe("AspectEdit", function() { beforeEach(function() { $('#jasmine_content').html( -'
  • ' + -' Alexander Hamiltom' + -'
  • ' - ); +'' + +'' + ); }); describe("initialize", function() { it("calls draggable on ul .person", function() { spyOn($.fn, "draggable"); AspectEdit.initialize(); - expect($.fn.draggable).toHaveBeenCalledWith( - {revert: true, start: AspectEdit.startDrag, - drag: AspectEdit.duringDrag, stop: AspectEdit.stopDrag}); + expect($.fn.draggable).toHaveBeenCalledWith({ + revert: true, + start: AspectEdit.startDrag, + drag: AspectEdit.duringDrag, + stop: AspectEdit.stopDrag + }); expect($.fn.draggable.mostRecentCall.object.selector).toEqual("ul .person"); }); it("calls droppable on .aspect ul.dropzone", function() { @@ -92,30 +99,75 @@ describe("AspectEdit", function() { }); describe("onDropMove", function() { + beforeEach(function() { + spyOn($, "ajax"); + }); + describe("when you drop the friend or request onto the div you dragged it from", function() { + it("doesn't call any ajax stuffs", function() { + var targetAspect = $('.dropzone.ui-droppable[data-aspect_id="guid-of-current-aspect"]'); + $.proxy(AspectEdit.onDropMove, targetAspect)(null, {draggable: $('.person.ui-draggable')}); + expect($.ajax).not.toHaveBeenCalled(); + }); + it("adds the person back into the original div", function() { + var targetAspect = $('.dropzone.ui-droppable[data-aspect_id="guid-of-current-aspect"]'); + spyOn($.fn, "append"); + $.proxy(AspectEdit.onDropMove, targetAspect)(null, {draggable: $('.person.ui-draggable')}); + expect($.fn.append).toHaveBeenCalledWith($('.person.ui-draggable')); + expect($.fn.append.mostRecentCall.object.attr("data-aspect_id")).toEqual("guid-of-current-aspect"); + }); + }); + describe("when moving an existing friend between aspects", function() { + it("calls move_friend", function() { + var targetAspect = $('.dropzone.ui-droppable[data-aspect_id="guid-of-target-aspect"]'); + $.proxy(AspectEdit.onDropMove, targetAspect)(null, {draggable: $('.person.ui-draggable')}); + expect($.ajax).toHaveBeenCalled(); + var args = $.ajax.mostRecentCall.args[0]; + expect(args["url"]).toEqual("/aspects/move_friend/"); + expect(args["data"]["friend_id"]).toEqual("guid-of-this-person"); + expect(args["data"]["from"]).toEqual("guid-of-current-aspect"); + expect(args["data"]["to"]).toEqual({"to": "guid-of-target-aspect" }); + }); + it("doesn't call the ajaxy request delete", function() { + var targetAspect = $('.dropzone.ui-droppable[data-aspect_id="guid-of-target-aspect"]'); + $.proxy(AspectEdit.onDropMove, targetAspect)(null, {draggable: $('.person.ui-draggable')}); + expect($.ajax.calls.length).toEqual(1); + }); + it("adds the person to the aspect div", function() { + var targetAspect = $('.dropzone.ui-droppable[data-aspect_id="guid-of-target-aspect"]'); + spyOn($.fn, "append"); + $.proxy(AspectEdit.onDropMove, targetAspect)(null, {draggable: $('.person.ui-draggable')}); + expect($.fn.append).toHaveBeenCalledWith($('.person.ui-draggable')); + expect($.fn.append.mostRecentCall.object.hasClass("dropzone")).toBeTruthy(); + }); + }); describe("when dragging a friend request", function() { beforeEach(function() { $('#jasmine_content').html( -'
  • ' + -' Alexander Hamiltom' + +'
  • ' + +' Alexander Hamiltom' + '
  • ' + -'