From 9c50f900eda130803d1c16a232339ca381986847 Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Fri, 24 Dec 2010 14:14:24 -0800 Subject: [PATCH] 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. --- features/manages_aspects.feature | 3 +-- public/javascripts/aspect-edit.js | 18 --------------- spec/javascripts/aspect-edit-spec.js | 34 +--------------------------- 3 files changed, 2 insertions(+), 53 deletions(-) diff --git a/features/manages_aspects.feature b/features/manages_aspects.feature index a96c15432..b81d19e1f 100644 --- a/features/manages_aspects.feature +++ b/features/manages_aspects.feature @@ -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." diff --git a/public/javascripts/aspect-edit.js b/public/javascripts/aspect-edit.js index 3b21d95b1..0039d8a40 100644 --- a/public/javascripts/aspect-edit.js +++ b/public/javascripts/aspect-edit.js @@ -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); } diff --git a/spec/javascripts/aspect-edit-spec.js b/spec/javascripts/aspect-edit-spec.js index 7023084e1..bbb10ff5b 100644 --- a/spec/javascripts/aspect-edit-spec.js +++ b/spec/javascripts/aspect-edit-spec.js @@ -183,17 +183,9 @@ describe("AspectEdit", function() { ' Alexander Hamiltom' + '' + '' + -'
Requests (1)
' +'' ); }); - 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("
Requests (1)
"); - 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("
Requests (67)
"); - 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("
Requests
"); - AspectEdit.decrementRequestsCounter(); - expect($('.new_requests').first().html()).toEqual("Requests"); - }); - }); - }); });