Newer
Older
# Copyright (c) 2010, 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
before do
@user = alice
@aspect = @user.aspects.first
sign_in :user, @user
Raphael
a validé
note = Factory(:notification, :recipient => @user)
put :update, :id => note.id
Notification.first.unread.should == false
Raphael
a validé
Factory(:notification, :recipient => @user)
note = Factory(:notification, :recipient => user2)
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
get :read_all
Notification.where(:unread => true).count.should == 0
Raphael Sofaer
a validé
before do
Raphael
a validé
Factory(:notification, :recipient => @user)
Raphael Sofaer
a validé
end
Raphael Sofaer
a validé
it 'paginates the notifications' do
Sarah Mei
a validé
assigns[:notifications].count.should == 25
assigns[:notifications].count.should == 1
Raphael Sofaer
a validé
it 'eager loads the target' do
get :index
assigns[:notifications].each{ |note| note.loaded_target?.should be_true }
end