started specs for AspectEdit.deletePersonFromAspect

This commit is contained in:
Sarah Mei 2010-11-12 17:04:15 -06:00
parent 9586ebb67e
commit 6c439608f0
2 changed files with 19 additions and 3 deletions

View file

@ -83,9 +83,9 @@ var AspectEdit = {
var person_id = person.attr('data-guid');
if( $(".person[data-guid='"+ person_id +"']").length == 1) {
alert("You can not remove the person from the last aspect");
} else {
AspectEdit.alertUser("You cannot remove the person from the last aspect");
}
else {
if (!person.hasClass('request')) {
$.ajax({
@ -173,6 +173,10 @@ var AspectEdit = {
request_html.replace(/\d+/, old_request_count - 1)
);
}
},
alertUser: function(message) {
alert(message);
}
};

View file

@ -204,6 +204,18 @@ describe("AspectEdit", function() {
});
});
describe("deletePersonFromAspect", function() {
beforeEach(function() {
spyOn($, 'ajax');
});
it("doesn't let you remove the person from the last aspect they're in", function() {
spyOn(AspectEdit, 'alertUser');
AspectEdit.deletePersonFromAspect($('li.person'));
expect(AspectEdit.alertUser).toHaveBeenCalled();
expect($.ajax).not.toHaveBeenCalled();
});
});
describe("decrementRequestsCounter", function() {
describe("when there is one request", function() {
it("removes the counter from the new requests div", function() {