encapsulate rails 3 check for easier testing
This commit is contained in:
parent
42061be142
commit
b405def424
@ -19,4 +19,8 @@ module Whenever
|
|||||||
Dir.pwd
|
Dir.pwd
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.rails3?
|
||||||
|
File.exists?(File.join(path, 'script', 'rails'))
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
@ -11,7 +11,7 @@ job_type :command, ":task :output"
|
|||||||
job_type :rake, "cd :path && RAILS_ENV=:environment rake :task --silent :output"
|
job_type :rake, "cd :path && RAILS_ENV=:environment rake :task --silent :output"
|
||||||
|
|
||||||
# Create a runner job that's appropriate for the Rails version,
|
# Create a runner job that's appropriate for the Rails version,
|
||||||
if File.exists?(File.join(path, 'script', 'rails'))
|
if Whenever.rails3?
|
||||||
job_type :runner, "cd :path && script/rails runner -e :environment ':task' :output"
|
job_type :runner, "cd :path && script/rails runner -e :environment ':task' :output"
|
||||||
else
|
else
|
||||||
job_type :runner, "cd :path && script/runner -e :environment ':task' :output"
|
job_type :runner, "cd :path && script/runner -e :environment ':task' :output"
|
||||||
|
@ -110,7 +110,7 @@ class OutputDefaultDefinedJobsTest < Test::Unit::TestCase
|
|||||||
context "A runner for a Rails 3 app" do
|
context "A runner for a Rails 3 app" do
|
||||||
setup do
|
setup do
|
||||||
Whenever.expects(:path).at_least_once.returns('/my/path')
|
Whenever.expects(:path).at_least_once.returns('/my/path')
|
||||||
File.expects(:exists?).with('/my/path/script/rails').returns(true)
|
Whenever.expects(:rails3?).returns(true)
|
||||||
@output = Whenever.cron \
|
@output = Whenever.cron \
|
||||||
<<-file
|
<<-file
|
||||||
set :job_template, nil
|
set :job_template, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user