Merry Christmas! I got you someting green.

Remove callback to decrementRequestCounter in aspect-edit.js, since we don't have a request counter on that page anymore. The callback was failing, so the ajax request was never officially completing. Cucumber hates that.
I am going to add jasmine fixture generation in the controller specs, so that next time, a jasmine test will fail in this situation.
Also: clean up manages_aspects.feature.
This commit is contained in:
Sarah Mei 2010-12-24 14:14:24 -08:00
parent a13136a4dc
commit 9c50f900ed
3 changed files with 2 additions and 53 deletions

View file

@ -8,8 +8,7 @@ Feature: User manages aspects
Given I am signed in
When I follow "Home" in the header
And I follow "manage aspects"
And I click '+ Add a new aspect'
And I follow "+ Add a new aspect"
And I fill in "Name" with "Dorm Mates" in the modal window
And I press "Create" in the modal window
Then I should see "Dorm Mates" in the header
And I should see "Your aspect 'Dorm Mates' is empty."

View file

@ -71,7 +71,6 @@ var AspectEdit = {
},
onDeleteRequestSuccess: function(person, dropzone) {
AspectEdit.decrementRequestsCounter();
person.removeClass('request');
person.attr('data-aspect_id', dropzone.attr('data-aspect_id'));
person.removeAttr('data-person_id');
@ -142,7 +141,6 @@ var AspectEdit = {
person.fadeOut(400, function() {
person.remove();
});
AspectEdit.decrementRequestsCounter();
}
});
}
@ -153,22 +151,6 @@ var AspectEdit = {
}
},
decrementRequestsCounter: function() {
var $new_requests = $(".new_requests");
var request_html = $new_requests.html();
var old_request_count = request_html.match(/\d+/);
if (old_request_count == 1) {
$new_requests.html(
request_html.replace(/ \(\d+\)/, '')
);
} else {
$new_requests.html(
request_html.replace(/\d+/, old_request_count - 1)
);
}
},
alertUser: function(message) {
alert(message);
}

View file

@ -183,17 +183,9 @@ describe("AspectEdit", function() {
' <img alt="Alexander Hamiltom" class="avatar" data-person_id="guid-of-friendship-requestor" src="/images/user/default.png?1287542906" original-title="Alexander Hamiltom">' +
'</li>' +
'<ul data-aspect_id="guid-of-target-aspect" class="dropzone ui-droppable">' +
'</ul>' +
'<div class="new_requests">Requests (1)</div>'
'</ul>'
);
});
it("decrements the request counter", function() {
var person = $('li.person');
var dropzone = $('.dropzone.ui-droppable[data-aspect_id="guid-of-target-aspect"]');
spyOn(AspectEdit, "decrementRequestsCounter");
AspectEdit.onDeleteRequestSuccess(person, dropzone);
expect(AspectEdit.decrementRequestsCounter).toHaveBeenCalled();
});
it("takes the request class off the person li", function() {
var person = $('li.person');
var dropzone = $('.dropzone.ui-droppable[data-aspect_id="guid-of-target-aspect"]');
@ -238,28 +230,4 @@ describe("AspectEdit", function() {
expect($.ajax).not.toHaveBeenCalled();
});
});
describe("decrementRequestsCounter", function() {
describe("when there is one request", function() {
it("removes the counter from the new requests div", function() {
$('#jasmine_content').html("<div class='new_requests'>Requests (1)</div>");
AspectEdit.decrementRequestsCounter();
expect($('.new_requests').first().html()).toEqual("Requests");
});
});
describe("when there is more than one request", function() {
it("decrements the request counter", function() {
$('#jasmine_content').html("<div class='new_requests'>Requests (67)</div>");
AspectEdit.decrementRequestsCounter();
expect($('.new_requests').first().html()).toEqual("Requests (66)");
});
});
describe("error cases", function() {
it("fails silently if there are no requests", function() {
$('#jasmine_content').html("<div class='new_requests'>Requests</div>");
AspectEdit.decrementRequestsCounter();
expect($('.new_requests').first().html()).toEqual("Requests");
});
});
});
});