diff --git a/config/initializers/in_memory_testing.rb b/config/initializers/in_memory_testing.rb new file mode 100644 index 0000000..a29c1ac --- /dev/null +++ b/config/initializers/in_memory_testing.rb @@ -0,0 +1,14 @@ +def in_memory_database? + if %w{test cucumber}.member? ENV['RAILS_ENV'] + ActiveRecord::Base.connection.class == ActiveRecord::ConnectionAdapters::SQLite3Adapter and + Rails::Configuration.new.database_configuration[ENV['RAILS_ENV']]['database'] == ':memory:' + else + false + end +end + +if in_memory_database? + puts "creating sqlite in memory database" + load "#{RAILS_ROOT}/db/schema.rb" # use db agnostic schema by default + # ActiveRecord::Migrator.up('db/migrate') # use migrations +end diff --git a/db/schema.rb b/db/schema.rb index cabf856..4132a2c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -76,8 +76,4 @@ ActiveRecord::Schema.define(:version => 20100316041234) do t.datetime "updated_at" end - add_foreign_key "projects", "users", :name => "projects_owner_id_fk", :column => "owner_id" - - add_foreign_key "tasks", "users", :name => "tasks_owner_id_fk", :column => "owner_id" - end