From b92cb921c1315648db4d257f849898b5098afd14 Mon Sep 17 00:00:00 2001 From: Dan Hansen Date: Sun, 23 Oct 2011 21:30:35 -0500 Subject: [PATCH] Publisher.bindAspectToggles() is called in Publisher.initialize(). only bind the events once jQuery objects containing the same elements don't evaluate as true. test that the elements within the jQuery objects are the same --- public/javascripts/publisher.js | 2 +- spec/javascripts/publisher-spec.js | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/public/javascripts/publisher.js b/public/javascripts/publisher.js index a329eddc7..8791e5de9 100644 --- a/public/javascripts/publisher.js +++ b/public/javascripts/publisher.js @@ -271,7 +271,7 @@ var Publisher = { }, determineSubmitAvailability: function(){ - var onlyWhitespaces = (Publisher.input().val().trim() === ''), + var onlyWhitespaces = ($.trim(Publisher.input().val()) === ''), isSubmitDisabled = Publisher.submit().attr('disabled'), isPhotoAttached = ($("#photodropzone").children().length > 0); diff --git a/spec/javascripts/publisher-spec.js b/spec/javascripts/publisher-spec.js index 38d7b24b1..11224a440 100644 --- a/spec/javascripts/publisher-spec.js +++ b/spec/javascripts/publisher-spec.js @@ -55,9 +55,8 @@ describe("Publisher", function() { }); }); - it('toggles removed only on the clicked icon', function(){ + it('toggles selected only on the clicked icon', function(){ Publisher.initialize(); - Publisher.bindAspectToggles(); $("#publisher .dropdown .dropdown_list li.aspect_selector").last().click(); @@ -69,12 +68,12 @@ describe("Publisher", function() { expect($("#publisher .dropdown .dropdown_list li.aspect_selector").last().hasClass("selected")).toBeTruthy(); }); - it('is called with the correct element', function(){ + it('calls toggleAspectIds with the clicked element', function(){ spyOn(Publisher, 'toggleAspectIds'); Publisher.bindAspectToggles(); var aspectBadge = $("#publisher .dropdown .dropdown_list li").last(); aspectBadge.click(); - expect(Publisher.toggleAspectIds).toHaveBeenCalledWith(aspectBadge); + expect(Publisher.toggleAspectIds.mostRecentCall.args[0].get(0)).toEqual(aspectBadge.get(0)); }); });