Skip to content

Commit

Permalink
Merge branch 'v2.x-stable' into merging-v2.x-stable
Browse files Browse the repository at this point in the history
Conflicts:
	lib/resque_scheduler/server.rb
	test/resque-web_test.rb
  • Loading branch information
meatballhat committed Feb 18, 2014
2 parents 59e1679 + 6613982 commit e52f821
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/resque_scheduler/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ def scheduler_template(name)
File.expand_path("../server/views/#{name}.erb", __FILE__)
)
end

def scheduled_in_this_env?(name)
return true if Resque.schedule[name]['rails_env'].nil?
Resque.schedule[name]['rails_env'] == Resque::Scheduler.env
end
end

get '/schedule' do
Expand Down
2 changes: 1 addition & 1 deletion lib/resque_scheduler/server/views/scheduler.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<th>Queue</th>
<th>Arguments</th>
</tr>
<% Resque.schedule.keys.sort.each do |name| %>
<% Resque.schedule.keys.sort.select { |n| scheduled_in_this_env?(n) }.each do |name| %>
<% config = Resque.schedule[name] %>
<tr>
<td style="padding-top: 12px; padding-bottom: 2px; width: 10px">
Expand Down
13 changes: 12 additions & 1 deletion test/resque-web_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

context 'on GET to /schedule with scheduled jobs' do
setup do
ENV['RAILS_ENV'] = 'production'
Resque::Scheduler.env = 'production'
Resque.schedule = {
'some_ivar_job' => {
'cron' => '* * * * *',
Expand All @@ -26,6 +26,13 @@
'args' => {
'b' => 'blah'
}
},
'some_fancy_job' => {
'every' => ['1m'],
'queue' => 'fancy',
'class' => 'SomeFancyJob',
'args' => 'sparkles',
'rails_env' => 'fancy'
}
}
Resque::Scheduler.load_schedule!
Expand All @@ -37,6 +44,10 @@
test 'see the scheduled job' do
assert last_response.body.include?('SomeIvarJob')
end

test 'excludes jobs for other envs' do
assert !last_response.body.include?('SomeFancyJob')
end
end

context 'on GET to /delayed' do
Expand Down
6 changes: 6 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ class SomeIvarJob < SomeJob
@queue = :ivar
end

class SomeFancyJob < SomeJob
def self.queue
:fancy
end
end

class SomeQuickJob < SomeJob
@queue = :quick
end
Expand Down

0 comments on commit e52f821

Please sign in to comment.