Merge pull request #2719 from stwf/return-contact-popup-to-notify
aspects popup menu missing from 'started sharing' notifications
This commit is contained in:
commit
6dbd644b01
7 changed files with 53 additions and 6 deletions
|
|
@ -52,7 +52,7 @@ class NotificationsController < ApplicationController
|
|||
def read_all
|
||||
Notification.where(:recipient_id => current_user.id).update_all(:unread => false)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to notifications_path }
|
||||
format.html { redirect_to multi_stream_path }
|
||||
format.xml { render :xml => {}.to_xml }
|
||||
format.json { render :json => {}.to_json }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -45,6 +45,10 @@ class Notification < ActiveRecord::Base
|
|||
raise NotImplementedError.new('Subclass this.')
|
||||
end
|
||||
|
||||
def effective_target
|
||||
self.popup_translation_key == "notifications.mentioned" ? self.target.post : self.target
|
||||
end
|
||||
|
||||
private
|
||||
def self.concatenate_or_create(recipient, target, actor, notification_type)
|
||||
return nil if suppress_notification?(recipient, target)
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@
|
|||
.span-8.notifications_for_day
|
||||
- notes.each do |note|
|
||||
.stream_element{:data=>{:guid => note.id}, :class => "#{note.unread ? 'unread' : 'read'}"}
|
||||
- if note.type == "Notifications::StartedSharing" && contact = current_user.contact_for(note[:target])
|
||||
- if note.type == "Notifications::StartedSharing" && contact = current_user.contact_for(note.effective_target)
|
||||
.right
|
||||
= aspect_membership_dropdown(contact, note[:target], 'left')
|
||||
= aspect_membership_dropdown(contact, note.effective_target, 'left')
|
||||
|
||||
%span.from
|
||||
= notification_message_for(note)
|
||||
|
|
|
|||
|
|
@ -72,7 +72,13 @@
|
|||
self.dropdownNotifications.find('.read').each(function(index) {
|
||||
Diaspora.page.header.notifications.setUpRead( $(this) );
|
||||
});
|
||||
|
||||
self.dropdownNotifications.find('.unread').each(function(index) {
|
||||
var myItem = $(this);
|
||||
setTimeout(function(){
|
||||
if ( self.dropdownNotifications.is(":visible") )
|
||||
myItem.trigger('click');
|
||||
}, 2000 );
|
||||
});
|
||||
self.ajaxLoader.hide();
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -46,7 +46,16 @@ describe("Diaspora.Widgets.Notifications", function() {
|
|||
});
|
||||
|
||||
describe("decrementCount", function() {
|
||||
it("wont decrement Notifications.count below zero", function() {
|
||||
var originalCount = notifications.count;
|
||||
notifications.decrementCount();
|
||||
expect(originalCount).toEqual(0);
|
||||
expect(notifications.count).toEqual(0);
|
||||
});
|
||||
|
||||
it("decrements Notifications.count", function() {
|
||||
notifications.incrementCount();
|
||||
notifications.incrementCount();
|
||||
var originalCount = notifications.count;
|
||||
notifications.decrementCount();
|
||||
expect(notifications.count).toBeLessThan(originalCount);
|
||||
|
|
|
|||
Loading…
Reference in a new issue