runners for Rails 3
This commit is contained in:
parent
e7e4a37b3a
commit
0055c36aef
8
lib/whenever/job_types/rails3.rb
Normal file
8
lib/whenever/job_types/rails3.rb
Normal file
@ -0,0 +1,8 @@
|
||||
# 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 { alias_method :rails2_runner, :runner }
|
||||
job_type :runner, "cd :path && script/rails runner -e :environment ':task'"
|
||||
end
|
@ -53,6 +53,28 @@ class OutputDefaultDefinedJobsTest < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "A runner for a Rails 3 app" do
|
||||
setup do
|
||||
Whenever.stubs(:path).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
|
||||
|
||||
context "A rake command with path set" do
|
||||
|
@ -86,7 +86,7 @@ class OutputDefinedJobTest < Test::Unit::TestCase
|
||||
|
||||
context "A defined job that uses a :path where none is explicitly set" do
|
||||
setup do
|
||||
Whenever.expects(:path).returns('/my/path')
|
||||
Whenever.stubs(:path).returns('/my/path')
|
||||
|
||||
@output = Whenever.cron \
|
||||
<<-file
|
||||
|
Loading…
Reference in New Issue
Block a user