rocketjob_mission_control 4.3.0 → 5.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +12 -12
  3. data/app/controllers/rocket_job_mission_control/application_controller.rb +1 -2
  4. data/app/controllers/rocket_job_mission_control/dirmon_entries_controller.rb +20 -19
  5. data/app/controllers/rocket_job_mission_control/jobs_controller.rb +36 -35
  6. data/app/controllers/rocket_job_mission_control/servers_controller.rb +32 -38
  7. data/app/datatables/rocket_job_mission_control/abstract_datatable.rb +8 -6
  8. data/app/datatables/rocket_job_mission_control/active_workers_datatable.rb +5 -5
  9. data/app/datatables/rocket_job_mission_control/dirmon_entries_datatable.rb +4 -4
  10. data/app/datatables/rocket_job_mission_control/jobs_datatable.rb +55 -62
  11. data/app/datatables/rocket_job_mission_control/servers_datatable.rb +13 -14
  12. data/app/helpers/rocket_job_mission_control/application_helper.rb +42 -41
  13. data/app/helpers/rocket_job_mission_control/jobs_helper.rb +9 -10
  14. data/app/helpers/rocket_job_mission_control/pagination_helper.rb +1 -1
  15. data/app/helpers/rocket_job_mission_control/servers_helper.rb +6 -6
  16. data/app/helpers/rocket_job_mission_control/slices_helper.rb +2 -4
  17. data/app/models/rocket_job_mission_control/access_policy.rb +1 -2
  18. data/app/models/rocket_job_mission_control/authorization.rb +3 -2
  19. data/app/models/rocket_job_mission_control/job_sanitizer.rb +14 -17
  20. data/app/models/rocket_job_mission_control/query.rb +2 -5
  21. data/app/views/rocket_job_mission_control/jobs/_exceptions.html.erb +1 -1
  22. data/app/views/rocket_job_mission_control/jobs/edit_slice.html.erb +1 -1
  23. data/app/views/rocket_job_mission_control/servers/index.html.erb +2 -2
  24. data/config/initializers/assets.rb +5 -7
  25. data/config/locales/en.yml +3 -0
  26. data/config/routes.rb +20 -21
  27. data/lib/rocket_job_mission_control/engine.rb +8 -9
  28. data/lib/rocket_job_mission_control/version.rb +1 -1
  29. data/lib/rocketjob_mission_control.rb +1 -1
  30. data/test/compare_hashes.rb +1 -2
  31. data/test/controllers/rocket_job_mission_control/application_controller_test.rb +13 -13
  32. data/test/controllers/rocket_job_mission_control/dirmon_entries_controller_test.rb +107 -108
  33. data/test/controllers/rocket_job_mission_control/jobs_controller_test.rb +89 -93
  34. data/test/controllers/rocket_job_mission_control/servers_controller_test.rb +66 -103
  35. data/test/helpers/rocket_job_mission_control/application_helper_test.rb +13 -14
  36. data/test/helpers/rocket_job_mission_control/jobs_helper_test.rb +31 -31
  37. data/test/helpers/rocket_job_mission_control/pagination_helper_test.rb +7 -9
  38. data/test/helpers/rocket_job_mission_control/servers_helper_test.rb +15 -15
  39. data/test/helpers/rocket_job_mission_control/slices_helper_test.rb +8 -10
  40. data/test/models/rocket_job_mission_control/job_sanitizer_test.rb +39 -40
  41. data/test/models/rocket_job_mission_control/query_test.rb +26 -28
  42. data/test/test_helper.rb +12 -12
  43. metadata +28 -28
@@ -1,22 +1,20 @@
1
- require_relative '../../test_helper'
1
+ require_relative "../../test_helper"
2
2
 
3
3
  module RocketJobMissionControl
4
4
  class PaginationHelperTest < ActionView::TestCase
5
5
  describe PaginationHelper do
6
-
7
- describe '#page_nav_disabled_class' do
8
- describe 'when the current position equals the boundary' do
9
- it 'returns disabled' do
10
- assert_equal 'disabled', page_nav_disabled_class(0, 0)
6
+ describe "#page_nav_disabled_class" do
7
+ describe "when the current position equals the boundary" do
8
+ it "returns disabled" do
9
+ assert_equal "disabled", page_nav_disabled_class(0, 0)
11
10
  end
12
11
  end
13
12
 
14
- describe 'when the current position is NOT equal to the boundary' do
15
- it 'returns blank' do
13
+ describe "when the current position is NOT equal to the boundary" do
14
+ it "returns blank" do
16
15
  assert page_nav_disabled_class(4, 0).blank?
17
16
  end
18
17
  end
19
-
20
18
  end
21
19
  end
22
20
  end
@@ -1,12 +1,12 @@
1
- require_relative '../../test_helper'
1
+ require_relative "../../test_helper"
2
2
 
3
3
  module RocketJobMissionControl
4
4
  ServersHelper.include(RocketJobMissionControl::ApplicationHelper)
5
5
 
6
6
  class ServersHelperTest < ActionView::TestCase
7
7
  describe ServersHelper do
8
- describe '#server_card_class' do
9
- describe 'when the server is running' do
8
+ describe "#server_card_class" do
9
+ describe "when the server is running" do
10
10
  let(:server) do
11
11
  server = RocketJob::Server.new
12
12
  server.started
@@ -14,12 +14,12 @@ module RocketJobMissionControl
14
14
  server
15
15
  end
16
16
 
17
- it 'returns the correct class' do
18
- assert_equal 'callout-success', server_card_class(server)
17
+ it "returns the correct class" do
18
+ assert_equal "callout-success", server_card_class(server)
19
19
  end
20
20
  end
21
21
 
22
- describe 'when the server is a zombie' do
22
+ describe "when the server is a zombie" do
23
23
  let(:server) do
24
24
  server = RocketJob::Server.new
25
25
  server.started
@@ -27,14 +27,14 @@ module RocketJobMissionControl
27
27
  server
28
28
  end
29
29
 
30
- it 'returns the correct class' do
31
- assert_equal 'callout-zombie', server_card_class(server)
30
+ it "returns the correct class" do
31
+ assert_equal "callout-zombie", server_card_class(server)
32
32
  end
33
33
  end
34
34
  end
35
35
 
36
- describe '#server_icon' do
37
- describe 'when the server is running' do
36
+ describe "#server_icon" do
37
+ describe "when the server is running" do
38
38
  let(:server) do
39
39
  server = RocketJob::Server.new
40
40
  server.started
@@ -42,12 +42,12 @@ module RocketJobMissionControl
42
42
  server
43
43
  end
44
44
 
45
- it 'returns the correct class' do
46
- assert_equal 'fas fa-play running', server_icon(server)
45
+ it "returns the correct class" do
46
+ assert_equal "fas fa-play running", server_icon(server)
47
47
  end
48
48
  end
49
49
 
50
- describe 'when the server is a zombie' do
50
+ describe "when the server is a zombie" do
51
51
  let(:server) do
52
52
  server = RocketJob::Server.new
53
53
  server.started
@@ -55,8 +55,8 @@ module RocketJobMissionControl
55
55
  server
56
56
  end
57
57
 
58
- it 'returns the correct class' do
59
- assert_equal 'fas fa-hourglass zombie', server_icon(server)
58
+ it "returns the correct class" do
59
+ assert_equal "fas fa-hourglass zombie", server_icon(server)
60
60
  end
61
61
  end
62
62
  end
@@ -1,29 +1,27 @@
1
- require_relative '../../test_helper'
1
+ require_relative "../../test_helper"
2
2
 
3
3
  module RocketJobMissionControl
4
4
  SlicesHelper.include(RocketJobMissionControl::ApplicationHelper)
5
5
  class SlicesHelperTest < ActionView::TestCase
6
6
  describe SlicesHelper do
7
+ describe "#display_slice_info" do
8
+ let(:slice) { {id: 42, name: "test"} }
7
9
 
8
- describe '#display_slice_info' do
9
- let(:slice) { {id: 42, name: 'test'} }
10
-
11
- describe 'when encrypted' do
12
- it 'only shows encrypted text' do
13
- assert_equal 'encrypted', display_slice_info(slice, true)
10
+ describe "when encrypted" do
11
+ it "only shows encrypted text" do
12
+ assert_equal "encrypted", display_slice_info(slice, true)
14
13
  end
15
14
  end
16
15
 
17
- describe 'when not encrypted' do
16
+ describe "when not encrypted" do
18
17
  it "does not return 'encrypted'" do
19
- refute_equal 'encrypted', display_slice_info([1, 2], false)
18
+ refute_equal "encrypted", display_slice_info([1, 2], false)
20
19
  end
21
20
 
22
21
  it "displays the slice info" do
23
22
  assert_equal "[<br /> 1,<br /> 2<br />]", display_slice_info([1, 2], false)
24
23
  end
25
24
  end
26
-
27
25
  end
28
26
  end
29
27
  end
@@ -1,4 +1,4 @@
1
- require_relative '../../test_helper'
1
+ require_relative "../../test_helper"
2
2
 
3
3
  class JobSanitizerTest < Minitest::Test
4
4
  describe RocketJobMissionControl::JobSanitizer do
@@ -10,83 +10,82 @@ class JobSanitizerTest < Minitest::Test
10
10
  after do
11
11
  end
12
12
 
13
- describe '.sanitize' do
14
- it 'passes permissible fields' do
13
+ describe ".sanitize" do
14
+ it "passes permissible fields" do
15
15
  properties = {
16
- string: 'hello',
17
- integer: '12',
18
- symbol: 'name',
19
- secure: 'Not permissible'
16
+ string: "hello",
17
+ integer: "12",
18
+ symbol: "name",
19
+ secure: "Not permissible"
20
20
  }
21
- cleansed = RocketJobMissionControl::JobSanitizer.sanitize(properties, @job.class, @job, false)
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
- it 'strips blank values' do
27
+ it "strips blank values" do
28
28
  properties = {
29
- string: '',
30
- integer: '',
31
- symbol: '',
32
- secure: 'Not permissible',
33
- log_level: ''
29
+ string: "",
30
+ integer: "",
31
+ symbol: "",
32
+ secure: "Not permissible",
33
+ log_level: ""
34
34
  }
35
- cleansed = RocketJobMissionControl::JobSanitizer.sanitize(properties, @job.class, @job, false)
35
+ cleansed = RocketJobMissionControl::JobSanitizer.sanitize(properties, @job.class, @job, false)
36
36
  assert_equal 0, @job.errors.count
37
37
  assert_equal 0, cleansed.count
38
38
  end
39
39
 
40
- it 'nils blank values' do
40
+ it "nils blank values" do
41
41
  properties = {
42
- string: '',
43
- integer: '',
44
- symbol: '',
45
- hash_field: '',
46
- secure: 'Not permissible',
47
- log_level: ''
42
+ string: "",
43
+ integer: "",
44
+ symbol: "",
45
+ hash_field: "",
46
+ secure: "Not permissible",
47
+ log_level: ""
48
48
  }
49
- cleansed = RocketJobMissionControl::JobSanitizer.sanitize(properties, @job.class, @job, true)
49
+ cleansed = RocketJobMissionControl::JobSanitizer.sanitize(properties, @job.class, @job, true)
50
50
  assert_equal 0, @job.errors.count, @job.errors
51
51
  assert_equal 5, cleansed.count
52
52
  assert_equal({log_level: nil, hash_field: nil, integer: nil, string: nil, symbol: nil}, cleansed)
53
53
  end
54
54
 
55
- it 'parses JSON' do
55
+ it "parses JSON" do
56
56
  properties = {
57
- string: '',
58
- secure: 'Not permissible',
57
+ string: "",
58
+ secure: "Not permissible",
59
59
  hash_field: '{"state":"FL"}'
60
60
  }
61
- cleansed = RocketJobMissionControl::JobSanitizer.sanitize(properties, @job.class, @job, false)
61
+ cleansed = RocketJobMissionControl::JobSanitizer.sanitize(properties, @job.class, @job, false)
62
62
  assert_equal 0, @job.errors.count
63
63
  assert_equal 1, cleansed.count
64
- assert_equal({'state' => 'FL'}, cleansed[:hash_field])
64
+ assert_equal({"state" => "FL"}, cleansed[:hash_field])
65
65
  end
66
66
 
67
- it 'sets the error for invalid JSON' do
67
+ it "sets the error for invalid JSON" do
68
68
  properties = {
69
- string: 'hello',
70
- secure: 'Not permissible',
71
- hash_field: '{ bad json }'
69
+ string: "hello",
70
+ secure: "Not permissible",
71
+ hash_field: "{ bad json }"
72
72
  }
73
- cleansed = RocketJobMissionControl::JobSanitizer.sanitize(properties, @job.class, @job, false)
73
+ cleansed = RocketJobMissionControl::JobSanitizer.sanitize(properties, @job.class, @job, false)
74
74
  assert_equal 1, @job.errors.count
75
75
  assert first = @job.errors.first
76
76
  assert_equal first.first, :properties
77
- assert first.second.include?('unexpected token'), first
78
- assert_equal({hash_field: "{ bad json }", string: 'hello'}, cleansed)
77
+ assert first.second.include?("unexpected token"), first
78
+ assert_equal({hash_field: "{ bad json }", string: "hello"}, cleansed)
79
79
  end
80
80
 
81
- it 'Keeps empty JSON Hash' do
81
+ it "Keeps empty JSON Hash" do
82
82
  properties = {
83
- hash_field: '{ }'
83
+ hash_field: "{ }"
84
84
  }
85
- cleansed = RocketJobMissionControl::JobSanitizer.sanitize(properties, @job.class, @job, false)
85
+ cleansed = RocketJobMissionControl::JobSanitizer.sanitize(properties, @job.class, @job, false)
86
86
  assert_equal 0, @job.errors.count
87
87
  assert_equal({hash_field: {}}, cleansed)
88
88
  end
89
89
  end
90
-
91
90
  end
92
91
  end
@@ -1,7 +1,6 @@
1
- require_relative '../../test_helper'
1
+ require_relative "../../test_helper"
2
2
 
3
3
  class QueryTest < Minitest::Test
4
-
5
4
  class NoopJob < RocketJob::Job
6
5
  field :record_count, type: Integer, default: 0
7
6
  def perform(record)
@@ -18,56 +17,56 @@ class QueryTest < Minitest::Test
18
17
  NoopJob.delete_all
19
18
  end
20
19
 
21
- describe '#query' do
22
- it 'sorts ascending by id' do
20
+ describe "#query" do
21
+ it "sorts ascending by id" do
23
22
  count = 0
24
23
  previous_id = nil
25
24
  RocketJobMissionControl::Query.new(NoopJob.all, _id: 1).query.each do |job|
26
25
  assert(previous_id < job.id, "Wrong sort order. #{previous_id} < #{job.id}") if previous_id
27
26
  previous_id = job.id
28
- count += 1
27
+ count += 1
29
28
  end
30
29
  assert_equal @jobs.count, count
31
30
  end
32
31
 
33
- it 'sorts descending by id' do
32
+ it "sorts descending by id" do
34
33
  count = 0
35
34
  previous_id = nil
36
35
  RocketJobMissionControl::Query.new(NoopJob.all, _id: -1).query.each do |job|
37
36
  assert(previous_id > job.id, "Wrong sort order. #{previous_id} > #{job.id}") if previous_id
38
37
  previous_id = job.id
39
- count += 1
38
+ count += 1
40
39
  end
41
40
  assert_equal @jobs.count, count
42
41
  end
43
42
 
44
- it 'sorts ascending by description' do
43
+ it "sorts ascending by description" do
45
44
  count = 0
46
45
  previous = nil
47
46
  RocketJobMissionControl::Query.new(NoopJob.all, description: 1).query.each do |job|
48
47
  assert(previous < job.description, "Wrong sort order. #{previous} < #{job.description}") if previous
49
48
  previous = job.description
50
- count += 1
49
+ count += 1
51
50
  end
52
51
  assert_equal @jobs.count, count
53
52
  end
54
53
 
55
- it 'sorts ascending by id with a search' do
54
+ it "sorts ascending by id with a search" do
56
55
  q = RocketJobMissionControl::Query.new(NoopJob.all, description: 1)
57
56
  q.search_columns << :description
58
- q.search_term = 'Job 1'
57
+ q.search_term = "Job 1"
59
58
 
60
59
  count = 0
61
60
  previous_id = nil
62
61
  q.query.each do |job|
63
62
  assert(previous_id < job.id, "Wrong sort order. #{previous_id} < #{job.id}") if previous_id
64
63
  previous_id = job.id
65
- count += 1
64
+ count += 1
66
65
  end
67
66
  assert_equal 2, count
68
67
  end
69
68
 
70
- it 'paginates with sort' do
69
+ it "paginates with sort" do
71
70
  q = RocketJobMissionControl::Query.new(NoopJob.all, _id: 1)
72
71
  q.start = 1
73
72
  q.page_size = 3
@@ -77,15 +76,15 @@ class QueryTest < Minitest::Test
77
76
  q.query.each do |job|
78
77
  assert(previous_id < job.id, "Wrong sort order. #{previous_id} < #{job.id}") if previous_id
79
78
  previous_id = job.id
80
- count += 1
79
+ count += 1
81
80
  end
82
81
  assert_equal 3, count
83
82
  end
84
83
 
85
- it 'paginates with sort and search' do
84
+ it "paginates with sort and search" do
86
85
  q = RocketJobMissionControl::Query.new(NoopJob.all, _id: 1)
87
86
  q.search_columns << :description
88
- q.search_term = 'Job'
87
+ q.search_term = "Job"
89
88
  q.start = 1
90
89
  q.page_size = 3
91
90
 
@@ -94,12 +93,12 @@ class QueryTest < Minitest::Test
94
93
  q.query.each do |job|
95
94
  assert(previous_id < job.id, "Wrong sort order. #{previous_id} < #{job.id}") if previous_id
96
95
  previous_id = job.id
97
- count += 1
96
+ count += 1
98
97
  end
99
98
  assert_equal 3, count
100
99
  end
101
100
 
102
- it 'sorts ascending by record_count' do
101
+ it "sorts ascending by record_count" do
103
102
  count = 0
104
103
  previous = nil
105
104
  RocketJobMissionControl::Query.new(NoopJob.all, record_count: 1).query.each do |job|
@@ -110,7 +109,7 @@ class QueryTest < Minitest::Test
110
109
  assert_equal @jobs.count, count
111
110
  end
112
111
 
113
- it 'sorts descending by record_count' do
112
+ it "sorts descending by record_count" do
114
113
  count = 0
115
114
  previous = nil
116
115
  RocketJobMissionControl::Query.new(NoopJob.all, record_count: -1).query.each do |job|
@@ -122,15 +121,15 @@ class QueryTest < Minitest::Test
122
121
  end
123
122
  end
124
123
 
125
- describe '#count' do
126
- it 'without search' do
124
+ describe "#count" do
125
+ it "without search" do
127
126
  assert_equal 10, RocketJobMissionControl::Query.new(NoopJob.all, description: 1).count
128
127
  end
129
128
 
130
- it 'with search and pagination' do
129
+ it "with search and pagination" do
131
130
  q = RocketJobMissionControl::Query.new(NoopJob.all, description: 1)
132
131
  q.search_columns << :description
133
- q.search_term = 'Job 1'
132
+ q.search_term = "Job 1"
134
133
  # Pagination should be ignored
135
134
  q.start = 1
136
135
  q.page_size = 1
@@ -138,21 +137,20 @@ class QueryTest < Minitest::Test
138
137
  end
139
138
  end
140
139
 
141
- describe '#unfiltered_count' do
142
- it 'without search' do
140
+ describe "#unfiltered_count" do
141
+ it "without search" do
143
142
  assert_equal 10, RocketJobMissionControl::Query.new(NoopJob.all, description: 1).unfiltered_count
144
143
  end
145
144
 
146
- it 'with search and pagination' do
145
+ it "with search and pagination" do
147
146
  q = RocketJobMissionControl::Query.new(NoopJob.all, description: 1)
148
147
  q.search_columns << :description
149
- q.search_term = 'Job 1'
148
+ q.search_term = "Job 1"
150
149
  # Pagination should be ignored
151
150
  q.start = 1
152
151
  q.page_size = 3
153
152
  assert_equal 10, q.unfiltered_count
154
153
  end
155
154
  end
156
-
157
155
  end
158
156
  end
@@ -1,18 +1,18 @@
1
- ENV['RAILS_ENV'] ||= 'test'
1
+ ENV["RAILS_ENV"] ||= "test"
2
2
 
3
- require 'yaml'
4
- require 'awesome_print'
5
- require 'rails/version'
3
+ require "yaml"
4
+ require "awesome_print"
5
+ require "rails/version"
6
6
  if Rails.version.to_f >= 5.2
7
- require_relative '../rjmc/config/environment'
8
- require 'minitest/autorun'
9
- require 'rails/test_help'
10
- require 'minispec/rails'
7
+ require_relative "../rjmc/config/environment"
8
+ require "minitest/autorun"
9
+ require "rails/test_help"
10
+ require "minispec/rails"
11
11
  else
12
- require_relative '../rjmc4/config/environment'
13
- require 'minitest/autorun'
14
- require 'rails/test_help'
15
- require 'minitest/rails'
12
+ require_relative "../rjmc4/config/environment"
13
+ require "minitest/autorun"
14
+ require "rails/test_help"
15
+ require "minitest/rails"
16
16
  end
17
17
 
18
18
  ActionController::TestCase