Merge remote branch 'nickvdb/763-notifications-paginate'
This commit is contained in:
commit
83d6b95c46
3 changed files with 16 additions and 2 deletions
|
|
@ -18,9 +18,8 @@ class NotificationsController < ApplicationController
|
|||
end
|
||||
|
||||
def index
|
||||
@notifications = Notification.for(current_user).limit(25)
|
||||
@notifications = Notification.for(current_user).paginate :page => params[:page], :per_page => 25
|
||||
@group_days = @notifications.group_by{|note| note.created_at.strftime("%B %d") }
|
||||
respond_with @notifications
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -40,3 +40,4 @@
|
|||
= object_link(note)
|
||||
|
||||
%span.time= "#{t('ago', :time => time_ago_in_words(note.created_at))}"
|
||||
= will_paginate @notifications
|
||||
|
|
|
|||
|
|
@ -32,4 +32,18 @@ describe NotificationsController do
|
|||
Notification.find(note.id).unread.should == true
|
||||
end
|
||||
end
|
||||
|
||||
describe '#index' do
|
||||
it 'paginates the notifications' do
|
||||
35.times do
|
||||
Notification.create(:user_id => user.id)
|
||||
end
|
||||
|
||||
get :index
|
||||
assigns[:notifications].should == Notification.all(:user_id => user.id, :limit => 25)
|
||||
|
||||
get :index, :page => 2
|
||||
assigns[:notifications].should == Notification.all(:user_id => user.id, :offset => 25, :limit => 25)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue