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

49 lines
1.1 KiB
Ruby
Raw Normal View History

2011-02-07 20:05:19 -05:00
require 'active_record'
require 'action_controller/railtie'
require 'action_view/railtie'
2011-02-11 10:07:26 -05:00
# database
2011-02-07 20:05:19 -05:00
ActiveRecord::Base.configurations = {'test' => {:adapter => 'sqlite3', :database => ':memory:'}}
ActiveRecord::Base.establish_connection('test')
2011-02-11 10:07:26 -05:00
# config
2011-02-07 20:05:19 -05:00
app = Class.new(Rails::Application)
app.config.secret_token = "3b7cd727ee24e8444053437c36cc66c4"
app.config.session_store :cookie_store, :key => "_myapp_session"
app.config.active_support.deprecation = :log
app.initialize!
2011-02-11 10:07:26 -05:00
# routes
2011-02-07 20:05:19 -05:00
app.routes.draw do
resources :users
end
2011-02-11 10:07:26 -05:00
# models
class User < ActiveRecord::Base
default_scope order(:name)
end
class Book < ActiveRecord::Base; end
# controllers
2011-02-07 20:05:19 -05:00
class ApplicationController < ActionController::Base; end
class UsersController < ApplicationController
def index
@users = User.page params[:page]
render :inline => <<-ERB
<%= @users.map(&:name).join("\n") %>
<%= paginate @users %>
ERB
end
end
2011-02-11 10:07:26 -05:00
# helpers
2011-02-07 20:05:19 -05:00
Object.const_set(:ApplicationHelper, Module.new)
2011-02-11 10:07:26 -05:00
#migrations
class CreateAllTables < ActiveRecord::Migration
def self.up
create_table(:users) {|t| t.string :name }
create_table(:books) {|t| t.string :title }
end
end