1
0
Fork 0
mirror of https://github.com/kaminari/kaminari.git synced 2022-11-09 13:44:37 -05:00

Merge branch 'wbyoung-pass-test-suite'

This commit is contained in:
Akira Matsuda 2013-11-10 03:00:53 +09:00
commit 32fb711d96
3 changed files with 57 additions and 5 deletions

View file

@ -0,0 +1,20 @@
module Engine
class Engine < ::Rails::Engine
isolate_namespace ::Engine
end
end
Engine::Engine.routes.draw do
resources :users
end
# controllers
class Engine::UsersController < ::ApplicationController
def index
@users = User.page(params[:page]).per(3)
render :inline => <<-ERB
<%= @users.map(&:name).join("\n") %>
<%= paginate @users %>
ERB
end
end

View file

@ -17,11 +17,6 @@ app.config.root = File.dirname(__FILE__)
Rails.backtrace_cleaner.remove_silencers!
app.initialize!
# routes
app.routes.draw do
resources :users
end
#models
require 'fake_app/active_record/models' if defined? ActiveRecord
require 'fake_app/data_mapper/models' if defined? DataMapper
@ -54,3 +49,14 @@ end
# helpers
Object.const_set(:ApplicationHelper, Module.new)
# routes
app.routes.draw do
resources :users
if Rails.version > '3.1.0'
$LOAD_PATH << File.join(File.dirname(__FILE__), 'engine/lib')
require 'engine'
mount Engine::Engine => '/engine'
end
end

View file

@ -0,0 +1,26 @@
# encoding: UTF-8
require 'spec_helper'
feature 'Pagination properly works in mouted Engines' do
background do
1.upto(10) {|i| User.create! :name => "user#{'%02d' % i}" }
end
scenario 'Showing normal pagination links' do
visit '/engine/users'
within 'nav.pagination' do
within 'span.page.current' do
page.should have_content '1'
end
within 'span.next' do
click_link 'Next '
end
end
within 'nav.pagination' do
within 'span.page.current' do
page.should have_content '2'
end
end
end
end if Rails.version > '3.1.0'