diff --git a/Gemfile b/Gemfile index 9ae55679..b47d1bc4 100644 --- a/Gemfile +++ b/Gemfile @@ -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" diff --git a/test/orm/active_record.rb b/test/orm/active_record.rb index ba7a5f54..d1bff6c2 100644 --- a/test/orm/active_record.rb +++ b/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 diff --git a/test/rails_app/config.ru b/test/rails_app/config.ru new file mode 100644 index 00000000..2c6ec586 --- /dev/null +++ b/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 diff --git a/test/rails_app/config/application.rb b/test/rails_app/config/application.rb index 85846c87..94d8c069 100644 --- a/test/rails_app/config/application.rb +++ b/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}" ] diff --git a/test/rails_app/config/boot.rb b/test/rails_app/config/boot.rb index b2c00088..6d0928a9 100644 --- a/test/rails_app/config/boot.rb +++ b/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 diff --git a/test/rails_app/config/database.yml b/test/rails_app/config/database.yml index 4033d4e7..f999fcce 100644 --- a/test/rails_app/config/database.yml +++ b/test/rails_app/config/database.yml @@ -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". diff --git a/test/rails_app/db/migrate/20100401102949_create_tables.rb b/test/rails_app/db/migrate/20100401102949_create_tables.rb new file mode 100644 index 00000000..96c22fa8 --- /dev/null +++ b/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 diff --git a/test/rails_app/db/schema.rb b/test/rails_app/db/schema.rb new file mode 100644 index 00000000..a4579fa2 --- /dev/null +++ b/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