diff --git a/Changelog.md b/Changelog.md index 1be2e6f7a28c41d11fc8ee918c010c066d4cf636..ad368f45885e162834849e5680c878dcbe435338 100644 --- a/Changelog.md +++ b/Changelog.md @@ -39,6 +39,7 @@ * Fix error with invite link box shows on search results page even if invites have been turned off. [#3708](https://github.com/diaspora/diaspora/pull/3708) * Fix misconfiguration of Devise to allow the session to be remembered. [#3472](https://github.com/diaspora/diaspora/issues/3472) * Fix problem with show reshares_count in stream. [#3700](https://github.com/diaspora/diaspora/pull/3700) +* Fix error with notifications count in mobile. [#3721](https://github.com/diaspora/diaspora/pull/3721) # 0.0.1.2 diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 886ccc4bd32aba184913689ac0482d18f365d617..d6435b1c4d38c5766ffc5e6e43b990341b7f93c5 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -105,7 +105,7 @@ class PostsController < ApplicationController end def mark_corresponding_notification_read - if notification = Notification.where(:recipient_id => current_user.id, :target_id => @post.id).first + if notification = Notification.where(:recipient_id => current_user.id, :target_id => @post.id, :unread => true).first notification.unread = false notification.save end diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index 84a6086c3edabfa9fd9296e4486d3a7a95880694..af3368de5c8acd09634b2fe4a243f9492666823c 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -41,22 +41,16 @@ describe PostsController do end it 'marks a corresponding notification as read' do - note = Notification.create(:recipient => alice, :target => @message, :unread => true) + # Ensure that it doesn't mark a read notification as read + FactoryGirl.create(:notification, :recipient => alice, :target => @message, :unread => false) + note = FactoryGirl.create(:notification, :recipient => alice, :target => @message, :unread => true) - lambda{ + expect { get :show, :id => @message.id note.reload }.should change(note, :unread).from(true).to(false) end - it 'change from unread to read a corresponding notification' do - FactoryGirl.create(:notification, :target => @message, :recipient => alice, :unread => true) - FactoryGirl.create(:notification, :recipient => alice, :unread => false) - Notification.where(:unread => true).count.should == 1 - get :show, :id => @message.id - Notification.where(:unread => true).count.should == 0 - end - it 'succeeds with a AS/photo' do photo = FactoryGirl.create(:activity_streams_photo, :author => bob.person) get :show, :id => photo.id