Skip to content
Browse files

don't worry about preserving the Rails 2 runner job_type if this is a…

… Rails 3 app
  • Loading branch information...
1 parent 4e0c357 commit ff0d68af55fb694ab7c8a9fabf017fcec57fa062 @javan javan committed Oct 19, 2010
View
7 lib/whenever/job_types/default.rb
@@ -1,3 +1,8 @@
job_type :command, ":task"
-job_type :runner, "cd :path && script/runner -e :environment ':task'"
job_type :rake, "cd :path && RAILS_ENV=:environment rake :task --silent"
+
+if File.exists?(File.join(Whenever.path, 'script', 'rails'))
+ job_type :runner, "cd :path && script/rails runner -e :environment ':task'"
+else
+ job_type :runner, "cd :path && script/runner -e :environment ':task'"
+end
View
11 lib/whenever/job_types/rails3.rb
@@ -1,11 +0,0 @@
-# Determine if this is a Rails 3 app by looking for a script/rails file.
-# If it is, preserve the Rails 2 runner job as rails2_runner and then
-# define a new job for Rails 3 as the default runner.
-
-if File.exists?(File.join(Whenever.path, 'script', 'rails'))
- class_eval do
- alias_method(:rails2_runner, :runner) if defined?(:runner)
- end
-
- job_type :runner, "cd :path && script/rails runner -e :environment ':task'"
-end
View
7 test/functional/output_default_defined_jobs_test.rb
@@ -55,24 +55,19 @@ class OutputDefaultDefinedJobsTest < Test::Unit::TestCase
context "A runner for a Rails 3 app" do
setup do
- Whenever.stubs(:path).returns('/my/path')
+ Whenever.expects(:path).at_least_once.returns('/my/path')
File.expects(:exists?).with('/my/path/script/rails').returns(true)
@output = Whenever.cron \
<<-file
every 2.hours do
runner 'blahblah'
- rails2_runner 'blahblah'
end
file
end
should "use the Rails 3 runner job by default" do
assert_match two_hours + %( cd /my/path && script/rails runner -e production 'blahblah'), @output
end
-
- should "have the Rails 2 runner job redefined as rails2_runner" do
- assert_match two_hours + %( cd /my/path && script/runner -e production 'blahblah'), @output
- end
end
# rake

0 comments on commit ff0d68a

Please sign in to comment.
Something went wrong with that request. Please try again.