foreman_remote_execution 12.0.5 → 13.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc +4 -1
  3. data/.github/workflows/js_ci.yml +1 -1
  4. data/.github/workflows/release.yml +4 -2
  5. data/.github/workflows/ruby_ci.yml +16 -81
  6. data/.packit.yaml +8 -3
  7. data/app/assets/javascripts/foreman_remote_execution/locale/de/foreman_remote_execution.js +23 -14
  8. data/app/assets/javascripts/foreman_remote_execution/locale/en/foreman_remote_execution.js +22 -4
  9. data/app/assets/javascripts/foreman_remote_execution/locale/en_GB/foreman_remote_execution.js +23 -14
  10. data/app/assets/javascripts/foreman_remote_execution/locale/es/foreman_remote_execution.js +23 -14
  11. data/app/assets/javascripts/foreman_remote_execution/locale/fr/foreman_remote_execution.js +23 -14
  12. data/app/assets/javascripts/foreman_remote_execution/locale/ja/foreman_remote_execution.js +23 -14
  13. data/app/assets/javascripts/foreman_remote_execution/locale/ka/foreman_remote_execution.js +23 -14
  14. data/app/assets/javascripts/foreman_remote_execution/locale/ko/foreman_remote_execution.js +23 -14
  15. data/app/assets/javascripts/foreman_remote_execution/locale/pt_BR/foreman_remote_execution.js +23 -14
  16. data/app/assets/javascripts/foreman_remote_execution/locale/ru/foreman_remote_execution.js +23 -14
  17. data/app/assets/javascripts/foreman_remote_execution/locale/zh_CN/foreman_remote_execution.js +23 -14
  18. data/app/assets/javascripts/foreman_remote_execution/locale/zh_TW/foreman_remote_execution.js +23 -14
  19. data/app/controllers/ui_job_wizard_controller.rb +1 -1
  20. data/app/helpers/job_invocations_helper.rb +1 -1
  21. data/app/helpers/remote_execution_helper.rb +2 -2
  22. data/app/lib/actions/remote_execution/proxy_action.rb +1 -1
  23. data/app/lib/actions/remote_execution/run_host_job.rb +9 -17
  24. data/app/models/concerns/foreman_remote_execution/host_extensions.rb +8 -0
  25. data/app/models/host_status/execution_status.rb +2 -2
  26. data/app/models/job_invocation_composer.rb +4 -3
  27. data/app/views/api/v2/job_invocations/base.json.rabl +5 -3
  28. data/app/views/job_invocations/_preview_hosts_list.html.erb +1 -1
  29. data/app/views/job_invocations/show.html.erb +12 -5
  30. data/app/views/job_invocations/show.js.erb +8 -1
  31. data/app/views/job_invocations/welcome.html.erb +1 -1
  32. data/app/views/template_invocations/_refresh.js.erb +10 -4
  33. data/app/views/template_invocations/show.html.erb +2 -2
  34. data/app/views/templates/script/convert2rhel_analyze.erb +1 -12
  35. data/app/views/templates/script/package_action.erb +11 -1
  36. data/app/views/templates/script/puppet_run_once.erb +3 -3
  37. data/lib/foreman_remote_execution/engine.rb +1 -1
  38. data/lib/foreman_remote_execution/version.rb +1 -1
  39. data/locale/de/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  40. data/locale/de/foreman_remote_execution.po +24 -6
  41. data/locale/en/foreman_remote_execution.po +24 -6
  42. data/locale/en_GB/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  43. data/locale/en_GB/foreman_remote_execution.po +24 -6
  44. data/locale/es/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  45. data/locale/es/foreman_remote_execution.po +24 -6
  46. data/locale/foreman_remote_execution.pot +170 -142
  47. data/locale/fr/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  48. data/locale/fr/foreman_remote_execution.po +24 -6
  49. data/locale/ja/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  50. data/locale/ja/foreman_remote_execution.po +24 -6
  51. data/locale/ka/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  52. data/locale/ka/foreman_remote_execution.po +24 -6
  53. data/locale/ko/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  54. data/locale/ko/foreman_remote_execution.po +24 -6
  55. data/locale/pt_BR/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  56. data/locale/pt_BR/foreman_remote_execution.po +24 -6
  57. data/locale/ru/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  58. data/locale/ru/foreman_remote_execution.po +24 -6
  59. data/locale/zh_CN/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  60. data/locale/zh_CN/foreman_remote_execution.po +24 -6
  61. data/locale/zh_TW/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  62. data/locale/zh_TW/foreman_remote_execution.po +24 -6
  63. data/package.json +7 -11
  64. data/test/functional/api/v2/job_invocations_controller_test.rb +7 -7
  65. data/test/functional/api/v2/template_invocations_controller_test.rb +3 -3
  66. data/test/helpers/remote_execution_helper_test.rb +8 -7
  67. data/test/unit/actions/run_host_job_test.rb +1 -1
  68. data/test/unit/actions/run_hosts_job_test.rb +11 -11
  69. data/test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb +5 -5
  70. data/test/unit/concerns/host_extensions_test.rb +34 -34
  71. data/test/unit/concerns/nic_extensions_test.rb +1 -1
  72. data/test/unit/execution_task_status_mapper_test.rb +10 -10
  73. data/test/unit/input_template_renderer_test.rb +53 -49
  74. data/test/unit/job_invocation_composer_test.rb +109 -81
  75. data/test/unit/job_invocation_test.rb +25 -25
  76. data/test/unit/job_template_effective_user_test.rb +3 -3
  77. data/test/unit/job_template_test.rb +28 -28
  78. data/test/unit/remote_execution_feature_test.rb +14 -14
  79. data/test/unit/remote_execution_provider_test.rb +39 -39
  80. data/test/unit/renderer_scope_input_test.rb +6 -6
  81. data/test/unit/targeting_test.rb +32 -32
  82. data/webpack/JobInvocationDetail/JobInvocationConstants.js +10 -0
  83. data/webpack/JobInvocationDetail/JobInvocationDetail.scss +38 -0
  84. data/webpack/JobInvocationDetail/JobInvocationOverview.js +13 -25
  85. data/webpack/JobInvocationDetail/JobInvocationSystemStatusChart.js +153 -0
  86. data/webpack/JobInvocationDetail/index.js +48 -10
  87. data/webpack/JobWizard/Footer.js +5 -1
  88. data/webpack/JobWizard/JobWizardConstants.js +4 -0
  89. data/webpack/JobWizard/JobWizardPageRerun.js +3 -0
  90. data/webpack/JobWizard/JobWizardSelectors.js +31 -3
  91. data/webpack/JobWizard/PermissionDenied.js +64 -0
  92. data/webpack/JobWizard/StartsBeforeErrorAlert.js +1 -0
  93. data/webpack/JobWizard/__tests__/fixtures.js +3 -3
  94. data/webpack/JobWizard/autofill.js +8 -4
  95. data/webpack/JobWizard/index.js +41 -1
  96. data/webpack/JobWizard/steps/AdvancedFields/DescriptionField.js +8 -1
  97. data/webpack/JobWizard/steps/AdvancedFields/Fields.js +7 -0
  98. data/webpack/JobWizard/steps/CategoryAndTemplate/CategoryAndTemplate.js +41 -7
  99. data/webpack/JobWizard/steps/HostsAndInputs/HostPreviewModal.js +7 -3
  100. data/webpack/JobWizard/steps/HostsAndInputs/SelectGQL.js +1 -0
  101. data/webpack/JobWizard/steps/HostsAndInputs/SelectedChips.js +21 -7
  102. data/webpack/JobWizard/steps/HostsAndInputs/hosts.gql +1 -0
  103. data/webpack/JobWizard/steps/HostsAndInputs/index.js +27 -2
  104. data/webpack/JobWizard/steps/ReviewDetails/index.js +7 -2
  105. data/webpack/JobWizard/steps/Schedule/PurposeField.js +1 -0
  106. data/webpack/JobWizard/steps/Schedule/QueryType.js +2 -0
  107. data/webpack/JobWizard/steps/Schedule/RepeatCron.js +1 -0
  108. data/webpack/JobWizard/steps/Schedule/RepeatHour.js +2 -0
  109. data/webpack/JobWizard/steps/Schedule/RepeatMonth.js +1 -0
  110. data/webpack/JobWizard/steps/Schedule/RepeatWeek.js +1 -0
  111. data/webpack/JobWizard/steps/Schedule/ScheduleFuture.js +2 -0
  112. data/webpack/JobWizard/steps/Schedule/ScheduleRecurring.js +6 -0
  113. data/webpack/JobWizard/steps/Schedule/ScheduleType.js +3 -0
  114. data/webpack/JobWizard/steps/form/FormHelpers.js +1 -0
  115. data/webpack/JobWizard/steps/form/GroupedSelectField.js +1 -0
  116. data/webpack/JobWizard/steps/form/NumberInput.js +1 -0
  117. data/webpack/JobWizard/steps/form/ResourceSelect.js +1 -0
  118. data/webpack/JobWizard/steps/form/SearchSelect.js +4 -1
  119. data/webpack/JobWizard/steps/form/SelectField.js +1 -0
  120. data/webpack/JobWizard/steps/form/WizardTitle.js +6 -1
  121. data/webpack/JobWizard/steps/form/__tests__/SelectSearch.test.js +2 -0
  122. data/webpack/__mocks__/foremanReact/routes/Hosts/constants.js +1 -0
  123. data/webpack/react_app/components/FeaturesDropdown/index.js +1 -0
  124. data/webpack/react_app/components/RecentJobsCard/RecentJobsCard.js +3 -0
  125. data/webpack/react_app/components/RecentJobsCard/RecentJobsTable.js +2 -1
  126. data/webpack/react_app/components/RegistrationExtension/RexInterface.js +1 -0
  127. data/webpack/react_app/components/RegistrationExtension/RexPull.js +1 -0
  128. data/webpack/react_app/components/RegistrationExtension/__tests__/__snapshots__/RexInterface.test.js.snap +1 -0
  129. metadata +10 -6
@@ -35,6 +35,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
35
35
  let(:trying_job_template_1) { FactoryBot.create(:job_template, :job_category => 'trying_job_template_1', :name => 'trying1', :provider_type => 'SSH') }
36
36
  let(:trying_job_template_2) { FactoryBot.create(:job_template, :job_category => 'trying_job_template_2', :name => 'trying2', :provider_type => 'Mcollective') }
37
37
  let(:trying_job_template_3) { FactoryBot.create(:job_template, :job_category => 'trying_job_template_1', :name => 'trying3', :provider_type => 'SSH') }
38
+ let(:trying_job_template_5) { FactoryBot.create(:job_template, :job_category => 'trying_job_template_5', :name => 'trying5', :provider_type => 'SSH') }
38
39
  let(:unauthorized_job_template_1) { FactoryBot.create(:job_template, :job_category => 'trying_job_template_1', :name => 'unauth1', :provider_type => 'SSH') }
39
40
  let(:unauthorized_job_template_2) { FactoryBot.create(:job_template, :job_category => 'unauthorized_job_template_2', :name => 'unauth2', :provider_type => 'Ansible') }
40
41
 
@@ -44,6 +45,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
44
45
  let(:input2) { FactoryBot.create(:template_input, :template => trying_job_template_3, :input_type => 'user') }
45
46
  let(:input3) { FactoryBot.create(:template_input, :template => trying_job_template_1, :input_type => 'user', :required => true) }
46
47
  let(:input4) { FactoryBot.create(:template_input, :template => provider_inputs_job_template, :input_type => 'user') }
48
+ let(:input5) { FactoryBot.create(:template_input, :template => trying_job_template_5, :input_type => 'user', :default => 'value') }
47
49
  let(:unauthorized_input1) { FactoryBot.create(:template_input, :template => unauthorized_job_template_1, :input_type => 'user') }
48
50
 
49
51
  let(:ansible_params) { { } }
@@ -75,13 +77,13 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
75
77
  describe '#available_templates_for(job_category)' do
76
78
  it 'find the templates only for a given job name' do
77
79
  results = composer.available_templates_for(trying_job_template_1.job_category)
78
- _(results).must_include trying_job_template_1
79
- _(results).wont_include trying_job_template_2
80
+ assert_includes results, trying_job_template_1
81
+ refute_includes results, trying_job_template_2
80
82
  end
81
83
 
82
84
  it 'it respects view permissions' do
83
85
  results = composer.available_templates_for(trying_job_template_1.job_category)
84
- _(results).wont_include unauthorized_job_template_1
86
+ refute_includes results, unauthorized_job_template_1
85
87
  end
86
88
  end
87
89
 
@@ -89,13 +91,13 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
89
91
  let(:job_categories) { composer.available_job_categories }
90
92
 
91
93
  it 'find only job names that user is granted to view' do
92
- _(job_categories).must_include trying_job_template_1.job_category
93
- _(job_categories).must_include trying_job_template_2.job_category
94
- _(job_categories).wont_include unauthorized_job_template_2.job_category
94
+ assert_includes job_categories, trying_job_template_1.job_category
95
+ assert_includes job_categories, trying_job_template_2.job_category
96
+ refute_includes job_categories, unauthorized_job_template_2.job_category
95
97
  end
96
98
 
97
99
  it 'every job name is listed just once' do
98
- _(job_categories.uniq).must_equal job_categories
100
+ assert_equal job_categories.uniq, job_categories
99
101
  end
100
102
  end
101
103
 
@@ -104,13 +106,13 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
104
106
 
105
107
  it 'finds only providers which user is granted to view' do
106
108
  composer.job_invocation.job_category = 'trying_job_template_1'
107
- _(provider_types).must_include 'SSH'
108
- _(provider_types).wont_include 'Mcollective'
109
- _(provider_types).wont_include 'Ansible'
109
+ assert_includes provider_types, 'SSH'
110
+ refute_includes provider_types, 'Mcollective'
111
+ refute_includes provider_types, 'Ansible'
110
112
  end
111
113
 
112
114
  it 'every provider type is listed just once' do
113
- _(provider_types.uniq).must_equal provider_types
115
+ assert_equal provider_types.uniq, provider_types
114
116
  end
115
117
  end
116
118
 
@@ -122,9 +124,9 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
122
124
  end
123
125
 
124
126
  it 'returns only authorized inputs based on templates' do
125
- _(composer.available_template_inputs).must_include(input1)
126
- _(composer.available_template_inputs).must_include(input2)
127
- _(composer.available_template_inputs).wont_include(unauthorized_input1)
127
+ assert_includes composer.available_template_inputs, input1
128
+ assert_includes composer.available_template_inputs, input2
129
+ refute_includes composer.available_template_inputs, unauthorized_input1
128
130
  end
129
131
 
130
132
  context 'params contains job template ids' do
@@ -134,9 +136,9 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
134
136
  let(:params) { { :job_invocation => providers_params }.with_indifferent_access }
135
137
 
136
138
  it 'finds the inputs only specified job templates' do
137
- _(composer.available_template_inputs).must_include(input1)
138
- _(composer.available_template_inputs).wont_include(input2)
139
- _(composer.available_template_inputs).wont_include(unauthorized_input1)
139
+ assert_includes composer.available_template_inputs, input1
140
+ refute_includes composer.available_template_inputs, input2
141
+ refute_includes composer.available_template_inputs, unauthorized_input1
140
142
  end
141
143
  end
142
144
  end
@@ -149,7 +151,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
149
151
 
150
152
  it 'returns false if there is one provider' do
151
153
  composer.stubs(:available_provider_types => [ 'SSH' ])
152
- assert_not composer.needs_provider_type_selection?
154
+ refute composer.needs_provider_type_selection?
153
155
  end
154
156
  end
155
157
 
@@ -161,40 +163,40 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
161
163
  it 'returns all templates for a given provider respecting template permissions' do
162
164
  trying_job_template_4 = FactoryBot.create(:job_template, :job_category => 'trying_job_template_1', :name => 'trying4', :provider_type => 'Ansible')
163
165
  result = composer.templates_for_provider('SSH')
164
- _(result).must_include trying_job_template_1
165
- _(result).must_include trying_job_template_3
166
- _(result).wont_include unauthorized_job_template_1
167
- _(result).wont_include trying_job_template_4
166
+ assert_includes result, trying_job_template_1
167
+ assert_includes result, trying_job_template_3
168
+ refute_includes result, unauthorized_job_template_1
169
+ refute_includes result, trying_job_template_4
168
170
 
169
171
  result = composer.templates_for_provider('Ansible')
170
- _(result).wont_include trying_job_template_1
171
- _(result).wont_include trying_job_template_3
172
- _(result).wont_include unauthorized_job_template_2
173
- _(result).must_include trying_job_template_4
172
+ refute_includes result, trying_job_template_1
173
+ refute_includes result, trying_job_template_3
174
+ refute_includes result, unauthorized_job_template_2
175
+ assert_includes result, trying_job_template_4
174
176
  end
175
177
  end
176
178
 
177
179
  describe '#rerun_possible?' do
178
180
  it 'is true when not rerunning' do
179
- _(composer).must_be :rerun_possible?
181
+ assert_predicate composer, :rerun_possible?
180
182
  end
181
183
 
182
184
  it 'is true when rerunning with pattern tempalte invocations' do
183
185
  composer.expects(:reruns).returns(1)
184
186
  composer.job_invocation.expects(:pattern_template_invocations).returns([1])
185
- _(composer).must_be :rerun_possible?
187
+ assert_predicate composer, :rerun_possible?
186
188
  end
187
189
 
188
190
  it 'is false when rerunning without pattern template invocations' do
189
191
  composer.expects(:reruns).returns(1)
190
192
  composer.job_invocation.expects(:pattern_template_invocations).returns([])
191
- _(composer).wont_be :rerun_possible?
193
+ refute_predicate composer, :rerun_possible?
192
194
  end
193
195
  end
194
196
 
195
197
  describe '#selected_job_templates' do
196
198
  it 'returns no template if none was selected through params' do
197
- _(composer.selected_job_templates).must_be_empty
199
+ assert_empty composer.selected_job_templates
198
200
  end
199
201
 
200
202
  context 'extra unavailable templates id were selected' do
@@ -207,14 +209,14 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
207
209
 
208
210
  it 'ignores unauthorized template' do
209
211
  unauthorized # make sure unautorized exists
210
- _(composer.selected_job_templates).wont_include unauthorized
212
+ refute_includes composer.selected_job_templates, unauthorized
211
213
  end
212
214
 
213
215
  it 'contains only authorized template specified in params' do
214
216
  mcollective_authorized # make sure mcollective_authorized exists
215
- _(composer.selected_job_templates).must_include trying_job_template_1
216
- _(composer.selected_job_templates).must_include mcollective_authorized
217
- _(composer.selected_job_templates).wont_include trying_job_template_3
217
+ assert_includes composer.selected_job_templates, trying_job_template_1
218
+ assert_includes composer.selected_job_templates, mcollective_authorized
219
+ refute_includes composer.selected_job_templates, trying_job_template_3
218
220
  end
219
221
  end
220
222
  end
@@ -222,7 +224,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
222
224
  describe '#preselected_template_for_provider(provider_type)' do
223
225
  context 'none template was selected through params' do
224
226
  it 'returns nil' do
225
- _(composer.preselected_template_for_provider('SSH')).must_be_nil
227
+ assert_nil composer.preselected_template_for_provider('SSH')
226
228
  end
227
229
  end
228
230
 
@@ -231,7 +233,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
231
233
  let(:params) { { :job_invocation => providers_params }.with_indifferent_access }
232
234
 
233
235
  it 'returns the selected template because it is available for provider' do
234
- _(composer.preselected_template_for_provider('SSH')).must_equal trying_job_template_1
236
+ assert_equal trying_job_template_1, composer.preselected_template_for_provider('SSH')
235
237
  end
236
238
  end
237
239
  end
@@ -249,9 +251,9 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
249
251
  let(:invocations) { composer.pattern_template_invocations }
250
252
 
251
253
  it 'builds pattern template invocations based on passed params and it filters out wrong inputs' do
252
- _(invocations.size).must_equal 1
253
- _(invocations.first.input_values.size).must_equal 1
254
- _(invocations.first.input_values.first.value).must_equal 'value1'
254
+ assert_equal 1, invocations.size
255
+ assert_equal 1, invocations.first.input_values.size
256
+ assert_equal 'value1', invocations.first.input_values.first.value
255
257
  end
256
258
  end
257
259
 
@@ -275,7 +277,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
275
277
  let(:invocation_effective_user) { 'invocation user' }
276
278
 
277
279
  it 'takes the value from the template invocation' do
278
- _(template_invocation.effective_user).must_equal 'invocation user'
280
+ assert_equal 'invocation user', template_invocation.effective_user
279
281
  end
280
282
  end
281
283
 
@@ -284,7 +286,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
284
286
  let(:invocation_effective_user) { '' }
285
287
 
286
288
  it 'takes the value from the job template' do
287
- _(template_invocation.effective_user).must_equal 'template user'
289
+ assert_equal 'template user', template_invocation.effective_user
288
290
  end
289
291
  end
290
292
 
@@ -293,14 +295,14 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
293
295
  let(:invocation_effective_user) { 'invocation user' }
294
296
 
295
297
  it 'takes the value from the job template' do
296
- _(template_invocation.effective_user).must_equal 'template user'
298
+ assert_equal 'template user', template_invocation.effective_user
297
299
  end
298
300
  end
299
301
  end
300
302
 
301
303
  describe '#displayed_search_query' do
302
304
  it 'is empty by default' do
303
- _(composer.displayed_search_query).must_be_empty
305
+ assert_empty composer.displayed_search_query
304
306
  end
305
307
 
306
308
  let(:host) { FactoryBot.create(:host) }
@@ -310,7 +312,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
310
312
  let(:params) { { :targeting => { :search_query => 'a', :bookmark_id => bookmark.id }, :host_ids => [ host.id ] }.with_indifferent_access }
311
313
 
312
314
  it 'explicit search query has highest priority' do
313
- _(composer.displayed_search_query).must_equal 'a'
315
+ assert_equal 'a', composer.displayed_search_query
314
316
  end
315
317
  end
316
318
 
@@ -318,7 +320,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
318
320
  let(:params) { { :targeting => { :bookmark_id => bookmark.id }, :host_ids => [ host.id ] }.with_indifferent_access }
319
321
 
320
322
  it 'hosts will be used instead of a bookmark' do
321
- _(composer.displayed_search_query).must_include host.name
323
+ assert_includes composer.displayed_search_query, host.name
322
324
  end
323
325
  end
324
326
 
@@ -327,20 +329,20 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
327
329
 
328
330
  it 'bookmark query is used if it is available for the user' do
329
331
  bookmark.update_attribute :public, false
330
- _(composer.displayed_search_query).must_equal bookmark.query
332
+ assert_equal bookmark.query, composer.displayed_search_query
331
333
  end
332
334
 
333
335
  it 'bookmark query is used if the bookmark is public' do
334
336
  bookmark.owner = nil
335
337
  bookmark.save(:validate => false) # skip validations so owner remains nil
336
- _(composer.displayed_search_query).must_equal bookmark.query
338
+ assert_equal bookmark.query, composer.displayed_search_query
337
339
  end
338
340
 
339
341
  it 'empty search is returned if bookmark is not owned by the user and is not public' do
340
342
  bookmark.public = false
341
343
  bookmark.owner = nil
342
344
  bookmark.save(:validate => false) # skip validations so owner remains nil
343
- _(composer.displayed_search_query).must_be_empty
345
+ assert_empty composer.displayed_search_query
344
346
  end
345
347
  end
346
348
  end
@@ -355,9 +357,9 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
355
357
  hosts
356
358
  dashboard
357
359
  hostgroups
358
- _(composer.available_bookmarks).must_include hosts
359
- _(composer.available_bookmarks).must_include dashboard
360
- _(composer.available_bookmarks).wont_include hostgroups
360
+ assert_includes composer.available_bookmarks, hosts
361
+ assert_includes composer.available_bookmarks, dashboard
362
+ refute_includes composer.available_bookmarks, hostgroups
361
363
  end
362
364
  end
363
365
  end
@@ -375,17 +377,17 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
375
377
 
376
378
  it 'searches hosts based on displayed_search_query' do
377
379
  composer.stubs(:displayed_search_query => "name = #{host.name}")
378
- _(composer.targeted_hosts_count).must_equal 1
380
+ assert_equal 1, composer.targeted_hosts_count
379
381
  end
380
382
 
381
383
  it 'returns 0 for queries with syntax errors' do
382
384
  composer.stubs(:displayed_search_query => 'name = ')
383
- _(composer.targeted_hosts_count).must_equal 0
385
+ assert_equal 0, composer.targeted_hosts_count
384
386
  end
385
387
 
386
388
  it 'returns 0 when no query is present' do
387
389
  composer.stubs(:displayed_search_query => '')
388
- _(composer.targeted_hosts_count).must_equal 0
390
+ assert_equal 0, composer.targeted_hosts_count
389
391
  end
390
392
  end
391
393
 
@@ -393,7 +395,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
393
395
  let(:value1) { composer.input_value_for(input1) }
394
396
  it 'returns new empty input value if there is no invocation' do
395
397
  assert value1.new_record?
396
- _(value1.value).must_be_empty
398
+ assert_empty value1.value
397
399
  end
398
400
 
399
401
  context 'there are invocations without input values for a given input' do
@@ -409,7 +411,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
409
411
 
410
412
  it 'returns new empty input value' do
411
413
  assert value1.new_record?
412
- _(value1.value).must_be_empty
414
+ assert_empty value1.value
413
415
  end
414
416
  end
415
417
 
@@ -425,7 +427,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
425
427
  let(:params) { { :job_invocation => { :providers => { :ssh => ssh_params } } }.with_indifferent_access }
426
428
 
427
429
  it 'finds the value among template invocations' do
428
- _(value1.value).must_equal 'value1'
430
+ assert_equal 'value1', value1.value
429
431
  end
430
432
  end
431
433
  end
@@ -462,12 +464,12 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
462
464
  end
463
465
 
464
466
  it 'accepts the concurrency options' do
465
- _(composer.job_invocation.concurrency_level).must_equal 5
467
+ assert_equal 5, composer.job_invocation.concurrency_level
466
468
  end
467
469
  end
468
470
 
469
471
  it 'can be disabled' do
470
- _(composer.job_invocation.concurrency_level).must_be_nil
472
+ assert_nil composer.job_invocation.concurrency_level
471
473
  end
472
474
  end
473
475
 
@@ -477,11 +479,11 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
477
479
  end
478
480
 
479
481
  it 'accepts the triggering params' do
480
- _(composer.job_invocation.triggering.mode).must_equal :future
482
+ assert_equal :future, composer.job_invocation.triggering.mode
481
483
  end
482
484
 
483
485
  it 'formats the triggering end time when its unordered' do
484
- _(composer.job_invocation.triggering.end_time).must_equal Time.local(3,2,1,4,5)
486
+ assert_equal Time.local(3,2,1,4,5), composer.job_invocation.triggering.end_time
485
487
  end
486
488
  end
487
489
 
@@ -515,7 +517,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
515
517
 
516
518
  it 'sets the password properly' do
517
519
  composer
518
- _(composer.job_invocation.password).must_equal password
520
+ assert_equal password, composer.job_invocation.password
519
521
  end
520
522
  end
521
523
 
@@ -527,7 +529,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
527
529
 
528
530
  it 'sets the key passphrase properly' do
529
531
  composer
530
- _(composer.job_invocation.key_passphrase).must_equal key_passphrase
532
+ assert_equal key_passphrase, composer.job_invocation.key_passphrase
531
533
  end
532
534
  end
533
535
 
@@ -539,7 +541,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
539
541
 
540
542
  it 'sets the effective_user_password password properly' do
541
543
  composer
542
- _(composer.job_invocation.effective_user_password).must_equal effective_user_password
544
+ assert_equal effective_user_password, composer.job_invocation.effective_user_password
543
545
  end
544
546
  end
545
547
 
@@ -581,29 +583,29 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
581
583
  end
582
584
 
583
585
  it 'sets the same job name' do
584
- _(new_composer.job_category).must_equal existing.job_category
586
+ assert_equal existing.job_category, new_composer.job_category
585
587
  end
586
588
 
587
589
  it 'accepts additional host ids' do
588
590
  new_composer = JobInvocationComposer.from_job_invocation(composer.job_invocation, { :host_ids => [host.id] })
589
- _(new_composer.search_query).must_equal("name ^ (#{host.name})")
591
+ assert_equal "name ^ (#{host.name})", new_composer.search_query
590
592
  end
591
593
 
592
594
  it 'builds new targeting object which keeps search query' do
593
- _(new_composer.targeting).wont_equal existing.targeting
594
- _(new_composer.search_query).must_equal existing.targeting.search_query
595
+ refute_equal existing.targeting, new_composer.targeting
596
+ assert_equal existing.targeting.search_query, new_composer.search_query
595
597
  end
596
598
 
597
599
  it 'keeps job template ids' do
598
- _(new_composer.job_template_ids).must_equal existing.pattern_template_invocations.map(&:template_id)
600
+ assert_equal existing.pattern_template_invocations.map(&:template_id), new_composer.job_template_ids
599
601
  end
600
602
 
601
603
  it 'keeps template invocations and their values' do
602
- _(new_composer.pattern_template_invocations.size).must_equal existing.pattern_template_invocations.size
604
+ assert_equal existing.pattern_template_invocations.size, new_composer.pattern_template_invocations.size
603
605
  end
604
606
 
605
607
  it 'sets the same concurrency control options' do
606
- _(new_composer.job_invocation.concurrency_level).must_equal existing.concurrency_level
608
+ assert_equal existing.concurrency_level, new_composer.job_invocation.concurrency_level
607
609
  end
608
610
 
609
611
  end
@@ -654,14 +656,40 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
654
656
 
655
657
  context 'with with inputs' do
656
658
  let(:params) do
657
- { :job_category => trying_job_template_1.job_category,
658
- :job_template_id => trying_job_template_1.id,
659
+ { :job_category => trying_job_template_5.job_category,
660
+ :job_template_id => trying_job_template_5.id,
659
661
  :targeting_type => 'static_query',
660
662
  :search_query => 'some hosts',
661
- :inputs => {input1.name => 'some_value'}}
663
+ :inputs => {input5.name => 'some_value'}}
662
664
  end
663
665
 
664
666
  it 'finds the inputs by name' do
667
+ assert composer.save!
668
+ values = composer.pattern_template_invocations.first.input_values
669
+ assert_equal 1, values.count
670
+ assert_equal 'some_value', values.first.value
671
+ end
672
+
673
+ it 'can be forced to be empty' do
674
+ params[:inputs] = {input5.name => ''}
675
+ assert composer.save!
676
+ values = composer.pattern_template_invocations.first.input_values
677
+ assert_equal 1, values.count
678
+ assert_equal '', values.first.value
679
+ end
680
+ end
681
+
682
+ context 'with inputs and default values' do
683
+ let(:params) do
684
+ { :job_category => trying_job_template_5.job_category,
685
+ :job_template_id => trying_job_template_5.id,
686
+ :targeting_type => 'static_query',
687
+ :search_query => 'some hosts',
688
+ :inputs => {}}
689
+ end
690
+
691
+ it 'uses the default input values' do
692
+ input5 # Force the factory to be materialized
665
693
  assert composer.save!
666
694
  assert_equal 1, composer.pattern_template_invocations.first.input_values.collect.count
667
695
  end
@@ -701,7 +729,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
701
729
 
702
730
  it 'sets the effective user based on the input' do
703
731
  assert composer.save!
704
- _(template_invocation.effective_user).must_equal 'invocation user'
732
+ assert_equal 'invocation user', template_invocation.effective_user
705
733
  end
706
734
  end
707
735
 
@@ -720,7 +748,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
720
748
 
721
749
  it 'sets the concurrency level based on the input' do
722
750
  assert composer.save!
723
- _(composer.job_invocation.concurrency_level).must_equal level
751
+ assert_equal level, composer.job_invocation.concurrency_level
724
752
  end
725
753
  end
726
754
 
@@ -737,7 +765,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
737
765
 
738
766
  it 'sets the remote execution feature based on the input' do
739
767
  assert composer.save!
740
- _(composer.job_invocation.remote_execution_feature).must_equal feature
768
+ assert_equal feature, composer.job_invocation.remote_execution_feature
741
769
  end
742
770
 
743
771
  it 'sets the remote execution_feature id based on `feature` param' do
@@ -747,7 +775,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
747
775
  refute_equal feature.job_template, trying_job_template_1
748
776
 
749
777
  assert composer.save!
750
- _(composer.job_invocation.remote_execution_feature).must_equal feature
778
+ assert_equal feature, composer.job_invocation.remote_execution_feature
751
779
  end
752
780
  end
753
781
 
@@ -797,7 +825,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
797
825
  error = assert_raises(ActiveRecord::RecordNotSaved) do
798
826
  composer.save!
799
827
  end
800
- _(error.message).must_include "Template #{trying_job_template_1.name}: Input #{input3.name.downcase}: Value can't be blank"
828
+ assert_includes error.message, "Template #{trying_job_template_1.name}: Input #{input3.name.downcase}: Value can't be blank"
801
829
  end
802
830
  end
803
831
 
@@ -826,13 +854,13 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
826
854
  end
827
855
 
828
856
  it 'handles errors' do
829
- _(input3).must_be :required
857
+ assert_predicate input3, :required
830
858
 
831
859
  error = assert_raises(ActiveRecord::RecordNotSaved) do
832
860
  composer.save!
833
861
  end
834
862
 
835
- _(error.message).must_include "Template #{trying_job_template_1.name}: Not all required inputs have values. Missing inputs: #{input3.name}"
863
+ assert_includes error.message, "Template #{trying_job_template_1.name}: Not all required inputs have values. Missing inputs: #{input3.name}"
836
864
  end
837
865
  end
838
866
  end