notifications tests pass
This commit is contained in:
parent
46c83a7c7d
commit
f9e8e7a041
5 changed files with 20 additions and 19 deletions
1
.pairs
1
.pairs
|
|
@ -7,6 +7,7 @@ pairs:
|
||||||
sm: Sarah Mei; sarah
|
sm: Sarah Mei; sarah
|
||||||
mjs: Michael Sofaer; michael
|
mjs: Michael Sofaer; michael
|
||||||
jd: Jeff Dickey; dickeytk
|
jd: Jeff Dickey; dickeytk
|
||||||
|
dc: Dennis Collinson
|
||||||
email:
|
email:
|
||||||
prefix: pair
|
prefix: pair
|
||||||
domain: joindiaspora.com
|
domain: joindiaspora.com
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ class NotificationsController < VannaController
|
||||||
def index(opts=params)
|
def index(opts=params)
|
||||||
@aspect = :notification
|
@aspect = :notification
|
||||||
conditions = {:recipient_id => current_user.id}
|
conditions = {:recipient_id => current_user.id}
|
||||||
page = params[:page] || 1
|
page = opts[:page] || 1
|
||||||
notifications = WillPaginate::Collection.create(page, 25, Notification.where(conditions).count ) do |pager|
|
notifications = WillPaginate::Collection.create(page, 25, Notification.where(conditions).count ) do |pager|
|
||||||
result = Notification.find(:all,
|
result = Notification.find(:all,
|
||||||
:conditions => conditions,
|
:conditions => conditions,
|
||||||
|
|
@ -34,9 +34,7 @@ class NotificationsController < VannaController
|
||||||
n[:actors] = n.actors
|
n[:actors] = n.actors
|
||||||
n[:translation_key] = n.popup_translation_key
|
n[:translation_key] = n.popup_translation_key
|
||||||
if n.translation_key == "notifications.mentioned"
|
if n.translation_key == "notifications.mentioned"
|
||||||
n[:post] = Mention.find(n.target_id).post
|
n[:target] = n[:target].post
|
||||||
else
|
|
||||||
n[:post] = Post.find(n.target_id)
|
|
||||||
end
|
end
|
||||||
# Go find out if the post exists, and set the target_id to nil if it doesn't
|
# Go find out if the post exists, and set the target_id to nil if it doesn't
|
||||||
end
|
end
|
||||||
|
|
@ -48,7 +46,7 @@ class NotificationsController < VannaController
|
||||||
Notification.where(:recipient_id => current_user.id).update_all(:unread => false)
|
Notification.where(:recipient_id => current_user.id).update_all(:unread => false)
|
||||||
end
|
end
|
||||||
post_process :html do
|
post_process :html do
|
||||||
def post_read_all
|
def post_read_all(json)
|
||||||
Response.new(:status => 302, :location => aspects_path)
|
Response.new(:status => 302, :location => aspects_path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,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' : ''}"}
|
.stream_element{:data=>{:guid => note.id}, :class => "#{note.unread ? 'unread' : ''}"}
|
||||||
- if note.type == "Notifications::StartedSharing" && contact = current_user.contact_for(note.target)
|
- if note.type == "Notifications::StartedSharing" && contact = current_user.contact_for(note[:target])
|
||||||
.right
|
.right
|
||||||
= render 'aspect_memberships/aspect_dropdown', :contact => contact, :person => note.target, :hang => 'left'
|
= render 'aspect_memberships/aspect_dropdown', :contact => contact, :person => note[:target], :hang => 'left'
|
||||||
|
|
||||||
%span.from
|
%span.from
|
||||||
= notification_message_for(note)
|
= notification_message_for(note)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
$(function() {
|
$(function() {
|
||||||
$("#notification_badge a").live("click", function(event){
|
$("#notification_badge a").live("_click", function(event){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$.getJSON("/notifications", function(hash) {
|
$.getJSON("/notifications", function(hash) {
|
||||||
$("#notifications_overlay").show();
|
$("#notifications_overlay").show();
|
||||||
|
|
@ -15,7 +15,7 @@ $(function() {
|
||||||
dayElement.find(".day").text(dayParts[1])
|
dayElement.find(".day").text(dayParts[1])
|
||||||
var notificationsForDay = hash["group_days"][day],
|
var notificationsForDay = hash["group_days"][day],
|
||||||
notificationsForDayElement = dayElement.find('.notifications_for_day');
|
notificationsForDayElement = dayElement.find('.notifications_for_day');
|
||||||
|
|
||||||
$.each(notificationsForDay, function(i, notificationHash) {
|
$.each(notificationsForDay, function(i, notificationHash) {
|
||||||
$.each(notificationHash, function(notificationType, notification) {
|
$.each(notificationHash, function(notificationType, notification) {
|
||||||
var actor = notification.actors[0];
|
var actor = notification.actors[0];
|
||||||
|
|
@ -27,15 +27,15 @@ $(function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
notificationsElement.append(dayElement)
|
notificationsElement.append(dayElement)
|
||||||
|
|
||||||
Diaspora.widgets.timeago.updateTimeAgo("time");
|
Diaspora.widgets.timeago.updateTimeAgo("time");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#notifications_overlay").delegate('a.close', 'click', function() {
|
$("#notifications_overlay").delegate('a.close', 'click', function() {
|
||||||
console.log("hi!");
|
console.log("hi!");
|
||||||
$('#notifications_overlay').hide();
|
$('#notifications_overlay').hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,9 @@ describe NotificationsController do
|
||||||
|
|
||||||
describe '#index' do
|
describe '#index' do
|
||||||
before do
|
before do
|
||||||
|
@post = Factory(:status_message)
|
||||||
26.times do
|
26.times do
|
||||||
Factory(:notification, :recipient => @user)
|
Factory(:notification, :recipient => @user, :target => @post)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -56,13 +57,14 @@ describe NotificationsController do
|
||||||
@controller.index(:page => 2)[:notifications].count.should == 1
|
@controller.index(:page => 2)[:notifications].count.should == 1
|
||||||
end
|
end
|
||||||
it "includes the actors" do
|
it "includes the actors" do
|
||||||
notification = Factory(:notification, :recipient => @user)
|
notification = Factory(:notification, :recipient => @user, :target => @post)
|
||||||
@controller.index({})[:notifications].first[:actors].should == notification.actors
|
response = @controller.index({})
|
||||||
|
response[:notifications].first[:actors].first.should be_a(Person)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'eager loads the target' do
|
it 'eager loads the target' do
|
||||||
get :index
|
response = @controller.index({})
|
||||||
assigns[:notifications].each{ |note| note.loaded_target?.should be_true }
|
response[:notifications].each{ |note| note[:target].should be }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue