foreman-tasks 11.0.2 → 11.0.4

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: 8727c799c331337534ad6e826edfc65c25c5b76fff264065535e0bf6b0e6c7f9
4
+ data.tar.gz: d1e9f35147ad693323614d5b4c293a02d694135be01cf1d0bfca349441b2bac5
5
5
  SHA512:
6
- metadata.gz: ed4850116bdc86ba5118a2c1a08e4d475285f3236dee047f8b3c98c24c5eb4030b31a409b0293e5016153e92522f90ef31fccca48e901c7ca30f56b95f55d06b
7
- data.tar.gz: c93ab2b4c78fac530e6bef4efca4c0baee0d03931522b15726526406881f8e538cec47dbba5ad863f86faca1a3ec025585453b3b47560435cd56fb1cd6fffb20
6
+ metadata.gz: f75e8f7b86f28931be8e8b0d5c153f0386c17b05004bbe1c657f9bed4e52d6f1295fb0ea8923a531daf28b0c3abb8c8e1fa159f607428321e001a71ccc5a6603
7
+ data.tar.gz: f7d331cfa5d37aa0daf82a01aec928418d3a749c3bb5e36327954e11834d47cc9e94dbd3492eb28d24c2603eeec2bb4de6ba37c90744723f35c13277ee675a67
@@ -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)
@@ -122,6 +122,7 @@ module ForemanTasks
122
122
  def can_start_future
123
123
  parse_start_before!
124
124
  parse_start_at!
125
+ return errors.add(:start_at, _('must be set')) if start_at.nil?
125
126
  errors.add(:start_before_raw, _('The task could not be started')) if !start_before.nil? && start_before < start_at
126
127
  end
127
128
 
@@ -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.4'.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
@@ -64,6 +64,14 @@ class TriggeringTest < ActiveSupport::TestCase
64
64
  Time.zone.expects(:now).never # No time comparisons should be done as nothing changed
65
65
  assert_predicate(triggering, :valid?)
66
66
  end
67
+
68
+ it 'requires start-at for future executions' do
69
+ triggering = ForemanTasks::Triggering.new_from_params({ :mode => "future" })
70
+ triggering.start_before = Time.zone.now + 1.hour
71
+ assert_not_predicate(triggering, :valid?)
72
+ triggering.start_at = Time.zone.now + 1.second
73
+ assert_predicate(triggering, :valid?)
74
+ end
67
75
  end
68
76
 
69
77
  it 'cannot have mode set to arbitrary value' do
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.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas