diff --git a/public/javascripts/widgets/notifications.js b/public/javascripts/widgets/notifications.js index eddfdc9de..8a8c1d8d8 100644 --- a/public/javascripts/widgets/notifications.js +++ b/public/javascripts/widgets/notifications.js @@ -131,8 +131,7 @@ }; this.changeNotificationCount = function(change) { - self.count += change; - + self.count = Math.max( self.count + change, 0 ) self.badge.text(self.count); if ( self.notificationArea ) self.notificationArea.find( ".notification_count" ).text(self.count); diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb index eedb697f4..4b0afa970 100644 --- a/spec/controllers/notifications_controller_spec.rb +++ b/spec/controllers/notifications_controller_spec.rb @@ -56,6 +56,16 @@ describe NotificationsController do get :read_all Notification.where(:unread => true).count.should == 0 end + it "should redirect to the stream in the html version" do + Factory(:notification, :recipient => @user) + get :read_all, :format => :html + response.should redirect_to(multi_stream_path) + end + it "should return a dummy value in the json version" do + Factory(:notification, :recipient => @user) + get :read_all, :format => :json + response.should_not be_redirect + end end describe '#index' do @@ -77,5 +87,24 @@ describe NotificationsController do get :index, "per_page" => 5 assigns[:notifications].count.should == 5 end + + describe "special case for start sharing notifications" do + it "should not provide a contacts menu for standard notifications" do + 2.times { Factory(:notification, :recipient => @user, :target => @post) } + get :index, "per_page" => 5 + + Nokogiri(response.body).css('.aspect_membership').should be_empty + end + it "should provide a contacts menu for start sharing notifications" do + 2.times { Factory(:notification, :recipient => @user, :target => @post) } + eve.share_with(alice.person, eve.aspects.first) + get :index, "per_page" => 5 + + Nokogiri(response.body).css('.aspect_membership').should_not be_empty + end + + + + end end end diff --git a/spec/javascripts/notification_view_spec.js b/spec/javascripts/notification_view_spec.js deleted file mode 100644 index 2acfeafa4..000000000 --- a/spec/javascripts/notification_view_spec.js +++ /dev/null @@ -1,30 +0,0 @@ -describe("app.views.Notification", function(){ - var pageText = null; - - - describe("render regular notifications", function(){ - beforeEach(function(){ - pageText = spec.readFixture("notifications_index"); - }); - - it("has two notifications", function(){ - expect( $( pageText ).find('.stream_element').length).toBe(2) - }); - it("has no aspects menu", function(){ - expect( $( pageText ).find('.dropdown_list').length).toBe(0) - }); - - }); - describe("render a start sharing notification", function(){ - beforeEach(function(){ - pageText = spec.readFixture("notifications_index_with_sharing"); - }); - - it("has three notifications", function(){ - expect( $( pageText ).find('.stream_element').length).toBe(3) - }); - it("has shows an aspect menu for the start sharing item", function(){ - expect( $( pageText ).find('.aspect_membership').length).toBe(1) - }); - }); -})