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
|
def read_all
|
||||||
Notification.where(:recipient_id => current_user.id).update_all(:unread => false)
|
Notification.where(:recipient_id => current_user.id).update_all(:unread => false)
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to notifications_path }
|
format.html { redirect_to multi_stream_path }
|
||||||
format.xml { render :xml => {}.to_xml }
|
format.xml { render :xml => {}.to_xml }
|
||||||
format.json { render :json => {}.to_json }
|
format.json { render :json => {}.to_json }
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,10 @@ class Notification < ActiveRecord::Base
|
||||||
raise NotImplementedError.new('Subclass this.')
|
raise NotImplementedError.new('Subclass this.')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def effective_target
|
||||||
|
self.popup_translation_key == "notifications.mentioned" ? self.target.post : self.target
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def self.concatenate_or_create(recipient, target, actor, notification_type)
|
def self.concatenate_or_create(recipient, target, actor, notification_type)
|
||||||
return nil if suppress_notification?(recipient, target)
|
return nil if suppress_notification?(recipient, target)
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@
|
||||||
.span-8.notifications_for_day
|
.span-8.notifications_for_day
|
||||||
- notes.each do |note|
|
- notes.each do |note|
|
||||||
.stream_element{:data=>{:guid => note.id}, :class => "#{note.unread ? 'unread' : 'read'}"}
|
.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
|
.right
|
||||||
= aspect_membership_dropdown(contact, note[:target], 'left')
|
= aspect_membership_dropdown(contact, note.effective_target, 'left')
|
||||||
|
|
||||||
%span.from
|
%span.from
|
||||||
= notification_message_for(note)
|
= notification_message_for(note)
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,13 @@
|
||||||
self.dropdownNotifications.find('.read').each(function(index) {
|
self.dropdownNotifications.find('.read').each(function(index) {
|
||||||
Diaspora.page.header.notifications.setUpRead( $(this) );
|
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();
|
self.ajaxLoader.hide();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -131,8 +131,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
this.changeNotificationCount = function(change) {
|
this.changeNotificationCount = function(change) {
|
||||||
self.count += change;
|
self.count = Math.max( self.count + change, 0 )
|
||||||
|
|
||||||
self.badge.text(self.count);
|
self.badge.text(self.count);
|
||||||
if ( self.notificationArea )
|
if ( self.notificationArea )
|
||||||
self.notificationArea.find( ".notification_count" ).text(self.count);
|
self.notificationArea.find( ".notification_count" ).text(self.count);
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,16 @@ describe NotificationsController do
|
||||||
get :read_all
|
get :read_all
|
||||||
Notification.where(:unread => true).count.should == 0
|
Notification.where(:unread => true).count.should == 0
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe '#index' do
|
describe '#index' do
|
||||||
|
|
@ -77,5 +87,24 @@ describe NotificationsController do
|
||||||
get :index, "per_page" => 5
|
get :index, "per_page" => 5
|
||||||
assigns[:notifications].count.should == 5
|
assigns[:notifications].count.should == 5
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,16 @@ describe("Diaspora.Widgets.Notifications", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("decrementCount", 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() {
|
it("decrements Notifications.count", function() {
|
||||||
|
notifications.incrementCount();
|
||||||
|
notifications.incrementCount();
|
||||||
var originalCount = notifications.count;
|
var originalCount = notifications.count;
|
||||||
notifications.decrementCount();
|
notifications.decrementCount();
|
||||||
expect(notifications.count).toBeLessThan(originalCount);
|
expect(notifications.count).toBeLessThan(originalCount);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue