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: 14937b8abb913127b2f1ab4028a967e25ed56ae35a476dc99dfd4bce07d9ec2a
4
- data.tar.gz: 124922626f20e21268d8fd2c341be934af3d17a1e1fe9df34a61d8a90718508f
3
+ metadata.gz: 92def6f8ee5c4a0ba4207f55389c6ac200c9d213d381f6ca611713f860190cd7
4
+ data.tar.gz: 366f26cab603dcdd70b5dcfb2b5e47a8b5f6bb28420c5f4a77379638c59765ff
5
5
  SHA512:
6
- metadata.gz: ed4850116bdc86ba5118a2c1a08e4d475285f3236dee047f8b3c98c24c5eb4030b31a409b0293e5016153e92522f90ef31fccca48e901c7ca30f56b95f55d06b
7
- data.tar.gz: c93ab2b4c78fac530e6bef4efca4c0baee0d03931522b15726526406881f8e538cec47dbba5ad863f86faca1a3ec025585453b3b47560435cd56fb1cd6fffb20
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 { |task| task.update(state: :stopped) }
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
@@ -1,3 +1,3 @@
1
1
  module ForemanTasks
2
- VERSION = '11.0.2'.freeze
2
+ VERSION = '11.0.3'.freeze
3
3
  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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.0.2
4
+ version: 11.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas