Newer
Older
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'spec_helper'
describe NotificationsController do
@aspect = @user.aspects.first
@controller = NotificationsController.new
@controller.stub!(:current_user).and_return(@user)
it 'marks a notification as read' do
Raphael
a validé
note = Factory(:notification, :recipient => @user)
@controller.update :id => note.id
Steven Fuchs
a validé
Raphael
a validé
Factory(:notification, :recipient => @user)
note = Factory(:notification, :recipient => user2)
@controller.update :id => note.id
Notification.find(note.id).unread.should == true
describe "#read_all" do
it 'marks all notifications as read' do
request.env["HTTP_REFERER"] = "I wish I were spelled right"
Raphael
a validé
Factory(:notification, :recipient => @user)
Factory(:notification, :recipient => @user)
Notification.where(:unread => true).count.should == 2
Notification.where(:unread => true).count.should == 0
Raphael Sofaer
a validé
before do
@post = Factory(:status_message)
Factory(:notification, :recipient => @user, :target => @post)
Raphael Sofaer
a validé
end
it 'paginates the notifications' do
25.times { Factory(:notification, :recipient => @user, :target => @post) }
@controller.index({})[:notifications].count.should == 25
@controller.index(:page => 2)[:notifications].count.should == 1
end
it "includes the actors" do
Factory(:notification, :recipient => @user, :target => @post)
response = @controller.index({})
response[:notifications].first[:actors].first.should be_a(Person)
it 'eager loads the target' do
response = @controller.index({})
response[:notifications].each { |note| note[:target].should be }
end
Raphael Sofaer
a validé
it "supports a limit per_page parameter" do
5.times { Factory(:notification, :recipient => @user, :target => @post) }
response = @controller.index({:per_page => 5})
response[:notifications].length.should == 5
Raphael Sofaer
a validé
end