rocketjob_mission_control 3.0.2 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/rocket_job_mission_control/application_helper.rb +12 -5
- data/app/views/rocket_job_mission_control/jobs/_status.html.erb +1 -1
- data/lib/rocket_job_mission_control/version.rb +1 -1
- data/test/models/rocket_job_mission_control/job_sanitizer_test.rb +17 -17
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e2dea4081f4b8564cf39e794ebb61274972e1ae
|
4
|
+
data.tar.gz: 9c4f65f8aacdd61122de54aeab93bde9df128ab2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 761d5a8c319993ae227fbd42e0730c4d73317ce73126eb5532de3d581f16d5d4167af80d7acdcc502c97c05263482aae2e4f3d6618a1145d266286e86826b30a
|
7
|
+
data.tar.gz: 2ac37a6e727677ff33f4f4d36013b614c818d7c8e25c30fc577806592660934d666efbd9efe2560983f02f81680fad1b5765822eff92c950ef85fc9b101e2f1b
|
@@ -54,6 +54,8 @@ module RocketJobMissionControl
|
|
54
54
|
|
55
55
|
# Returns the editable field as html for use in editing dynamic fields from a Job class.
|
56
56
|
def editable_field_html(klass, field_name, value, f, include_nil_selectors = false)
|
57
|
+
# When editing a job the values are of the correct type.
|
58
|
+
# When editing a dirmon entry values are strings.
|
57
59
|
field = klass.fields[field_name.to_s]
|
58
60
|
return unless field && field.type
|
59
61
|
|
@@ -82,13 +84,18 @@ module RocketJobMissionControl
|
|
82
84
|
f.select(field_name, options_for_select(options, options), {include_hidden: false}, {class: 'selectize', multiple: true})
|
83
85
|
when 'Mongoid::Boolean'
|
84
86
|
name = "#{field_name}_true".to_sym
|
87
|
+
value = value.to_s
|
85
88
|
str = '<div class="radio-buttons">'.html_safe
|
86
|
-
str << f.label(name, 'true')
|
87
89
|
str << f.radio_button(field_name, 'true', checked: value == 'true')
|
88
|
-
str << f.label(name, '
|
89
|
-
str << f.radio_button(field_name, 'false', checked: value == 'false')
|
90
|
-
str << f.label(name, '
|
91
|
-
|
90
|
+
str << ' '.html_safe + f.label(name, 'true')
|
91
|
+
str << ' '.html_safe + f.radio_button(field_name, 'false', checked: value == 'false')
|
92
|
+
str << ' '.html_safe + f.label(name, 'false')
|
93
|
+
# Allow this field to be unset (nil).
|
94
|
+
if include_nil_selectors
|
95
|
+
str << ' '.html_safe + f.radio_button(field_name, '', checked: value == '')
|
96
|
+
str << ' '.html_safe + f.label(name, 'nil')
|
97
|
+
end
|
98
|
+
|
92
99
|
str << '</div>'.html_safe
|
93
100
|
else
|
94
101
|
"[#{field.type.name}]".html_safe +
|
@@ -23,7 +23,7 @@
|
|
23
23
|
<%
|
24
24
|
remaining = {}
|
25
25
|
status.each_pair do |key, value|
|
26
|
-
next if value.blank? || ['state', '_type', 'sub_state'].include?(key)
|
26
|
+
next if ((value != false) && value.blank?) || ['state', '_type', 'sub_state'].include?(key)
|
27
27
|
if value.kind_of?(Hash) || value.kind_of?(Array)
|
28
28
|
remaining[key] = value
|
29
29
|
next
|
@@ -39,52 +39,52 @@ class JobSanitizerTest < Minitest::Test
|
|
39
39
|
|
40
40
|
it 'nils blank values' do
|
41
41
|
properties = {
|
42
|
-
string:
|
43
|
-
integer:
|
44
|
-
symbol:
|
45
|
-
|
46
|
-
secure:
|
47
|
-
log_level:
|
42
|
+
string: '',
|
43
|
+
integer: '',
|
44
|
+
symbol: '',
|
45
|
+
hash_field: '',
|
46
|
+
secure: 'Not permissible',
|
47
|
+
log_level: ''
|
48
48
|
}
|
49
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
|
-
assert_equal({log_level: nil,
|
52
|
+
assert_equal({log_level: nil, hash_field: nil, integer: nil, string: nil, symbol: nil}, cleansed)
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'parses JSON' do
|
56
56
|
properties = {
|
57
|
-
string:
|
58
|
-
secure:
|
59
|
-
|
57
|
+
string: '',
|
58
|
+
secure: 'Not permissible',
|
59
|
+
hash_field: '{"state":"FL"}'
|
60
60
|
}
|
61
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[:
|
64
|
+
assert_equal({'state' => 'FL'}, cleansed[:hash_field])
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'sets the error for invalid JSON' do
|
68
68
|
properties = {
|
69
|
-
string:
|
70
|
-
secure:
|
71
|
-
|
69
|
+
string: 'hello',
|
70
|
+
secure: 'Not permissible',
|
71
|
+
hash_field: '{ bad json }'
|
72
72
|
}
|
73
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
77
|
assert first.second.include?('unexpected token'), first
|
78
|
-
assert_equal({
|
78
|
+
assert_equal({hash_field: "{ bad json }", string: 'hello'}, cleansed)
|
79
79
|
end
|
80
80
|
|
81
81
|
it 'Keeps empty JSON Hash' do
|
82
82
|
properties = {
|
83
|
-
|
83
|
+
hash_field: '{ }'
|
84
84
|
}
|
85
85
|
cleansed = RocketJobMissionControl::JobSanitizer.sanitize(properties, @job.class, @job, false)
|
86
86
|
assert_equal 0, @job.errors.count
|
87
|
-
assert_equal({
|
87
|
+
assert_equal({hash_field: {}}, cleansed)
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
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.
|
4
|
+
version: 3.0.3
|
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-
|
14
|
+
date: 2017-07-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|