diff --git a/lib/whenever/job_types/default.rb b/lib/whenever/job_types/default.rb index e9c7ec1..abc9e01 100644 --- a/lib/whenever/job_types/default.rb +++ b/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 diff --git a/lib/whenever/job_types/rails3.rb b/lib/whenever/job_types/rails3.rb deleted file mode 100644 index 336f64e..0000000 --- a/lib/whenever/job_types/rails3.rb +++ /dev/null @@ -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 \ No newline at end of file diff --git a/test/functional/output_default_defined_jobs_test.rb b/test/functional/output_default_defined_jobs_test.rb index df83f90..3b038dc 100644 --- a/test/functional/output_default_defined_jobs_test.rb +++ b/test/functional/output_default_defined_jobs_test.rb @@ -55,13 +55,12 @@ 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 @@ -69,10 +68,6 @@ class OutputDefaultDefinedJobsTest < Test::Unit::TestCase 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