rocketjob_mission_control 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95c31dad97c24947bcd03965186d8e2e3a18d9e6
4
- data.tar.gz: '064995269a737889937e84659e86160d8b0a7c26'
3
+ metadata.gz: 21d26a16d5a42afc84e40b409b784dc9114a0964
4
+ data.tar.gz: ba1b5b6abdee92bd07e235365edeba6b4d5be340
5
5
  SHA512:
6
- metadata.gz: 0a5a5b0ce3cae2cd1964deef79a70f2d35fabe7348e4e8f01e86fe22059d0c2dad02ffd82a32bd4442cbce9d2b149b62d088b4851393d818225030ec72bdfe4d
7
- data.tar.gz: 4fda4abf731c3c5487d7bcf2601d4b528d2ff6f887a91cb9ce059860f0802ae617ffcde72f0ec07f605ede8e6326c1cd3015f8a78e50c3e58ed3675d54f3fbb2
6
+ metadata.gz: 603390cc09d91dc638e1014b1121125a2c7438b14e3c360edf1cb666faa434211bcea7aa230d10b9ae934fa62dad0fd03823289b0db9a1ec693e6316fefe43eb
7
+ data.tar.gz: 51cd9a8828ec473401f1b95dc23c2e0fe56e419d3cb7a965cf86a350ee43d466e55f75bc4ee74d784229e1d8a7bd5ece904072c91d8ac92adfa1d75f06b2505c
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # rocketjob mission control
2
- [![Gem Version](https://badge.fury.io/rb/rocketjob_mission_control.svg)](http://badge.fury.io/rb/rocketjob_mission_control) [![Build Status](https://secure.travis-ci.org/rocketjob/rocketjob_mission_control.png?branch=master)](http://travis-ci.org/rocketjob/rocketjob_mission_control) ![](http://ruby-gem-downloads-badge.herokuapp.com/rocketjob_mission_control)
1
+ # Rocket Job Mission Control
2
+ [![Gem Version](https://badge.fury.io/rb/rocketjob_mission_control.svg)](http://badge.fury.io/rb/rocketjob_mission_control) [![Build Status](https://secure.travis-ci.org/rocketjob/rocketjob_mission_control.png?branch=master)](http://travis-ci.org/rocketjob/rocketjob_mission_control)
3
3
 
4
- Web based management interface for [rocketjob][0].
4
+ Web based management interface for [Rocket Job][0].
5
5
 
6
6
  ![Screen shot](http://rocketjob.io/images/rjmc_running.png)
7
7
 
@@ -10,24 +10,24 @@ Web based management interface for [rocketjob][0].
10
10
  Production Ready
11
11
 
12
12
  Already in use in production processing large files with millions
13
- of records, as well as large jobs to walk though large databases.
13
+ of records, as well as large jobs to walk through large databases.
14
14
 
15
15
  ## Features
16
16
 
17
17
  Job Management
18
18
 
19
- * View all queued, running, failed, and running jobs
20
- * View all completed jobs where `destroy_on_complete == false`
21
- * Pause any running jobs
22
- * Resume paused jobs
23
- * Retry failed jobs
24
- * Abort, or fail queued or running jobs
25
- * Destroy a completed or aborted job
19
+ * View all queued, running, failed, and running jobs.
20
+ * View all completed jobs where `destroy_on_complete` is `false`.
21
+ * Pause any running jobs.
22
+ * Resume paused jobs.
23
+ * Retry failed jobs.
24
+ * Abort, or fail queued or running jobs.
25
+ * Destroy a completed or aborted job.
26
26
 
27
27
  Server Management
28
28
 
29
- * View running servers
30
- * Stop servers
29
+ * View running servers.
30
+ * Stop servers.
31
31
 
32
32
  Running Jobs
33
33
 
@@ -35,31 +35,30 @@ Running Jobs
35
35
 
36
36
  Directory Monitor Management
37
37
 
38
- * Create, update, enable, disable directory monitoring entries
38
+ * Create, update, enable, disable directory monitoring entries.
39
39
 
40
40
  ## Documentation
41
41
 
42
42
  * [Guide](http://rocketjob.io/mission_control)
43
43
 
44
- ## Rails 4 Installation
44
+ ## Rails Installation
45
45
 
46
46
  This gem is a Rails Engine and can be installed directly into existing Rails 4
47
- applications.
47
+ or 5 applications.
48
48
 
49
- Add the dependency to your Gemfile
49
+ Add to Gemfile:
50
50
 
51
51
  ```ruby
52
52
  gem 'rocketjob_mission_control'
53
53
  ```
54
54
 
55
- Install it...
55
+ Install:
56
56
 
57
57
  ```ruby
58
58
  bundle
59
59
  ```
60
60
 
61
- Add the following route to your application for accessing the interface,
62
- and retrying failed jobs.
61
+ Add the following route to `config/routes.rb`:
63
62
 
64
63
  ```ruby
65
64
  mount RocketJobMissionControl::Engine => 'rocketjob'
@@ -74,9 +73,6 @@ This project uses [Semantic Versioning](http://semver.org/).
74
73
  * [Michael Cloutier][1]
75
74
  * [Chris Lamb][2]
76
75
  * [Jonathan Whittington][4]
77
-
78
- ## Contributors
79
-
80
76
  * [Reid Morrison][3] :: @reidmorrison
81
77
 
82
78
  [0]: http://rocketjob.io
@@ -15,6 +15,7 @@
15
15
  //= require dataTables/jquery.dataTables
16
16
  //= require dataTables/extras/dataTables.responsive
17
17
  //= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
18
+ //= require bootstrap-sprockets
18
19
  //
19
20
  // Selectize is used by Array builder in application_helper#editable_field_html
20
21
  //= require microplugin
@@ -257,9 +257,13 @@ table.dataTable thead > tr > th {
257
257
  left: 50%;
258
258
  margin-left: -96px !important;
259
259
  display: block;
260
+
260
261
  img {
261
262
  display: inline;
262
263
  height: 40px;
264
+ position: relative;
265
+ bottom: 3px;
266
+ left: 8px;
263
267
  }
264
268
  }
265
269
 
@@ -267,10 +271,10 @@ table.dataTable thead > tr > th {
267
271
  .last { right: 15px; }
268
272
 
269
273
  a.navbar-brand.brand {
270
- font-size: 36px;
274
+ font-size: 23px;
271
275
  color: white;
272
276
  font-weight: bold;
273
- margin-top: -10px;
277
+ top: -5px;
274
278
 
275
279
  span {
276
280
  display: inline-block;
@@ -1,7 +1,12 @@
1
1
  module RocketJobMissionControl
2
2
  class DirmonEntriesController < RocketJobMissionControl::ApplicationController
3
- before_filter :find_entry_or_redirect, except: [:index, :disabled, :enabled, :failed, :pending, :new, :create]
4
- before_filter :show_sidebar
3
+ if Rails.version.to_i < 5
4
+ before_filter :find_entry_or_redirect, except: [:index, :disabled, :enabled, :failed, :pending, :new, :create]
5
+ before_filter :show_sidebar
6
+ else
7
+ before_action :find_entry_or_redirect, except: [:index, :disabled, :enabled, :failed, :pending, :new, :create]
8
+ before_action :show_sidebar
9
+ end
5
10
 
6
11
  def index
7
12
  @data_table_url = dirmon_entries_url(format: 'json')
@@ -65,8 +70,7 @@ module RocketJobMissionControl
65
70
  if properties = params[:rocket_job_dirmon_entry][:properties]
66
71
  @dirmon_entry.properties = JobSanitizer.sanitize(properties, @dirmon_entry.job_class, @dirmon_entry, false)
67
72
  end
68
-
69
- if @dirmon_entry.errors.empty? && @dirmon_entry.valid? && @dirmon_entry.save
73
+ if @dirmon_entry.errors.empty? && @dirmon_entry.valid? && @dirmon_entry.update_attributes(dirmon_params)
70
74
  redirect_to(rocket_job_mission_control.dirmon_entry_path(@dirmon_entry))
71
75
  else
72
76
  render :edit
@@ -1,7 +1,12 @@
1
1
  module RocketJobMissionControl
2
2
  class JobsController < RocketJobMissionControl::ApplicationController
3
- before_filter :find_job_or_redirect, except: [:index, :aborted, :completed, :failed, :paused, :queued, :running, :scheduled]
4
- before_filter :show_sidebar
3
+ if Rails.version.to_i < 5
4
+ before_filter :find_job_or_redirect, except: [:index, :aborted, :completed, :failed, :paused, :queued, :running, :scheduled]
5
+ before_filter :show_sidebar
6
+ else
7
+ before_action :find_job_or_redirect, except: [:index, :aborted, :completed, :failed, :paused, :queued, :running, :scheduled]
8
+ before_action :show_sidebar
9
+ end
5
10
  rescue_from StandardError, with: :error_occurred
6
11
 
7
12
  def index
@@ -1,7 +1,12 @@
1
1
  module RocketJobMissionControl
2
2
  class ServersController < RocketJobMissionControl::ApplicationController
3
- before_filter :find_server_or_redirect, only: [:stop, :pause, :resume, :destroy]
4
- before_filter :show_sidebar
3
+ if Rails.version.to_i < 5
4
+ before_filter :find_server_or_redirect, only: [:stop, :pause, :resume, :destroy]
5
+ before_filter :show_sidebar
6
+ else
7
+ before_action :find_server_or_redirect, only: [:stop, :pause, :resume, :destroy]
8
+ before_action :show_sidebar
9
+ end
5
10
 
6
11
  def index
7
12
  @data_table_url = servers_url(format: 'json')
@@ -16,7 +16,7 @@ module RocketJobMissionControl
16
16
  draw: params[:draw].to_i,
17
17
  recordsTotal: query.unfiltered_count,
18
18
  recordsFiltered: query.count,
19
- data: query.query.collect{|record| map(record)}
19
+ data: query.query.collect { |record| map(record) }
20
20
  }
21
21
  end
22
22
 
@@ -1,28 +1,28 @@
1
1
  module RocketJobMissionControl
2
2
  class JobsDatatable < AbstractDatatable
3
3
  delegate :job_path, :job_icon, :edit_job_path,
4
- :abort_job_path, :job_path, :fail_job_path, :run_now_job_path, :pause_job_path,
5
- :resume_job_path, :retry_job_path, :exception_job_path, :job_action_link, :exceptions_job_path, to: :@view
4
+ :abort_job_path, :job_path, :fail_job_path, :run_now_job_path, :pause_job_path,
5
+ :resume_job_path, :retry_job_path, :exception_job_path, :job_action_link, :exceptions_job_path, to: :@view
6
6
 
7
7
  COMMON_FIELDS = [:id, :_type, :description, :completed_at, :created_at, :started_at, :state].freeze
8
8
 
9
- ABORTED_COLUMNS = [
9
+ ABORTED_COLUMNS = [
10
10
  {display: 'Class', value: :class_with_link, field: '_type', width: '30%'},
11
11
  {display: 'Description', value: :description, field: 'description', width: '30%'},
12
12
  {display: 'Aborted', value: :completed_ago, field: 'completed_at'},
13
13
  {display: 'Actions', value: :action_buttons, orderable: false}
14
14
  ]
15
15
 
16
- ALL_COLUMNS = [
16
+ ALL_COLUMNS = [
17
17
  {display: 'Class', value: :class_with_link, field: '_type'},
18
18
  {display: 'Description', value: :description, field: 'description'},
19
19
  {display: 'Created', value: :created_at, field: 'created_at'},
20
20
  {display: 'Duration', value: :duration, field: 'duration', orderable: false},
21
21
  {display: 'Actions', value: :action_buttons, orderable: false}
22
22
  ]
23
- ALL_FIELDS = COMMON_FIELDS + [:run_at].freeze
23
+ ALL_FIELDS = COMMON_FIELDS + [:run_at].freeze
24
24
 
25
- COMPLETED_COLUMNS = [
25
+ COMPLETED_COLUMNS = [
26
26
  {display: 'Class', value: :class_with_link, field: '_type', width: '30%'},
27
27
  {display: 'Description', value: :description, field: 'description', width: '30%'},
28
28
  {display: 'Duration', value: :duration, field: 'duration', orderable: false},
@@ -36,16 +36,16 @@ module RocketJobMissionControl
36
36
  PAUSED_COLUMNS = ABORTED_COLUMNS.deep_dup
37
37
  PAUSED_COLUMNS[2][:display] = 'Paused'
38
38
 
39
- QUEUED_COLUMNS = [
39
+ QUEUED_COLUMNS = [
40
40
  {display: 'Class', value: :class_with_link, field: '_type'},
41
41
  {display: 'Description', value: :description, field: 'description'},
42
42
  {display: 'Priority', value: :priority, field: 'priority'},
43
43
  {display: 'Queued For', value: :duration, field: 'duration', orderable: false},
44
44
  {display: 'Actions', value: :action_buttons, orderable: false}
45
45
  ]
46
- QUEUED_FIELDS = COMMON_FIELDS + [:run_at, :priority].freeze
46
+ QUEUED_FIELDS = COMMON_FIELDS + [:run_at, :priority].freeze
47
47
 
48
- RUNNING_COLUMNS = [
48
+ RUNNING_COLUMNS = [
49
49
  {display: 'Class', value: :class_with_link, field: '_type'},
50
50
  {display: 'Description', value: :description, field: 'description'},
51
51
  {display: 'Progress', value: :progress, field: 'percent_complete', orderable: false},
@@ -53,16 +53,16 @@ module RocketJobMissionControl
53
53
  {display: 'Started', value: :started, field: 'started_at'},
54
54
  {display: 'Actions', value: :action_buttons, orderable: false}
55
55
  ]
56
- RUNNING_FIELDS = COMMON_FIELDS + [:record_count, :collect_output, :input_categories, :output_categories, :encrypt, :compress, :slice_size, :priority, :sub_state, :percent_complete].freeze
56
+ RUNNING_FIELDS = COMMON_FIELDS + [:record_count, :collect_output, :input_categories, :output_categories, :encrypt, :compress, :slice_size, :priority, :sub_state, :percent_complete].freeze
57
57
 
58
- SCHEDULED_COLUMNS = [
58
+ SCHEDULED_COLUMNS = [
59
59
  {display: 'Class', value: :class_with_link, field: '_type'},
60
60
  {display: 'Description', value: :description, field: 'description'},
61
61
  {display: 'Runs in', value: :time_till_run, field: 'run_at'},
62
62
  {display: 'Cron Schedule', value: :cron_schedule, field: 'cron_schedule'},
63
63
  {display: 'Actions', value: :action_buttons, orderable: false}
64
64
  ]
65
- SCHEDULED_FIELDS = COMMON_FIELDS + [:run_at, :cron_schedule].freeze
65
+ SCHEDULED_FIELDS = COMMON_FIELDS + [:run_at, :cron_schedule].freeze
66
66
 
67
67
  def initialize(view, query, columns)
68
68
  @columns = columns
@@ -78,10 +78,10 @@ module RocketJobMissionControl
78
78
  # Map the values for each column
79
79
  def map(job)
80
80
  index = 0
81
- h = {}
81
+ h = {}
82
82
  @columns.each do |column|
83
83
  h[index.to_s] = send(column[:value], job)
84
- index += 1
84
+ index += 1
85
85
  end
86
86
  h['DT_RowClass'] = "card callout callout-#{job.state}"
87
87
  h
@@ -2,7 +2,7 @@ module RocketJobMissionControl
2
2
  class Query
3
3
  attr_reader :scope
4
4
  attr_accessor :search_term, :order_by, :start, :page_size,
5
- :search_columns, :display_columns
5
+ :search_columns, :display_columns
6
6
 
7
7
  def initialize(scope, order_by = nil)
8
8
  @scope = scope
@@ -12,7 +12,7 @@
12
12
  <% end %>
13
13
  </ul>
14
14
  <% else %>
15
- <%= msg.html_safe %>
15
+ <%= msg.to_s.html_safe %>
16
16
  <% end %>
17
17
  </div>
18
18
  <% end %>
@@ -8,7 +8,7 @@
8
8
  <span class="icon-bar"></span>
9
9
  </button>
10
10
  <a class="navbar-brand brand" href="http://rocketjob.io" target="_blank">
11
- <img src="/assets/rocket_job_mission_control/rocket-icon-64x64.png" alt="Rocket icon 64x64">
11
+ <%= image_tag('rocket_job_mission_control/rocket-icon-64x64.png') %>
12
12
  Rocket Job
13
13
  </a>
14
14
  </div>
@@ -1,23 +1,23 @@
1
1
  <% status = job.status(Time.zone) %>
2
- <div class="id"><label>ID:</label><%= status.delete('_id') %></div>
2
+ <div class="id"><label>ID:</label> <%= status.delete('_id') %></div>
3
3
 
4
4
  <% if description = status.delete('description') %>
5
- <div class="status-message"><label>Description:</label><%= description %></div>
5
+ <div class="status-message"><label>Description:</label> <%= description %></div>
6
6
  <% end %>
7
7
  <% if duration = status.delete('duration') %>
8
- <div class="status-message"><label>Duration:</label><%= duration %></div>
8
+ <div class="status-message"><label>Duration:</label> <%= duration %></div>
9
9
  <% end %>
10
10
  <% if record_count = status.delete('record_count') %>
11
- <div class="status-message"><label>Record Count:</label><%= record_count %></div>
11
+ <div class="status-message"><label>Record Count:</label> <%= record_count %></div>
12
12
  <% end %>
13
13
 
14
- <div class="created_at"><label>Created At:</label><%= status.delete('created_at') %></div>
14
+ <div class="created_at"><label>Created At:</label> <%= status.delete('created_at') %></div>
15
15
 
16
16
  <% if started_at = status.delete('started_at') %>
17
- <div class="status-message"><label>Started At:</label><%= started_at %></div>
17
+ <div class="status-message"><label>Started At:</label> <%= started_at %></div>
18
18
  <% end %>
19
19
  <% if percent_complete = status.delete('percent_complete') %>
20
- <div class="status-message"><label>% Complete:</label><%= percent_complete %></div>
20
+ <div class="status-message"><label>% Complete:</label> <%= percent_complete %></div>
21
21
  <% end %>
22
22
 
23
23
  <%
@@ -29,7 +29,7 @@
29
29
  next
30
30
  end
31
31
  %>
32
- <div class="status-message"><label><%= key.to_s.titleize %>:</label><%= value %></div>
32
+ <div class="status-message"><label><%= key.to_s.titleize %>:</label> <%= value %></div>
33
33
  <% end %>
34
34
 
35
35
  <div class="clearfix"></div>
@@ -1,3 +1,4 @@
1
+ #@formatter:off
1
2
  RocketJobMissionControl::Engine.routes.draw do
2
3
 
3
4
  resources :jobs, only: [:index, :show, :update, :destroy, :edit] do
@@ -1,3 +1,3 @@
1
1
  module RocketJobMissionControl
2
- VERSION = '3.0.1'
2
+ VERSION = '3.0.2'
3
3
  end
@@ -37,11 +37,9 @@ module RocketJobMissionControl
37
37
  describe 'PATCH #enable' do
38
38
  describe 'when transition is allowed' do
39
39
  before do
40
- if Rails.version.to_i >= 5
41
- patch :enable, params: {id: existing_dirmon_entry.id}
42
- else
43
- patch :enable, id: existing_dirmon_entry.id
44
- end
40
+ params = {id: existing_dirmon_entry.id}
41
+ params = {params: params} if Rails.version.to_i >= 5
42
+ patch :enable, params
45
43
  end
46
44
 
47
45
  it do
@@ -56,11 +54,9 @@ module RocketJobMissionControl
56
54
  describe 'when transition is not allowed' do
57
55
  before do
58
56
  existing_dirmon_entry.enable!
59
- if Rails.version.to_i >= 5
60
- patch :enable, params: {id: existing_dirmon_entry.id}
61
- else
62
- patch :enable, id: existing_dirmon_entry.id
63
- end
57
+ params = {id: existing_dirmon_entry.id}
58
+ params = {params: params} if Rails.version.to_i >= 5
59
+ patch :enable, params
64
60
  end
65
61
 
66
62
  it 'succeeds' do
@@ -77,11 +73,9 @@ module RocketJobMissionControl
77
73
  describe 'when transition is allowed' do
78
74
  before do
79
75
  existing_dirmon_entry.enable!
80
- if Rails.version.to_i >= 5
81
- patch :disable, params: {id: existing_dirmon_entry.id}
82
- else
83
- patch :disable, id: existing_dirmon_entry.id
84
- end
76
+ params = {id: existing_dirmon_entry.id}
77
+ params = {params: params} if Rails.version.to_i >= 5
78
+ patch :disable, params
85
79
  end
86
80
 
87
81
  it do
@@ -95,11 +89,9 @@ module RocketJobMissionControl
95
89
 
96
90
  describe 'when transition is not allowed' do
97
91
  before do
98
- if Rails.version.to_i >= 5
99
- patch :disable, params: {id: existing_dirmon_entry.id}
100
- else
101
- patch :disable, id: existing_dirmon_entry.id
102
- end
92
+ params = {id: existing_dirmon_entry.id}
93
+ params = {params: params} if Rails.version.to_i >= 5
94
+ patch :disable, params
103
95
  end
104
96
 
105
97
  it 'succeeds' do
@@ -116,11 +108,9 @@ module RocketJobMissionControl
116
108
  let(:entry_params) { {} }
117
109
 
118
110
  before do
119
- if Rails.version.to_i >= 5
120
- get :new, params: entry_params
121
- else
122
- get :new, entry_params
123
- end
111
+ params = entry_params
112
+ params = {params: entry_params} if Rails.version.to_i >= 5
113
+ get :new, params
124
114
  end
125
115
 
126
116
  it 'succeeds' do
@@ -173,11 +163,9 @@ module RocketJobMissionControl
173
163
  describe 'PATCH #update' do
174
164
  describe 'with valid parameters' do
175
165
  before do
176
- if Rails.version.to_i >= 5
177
- patch :update, params: {id: existing_dirmon_entry.id, rocket_job_dirmon_entry: {pattern: 'the_path2', job_class_name: job_class_name}}
178
- else
179
- patch :update, id: existing_dirmon_entry.id, rocket_job_dirmon_entry: {pattern: 'the_path2', job_class_name: job_class_name}
180
- end
166
+ params = {id: existing_dirmon_entry.id, rocket_job_dirmon_entry: {pattern: 'the_path2', job_class_name: job_class_name}}
167
+ params = {params: params} if Rails.version.to_i >= 5
168
+ patch :update, params
181
169
  end
182
170
 
183
171
  it 'redirects to the updated entry' do
@@ -185,27 +173,23 @@ module RocketJobMissionControl
185
173
  end
186
174
 
187
175
  it 'updates the entry' do
188
- #follow_redirect!
189
- #assert_equal 'the_path2', existing_dirmon_entry.reload.pattern
176
+ assert_equal 'the_path2', existing_dirmon_entry.reload.pattern
190
177
  end
191
178
  end
192
179
 
193
180
  describe 'with invalid parameters' do
194
181
  before do
195
- if Rails.version.to_i >= 5
196
- patch :update, params: {id: existing_dirmon_entry.id, rocket_job_dirmon_entry: {job_class_name: 'FakeAndBadJob'}}
197
- else
198
- patch :update, id: existing_dirmon_entry.id, rocket_job_dirmon_entry: {job_class_name: 'FakeAndBadJob'}
199
- end
182
+ params = {id: existing_dirmon_entry.id, rocket_job_dirmon_entry: {job_class_name: 'FakeAndBadJob'}}
183
+ params = {params: params} if Rails.version.to_i >= 5
184
+ patch :update, params
200
185
  end
201
186
 
202
187
  it 'renders the edit template' do
203
- assert_redirected_to dirmon_entry_path(existing_dirmon_entry)
188
+ assert_response :success
204
189
  end
205
190
 
206
191
  it 'alerts the user' do
207
- #follow_redirect!
208
- #assert_select 'div.message', "job_class_name: #{I18n.t(:failure, scope: [:dirmon_entry, :disable])}"
192
+ assert_select 'div.message', "job_class_name: [\"job_class_name must be defined and must be derived from RocketJob::Job\"]"
209
193
  end
210
194
  end
211
195
  end
@@ -222,11 +206,9 @@ module RocketJobMissionControl
222
206
  end
223
207
 
224
208
  before do
225
- if Rails.version.to_i >= 5
226
- post :create, params: {rocket_job_dirmon_entry: dirmon_params}
227
- else
228
- post :create, rocket_job_dirmon_entry: dirmon_params
229
- end
209
+ params = {rocket_job_dirmon_entry: dirmon_params}
210
+ params = {params: params} if Rails.version.to_i >= 5
211
+ post :create, params
230
212
  end
231
213
 
232
214
  it 'creates the entry' do
@@ -265,11 +247,9 @@ module RocketJobMissionControl
265
247
  end
266
248
 
267
249
  before do
268
- if Rails.version.to_i >= 5
269
- post :create, params: {rocket_job_dirmon_entry: dirmon_params}
270
- else
271
- post :create, rocket_job_dirmon_entry: dirmon_params
272
- end
250
+ params = {rocket_job_dirmon_entry: dirmon_params}
251
+ params = {params: params} if Rails.version.to_i >= 5
252
+ post :create, params
273
253
  end
274
254
 
275
255
  describe 'on model attributes' do
@@ -287,11 +267,9 @@ module RocketJobMissionControl
287
267
 
288
268
  describe 'GET #edit' do
289
269
  before do
290
- if Rails.version.to_i >= 5
291
- get :edit, params: {id: existing_dirmon_entry.id}
292
- else
293
- get :edit, id: existing_dirmon_entry.id
294
- end
270
+ params = {id: existing_dirmon_entry.id}
271
+ params = {params: params} if Rails.version.to_i >= 5
272
+ get :edit, params
295
273
  end
296
274
 
297
275
  it 'succeeds' do
@@ -306,11 +284,9 @@ module RocketJobMissionControl
306
284
  describe 'GET #show' do
307
285
  describe 'with an invalid id' do
308
286
  before do
309
- if Rails.version.to_i >= 5
310
- get :show, params: {id: 42}
311
- else
312
- get :show, id: 42
313
- end
287
+ params = {id: 42}
288
+ params = {params: params} if Rails.version.to_i >= 5
289
+ get :show, params
314
290
  end
315
291
 
316
292
  it 'redirects' do
@@ -324,11 +300,9 @@ module RocketJobMissionControl
324
300
 
325
301
  describe 'with a valid id' do
326
302
  before do
327
- if Rails.version.to_i >= 5
328
- get :show, params: {id: existing_dirmon_entry.id}
329
- else
330
- get :show, id: existing_dirmon_entry.id
331
- end
303
+ params = {id: existing_dirmon_entry.id}
304
+ params = {params: params} if Rails.version.to_i >= 5
305
+ get :show, params
332
306
  end
333
307
 
334
308
  it 'succeeds' do
@@ -344,11 +318,9 @@ module RocketJobMissionControl
344
318
  describe 'DELETE #destroy' do
345
319
  describe 'with a valid id' do
346
320
  before do
347
- if Rails.version.to_i >= 5
348
- delete :destroy, params: {id: existing_dirmon_entry.id}
349
- else
350
- delete :destroy, id: existing_dirmon_entry.id
351
- end
321
+ params = {id: existing_dirmon_entry.id}
322
+ params = {params: params} if Rails.version.to_i >= 5
323
+ delete :destroy, params
352
324
  end
353
325
 
354
326
  it 'redirects to index' do
@@ -3,6 +3,15 @@ require_relative '../../compare_hashes'
3
3
 
4
4
  module RocketJobMissionControl
5
5
  class JobsControllerTest < ActionController::TestCase
6
+
7
+ class PausableJob < RocketJob::Job
8
+ self.pausable = true
9
+
10
+ def perform
11
+ 21
12
+ end
13
+ end
14
+
6
15
  describe JobsController do
7
16
  before do
8
17
  RocketJob::Job.delete_all
@@ -12,6 +21,10 @@ module RocketJobMissionControl
12
21
  RocketJob::Jobs::SimpleJob.create!
13
22
  end
14
23
 
24
+ let :pausable_job do
25
+ PausableJob.create!
26
+ end
27
+
15
28
  let :failed_job do
16
29
  job = KaboomBatchJob.new(slice_size: 1)
17
30
  job.upload do |stream|
@@ -44,7 +57,9 @@ module RocketJobMissionControl
44
57
  describe "PATCH ##{state}" do
45
58
  describe 'with an invalid job id' do
46
59
  before do
47
- patch state, id: 42, job: {id: 42, priority: 12}
60
+ params = {id: 42, job: {id: 42, priority: 12}}
61
+ params = {params: params} if Rails.version.to_i >= 5
62
+ patch state, params
48
63
  end
49
64
 
50
65
  it 'redirects' do
@@ -60,21 +75,23 @@ module RocketJobMissionControl
60
75
  before do
61
76
  case state
62
77
  when :pause, :fail, :abort
63
- job.start!
78
+ pausable_job.start!
64
79
  when :resume
65
- job.pause!
80
+ pausable_job.pause!
66
81
  when :retry
67
- job.fail!
82
+ pausable_job.fail!
68
83
  end
69
- patch state, id: job.id, job: {id: job.id, priority: job.priority}
84
+ params = {id: pausable_job.id, job: {id: pausable_job.id, priority: pausable_job.priority}}
85
+ params = {params: params} if Rails.version.to_i >= 5
86
+ patch state, params
70
87
  end
71
88
 
72
89
  it 'redirects to the job' do
73
- assert_redirected_to job_path(job.id)
90
+ assert_redirected_to job_path(pausable_job.id)
74
91
  end
75
92
 
76
93
  it 'transitions the job' do
77
- refute_equal state, job.state
94
+ refute_equal state, pausable_job.state
78
95
  end
79
96
  end
80
97
  end
@@ -84,7 +101,9 @@ module RocketJobMissionControl
84
101
  let(:scheduled_job) { RocketJob::Jobs::SimpleJob.create!(run_at: 2.days.from_now) }
85
102
 
86
103
  before do
87
- patch :run_now, id: scheduled_job.id
104
+ params = {id: scheduled_job.id}
105
+ params = {params: params} if Rails.version.to_i >= 5
106
+ patch :run_now, params
88
107
  end
89
108
 
90
109
  it 'redirects to the job path' do
@@ -100,7 +119,9 @@ module RocketJobMissionControl
100
119
  describe "PATCH #update" do
101
120
  describe 'with an invalid job id' do
102
121
  before do
103
- patch :update, id: 42, job: {id: 42, priority: 12}
122
+ params = {id: 42, job: {id: 42, priority: 12}}
123
+ params = {params: params} if Rails.version.to_i >= 5
124
+ patch :update, params
104
125
  end
105
126
 
106
127
  it 'redirects' do
@@ -114,7 +135,9 @@ module RocketJobMissionControl
114
135
 
115
136
  describe "with a valid job id" do
116
137
  before do
117
- patch :update, id: job.id, job: {id: job.id, priority: 12, blah: 23, description: '', log_level: '', state: 'failed'}
138
+ params = {id: job.id, job: {id: job.id, priority: 12, blah: 23, description: '', log_level: '', state: 'failed'}}
139
+ params = {params: params} if Rails.version.to_i >= 5
140
+ patch :update, params
118
141
  end
119
142
 
120
143
  it 'redirects to the job' do
@@ -137,7 +160,9 @@ module RocketJobMissionControl
137
160
  describe 'GET #show' do
138
161
  describe 'with an invalid job id' do
139
162
  before do
140
- get :show, id: 42
163
+ params = {id: 42}
164
+ params = {params: params} if Rails.version.to_i >= 5
165
+ get :show, params
141
166
  end
142
167
 
143
168
  it 'redirects' do
@@ -151,7 +176,9 @@ module RocketJobMissionControl
151
176
 
152
177
  describe "with a valid job id" do
153
178
  before do
154
- get :show, id: job.id
179
+ params = {id: job.id}
180
+ params = {params: params} if Rails.version.to_i >= 5
181
+ get :show, params
155
182
  end
156
183
 
157
184
  it 'succeeds' do
@@ -167,7 +194,9 @@ module RocketJobMissionControl
167
194
  describe 'GET #exception' do
168
195
  describe 'with an invalid job id' do
169
196
  before do
170
- get :exception, id: 42
197
+ params = {id: 42}
198
+ params = {params: params} if Rails.version.to_i >= 5
199
+ get :exception, params
171
200
  end
172
201
 
173
202
  it 'redirects' do
@@ -181,13 +210,14 @@ module RocketJobMissionControl
181
210
 
182
211
  describe 'with a valid job id' do
183
212
  before do
184
- skip 'Only tested with Rocket Job Pro' unless defined?(RocketJob::Plugins::Batch)
185
- get :exception, id: failed_job.id, error_type: 'Blah'
213
+ skip('Only tested with Rocket Job Pro') unless defined?(RocketJob::Plugins::Batch)
186
214
  end
187
215
 
188
216
  describe 'without an exception' do
189
217
  before do
190
- get :exception, id: failed_job.id, error_type: 'Blah'
218
+ params = {id: failed_job.id, error_type: 'Blah'}
219
+ params = {params: params} if Rails.version.to_i >= 5
220
+ get :exception, params
191
221
  end
192
222
 
193
223
  it 'redirects to job path' do
@@ -201,7 +231,9 @@ module RocketJobMissionControl
201
231
 
202
232
  describe 'with exception' do
203
233
  before do
204
- get :exception, id: failed_job.id, error_type: 'ArgumentError'
234
+ params = {id: failed_job.id, error_type: 'ArgumentError'}
235
+ params = {params: params} if Rails.version.to_i >= 5
236
+ get :exception, params
205
237
  end
206
238
 
207
239
  it 'succeeds' do
@@ -31,7 +31,9 @@ module RocketJobMissionControl
31
31
  describe 'with a valid server id' do
32
32
  before do
33
33
  server.pause! if server_action == :resume
34
- patch server_action, id: server.id
34
+ params = {id: server.id}
35
+ params = {params: params} if Rails.version.to_i >= 5
36
+ patch server_action, params
35
37
  end
36
38
 
37
39
  it 'redirects to servers' do
@@ -48,7 +50,9 @@ module RocketJobMissionControl
48
50
  before do
49
51
  server.pause! if server_action == :pause
50
52
  server.stop! if server_action == :stop
51
- patch server_action, id: server.id
53
+ params = {id: server.id}
54
+ params = {params: params} if Rails.version.to_i >= 5
55
+ patch server_action, params
52
56
  end
53
57
 
54
58
  it 'redirects to servers' do
@@ -66,7 +70,9 @@ module RocketJobMissionControl
66
70
  RocketJobMissionControl::ServersController::VALID_ACTIONS.each do |server_action, action_message|
67
71
  describe "with '#{server_action}' as the server_action param" do
68
72
  before do
69
- patch :update_all, server_action: server_action
73
+ params = {server_action: server_action}
74
+ params = {params: params} if Rails.version.to_i >= 5
75
+ patch :update_all, params
70
76
  end
71
77
 
72
78
  it 'redirects to servers' do
@@ -81,7 +87,9 @@ module RocketJobMissionControl
81
87
 
82
88
  describe 'with an invalid server_action param' do
83
89
  before do
84
- patch :update_all, server_action: :bad_server_action
90
+ params = {server_action: :bad_server_action}
91
+ params = {params: params} if Rails.version.to_i >= 5
92
+ patch :update_all, params
85
93
  end
86
94
 
87
95
  it 'redirects to servers' do
@@ -101,7 +109,9 @@ module RocketJobMissionControl
101
109
  describe 'DELETE #destroy' do
102
110
  describe 'with a valid server id' do
103
111
  before do
104
- delete :destroy, id: server.id
112
+ params = {id: server.id}
113
+ params = {params: params} if Rails.version.to_i >= 5
114
+ delete :destroy, params
105
115
  end
106
116
 
107
117
  it 'redirects to servers' do
@@ -119,7 +129,9 @@ module RocketJobMissionControl
119
129
 
120
130
  describe 'when the server is not found' do
121
131
  before do
122
- delete :destroy, id: 999999
132
+ params = {id: 999999}
133
+ params = {params: params} if Rails.version.to_i >= 5
134
+ delete :destroy, params
123
135
  end
124
136
 
125
137
  it 'redirects to servers' do
@@ -192,7 +204,7 @@ module RocketJobMissionControl
192
204
 
193
205
  it 'succeeds' do
194
206
  assert_response :success
195
- json = JSON.parse(response.body)
207
+ json = JSON.parse(response.body)
196
208
  expected_data = {
197
209
  starting: {
198
210
  "0" => /#{RocketJob::Server.starting.first.name}/,
@@ -16,11 +16,11 @@ module RocketJobMissionControl
16
16
 
17
17
  describe 'when not encrypted' do
18
18
  it "does not return 'encrypted'" do
19
- refute_equal 'encrypted', display_slice_info([1,2], false)
19
+ refute_equal 'encrypted', display_slice_info([1, 2], false)
20
20
  end
21
21
 
22
22
  it "displays the slice info" do
23
- assert_equal "[<br /> 1,<br /> 2<br />]", display_slice_info([1,2], false)
23
+ assert_equal "[<br /> 1,<br /> 2<br />]", display_slice_info([1, 2], false)
24
24
  end
25
25
  end
26
26
 
@@ -21,15 +21,15 @@ class JobSanitizerTest < Minitest::Test
21
21
  cleansed = RocketJobMissionControl::JobSanitizer.sanitize(properties, @job.class, @job, false)
22
22
  assert_equal 0, @job.errors.count
23
23
  assert_equal 3, cleansed.count
24
- assert_equal({:string=>"hello", :integer=>"12", :symbol=>"name"}, cleansed)
24
+ assert_equal({:string => "hello", :integer => "12", :symbol => "name"}, cleansed)
25
25
  end
26
26
 
27
27
  it 'strips blank values' do
28
28
  properties = {
29
- string: '',
30
- integer: '',
31
- symbol: '',
32
- secure: 'Not permissible',
29
+ string: '',
30
+ integer: '',
31
+ symbol: '',
32
+ secure: 'Not permissible',
33
33
  log_level: ''
34
34
  }
35
35
  cleansed = RocketJobMissionControl::JobSanitizer.sanitize(properties, @job.class, @job, false)
@@ -39,11 +39,11 @@ class JobSanitizerTest < Minitest::Test
39
39
 
40
40
  it 'nils blank values' do
41
41
  properties = {
42
- string: '',
43
- integer: '',
44
- symbol: '',
45
- hash: '',
46
- secure: 'Not permissible',
42
+ string: '',
43
+ integer: '',
44
+ symbol: '',
45
+ hash: '',
46
+ secure: 'Not permissible',
47
47
  log_level: ''
48
48
  }
49
49
  cleansed = RocketJobMissionControl::JobSanitizer.sanitize(properties, @job.class, @job, true)
@@ -54,9 +54,9 @@ class JobSanitizerTest < Minitest::Test
54
54
 
55
55
  it 'parses JSON' do
56
56
  properties = {
57
- string: '',
58
- secure: 'Not permissible',
59
- hash: '{"state":"FL"}'
57
+ string: '',
58
+ secure: 'Not permissible',
59
+ hash: '{"state":"FL"}'
60
60
  }
61
61
  cleansed = RocketJobMissionControl::JobSanitizer.sanitize(properties, @job.class, @job, false)
62
62
  assert_equal 0, @job.errors.count
@@ -66,9 +66,9 @@ class JobSanitizerTest < Minitest::Test
66
66
 
67
67
  it 'sets the error for invalid JSON' do
68
68
  properties = {
69
- string: 'hello',
70
- secure: 'Not permissible',
71
- hash: '{ bad json }'
69
+ string: 'hello',
70
+ secure: 'Not permissible',
71
+ hash: '{ bad json }'
72
72
  }
73
73
  cleansed = RocketJobMissionControl::JobSanitizer.sanitize(properties, @job.class, @job, false)
74
74
  assert_equal 1, @job.errors.count
@@ -80,7 +80,7 @@ class JobSanitizerTest < Minitest::Test
80
80
 
81
81
  it 'Keeps empty JSON Hash' do
82
82
  properties = {
83
- hash: '{ }'
83
+ hash: '{ }'
84
84
  }
85
85
  cleansed = RocketJobMissionControl::JobSanitizer.sanitize(properties, @job.class, @job, false)
86
86
  assert_equal 0, @job.errors.count
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocketjob_mission_control
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Cloutier
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2017-03-07 00:00:00.000000000 Z
14
+ date: 2017-06-01 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -205,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
205
  version: '0'
206
206
  requirements: []
207
207
  rubyforge_project:
208
- rubygems_version: 2.6.8
208
+ rubygems_version: 2.6.11
209
209
  signing_key:
210
210
  specification_version: 4
211
211
  summary: Enterprise Batch Processing System for Ruby.