encapsulate rails 3 check for easier testing
This commit is contained in:
parent
42061be142
commit
b405def424
@ -19,4 +19,8 @@ module Whenever
|
||||
Dir.pwd
|
||||
end
|
||||
|
||||
def self.rails3?
|
||||
File.exists?(File.join(path, 'script', 'rails'))
|
||||
end
|
||||
|
||||
end
|
@ -11,7 +11,7 @@ job_type :command, ":task :output"
|
||||
job_type :rake, "cd :path && RAILS_ENV=:environment rake :task --silent :output"
|
||||
|
||||
# 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"
|
||||
else
|
||||
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
|
||||
setup do
|
||||
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 \
|
||||
<<-file
|
||||
set :job_template, nil
|
||||
|
Loading…
Reference in New Issue
Block a user