resque-scheduler-web 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +48 -0
- data/Rakefile +2 -0
- data/app/controllers/resque_web/plugins/resque_scheduler/delayed_controller.rb +55 -0
- data/app/controllers/resque_web/plugins/resque_scheduler/schedules_controller.rb +62 -0
- data/app/helpers/resque_web/plugins/resque_scheduler/delayed_helper.rb +11 -0
- data/app/helpers/resque_web/plugins/resque_scheduler/schedules_helper.rb +53 -0
- data/app/models/resque_web/plugins/resque_scheduler/job_finder/working_job_finder.rb +40 -0
- data/app/models/resque_web/plugins/resque_scheduler/job_finder.rb +81 -0
- data/app/views/resque_web/plugins/resque_scheduler/delayed/_next_more.erb +23 -0
- data/app/views/resque_web/plugins/resque_scheduler/delayed/_search_form.erb +8 -0
- data/app/views/resque_web/plugins/resque_scheduler/delayed/index.erb +61 -0
- data/app/views/resque_web/plugins/resque_scheduler/delayed/jobs_klass.erb +20 -0
- data/app/views/resque_web/plugins/resque_scheduler/delayed/search.erb +72 -0
- data/app/views/resque_web/plugins/resque_scheduler/delayed/timestamp.erb +25 -0
- data/app/views/resque_web/plugins/resque_scheduler/schedules/index.html.erb +51 -0
- data/app/views/resque_web/plugins/resque_scheduler/schedules/requeue-params.erb +23 -0
- data/lib/resque/scheduler/web/version.rb +7 -0
- data/lib/resque/scheduler/web.rb +6 -0
- data/lib/resque_web/plugins/resque_scheduler/engine.rb +49 -0
- data/resque-scheduler-web.gemspec +35 -0
- data/spec/controllers/delayed_controller_spec.rb +117 -0
- data/spec/controllers/schedules_controller_spec.rb +152 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config/application.rb +31 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +42 -0
- data/spec/dummy/config/environments/production.rb +83 -0
- data/spec/dummy/config/environments/test.rb +43 -0
- data/spec/dummy/config/initializers/assets.rb +12 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +9 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +15 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +18 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/log/development.log +4 -0
- data/spec/dummy/log/test.log +56454 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/features/navigation_spec.rb +16 -0
- data/spec/features/schedules/requeuing_a_job_with_parameters_spec.rb +36 -0
- data/spec/features/schedules/scheduled_jobs_page_spec.rb +80 -0
- data/spec/models/job_finder/working_job_finder_spec.rb +38 -0
- data/spec/models/job_finder_spec.rb +68 -0
- data/spec/rails_helper.rb +25 -0
- data/spec/routing/delayed_routing_spec.rb +9 -0
- data/spec/spec_helper.rb +96 -0
- data/spec/support/redis_instance.rb +133 -0
- data/spec/support/test_jobs.rb +77 -0
- metadata +312 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
<h1>Schedule</h1>
|
2
|
+
|
3
|
+
<p class='intro'>
|
4
|
+
The list below contains all scheduled jobs. Click "Queue now" to
|
5
|
+
queue a job immediately.
|
6
|
+
Server local time: <%= Time.now %>
|
7
|
+
Current master: <%= Resque.redis.get(Resque::Scheduler.master_lock.key) %>
|
8
|
+
</p>
|
9
|
+
<div style="overflow-y: auto; width:100%; padding: 0px 5px;">
|
10
|
+
<table class="table table-bordered">
|
11
|
+
<tr>
|
12
|
+
<% if Resque::Scheduler.dynamic %>
|
13
|
+
<th></th>
|
14
|
+
<% end %>
|
15
|
+
<th></th>
|
16
|
+
<th>Name</th>
|
17
|
+
<th>Description</th>
|
18
|
+
<th>Interval</th>
|
19
|
+
<th>Class</th>
|
20
|
+
<th>Queue</th>
|
21
|
+
<th>Arguments</th>
|
22
|
+
<th>Last Enqueued</th>
|
23
|
+
</tr>
|
24
|
+
<% @scheduled_jobs.each do |job_name, job_config| %>
|
25
|
+
<tr class="job" id="job_<%= job_name %>">
|
26
|
+
<% if Resque::Scheduler.dynamic %>
|
27
|
+
<td class="delete-job-button-cell" style="padding-top: 12px; padding-bottom: 2px; width: 10px">
|
28
|
+
<form action="<%= schedule_path %>" method="post" style="margin-left: 0">
|
29
|
+
<input type="hidden" name="job_name" value="<%= h job_name %>">
|
30
|
+
<input type="hidden" name="_method" value="delete">
|
31
|
+
<input type="submit" value="Delete">
|
32
|
+
</form>
|
33
|
+
</td>
|
34
|
+
<% end %>
|
35
|
+
<td class="requeue-job-button-cell" style="padding-top: 12px; padding-bottom: 2px; width: 10px">
|
36
|
+
<form action="<%= requeue_path %>" method="post" style="margin-left: 0">
|
37
|
+
<input type="hidden" name="job_name" value="<%= h job_name %>">
|
38
|
+
<input type="submit" value="Queue now" id="requeue_job_<%= job_name %>" class="btn btn-default">
|
39
|
+
</form>
|
40
|
+
</td>
|
41
|
+
<td><%= h job_name %></td>
|
42
|
+
<td><%= h job_config['description'] %></td>
|
43
|
+
<td style="white-space:nowrap"><%= h schedule_interval(job_config) %></td>
|
44
|
+
<td><%= h schedule_class(job_config) %></td>
|
45
|
+
<td><%= h job_config['queue'] || queue_from_class_name(job_config['class']) %></td>
|
46
|
+
<td><%= h job_config['args'].inspect %></td>
|
47
|
+
<td><%= h Resque.get_last_enqueued_at(job_name) || 'Never' %></td>
|
48
|
+
</tr>
|
49
|
+
<% end %>
|
50
|
+
</table>
|
51
|
+
</div>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<h1><%= @job_name %></h1>
|
2
|
+
|
3
|
+
<p class='intro'>
|
4
|
+
This job requires parameters:
|
5
|
+
</p>
|
6
|
+
|
7
|
+
<form style="float:left" action="<%= requeue_with_params_path %>" method="post">
|
8
|
+
<table>
|
9
|
+
<% @parameters.each do |key, value| %>
|
10
|
+
<% value ||= {} %>
|
11
|
+
<tr>
|
12
|
+
<td>
|
13
|
+
<%= key %>
|
14
|
+
<% if value['description'] || value[:description] %>
|
15
|
+
<span style="border-bottom:1px dotted;" title="<%=value ['description'] || value[:description] %>">(?)</span>
|
16
|
+
<% end %>:
|
17
|
+
</td>
|
18
|
+
<td><input type="text" name="<%= key %>" value="<%= value['default'] || value[:default] %>"></td>
|
19
|
+
<% end %>
|
20
|
+
</table>
|
21
|
+
<input type="hidden" name="job_name" value="<%= @job_name %>">
|
22
|
+
<input type="submit" value="Queue now">
|
23
|
+
</form>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'resque_web'
|
2
|
+
|
3
|
+
module ResqueWeb
|
4
|
+
module Plugins
|
5
|
+
module ResqueScheduler
|
6
|
+
class Engine < ::Rails::Engine
|
7
|
+
isolate_namespace ResqueWeb::Plugins::ResqueScheduler
|
8
|
+
|
9
|
+
# paths['app'] << 'app'
|
10
|
+
# paths['app/helpers'] << 'app/helpers'
|
11
|
+
# paths['app/views'] << 'app/views'
|
12
|
+
# paths['app/controllers'] << 'app/controllers'
|
13
|
+
# paths['app/models'] << 'app/models'
|
14
|
+
end
|
15
|
+
|
16
|
+
Engine.routes do
|
17
|
+
get 'schedule', to: 'schedules#index', as: 'schedules'
|
18
|
+
post 'schedule/requeue', to: 'schedules#requeue', as: 'requeue'
|
19
|
+
post 'schedule/requeue_with_params',
|
20
|
+
to: 'schedules#requeue_with_params',
|
21
|
+
as: 'requeue_with_params'
|
22
|
+
delete 'schedule', to: 'schedules#destroy', as: 'schedule'
|
23
|
+
|
24
|
+
get 'delayed', to: 'delayed#index', as: 'delayed'
|
25
|
+
get 'delayed/jobs/:klass',
|
26
|
+
to: 'delayed#jobs_klass',
|
27
|
+
as: 'delayed_job_class'
|
28
|
+
post 'delayed/search', to: 'delayed#search', as: 'delayed_search'
|
29
|
+
get 'delayed/:timestamp', to: 'delayed#timestamp', as: 'timestamp'
|
30
|
+
post 'delayed/queue_now', to: 'delayed#queue_now', as: 'queue_now'
|
31
|
+
post '/delayed/cancel_now', to: 'delayed#cancel_now', as: 'cancel_now'
|
32
|
+
post '/delayed/clear', to: 'delayed#clear', as: 'clear'
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.engine_path
|
36
|
+
'/scheduler'
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.tabs
|
40
|
+
[
|
41
|
+
{
|
42
|
+
'schedule' => Engine.app.url_helpers.schedules_path,
|
43
|
+
'delayed' => Engine.app.url_helpers.delayed_path
|
44
|
+
}
|
45
|
+
]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'resque/scheduler/web/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'resque-scheduler-web'
|
8
|
+
spec.version = Resque::Scheduler::Web::VERSION
|
9
|
+
spec.authors = ['Matt Gibson']
|
10
|
+
spec.email = ['downrightlies@gmail.com']
|
11
|
+
spec.summary = 'This gem provides tabs in Resque Web for managing '\
|
12
|
+
'Resque Scheduler.'
|
13
|
+
spec.description = 'Use this if you want to move to the new Resque Web '\
|
14
|
+
'plugin architecture via the resque-web gem, rather '\
|
15
|
+
'than the Sinatra-based approach that is bundled with '\
|
16
|
+
'Resque 1.x'
|
17
|
+
spec.homepage = 'https://github.com/mattgibson/resque-scheduler-web'
|
18
|
+
spec.license = 'MIT'
|
19
|
+
|
20
|
+
spec.files = `git ls-files -z`.split("\x0")
|
21
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
23
|
+
spec.require_paths = ['lib']
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
27
|
+
spec.add_development_dependency 'rails', '~> 4.2'
|
28
|
+
spec.add_development_dependency 'resque-web', '~> 0'
|
29
|
+
spec.add_development_dependency 'resque-scheduler', '~> 4.0'
|
30
|
+
spec.add_development_dependency 'sqlite3', '~> 1.3'
|
31
|
+
spec.add_development_dependency 'rspec-rails', '~> 3.2'
|
32
|
+
spec.add_development_dependency 'capybara', '~> 2.4'
|
33
|
+
spec.add_development_dependency 'sass', '~> 3.4' # Avoids non-thread-safe error.
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe ResqueWeb::Plugins::ResqueScheduler::DelayedController, type: :controller do
|
4
|
+
routes { ResqueWeb::Plugins::ResqueScheduler::Engine.routes }
|
5
|
+
|
6
|
+
let(:some_time_in_the_future) { Time.now + 3600 }
|
7
|
+
|
8
|
+
describe 'GET index' do
|
9
|
+
it 'includes delayed jobs timestamp' do
|
10
|
+
Resque.enqueue_at(some_time_in_the_future, SomeIvarJob)
|
11
|
+
get :index
|
12
|
+
expect(assigns(:timestamps)).to include(some_time_in_the_future.to_i)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'POST cancel_now' do
|
17
|
+
it 'redirects to delayed index' do
|
18
|
+
post :cancel_now
|
19
|
+
expect(response).to redirect_to delayed_path
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'POST clear' do
|
24
|
+
it 'redirects to delayed index' do
|
25
|
+
post :clear
|
26
|
+
expect(response).to redirect_to delayed_path
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'GET jobs_klass' do
|
31
|
+
|
32
|
+
shared_examples 'a delayed job class request' do
|
33
|
+
it 'is a 200' do
|
34
|
+
expect(response).to be_success
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'see the scheduled job timestamp' do
|
38
|
+
expect(assigns(:timestamps)).to include(some_time_in_the_future.to_i)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
before do
|
43
|
+
Resque.enqueue_at(some_time_in_the_future, klass, 'foo', 'bar')
|
44
|
+
|
45
|
+
params = { klass: klass.to_s, args: URI.encode(%w(foo bar).to_json) }
|
46
|
+
get :jobs_klass, params
|
47
|
+
end
|
48
|
+
|
49
|
+
after do
|
50
|
+
Resque.reset_delayed_queue
|
51
|
+
Resque.queues.each { |q| Resque.remove_queue q }
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'with a normal class' do
|
55
|
+
let(:klass) { SomeIvarJob }
|
56
|
+
it_behaves_like 'a delayed job class request'
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'with a namespaced class' do
|
60
|
+
let(:klass) { Foo::Bar }
|
61
|
+
it_behaves_like 'a delayed job class request'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe 'GET search' do
|
66
|
+
|
67
|
+
shared_examples 'a successful search request' do
|
68
|
+
it 'is a 200' do
|
69
|
+
expect(response).to be_success
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'see the scheduled job timestamp' do
|
73
|
+
expect(assigns(:jobs)).to include(hash_including 'class' => 'SomeIvarJob')
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
after do
|
78
|
+
Resque.reset_delayed_queue
|
79
|
+
Resque.queues.each { |q| Resque.remove_queue q }
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'with a delayed job scheduled for the future' do
|
83
|
+
|
84
|
+
before do
|
85
|
+
Resque.enqueue_at(some_time_in_the_future, SomeIvarJob)
|
86
|
+
post :search, 'search' => 'ivar'
|
87
|
+
end
|
88
|
+
|
89
|
+
it_behaves_like 'a successful search request'
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'with a job in the queue now' do
|
94
|
+
before do
|
95
|
+
Resque.enqueue(SomeIvarJob)
|
96
|
+
post :search, 'search' => 'ivar'
|
97
|
+
end
|
98
|
+
|
99
|
+
it_behaves_like 'a successful search request'
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe 'POST queue_now' do
|
105
|
+
it 'redirects to overview' do
|
106
|
+
post :queue_now
|
107
|
+
expect(response.location).to include('overview') # In parent engine
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe 'GET timestamp' do
|
112
|
+
it 'succeeds' do
|
113
|
+
get :timestamp, timestamp: '1234567890'
|
114
|
+
expect(response).to be_success
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe ResqueWeb::Plugins::ResqueScheduler::SchedulesController, type: :controller do
|
4
|
+
routes { ResqueWeb::Plugins::ResqueScheduler::Engine.routes }
|
5
|
+
|
6
|
+
describe 'GET index' do
|
7
|
+
|
8
|
+
before do
|
9
|
+
Resque::Scheduler.env = 'production'
|
10
|
+
|
11
|
+
Resque.schedule = {
|
12
|
+
'some_ivar_job' => {
|
13
|
+
'cron' => '* * * * *',
|
14
|
+
'class' => 'SomeIvarJob',
|
15
|
+
'args' => '/tmp',
|
16
|
+
'rails_env' => 'production'
|
17
|
+
},
|
18
|
+
'some_other_job' => {
|
19
|
+
'every' => ['1m', ['1h']],
|
20
|
+
'queue' => 'high',
|
21
|
+
'custom_job_class' => 'SomeOtherJob',
|
22
|
+
'args' => {
|
23
|
+
'b' => 'blah'
|
24
|
+
}
|
25
|
+
},
|
26
|
+
'some_fancy_job' => {
|
27
|
+
'every' => ['1m'],
|
28
|
+
'queue' => 'fancy',
|
29
|
+
'class' => 'SomeFancyJob',
|
30
|
+
'args' => 'sparkles',
|
31
|
+
'rails_env' => 'fancy'
|
32
|
+
},
|
33
|
+
'shared_env_job' => {
|
34
|
+
'cron' => '* * * * *',
|
35
|
+
'class' => 'SomeSharedEnvJob',
|
36
|
+
'args' => '/tmp',
|
37
|
+
'rails_env' => 'fancy, production'
|
38
|
+
}
|
39
|
+
}
|
40
|
+
Resque::Scheduler.load_schedule!
|
41
|
+
get :index
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'sees the scheduled job' do
|
45
|
+
expect(assigns(:scheduled_jobs)).to match hash_including('some_ivar_job' => hash_including('class' => 'SomeIvarJob'))
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'excludes jobs for other envs' do
|
49
|
+
expect(assigns(:scheduled_jobs)).to_not match hash_including('some_fancy_job' => hash_including('class' => 'SomeFancyJob'))
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'includes job used in multiple environments' do
|
53
|
+
expect(assigns(:scheduled_jobs)).to match hash_including('shared_env_job' => hash_including('class' => 'SomeSharedEnvJob'))
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
describe 'POST requeue_with_params' do
|
59
|
+
before do
|
60
|
+
Resque.schedule = Test::RESQUE_SCHEDULE
|
61
|
+
Resque::Scheduler.load_schedule!
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'redirects correctly to the Resque Web overview' do
|
65
|
+
job_name = 'job_with_params'
|
66
|
+
log_level = 'error'
|
67
|
+
|
68
|
+
job_config = Resque.schedule[job_name]
|
69
|
+
args = job_config['args'].merge('log_level' => log_level)
|
70
|
+
job_config.merge!('args' => args)
|
71
|
+
|
72
|
+
allow(Resque::Scheduler).to receive(:enqueue_from_config).once.with(job_config)
|
73
|
+
|
74
|
+
post :requeue_with_params, 'job_name' => job_name, 'log_level' => log_level
|
75
|
+
|
76
|
+
expect(response).to redirect_to ResqueWeb::Engine.app.url_helpers.overview_path
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe 'POST requeue' do
|
81
|
+
before do
|
82
|
+
Resque.schedule = Test::RESQUE_SCHEDULE
|
83
|
+
Resque::Scheduler.load_schedule!
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'with a job that has no defined params' do
|
87
|
+
it 'redirects to the overview page' do
|
88
|
+
job_name = 'job_without_params'
|
89
|
+
allow(Resque::Scheduler).to receive(:enqueue_from_config)
|
90
|
+
.once.with(Resque.schedule[job_name])
|
91
|
+
|
92
|
+
post :requeue, 'job_name' => job_name
|
93
|
+
expect(response).to redirect_to ResqueWeb::Engine.app.url_helpers.overview_path
|
94
|
+
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'with a job that has defined params' do
|
99
|
+
|
100
|
+
it 'renders a form for the params to be entered' do
|
101
|
+
job_name = 'job_with_params'
|
102
|
+
post :requeue, 'job_name' => job_name
|
103
|
+
expect(response).to render_template 'requeue-params'
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe 'DELETE destroy' do
|
110
|
+
before do
|
111
|
+
Resque.schedule = Test::RESQUE_SCHEDULE
|
112
|
+
Resque::Scheduler.load_schedule!
|
113
|
+
end
|
114
|
+
|
115
|
+
context 'with a static schedule' do
|
116
|
+
|
117
|
+
before do
|
118
|
+
allow(Resque::Scheduler).to receive(:dynamic).and_return(false)
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'does not delete the job' do
|
122
|
+
params = {job_name: 'job_with_params'}
|
123
|
+
delete :destroy, params
|
124
|
+
|
125
|
+
msg = 'The job should not have been deleted from redis.'
|
126
|
+
expect(Resque.fetch_schedule('job_with_params')).to be_truthy, msg
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
context 'with a dynamic schedule' do
|
132
|
+
before do
|
133
|
+
allow(Resque::Scheduler).to receive(:dynamic).and_return(true)
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'redirects to schedule page' do
|
137
|
+
params = {job_name: 'job_with_params'}
|
138
|
+
delete :destroy, params
|
139
|
+
|
140
|
+
expect(response).to redirect_to resque_scheduler_engine_routes.schedules_path
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'removes job from redis' do
|
144
|
+
params = {job_name: 'job_with_params'}
|
145
|
+
delete :destroy, params
|
146
|
+
|
147
|
+
msg = 'The job was not deleted from redis.'
|
148
|
+
expect(Resque.fetch_schedule('job_with_params')).to be_nil, msg
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/spec/dummy/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
6
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/spec/dummy/bin/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
# path to your application root.
|
5
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
6
|
+
|
7
|
+
Dir.chdir APP_ROOT do
|
8
|
+
# This script is a starting point to setup your application.
|
9
|
+
# Add necessary setup steps to this file:
|
10
|
+
|
11
|
+
puts '== Installing dependencies =='
|
12
|
+
system 'gem install bundler --conservative'
|
13
|
+
system 'bundle check || bundle install'
|
14
|
+
|
15
|
+
# puts "\n== Copying sample files =="
|
16
|
+
# unless File.exist?("config/database.yml")
|
17
|
+
# system "cp config/database.yml.sample config/database.yml"
|
18
|
+
# end
|
19
|
+
|
20
|
+
puts "\n== Preparing database =="
|
21
|
+
system 'bin/rake db:setup'
|
22
|
+
|
23
|
+
puts "\n== Removing old logs and tempfiles =="
|
24
|
+
system 'rm -f log/*'
|
25
|
+
system 'rm -rf tmp/cache'
|
26
|
+
|
27
|
+
puts "\n== Restarting application server =="
|
28
|
+
system 'touch tmp/restart.txt'
|
29
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require(*Rails.groups)
|
6
|
+
require 'resque_web'
|
7
|
+
require 'resque-scheduler'
|
8
|
+
|
9
|
+
module Dummy
|
10
|
+
class Application < Rails::Application
|
11
|
+
# Settings in config/environments/* take precedence over those specified
|
12
|
+
# here. Application configuration should go into files in
|
13
|
+
# config/initializers
|
14
|
+
# -- all .rb files in that directory are automatically loaded.
|
15
|
+
|
16
|
+
# Set Time.zone default to the specified zone and make Active Record
|
17
|
+
# auto-convert to this zone. Run "rake -D time" for a list of tasks for
|
18
|
+
# finding time zone names. Default is UTC.
|
19
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
20
|
+
|
21
|
+
# The default locale is :en and all translations from
|
22
|
+
# config/locales/*.rb,yml are auto loaded.
|
23
|
+
# config.i18n.load_path += Dir[Rails.root.join('my',
|
24
|
+
# 'locales',
|
25
|
+
# '*.{rb,yml}').to_s]
|
26
|
+
# config.i18n.default_locale = :de
|
27
|
+
|
28
|
+
# Do not swallow errors in after_commit/after_rollback callbacks.
|
29
|
+
config.active_record.raise_in_transactional_callbacks = true
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
#
|
7
|
+
default: &default
|
8
|
+
adapter: sqlite3
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
development:
|
13
|
+
<<: *default
|
14
|
+
database: db/development.sqlite3
|
15
|
+
|
16
|
+
# Warning: The database defined as "test" will be erased and
|
17
|
+
# re-generated from your development database when you run "rake".
|
18
|
+
# Do not set this db to the same as development or production.
|
19
|
+
test:
|
20
|
+
<<: *default
|
21
|
+
database: db/test.sqlite3
|
22
|
+
|
23
|
+
production:
|
24
|
+
<<: *default
|
25
|
+
database: db/production.sqlite3
|