More specs for aspect edit JS
This commit is contained in:
parent
26c4760e25
commit
feec6d971d
2 changed files with 40 additions and 10 deletions
|
|
@ -50,29 +50,35 @@ var AspectEdit = {
|
|||
type: "DELETE",
|
||||
url: "/requests/" + person.attr('data-guid'),
|
||||
data: {"accept" : true, "aspect_id" : dropzone.attr('data-aspect_id') },
|
||||
success: function(data) {
|
||||
AspectEdit.decrementRequestsCounter();
|
||||
person.removeClass('request');
|
||||
}
|
||||
success: function() { AspectEdit.onDeleteRequestSuccess(person); }
|
||||
});
|
||||
}
|
||||
|
||||
if (dropzone.attr('data-aspect_id') != person.attr('data-aspect_id')) {
|
||||
$.ajax({
|
||||
url: "/aspects/move_friend/",
|
||||
data: {"friend_id" : person.attr('data-guid'),
|
||||
data: {
|
||||
"friend_id" : person.attr('data-guid'),
|
||||
"from" : person.attr('data-aspect_id'),
|
||||
"to" : { "to" : dropzone.attr('data-aspect_id') }},
|
||||
success: function(data) {
|
||||
person.attr('data-aspect_id', dropzone.attr('data-aspect_id'));
|
||||
}});
|
||||
"to" : { "to" : dropzone.attr('data-aspect_id') }
|
||||
},
|
||||
success: function() { AspectEdit.onMovePersonSuccess(person, dropzone); }
|
||||
});
|
||||
}
|
||||
|
||||
dropzone.closest("ul").append(person);
|
||||
},
|
||||
|
||||
onDeleteRequestSuccess: function(person) {
|
||||
AspectEdit.decrementRequestsCounter();
|
||||
person.removeClass('request');
|
||||
},
|
||||
|
||||
onMovePersonSuccess: function(person, dropzone) {
|
||||
person.attr('data-aspect_id', dropzone.attr('data-aspect_id'));
|
||||
},
|
||||
|
||||
deletePersonFromAspect: function(person) {
|
||||
|
||||
var person_id = person.attr('data-guid');
|
||||
|
||||
if( $(".person[data-guid='"+ person_id +"']").length == 1) {
|
||||
|
|
|
|||
|
|
@ -91,6 +91,30 @@ describe("AspectEdit", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("onDropMove", function() {
|
||||
beforeEach(function() {
|
||||
$('#jasmine_content').html(
|
||||
'<li class="person request ui-draggable" data-aspect_id="4cae42e12367bca44e000005" data-guid="4cae42d32367bca44e000003" style="top: 0px; left: 0px; ">' +
|
||||
' <img alt="Alexander Hamiltom" class="avatar" data-person_id="4cae42d32367bca44e000003" src="/images/user/default.png?1287542906" original-title="Alexander Hamiltom" style="height: 70px; width: 70px; opacity: 1; display: inline; ">' +
|
||||
'</li>' +
|
||||
'<ul data-aspect_id="4cdae5ed2367bc30aa000007" class="dropzone ui-droppable">' +
|
||||
'</ul>'
|
||||
);
|
||||
});
|
||||
describe("when dragging a friend request", function() {
|
||||
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];
|
||||
expect(args["type"]).toEqual("DELETE");
|
||||
expect(args["url"]).toEqual("/requests/4cae42d32367bca44e000003");
|
||||
expect(args["data"]).toEqual({"accept" : true, "aspect_id" : "4cdae5ed2367bc30aa000007" });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("decrementRequestsCounter", function() {
|
||||
describe("when there is one request", function() {
|
||||
it("removes the counter from the new requests div", function() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue