foreman-tasks 9.1.0 → 9.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby_tests.yml +2 -0
  3. data/.rubocop.yml +6 -35
  4. data/.rubocop_todo.yml +216 -24
  5. data/Gemfile +2 -17
  6. data/app/controllers/foreman_tasks/tasks_controller.rb +8 -9
  7. data/app/models/foreman_tasks/remote_task.rb +3 -0
  8. data/app/models/foreman_tasks/task/dynflow_task.rb +4 -0
  9. data/foreman-tasks.gemspec +1 -1
  10. data/lib/foreman_tasks/tasks/export_tasks.rake +2 -2
  11. data/lib/foreman_tasks/version.rb +1 -1
  12. data/test/controllers/api/tasks_controller_test.rb +17 -17
  13. data/test/controllers/tasks_controller_test.rb +6 -6
  14. data/test/helpers/foreman_tasks/foreman_tasks_helper_test.rb +7 -7
  15. data/test/helpers/foreman_tasks/tasks_helper_test.rb +3 -3
  16. data/test/lib/actions/middleware/keep_current_request_id_test.rb +3 -3
  17. data/test/lib/concerns/polling_action_extensions_test.rb +4 -4
  18. data/test/tasks/generate_task_actions_test.rb +1 -1
  19. data/test/unit/actions/action_with_sub_plans_test.rb +4 -4
  20. data/test/unit/actions/bulk_action_test.rb +9 -9
  21. data/test/unit/actions/proxy_action_test.rb +20 -20
  22. data/test/unit/actions/recurring_action_test.rb +15 -15
  23. data/test/unit/actions/trigger_proxy_batch_test.rb +4 -4
  24. data/test/unit/cleaner_test.rb +24 -24
  25. data/test/unit/locking_test.rb +8 -8
  26. data/test/unit/proxy_selector_test.rb +9 -9
  27. data/test/unit/recurring_logic_test.rb +31 -32
  28. data/test/unit/remote_task_test.rb +4 -4
  29. data/test/unit/task_groups_test.rb +4 -4
  30. data/test/unit/task_test.rb +51 -51
  31. data/test/unit/triggering_test.rb +11 -11
  32. data/test/unit/troubleshooting_help_generator_test.rb +6 -6
  33. data/test/unit/ui_notifications_test.rb +20 -21
  34. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 959e8a5bbb07d3d1b6b0d1f0b57f502b4397d5797ccc3037b1e9f77a8229b06a
4
- data.tar.gz: f0bef4b1aca4d471a2616e6b41751f1da2165eb23d9da65be87bf055bc4fab05
3
+ metadata.gz: '09ec7edf2024b4efaeb9904c2f03672efbe85791d08bfe2eae0800cd99b837aa'
4
+ data.tar.gz: 77057f77a6fe853422c8a45f3c100a70bd45d8b3e03582d58d27c692be192550
5
5
  SHA512:
6
- metadata.gz: 2740338c22e5f0371358d037212a2964d4a46119dd2d2275dc290b91742be20bdd2b74ef8b9b036f60e975b4e798424b20776eabfeaa9f49049f24a2389d48c7
7
- data.tar.gz: 43ae242cf9b8d2e7e873ab9fa99b5be157d1f9467e931d163ccf0e831d1e1969cd81ceb0391d1397f1d6606ee159b62e88e97202ddeac112579a34cc74f3d698
6
+ metadata.gz: 31f56309bd113a01bb91be4dc8d4d9c473ebbc438d3496dd18317a079c5a96301cf42771a7f1673e7bfee6cee5999a6cf92e92344e0e5cf56addf03e48e2dbf0
7
+ data.tar.gz: 1885aa1016226b0230bcfcb0d4ad7e282b34bf716ed96f6b13a38db0023866fe07f9f4ef55a4ecdee76241618c365abc9c452525eefc7cf51beb5ce357aacc1a
@@ -11,6 +11,8 @@ jobs:
11
11
  rubocop:
12
12
  name: Rubocop
13
13
  uses: theforeman/actions/.github/workflows/rubocop.yml@v0
14
+ with:
15
+ command: bundle exec rubocop --parallel --format github
14
16
 
15
17
  test:
16
18
  name: Ruby
data/.rubocop.yml CHANGED
@@ -1,10 +1,9 @@
1
- require:
2
- - rubocop-minitest
3
- - rubocop-performance
4
- - rubocop-rails
5
-
6
1
  inherit_from: .rubocop_todo.yml
7
2
 
3
+ inherit_gem:
4
+ theforeman-rubocop:
5
+ - lenient.yml
6
+
8
7
  AllCops:
9
8
  Exclude:
10
9
  - 'node_modules/**/*'
@@ -15,25 +14,10 @@ AllCops:
15
14
  Lint/ShadowingOuterLocalVariable:
16
15
  Enabled: false
17
16
 
18
- Rails:
19
- Enabled: true
20
-
21
- # Don't prefer is_a? over kind_of?
22
- Style/ClassCheck:
23
- Enabled: false
24
-
25
- # Don't enforce documentation
26
- Style/Documentation:
27
- Enabled: false
28
-
29
17
  # Support both ruby19 and hash_rockets
30
18
  Style/HashSyntax:
31
19
  Enabled: false
32
20
 
33
- # Both double and single quotes are OK
34
- Style/StringLiterals:
35
- Enabled: false
36
-
37
21
  # Don't enforce frozen string literals
38
22
  Style/FrozenStringLiteralComment:
39
23
  Enabled: false
@@ -61,21 +45,17 @@ Layout/LineLength:
61
45
 
62
46
  Naming/FileName:
63
47
  Exclude:
64
- - '*.gemspec'
48
+ - "*.gemspec"
65
49
  - Gemfile
66
50
  - db/seeds.d/*
67
51
  - lib/foreman-tasks.rb
68
52
  - gemfile.d/foreman-tasks.rb
69
53
 
70
-
71
54
  Layout/HeredocIndentation:
72
55
  Exclude:
73
- - '*.gemspec'
56
+ - "*.gemspec"
74
57
  - bin/*
75
58
 
76
- Layout/EmptyLineAfterGuardClause:
77
- Enabled: false
78
-
79
59
  Style/RescueStandardError:
80
60
  Enabled: false
81
61
 
@@ -111,12 +91,3 @@ Rails/HelperInstanceVariable:
111
91
 
112
92
  Naming/RescuedExceptionsVariableName:
113
93
  Enabled: false
114
-
115
- Style/WordArray:
116
- Enabled: false
117
-
118
- Style/TrailingCommaInArrayLiteral:
119
- EnforcedStyleForMultiline: comma
120
-
121
- Style/TrailingCommaInHashLiteral:
122
- EnforcedStyleForMultiline: comma
data/.rubocop_todo.yml CHANGED
@@ -1,35 +1,95 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2020-08-07 08:31:32 UTC using RuboCop version 0.89.0.
3
+ # on 2024-04-12 08:56:48 UTC using RuboCop version 1.23.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 2
9
+ # Offense count: 1
10
10
  # Configuration parameters: Include.
11
11
  # Include: **/*.gemspec
12
12
  Gemspec/RequiredRubyVersion:
13
13
  Exclude:
14
14
  - 'foreman-tasks.gemspec'
15
15
 
16
+ # Offense count: 106
17
+ # Cop supports --auto-correct.
18
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
19
+ # SupportedStyles: with_first_argument, with_fixed_indentation
20
+ Layout/ArgumentAlignment:
21
+ Enabled: false
22
+
23
+ # Offense count: 5
24
+ # Cop supports --auto-correct.
25
+ # Configuration parameters: EnforcedStyleAlignWith, Severity.
26
+ # SupportedStylesAlignWith: start_of_line, begin
27
+ Layout/BeginEndAlignment:
28
+ Exclude:
29
+ - 'app/models/foreman_tasks/remote_task.rb'
30
+ - 'app/models/foreman_tasks/task/dynflow_task.rb'
31
+ - 'lib/tasks/gettext.rake'
32
+ - 'test/unit/actions/proxy_action_test.rb'
33
+
34
+ # Offense count: 3
35
+ # Cop supports --auto-correct.
36
+ # Configuration parameters: AllowAliasSyntax, AllowedMethods.
37
+ # AllowedMethods: alias_method, public, protected, private
38
+ Layout/EmptyLinesAroundAttributeAccessor:
39
+ Exclude:
40
+ - 'app/models/foreman_tasks/lock.rb'
41
+ - 'lib/foreman_tasks/cleaner.rb'
42
+ - 'lib/foreman_tasks/triggers.rb'
43
+
44
+ # Offense count: 1
45
+ # Cop supports --auto-correct.
46
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
47
+ # SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
48
+ Layout/FirstArgumentIndentation:
49
+ Exclude:
50
+ - 'test/support/dummy_dynflow_action.rb'
51
+
52
+ # Offense count: 4
53
+ # Cop supports --auto-correct.
54
+ Layout/RescueEnsureAlignment:
55
+ Exclude:
56
+ - 'app/models/foreman_tasks/remote_task.rb'
57
+ - 'lib/foreman_tasks/cleaner.rb'
58
+ - 'lib/tasks/gettext.rake'
59
+ - 'test/unit/actions/proxy_action_test.rb'
60
+
61
+ # Offense count: 8
62
+ # Configuration parameters: AllowedMethods.
63
+ # AllowedMethods: enums
64
+ Lint/ConstantDefinitionInBlock:
65
+ Exclude:
66
+ - 'lib/foreman_tasks/tasks/export_tasks.rake'
67
+ - 'lib/foreman_tasks/tasks/generate_task_actions.rake'
68
+ - 'test/controllers/api/tasks_controller_test.rb'
69
+ - 'test/unit/cleaner_test.rb'
70
+ - 'test/unit/locking_test.rb'
71
+
72
+ # Offense count: 5
73
+ Lint/MissingSuper:
74
+ Exclude:
75
+ - 'app/lib/actions/helpers/humanizer.rb'
76
+ - 'app/services/ui_notifications/tasks.rb'
77
+ - 'app/services/ui_notifications/tasks/task_bulk_cancel.rb'
78
+ - 'app/services/ui_notifications/tasks/task_bulk_resume.rb'
79
+ - 'app/services/ui_notifications/tasks/task_bulk_stop.rb'
80
+
16
81
  # Offense count: 1
17
82
  Lint/UselessAssignment:
18
83
  Exclude:
19
84
  - 'lib/foreman_tasks/tasks/export_tasks.rake'
20
85
 
21
86
  # Offense count: 1
22
- # Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, Regex, IgnoreExecutableScripts, AllowedAcronyms.
23
- # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
24
- Naming/FileName:
87
+ # Cop supports --auto-correct.
88
+ Minitest/AssertEmptyLiteral:
25
89
  Exclude:
26
- - '*.gemspec'
27
- - 'Gemfile'
28
- - 'db/seeds.d/*'
29
- - 'lib/foreman-tasks.rb'
30
- - 'gemfile.d/foreman-tasks.rb'
90
+ - 'test/unit/cleaner_test.rb'
31
91
 
32
- # Offense count: 3
92
+ # Offense count: 2
33
93
  # Configuration parameters: EnforcedStyleForLeadingUnderscores.
34
94
  # SupportedStylesForLeadingUnderscores: disallowed, required, optional
35
95
  Naming/MemoizedInstanceVariableName:
@@ -52,9 +112,15 @@ Naming/MethodParameterName:
52
112
  # MethodDefinitionMacros: define_method, define_singleton_method
53
113
  Naming/PredicateName:
54
114
  Exclude:
55
- - 'spec/**/*'
56
115
  - 'app/models/foreman_tasks/task/status_explicator.rb'
57
116
 
117
+ # Offense count: 2
118
+ # Configuration parameters: MinSize.
119
+ Performance/CollectionLiteralInLoop:
120
+ Exclude:
121
+ - 'app/lib/actions/middleware/watch_delegated_proxy_sub_tasks.rb'
122
+ - 'db/seeds.d/61-foreman_tasks_bookmarks.rb'
123
+
58
124
  # Offense count: 6
59
125
  # Configuration parameters: Include.
60
126
  # Include: db/migrate/*.rb
@@ -67,6 +133,7 @@ Rails/CreateTableWithTimestamps:
67
133
  - 'db/migrate/20151112152108_create_triggerings.rb'
68
134
 
69
135
  # Offense count: 1
136
+ # Cop supports --auto-correct.
70
137
  # Configuration parameters: Include.
71
138
  # Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb
72
139
  Rails/Output:
@@ -78,18 +145,47 @@ Rails/OutputSafety:
78
145
  Exclude:
79
146
  - 'app/helpers/foreman_tasks/foreman_tasks_helper.rb'
80
147
 
81
- # Offense count: 2
148
+ # Offense count: 1
149
+ # Cop supports --auto-correct.
150
+ Rails/Pick:
151
+ Exclude:
152
+ - 'app/lib/actions/helpers/lifecycle_logging.rb'
153
+
154
+ # Offense count: 1
155
+ # Cop supports --auto-correct.
82
156
  # Configuration parameters: Include.
83
157
  # Include: **/Rakefile, **/*.rake
84
158
  Rails/RakeEnvironment:
85
159
  Exclude:
86
- - 'lib/capistrano/tasks/**/*.rake'
87
160
  - 'lib/foreman_tasks/tasks/dynflow.rake'
88
- - 'lib/foreman_tasks/tasks/test.rake'
89
161
 
90
- # Offense count: 12
162
+ # Offense count: 1
163
+ # Cop supports --auto-correct.
164
+ Rails/RedundantForeignKey:
165
+ Exclude:
166
+ - 'app/models/foreman_tasks/triggering.rb'
167
+
168
+ # Offense count: 2
169
+ # Cop supports --auto-correct.
170
+ # Configuration parameters: EnforcedStyle.
171
+ # SupportedStyles: separated, grouped
172
+ Style/AccessorGrouping:
173
+ Exclude:
174
+ - 'lib/foreman_tasks/task_error.rb'
175
+
176
+ # Offense count: 4
177
+ # Cop supports --auto-correct.
178
+ # Configuration parameters: EnforcedStyle.
179
+ # SupportedStyles: prefer_alias, prefer_alias_method
180
+ Style/Alias:
181
+ Exclude:
182
+ - 'app/models/foreman_tasks/concerns/action_triggering.rb'
183
+ - 'app/models/foreman_tasks/task.rb'
184
+ - 'app/models/foreman_tasks/task_groups/recurring_logic_task_group.rb'
185
+
186
+ # Offense count: 10
91
187
  # Cop supports --auto-correct.
92
- # Configuration parameters: AutoCorrect, EnforcedStyle.
188
+ # Configuration parameters: EnforcedStyle.
93
189
  # SupportedStyles: nested, compact
94
190
  Style/ClassAndModuleChildren:
95
191
  Exclude:
@@ -98,21 +194,117 @@ Style/ClassAndModuleChildren:
98
194
  - 'app/models/foreman_tasks/task/status_explicator.rb'
99
195
  - 'app/models/foreman_tasks/task/summarizer.rb'
100
196
  - 'app/models/foreman_tasks/task/task_cancelled_exception.rb'
101
- - 'app/models/setting/foreman_tasks.rb'
102
197
  - 'lib/foreman_tasks/dynflow/configuration.rb'
103
198
  - 'lib/foreman_tasks/dynflow/console_authorizer.rb'
104
- - 'lib/foreman_tasks/dynflow/persistence.rb'
105
199
  - 'test/controllers/api/recurring_logics_controller_test.rb'
106
200
  - 'test/controllers/api/tasks_controller_test.rb'
107
201
 
202
+ # Offense count: 3
203
+ # Cop supports --auto-correct.
204
+ # Configuration parameters: IgnoredMethods.
205
+ # IgnoredMethods: ==, equal?, eql?
206
+ Style/ClassEqualityComparison:
207
+ Exclude:
208
+ - 'app/lib/actions/proxy_action.rb'
209
+ - 'app/models/foreman_tasks/task/dynflow_task.rb'
210
+ - 'lib/foreman_tasks/test_extensions.rb'
211
+
108
212
  # Offense count: 1
213
+ # Cop supports --auto-correct.
214
+ # Configuration parameters: Keywords, RequireColon.
215
+ # Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW, NOTE
216
+ Style/CommentAnnotation:
217
+ Exclude:
218
+ - 'app/models/foreman_tasks/task.rb'
219
+
220
+ # Offense count: 14
221
+ # Cop supports --auto-correct.
109
222
  # Configuration parameters: EnforcedStyle.
110
- # SupportedStyles: allowed_in_returns, forbidden
111
- Style/DoubleNegation:
223
+ # SupportedStyles: compact, expanded
224
+ Style/EmptyMethod:
112
225
  Exclude:
113
- - 'app/models/foreman_tasks/recurring_logic.rb'
226
+ - 'app/controllers/foreman_tasks/api/recurring_logics_controller.rb'
227
+ - 'app/controllers/foreman_tasks/api/tasks_controller.rb'
228
+ - 'app/controllers/foreman_tasks/recurring_logics_controller.rb'
229
+ - 'app/lib/actions/helpers/humanizer.rb'
230
+ - 'app/models/foreman_tasks/concerns/action_triggering.rb'
231
+ - 'test/lib/actions/middleware/keep_current_taxonomies_test.rb'
232
+ - 'test/lib/actions/middleware/keep_current_timezone_test.rb'
233
+ - 'test/lib/actions/middleware/keep_current_user_test.rb'
234
+ - 'test/unit/actions/action_with_sub_plans_test.rb'
114
235
 
115
- # Offense count: 35
236
+ # Offense count: 6
237
+ # Cop supports --auto-correct.
238
+ Style/ExplicitBlockArgument:
239
+ Exclude:
240
+ - 'app/lib/actions/middleware/keep_current_request_id.rb'
241
+ - 'app/lib/actions/middleware/keep_current_taxonomies.rb'
242
+ - 'app/lib/actions/middleware/keep_current_timezone.rb'
243
+ - 'app/lib/actions/middleware/keep_current_user.rb'
244
+ - 'app/lib/actions/middleware/watch_delegated_proxy_sub_tasks.rb'
245
+ - 'lib/foreman_tasks.rb'
246
+
247
+ # Offense count: 31
116
248
  # Configuration parameters: MinBodyLength.
117
249
  Style/GuardClause:
118
- Enabled: false
250
+ Exclude:
251
+ - 'app/lib/actions/bulk_action.rb'
252
+ - 'app/lib/actions/entry_action.rb'
253
+ - 'app/lib/actions/helpers/humanizer.rb'
254
+ - 'app/lib/actions/helpers/with_delegated_action.rb'
255
+ - 'app/lib/actions/proxy_action.rb'
256
+ - 'app/models/foreman_tasks/concerns/action_triggering.rb'
257
+ - 'app/models/foreman_tasks/concerns/user_extensions.rb'
258
+ - 'app/models/foreman_tasks/task/dynflow_task.rb'
259
+ - 'app/models/foreman_tasks/triggering.rb'
260
+ - 'db/migrate/20161003091412_add_missing_indexes.rb'
261
+ - 'db/migrate/20180216092715_use_uuid.rb'
262
+ - 'lib/foreman_tasks/dynflow/console_authorizer.rb'
263
+ - 'lib/foreman_tasks/tasks/export_tasks.rake'
264
+ - 'lib/foreman_tasks/test_extensions.rb'
265
+ - 'test/controllers/api/tasks_controller_test.rb'
266
+
267
+ # Offense count: 2
268
+ # Configuration parameters: MinBranchesCount.
269
+ Style/HashLikeCase:
270
+ Exclude:
271
+ - 'app/models/foreman_tasks/recurring_logic.rb'
272
+ - 'app/models/foreman_tasks/task.rb'
273
+
274
+ # Offense count: 6
275
+ # Configuration parameters: AllowedMethods.
276
+ # AllowedMethods: respond_to_missing?
277
+ Style/OptionalBooleanParameter:
278
+ Exclude:
279
+ - 'app/helpers/foreman_tasks/foreman_tasks_helper.rb'
280
+ - 'app/lib/actions/proxy_action.rb'
281
+ - 'app/models/foreman_tasks/task/dynflow_task.rb'
282
+ - 'lib/foreman_tasks/cleaner.rb'
283
+ - 'test/controllers/api/tasks_controller_test.rb'
284
+ - 'test/lib/actions/middleware/keep_current_request_id_test.rb'
285
+
286
+ # Offense count: 2
287
+ # Cop supports --auto-correct.
288
+ Style/RedundantAssignment:
289
+ Exclude:
290
+ - 'bin/dynflow-executor'
291
+ - 'lib/foreman_tasks/cleaner.rb'
292
+
293
+ # Offense count: 2
294
+ # Cop supports --auto-correct.
295
+ Style/RedundantBegin:
296
+ Exclude:
297
+ - 'app/models/foreman_tasks/task/dynflow_task.rb'
298
+
299
+ # Offense count: 2
300
+ # Cop supports --auto-correct.
301
+ Style/SlicingWithRange:
302
+ Exclude:
303
+ - 'test/unit/task_test.rb'
304
+
305
+ # Offense count: 1
306
+ # Cop supports --auto-correct.
307
+ # Configuration parameters: AllowModifier.
308
+ Style/SoleNestedConditional:
309
+ Exclude:
310
+ - 'app/lib/actions/task_synchronization.rb'
data/Gemfile CHANGED
@@ -1,20 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- # Declare your gem's dependencies in tasks.gemspec.
4
- # Bundler will treat runtime dependencies like base dependencies, and
5
- # development dependencies will be added by default to the :development group.
3
+ gemspec
6
4
 
7
- gemspec :name => 'foreman-tasks'
8
-
9
- # Declare any dependencies that are still in development here instead of in
10
- # your gemspec. These might include edge Rails or gems from your path or
11
- # Git. Remember to move these dependencies to your gemspec before releasing
12
- # your gem to rubygems.org.
13
-
14
- # To use debugger
15
- # gem 'debugger'
16
-
17
- gem 'rubocop', '~> 0.87'
18
- gem 'rubocop-minitest', '~> 0.9.0'
19
- gem 'rubocop-performance', '~> 1.5.2'
20
- gem 'rubocop-rails', '~> 2.5.2'
5
+ gem 'theforeman-rubocop', '~> 0.1.0'
@@ -69,7 +69,7 @@ module ForemanTasks
69
69
 
70
70
  def unlock
71
71
  if @dynflow_task.paused?
72
- unlock_task(@dynflow_task)
72
+ @dynflow_task.halt
73
73
  render json: { statusText: 'OK' }
74
74
  else
75
75
  render json: {}, status: :bad_request
@@ -77,8 +77,13 @@ module ForemanTasks
77
77
  end
78
78
 
79
79
  def force_unlock
80
- unlock_task(@dynflow_task)
81
- render json: { statusText: 'OK' }
80
+ if @dynflow_task.pending?
81
+ @dynflow_task.halt
82
+ render json: { statusText: 'OK' }
83
+ else
84
+ # Cannot halt an already stopped task
85
+ render json: {}, status: :bad_request
86
+ end
82
87
  end
83
88
 
84
89
  # we need do this to make the Foreman helpers working properly
@@ -92,12 +97,6 @@ module ForemanTasks
92
97
 
93
98
  private
94
99
 
95
- def unlock_task(task)
96
- task.state = :stopped
97
- task.locks.destroy_all
98
- task.save!
99
- end
100
-
101
100
  def respond_with_tasks(scope)
102
101
  @tasks = filter(scope, paginate: false).with_duration
103
102
  csv_response(@tasks, [:id, :action, :state, :result, 'started_at.in_time_zone', 'ended_at.in_time_zone', :duration, :username], ['Id', 'Action', 'State', 'Result', 'Started At', 'Ended At', 'Duration', 'User'])
@@ -42,6 +42,9 @@ module ForemanTasks
42
42
  end
43
43
 
44
44
  def update_from_batch_trigger(data, parent = {})
45
+ # The ID might get overwritten later, but it is a sane default in case of async
46
+ # triggering where we only get an id of a remote parent
47
+ self.remote_task_id = execution_plan_id
45
48
  if data['result'] == 'success'
46
49
  self.remote_task_id = data['task_id']
47
50
  self.state = 'triggered'
@@ -251,6 +251,10 @@ module ForemanTasks
251
251
  superclass.model_name
252
252
  end
253
253
 
254
+ def halt
255
+ ::ForemanTasks.dynflow.world.halt(external_id)
256
+ end
257
+
254
258
  private
255
259
 
256
260
  def string_to_time(zone, time)
@@ -26,7 +26,7 @@ same resource. It also optionally provides Dynflow infrastructure for using it f
26
26
  s.test_files = `git ls-files test`.split("\n")
27
27
  s.extra_rdoc_files = Dir['README*', 'LICENSE']
28
28
 
29
- s.add_dependency "dynflow", '>= 1.8.0'
29
+ s.add_dependency "dynflow", '>= 1.9.0'
30
30
  s.add_dependency 'fugit', '~> 1.8'
31
31
  s.add_dependency "get_process_mem" # for memory polling
32
32
  s.add_dependency "sinatra" # for Dynflow web console
@@ -51,7 +51,7 @@ namespace :foreman_tasks do
51
51
  end
52
52
 
53
53
  def template(filename)
54
- File.join(Gem::Specification.find_by_name('dynflow').gem_dir, 'web', 'views', "#{filename}.erb") # rubocop:disable Rails/DynamicFindBy
54
+ File.join(Gem::Specification.find_by_name('dynflow').gem_dir, 'web', 'views', "#{filename}.erb")
55
55
  end
56
56
 
57
57
  def erb(file, options = {})
@@ -216,7 +216,7 @@ namespace :foreman_tasks do
216
216
  'javascripts/application.js',
217
217
  'vendor/bootstrap/css/bootstrap.css',
218
218
  'stylesheets/application.css'].each do |file|
219
- filename = File.join(Gem::Specification.find_by_name('dynflow').gem_dir, 'web', 'assets', file) # rubocop:disable Rails/DynamicFindBy
219
+ filename = File.join(Gem::Specification.find_by_name('dynflow').gem_dir, 'web', 'assets', file)
220
220
  FileUtils.copy_file(filename, File.join(tmp_dir, File.basename(file)))
221
221
  end
222
222
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanTasks
2
- VERSION = '9.1.0'.freeze
2
+ VERSION = '9.2.0'.freeze
3
3
  end
@@ -17,14 +17,14 @@ module ForemanTasks
17
17
  get :index
18
18
  assert_response :success
19
19
  data = JSON.parse(response.body)
20
- _(data['results'].count).must_equal 5
20
+ assert_equal 5, data['results'].count
21
21
  end
22
22
 
23
23
  it 'supports searching' do
24
24
  get :index, params: { :search => 'label = Actions::User::Create' }
25
25
  assert_response :success
26
26
  data = JSON.parse(response.body)
27
- _(data['results'].count).must_equal 5
27
+ assert_equal 5, data['results'].count
28
28
  end
29
29
 
30
30
  it 'renders task ids when searching by resource id' do
@@ -33,15 +33,15 @@ module ForemanTasks
33
33
  get :index, params: { :search => "label = Actions::Katello::Product::Create and resource_id = 1" }
34
34
  assert_response :success
35
35
  data = JSON.parse(response.body)
36
- _(data['results'].first["id"]).must_equal task.id
36
+ assert_equal task.id, data['results'].first["id"]
37
37
  end
38
38
 
39
39
  it 'supports ordering by duration' do
40
40
  get :index, params: { :sort_by => 'duration' }
41
41
  assert_response :success
42
42
  data = JSON.parse(response.body)
43
- _(data.dig('sort', 'by')).must_equal 'duration'
44
- _(data['results'].count).must_equal 5
43
+ assert_equal 'duration', data.dig('sort', 'by')
44
+ assert_equal 5, data['results'].count
45
45
  end
46
46
 
47
47
  context 'with current taxonomies' do
@@ -53,9 +53,9 @@ module ForemanTasks
53
53
  get :index, params: { organization_id: org1.id }
54
54
  assert_response :success
55
55
  results = JSON.parse(response.body)['results']
56
- _(results.count).must_equal 6
57
- _(results.map { |r| r['id'] }).must_include org1_task.id
58
- _(results.map { |r| r['id'] }).wont_include org2_task.id
56
+ assert_equal 6, results.count
57
+ assert_includes results.map { |r| r['id'] }, org1_task.id
58
+ assert_not_includes results.map { |r| r['id'] }, org2_task.id
59
59
  end
60
60
  end
61
61
  end
@@ -66,7 +66,7 @@ module ForemanTasks
66
66
  post :bulk_search, params: { :searches => [{ :type => "task", :task_id => task.id, :search_id => "1" }] }
67
67
  assert_response :success
68
68
  data = JSON.parse(response.body)
69
- _(data[0]['results'][0]['id']).must_equal task.id
69
+ assert_equal task.id, data[0]['results'][0]['id']
70
70
  end
71
71
 
72
72
  it 'can search for a specific resource' do
@@ -77,7 +77,7 @@ module ForemanTasks
77
77
 
78
78
  assert_response :success
79
79
  data = JSON.parse(response.body)
80
- _(data[0]['results'][0]['id']).must_equal task.id
80
+ assert_equal task.id, data[0]['results'][0]['id']
81
81
  end
82
82
  end
83
83
 
@@ -108,7 +108,7 @@ module ForemanTasks
108
108
  get :show, params: { id: task.id }, session: set_session_user
109
109
  assert_response :success
110
110
  data = JSON.parse(response.body)
111
- _(data['duration']).must_equal task.duration.in_seconds.to_s
111
+ assert_equal task.duration.in_seconds.to_s, data['duration']
112
112
  end
113
113
  end
114
114
 
@@ -118,7 +118,7 @@ module ForemanTasks
118
118
  get :index, session: set_session_user
119
119
  assert_response :success
120
120
  data = JSON.parse(response.body)
121
- _(data['results'][0]['duration']).must_equal task.duration.in_seconds.to_s
121
+ assert_equal task.duration.in_seconds.to_s, data['results'][0]['duration']
122
122
  end
123
123
  end
124
124
 
@@ -189,17 +189,17 @@ module ForemanTasks
189
189
  wait_for { ForemanTasks::Task.find_by(external_id: triggered.id).state == 'running' }
190
190
 
191
191
  task = ForemanTasks::Task.where(:external_id => triggered.id).first
192
- _(task.state).must_equal 'running'
193
- _(task.result).must_equal 'pending'
192
+ assert_equal 'running', task.state
193
+ assert_equal 'pending', task.result
194
194
 
195
195
  callback = Support::DummyProxyAction.proxy.log[:trigger_task].first[1].first[1][:action_input][:callback]
196
196
  post :callback, params: { 'callback' => callback, 'data' => { 'result' => 'success' } }
197
197
  triggered.finished.wait(5)
198
198
 
199
199
  task.reload
200
- _(task.state).must_equal 'stopped'
201
- _(task.result).must_equal 'success'
202
- _(task.main_action.output['proxy_output']).must_equal('result' => 'success')
200
+ assert_equal 'stopped', task.state
201
+ assert_equal 'success', task.result
202
+ assert_equal({ 'result' => 'success' }, task.main_action.output['proxy_output'])
203
203
  end
204
204
  end
205
205
  end
@@ -141,30 +141,30 @@ module ForemanTasks
141
141
  @controller.stubs(:params).returns(:search => "id = #{task.id}")
142
142
  in_taxonomy_scope(organizations.first) do |_o, _l|
143
143
  results = @controller.send(:filter, ForemanTasks::Task)
144
- _(results.map(&:id).sort).must_equal [task.id]
144
+ assert_equal [task.id], results.map(&:id).sort
145
145
  end
146
146
  end
147
147
 
148
148
  it 'does not scope by taxonomy if unset' do
149
149
  organizations
150
150
  tasks
151
- _(@controller.send(:current_taxonomy_search)).must_equal ''
151
+ assert_equal '', @controller.send(:current_taxonomy_search)
152
152
  results = @controller.send(:filter, ForemanTasks::Task)
153
- _(results.map(&:id).sort).must_equal tasks.map(&:id).sort
153
+ assert_equal tasks.map(&:id).sort, results.map(&:id).sort
154
154
  end
155
155
 
156
156
  it 'scopes by organization if set' do
157
157
  scoped, _, unscoped = tasks
158
158
  in_taxonomy_scope(organizations.first) do |o, _l|
159
- _(@controller.send(:current_taxonomy_search)).must_equal "(organization_id = #{o.id})"
159
+ assert_equal "(organization_id = #{o.id})", @controller.send(:current_taxonomy_search)
160
160
  results = @controller.send(:filter, ForemanTasks::Task)
161
- _(results.map(&:id).sort).must_equal [scoped, unscoped].map(&:id).sort
161
+ assert_equal [scoped, unscoped].map(&:id).sort, results.map(&:id).sort
162
162
  end
163
163
  end
164
164
 
165
165
  it 'scopes by org and location if set' do
166
166
  in_taxonomy_scope(organizations.first, FactoryBot.create(:location)) do |o, l|
167
- _(@controller.send(:current_taxonomy_search)).must_equal "(organization_id = #{o.id} AND location_id = #{l.id})"
167
+ assert_equal "(organization_id = #{o.id} AND location_id = #{l.id})", @controller.send(:current_taxonomy_search)
168
168
  end
169
169
  end
170
170
  end