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