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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21d26a16d5a42afc84e40b409b784dc9114a0964
4
- data.tar.gz: ba1b5b6abdee92bd07e235365edeba6b4d5be340
3
+ metadata.gz: 1e2dea4081f4b8564cf39e794ebb61274972e1ae
4
+ data.tar.gz: 9c4f65f8aacdd61122de54aeab93bde9df128ab2
5
5
  SHA512:
6
- metadata.gz: 603390cc09d91dc638e1014b1121125a2c7438b14e3c360edf1cb666faa434211bcea7aa230d10b9ae934fa62dad0fd03823289b0db9a1ec693e6316fefe43eb
7
- data.tar.gz: 51cd9a8828ec473401f1b95dc23c2e0fe56e419d3cb7a965cf86a350ee43d466e55f75bc4ee74d784229e1d8a7bd5ece904072c91d8ac92adfa1d75f06b2505c
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, 'false')
89
- str << f.radio_button(field_name, 'false', checked: value == 'false')
90
- str << f.label(name, 'none')
91
- str << f.radio_button(field_name, '', checked: value.blank?)
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
@@ -1,3 +1,3 @@
1
1
  module RocketJobMissionControl
2
- VERSION = '3.0.2'
2
+ VERSION = '3.0.3'
3
3
  end
@@ -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
- hash: '',
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
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, hash: nil, integer: nil, string: nil, symbol: nil}, cleansed)
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: 'Not permissible',
59
- hash: '{"state":"FL"}'
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[:hash])
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: 'hello',
70
- secure: 'Not permissible',
71
- hash: '{ bad json }'
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({hash: "{ bad json }", string: 'hello'}, cleansed)
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
- hash: '{ }'
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({hash: {}}, cleansed)
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.2
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-06-01 00:00:00.000000000 Z
14
+ date: 2017-07-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails