foreman-tasks 11.0.2 → 11.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92def6f8ee5c4a0ba4207f55389c6ac200c9d213d381f6ca611713f860190cd7
|
4
|
+
data.tar.gz: 366f26cab603dcdd70b5dcfb2b5e47a8b5f6bb28420c5f4a77379638c59765ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d833d6c5563a5f8ec7579488d9d8c2724681be431becf1f8322138b07291845a05c946d3977b79809bc7d992585092509e78ba8d79f55c966416c76233c0077a
|
7
|
+
data.tar.gz: d2fdf22b85e575ffc4654f5c9a38bb6163af027f19855acdd209cf6dc86928ed1ca7b9dabb5b4485480e1ef4fe45b0a7c71e2690aa4691b7c8cffc9ec259805c
|
@@ -160,7 +160,7 @@ module ForemanTasks
|
|
160
160
|
to_stop_length = to_stop.count
|
161
161
|
skipped_length = total_length - to_stop_length
|
162
162
|
|
163
|
-
to_stop.find_each
|
163
|
+
to_stop.find_each(&:halt)
|
164
164
|
|
165
165
|
if params[:search]
|
166
166
|
notification = UINotifications::Tasks::TaskBulkStop.new(filtered_scope.first, to_stop_length, skipped_length)
|
@@ -18,6 +18,11 @@ module ForemanTasks
|
|
18
18
|
{ _('Back to tasks') => "/#{ForemanTasks::TasksController.controller_path}" }
|
19
19
|
end
|
20
20
|
set(:world) { ::Rails.application.dynflow.world }
|
21
|
+
# Do not show Sinatra's pretty error pages in production
|
22
|
+
set(:show_exceptions) { ::Rails.env.development? }
|
23
|
+
# Let the errors propagate out from Sinatra to Rails.
|
24
|
+
# Without this, we'd only get a mostly blank 500 ISE page
|
25
|
+
set(:raise_errors) { !::Rails.env.development? }
|
21
26
|
end
|
22
27
|
end
|
23
28
|
end
|
@@ -202,6 +202,47 @@ module ForemanTasks
|
|
202
202
|
assert_equal({ 'result' => 'success' }, task.main_action.output['proxy_output'])
|
203
203
|
end
|
204
204
|
end
|
205
|
+
|
206
|
+
describe 'POST /api/tasks/bulk_stop' do
|
207
|
+
it 'requires search or task_ids parameter' do
|
208
|
+
post :bulk_stop
|
209
|
+
assert_response :bad_request
|
210
|
+
data = JSON.parse(response.body)
|
211
|
+
assert_includes data['error']['message'], 'Please provide at least one of search or task_ids parameters'
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'stops tasks by task_ids and calls halt' do
|
215
|
+
task1 = FactoryBot.create(:task_with_locks, :user_create_task, state: 'running')
|
216
|
+
task2 = FactoryBot.create(:dynflow_task, :user_create_task, state: 'pending')
|
217
|
+
task3 = FactoryBot.create(:dynflow_task, :user_create_task, state: 'stopped')
|
218
|
+
post :bulk_stop, params: { task_ids: [task1.id, task2.id, task3.id] }
|
219
|
+
assert_response :success
|
220
|
+
data = JSON.parse(response.body)
|
221
|
+
assert_equal 3, data['total']
|
222
|
+
assert_equal 2, data['stopped_length']
|
223
|
+
assert_equal 1, data['skipped_length']
|
224
|
+
wait_for { task1.reload.state == 'stopped' }
|
225
|
+
wait_for { task2.reload.state == 'stopped' }
|
226
|
+
assert_predicate task1.locks, :empty?
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'stops tasks by search query' do
|
230
|
+
task1 = FactoryBot.create(:task_with_locks, :user_create_task, state: 'running')
|
231
|
+
task2 = FactoryBot.create(:dynflow_task, :user_create_task, state: 'pending')
|
232
|
+
|
233
|
+
UINotifications::Tasks::TaskBulkStop.any_instance.expects(:deliver!)
|
234
|
+
|
235
|
+
post :bulk_stop, params: { search: 'label = Actions::User::Create' }
|
236
|
+
assert_response :success
|
237
|
+
data = JSON.parse(response.body)
|
238
|
+
assert_equal 2, data['total']
|
239
|
+
assert_equal 2, data['stopped_length']
|
240
|
+
assert_equal 0, data['skipped_length']
|
241
|
+
wait_for { task1.reload.state == 'stopped' }
|
242
|
+
wait_for { task2.reload.state == 'stopped' }
|
243
|
+
assert_predicate task1.locks, :empty?
|
244
|
+
end
|
245
|
+
end
|
205
246
|
end
|
206
247
|
end
|
207
248
|
end
|