Skip to content

Commit

Permalink
Allow the dummy application in test/rails_app to boot.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Apr 1, 2010
1 parent 42d06a2 commit dac7887
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -19,7 +19,7 @@ group :mongoid do
end

group :data_mapper do
gem 'do_sqlite3', '>= 0.10.1'
gem "do_sqlite3", '>= 0.10.1'
gem "dm-core", :git => "git://github.com/datamapper/dm-core.git"
gem "dm-validations", :git => "git://github.com/datamapper/dm-more.git"
gem "dm-timestamps", :git => "git://github.com/datamapper/dm-more.git"
Expand Down
20 changes: 1 addition & 19 deletions test/orm/active_record.rb
@@ -1,25 +1,7 @@
ActiveRecord::Migration.verbose = false
ActiveRecord::Base.logger = Logger.new(nil)

ActiveRecord::Schema.define(:version => 1) do
[:users, :admins, :accounts].each do |table|
create_table table do |t|
t.authenticatable :null => table == :admins

if table != :admin
t.string :username
t.confirmable
t.recoverable
t.rememberable
t.trackable
t.lockable
t.token_authenticatable
end

t.timestamps
end
end
end
ActiveRecord::Migrator.migrate(File.expand_path("../../rails_app/db/migrate/", __FILE__))

class ActiveSupport::TestCase
self.use_transactional_fixtures = true
Expand Down
4 changes: 4 additions & 0 deletions test/rails_app/config.ru
@@ -0,0 +1,4 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
run RailsApp::Application
11 changes: 6 additions & 5 deletions test/rails_app/config/application.rb
@@ -1,20 +1,21 @@
require File.expand_path('../boot', __FILE__)

DEVISE_ORM = :active_record unless defined? DEVISE_ORM

require "active_record/railtie" if DEVISE_ORM == :active_record
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"

Bundler.require :default, DEVISE_ORM

begin
require "#{DEVISE_ORM}/railtie"
rescue LoadError
end

require "devise"

module RailsApp
class Application < Rails::Application
config.root = File.expand_path("../..", __FILE__)

# Add additional load paths for your own custom dirs
config.load_paths.reject!{ |p| p =~ /\/app\/(\w+)$/ && !%w(controllers helpers views).include?($1) }
config.load_paths += [ "#{config.root}/app/#{DEVISE_ORM}" ]
Expand Down
4 changes: 4 additions & 0 deletions test/rails_app/config/boot.rb
@@ -1,3 +1,7 @@
unless defined?(DEVISE_ORM)
DEVISE_ORM = (ENV["DEVISE_ORM"] || :active_record).to_sym
end

begin
require File.expand_path("../../../../.bundle/environment", __FILE__)
rescue LoadError
Expand Down
4 changes: 3 additions & 1 deletion test/rails_app/config/database.yml
Expand Up @@ -2,7 +2,9 @@
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: sqlite3
database: ":memory:"
database: db/development.sqlite3
pool: 5
timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
Expand Down
27 changes: 27 additions & 0 deletions test/rails_app/db/migrate/20100401102949_create_tables.rb
@@ -0,0 +1,27 @@
class CreateTables < ActiveRecord::Migration
def self.up
[:users, :admins, :accounts].each do |table|
create_table table do |t|
t.authenticatable :null => table == :admins

if table != :admin
t.string :username
t.confirmable
t.recoverable
t.rememberable
t.trackable
t.lockable
t.token_authenticatable
end

t.timestamps
end
end
end

def self.down
[:users, :admins, :accounts].each do |table|
drop_table table
end
end
end
86 changes: 86 additions & 0 deletions test/rails_app/db/schema.rb
@@ -0,0 +1,86 @@
# This file is auto-generated from the current state of the database. Instead of editing this file,
# please use the migrations feature of Active Record to incrementally modify your database, and
# then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your database schema. If you need
# to create the application database on another system, you should be using db:schema:load, not running
# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20100401102949) do

create_table "accounts", :force => true do |t|
t.string "email", :default => "", :null => false
t.string "encrypted_password", :default => "", :null => false
t.string "password_salt", :default => "", :null => false
t.string "username"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "reset_password_token"
t.string "remember_token"
t.datetime "remember_created_at"
t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.integer "failed_attempts", :default => 0
t.string "unlock_token"
t.datetime "locked_at"
t.string "authentication_token"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "admins", :force => true do |t|
t.string "email", :default => ""
t.string "encrypted_password", :default => ""
t.string "password_salt", :default => ""
t.string "username"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "reset_password_token"
t.string "remember_token"
t.datetime "remember_created_at"
t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.integer "failed_attempts", :default => 0
t.string "unlock_token"
t.datetime "locked_at"
t.string "authentication_token"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "users", :force => true do |t|
t.string "email", :default => "", :null => false
t.string "encrypted_password", :default => "", :null => false
t.string "password_salt", :default => "", :null => false
t.string "username"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "reset_password_token"
t.string "remember_token"
t.datetime "remember_created_at"
t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.integer "failed_attempts", :default => 0
t.string "unlock_token"
t.datetime "locked_at"
t.string "authentication_token"
t.datetime "created_at"
t.datetime "updated_at"
end

end

0 comments on commit dac7887

Please sign in to comment.