Permalink
Browse files

Use mysql to run specs

  • Loading branch information...
1 parent 234fcf8 commit dca7dd745a576e25dcb68caa9ea6ba949d2663ac @bkeepers bkeepers committed Sep 17, 2010
Showing with 15 additions and 1 deletion.
  1. +2 −0 Gemfile.lock
  2. +1 −0 delayed_job.gemspec
  3. +4 −0 lib/delayed/backend/active_record.rb
  4. +4 −0 spec/database.yml
  5. +4 −1 spec/spec_helper.rb
View
2 Gemfile.lock
@@ -49,6 +49,7 @@ GEM
mime-types
treetop (>= 1.4.5)
mime-types (1.16)
+ mysql (2.8.1)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
@@ -88,6 +89,7 @@ DEPENDENCIES
activesupport (~> 3.0)
daemons
delayed_job!
+ mysql
rails (~> 3.0)
rake
rspec
View
1 delayed_job.gemspec
@@ -24,5 +24,6 @@ This gem is collectiveidea's fork (http://github.com/collectiveidea/delayed_job)
s.add_development_dependency 'rails', '~>3.0'
s.add_development_dependency 'sqlite3-ruby'
s.add_development_dependency 'ruby-debug'
+ s.add_development_dependency 'mysql'
end
View
4 lib/delayed/backend/active_record.rb
@@ -30,6 +30,10 @@ class Job < ::ActiveRecord::Base
}
scope :by_priority, order('priority ASC, run_at ASC')
+ def self.before_fork
+ ::ActiveRecord::Base.clear_all_connections!
+ end
+
def self.after_fork
::ActiveRecord::Base.establish_connection
end
View
4 spec/database.yml
@@ -0,0 +1,4 @@
+mysql:
+ adapter: mysql
+ database: delayed_job
+ username: root
View
5 spec/spec_helper.rb
@@ -13,8 +13,11 @@
Delayed::Worker.logger = Logger.new('/tmp/dj.log')
ENV['RAILS_ENV'] = 'test'
+require 'rails'
-ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
+config = YAML.load(File.read('spec/database.yml'))
+ActiveRecord::Base.configurations = {'test' => config['mysql']}
+ActiveRecord::Base.establish_connection
ActiveRecord::Base.logger = Delayed::Worker.logger
ActiveRecord::Migration.verbose = false

0 comments on commit dca7dd7

Please sign in to comment.