Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add Delayed::Job

* Use style-guide-appropriate database migration.
* Configure RSpec request specs to run jobs immediately.
* Run `Delayed::Job` workers via the `Procfile`.
* Ensure delay_jobs is reset when example fails.
commit 7b3e73b54d37f29f6867c8984a487ffbdb051516 1 parent 969dbd9
@croaky croaky authored
View
5 lib/suspenders/app_builder.rb
@@ -147,6 +147,11 @@ def configure_rspec
inject_into_class 'config/application.rb', 'Application', config
end
+ def configure_background_jobs_for_rspec
+ copy_file 'background_jobs_rspec.rb', 'spec/support/background_jobs.rb'
+ run 'rails g delayed_job:active_record'
+ end
+
def blacklist_active_record_attributes
replace_in_file 'config/application.rb',
'config.active_record.whitelist_attributes = true',
View
1  lib/suspenders/generators/app_generator.rb
@@ -75,6 +75,7 @@ def setup_test_environment
build :test_factories_first
build :generate_rspec
build :configure_rspec
+ build :configure_background_jobs_for_rspec
build :enable_database_cleaner
build :configure_capybara_webkit
build :setup_guard_spork
View
2  suspenders.gemspec
@@ -19,7 +19,7 @@ rush to build something amazing; don't use it if you like missing deadlines.
HERE
s.email = 'support@thoughtbot.com'
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |file| File.basename(file) }
s.extra_rdoc_files = %w[README.md LICENSE]
s.files = `git ls-files`.split("\n")
s.homepage = 'http://github.com/thoughtbot/suspenders'
View
1  templates/Gemfile_clean
@@ -2,6 +2,7 @@ source 'https://rubygems.org'
gem 'airbrake'
gem 'bourbon'
+gem 'delayed_job_active_record', '>= 4.0.0.beta2'
gem 'flutie'
gem 'high_voltage'
gem 'jquery-rails'
View
1  templates/Procfile
@@ -1 +1,2 @@
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
+worker: bundle exec rake jobs:work
View
19 templates/background_jobs_rspec.rb
@@ -0,0 +1,19 @@
+module BackgroundJobs
+ def run_background_jobs_immediately
+ delay_jobs = Delayed::Worker.delay_jobs
+ Delayed::Worker.delay_jobs = false
+ yield
+ ensure
+ Delayed::Worker.delay_jobs = delay_jobs
+ end
+end
+
+RSpec.configure do |config|
+ config.around(:each, type: :feature) do |example|
+ run_background_jobs_immediately do
+ example.run
+ end
+ end
+
+ config.include BackgroundJobs
+end
Please sign in to comment.
Something went wrong with that request. Please try again.