mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-18 13:38:24 -04:00
Resolved #562 - Pagination of notifications.
This commit is contained in:
3
Gemfile
3
Gemfile
@@ -35,6 +35,9 @@ gem 'ruby-units' # for unit conversion
|
||||
|
||||
gem 'comfortable_mexican_sofa', '~> 1.12.0' # content management system
|
||||
|
||||
gem 'kaminari' # pagination
|
||||
gem 'bootstrap-kaminari-views' # bootstrap views for kaminari
|
||||
|
||||
# vendored activemerchant for testing- needed for bogus paypal
|
||||
# gateway monkeypatch
|
||||
gem 'activemerchant', '1.33.0',
|
||||
|
||||
@@ -64,6 +64,9 @@ GEM
|
||||
bonsai-elasticsearch-rails (0.0.4)
|
||||
bootstrap-datepicker-rails (1.3.0.2)
|
||||
railties (>= 3.0)
|
||||
bootstrap-kaminari-views (0.0.5)
|
||||
kaminari (>= 0.13)
|
||||
rails (>= 3.1)
|
||||
bootstrap-sass (3.3.3)
|
||||
autoprefixer-rails (>= 5.0.0.1)
|
||||
sass (>= 3.2.19)
|
||||
@@ -216,6 +219,9 @@ GEM
|
||||
railties (>= 3.2)
|
||||
sprockets-rails
|
||||
json (1.8.2)
|
||||
kaminari (0.16.3)
|
||||
actionpack (>= 3.0.0)
|
||||
activesupport (>= 3.0.0)
|
||||
kgio (2.9.2)
|
||||
kramdown (1.5.0)
|
||||
launchy (2.4.3)
|
||||
@@ -402,6 +408,7 @@ DEPENDENCIES
|
||||
bluecloth
|
||||
bonsai-elasticsearch-rails
|
||||
bootstrap-datepicker-rails
|
||||
bootstrap-kaminari-views
|
||||
bundler (>= 1.1.5)
|
||||
byebug
|
||||
cancancan (~> 1.9)
|
||||
@@ -430,6 +437,7 @@ DEPENDENCIES
|
||||
jquery-rails
|
||||
jquery-ui-rails (~> 5.0.2)
|
||||
js-routes
|
||||
kaminari
|
||||
leaflet-markercluster-rails
|
||||
leaflet-rails
|
||||
less (~> 2.5.0)
|
||||
|
||||
@@ -5,7 +5,7 @@ class NotificationsController < ApplicationController
|
||||
|
||||
# GET /notifications
|
||||
def index
|
||||
@notifications = Notification.where(recipient_id: current_member)
|
||||
@notifications = Notification.where(recipient_id: current_member).page(params[:page])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
- content_for :title, "Inbox"
|
||||
|
||||
- if @notifications.size > 0
|
||||
= paginate @notifications, theme: 'twitter-bootstrap-3'
|
||||
%table.table.table-striped
|
||||
%tr
|
||||
%th From
|
||||
@@ -28,5 +29,6 @@
|
||||
%strong= n.created_at
|
||||
%td
|
||||
= link_to 'Delete', n, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs'
|
||||
= paginate @notifications, theme: 'twitter-bootstrap-3'
|
||||
- else
|
||||
You have no messages.
|
||||
|
||||
@@ -22,4 +22,25 @@ feature "Notifications", :js => true do
|
||||
expect(page).to have_content "Message was successfully sent"
|
||||
end
|
||||
end
|
||||
|
||||
describe 'pagination' do
|
||||
before do
|
||||
34.times { FactoryGirl.create :notification, recipient: recipient }
|
||||
login_as recipient
|
||||
visit notifications_path
|
||||
end
|
||||
|
||||
it 'has page navigation' do
|
||||
expect(page).to have_selector 'a[rel="next"]'
|
||||
end
|
||||
|
||||
it 'paginates at 30 notifications per page' do
|
||||
expect(page).to have_selector 'tr', count: 31
|
||||
end
|
||||
|
||||
it 'navigates pages' do
|
||||
first('a[rel="next"]').click
|
||||
expect(page).to have_selector 'tr', count: 5
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user