foreman-tasks 2.0.3 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/js_tests.yml +27 -0
  3. data/.github/workflows/ruby_tests.yml +74 -0
  4. data/.rubocop.yml +12 -4
  5. data/.rubocop_todo.yml +32 -25
  6. data/Gemfile +5 -0
  7. data/app/controllers/foreman_tasks/api/tasks_controller.rb +31 -58
  8. data/app/controllers/foreman_tasks/concerns/parameters/triggering.rb +1 -1
  9. data/app/controllers/foreman_tasks/recurring_logics_controller.rb +7 -0
  10. data/app/helpers/foreman_tasks/foreman_tasks_helper.rb +3 -3
  11. data/app/models/foreman_tasks/recurring_logic.rb +4 -4
  12. data/app/models/foreman_tasks/task.rb +11 -0
  13. data/app/models/foreman_tasks/task/dynflow_task.rb +27 -33
  14. data/app/models/foreman_tasks/task/status_explicator.rb +1 -1
  15. data/app/models/foreman_tasks/triggering.rb +1 -1
  16. data/app/models/setting/foreman_tasks.rb +1 -1
  17. data/app/views/foreman_tasks/api/tasks/index.json.rabl +2 -0
  18. data/app/views/foreman_tasks/recurring_logics/index.html.erb +3 -1
  19. data/config/routes.rb +2 -1
  20. data/db/migrate/20200517215015_rename_bookmarks_controller.rb +2 -2
  21. data/db/seeds.d/30-notification_blueprints.rb +7 -7
  22. data/db/seeds.d/61-foreman_tasks_bookmarks.rb +1 -1
  23. data/lib/foreman_tasks/cleaner.rb +4 -6
  24. data/lib/foreman_tasks/dynflow/configuration.rb +1 -1
  25. data/lib/foreman_tasks/dynflow/persistence.rb +4 -6
  26. data/lib/foreman_tasks/engine.rb +2 -2
  27. data/lib/foreman_tasks/version.rb +1 -1
  28. data/package.json +0 -1
  29. data/test/controllers/api/recurring_logics_controller_test.rb +1 -1
  30. data/test/controllers/api/tasks_controller_test.rb +7 -7
  31. data/test/controllers/tasks_controller_test.rb +6 -6
  32. data/test/core/unit/runner_test.rb +20 -20
  33. data/test/core/unit/task_launcher_test.rb +8 -8
  34. data/test/helpers/foreman_tasks/foreman_tasks_helper_test.rb +7 -7
  35. data/test/helpers/foreman_tasks/tasks_helper_test.rb +3 -3
  36. data/test/lib/actions/middleware/keep_current_request_id_test.rb +3 -3
  37. data/test/support/history_tasks_builder.rb +1 -1
  38. data/test/tasks/generate_task_actions_test.rb +1 -1
  39. data/test/unit/actions/action_with_sub_plans_test.rb +2 -2
  40. data/test/unit/actions/bulk_action_test.rb +6 -6
  41. data/test/unit/actions/proxy_action_test.rb +20 -20
  42. data/test/unit/actions/recurring_action_test.rb +30 -32
  43. data/test/unit/cleaner_test.rb +24 -24
  44. data/test/unit/dashboard_table_filter_test.rb +5 -5
  45. data/test/unit/otp_manager_test.rb +2 -2
  46. data/test/unit/proxy_selector_test.rb +9 -9
  47. data/test/unit/recurring_logic_test.rb +32 -38
  48. data/test/unit/remote_task_test.rb +2 -2
  49. data/test/unit/task_groups_test.rb +4 -4
  50. data/test/unit/task_test.rb +18 -18
  51. data/test/unit/triggering_test.rb +8 -8
  52. data/test/unit/troubleshooting_help_generator_test.rb +6 -6
  53. data/test/unit/ui_notifications_test.rb +11 -11
  54. data/webpack/ForemanTasks/Components/TaskDetails/Components/RunningSteps.js +3 -3
  55. data/webpack/ForemanTasks/Components/TaskDetails/Components/Task.js +8 -157
  56. data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskButtons.js +168 -0
  57. data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskInfo.js +6 -7
  58. data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskSkeleton.js +48 -0
  59. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/RunningSteps.test.js +1 -1
  60. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Task.test.js +12 -70
  61. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/TaskButtons.test.js +95 -0
  62. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Task.test.js.snap +78 -225
  63. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskButtons.test.js.snap +212 -0
  64. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskInfo.test.js.snap +8 -4
  65. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.js +87 -70
  66. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsActions.js +48 -125
  67. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsConstants.js +3 -16
  68. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsSelectors.js +55 -29
  69. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.fixtures.js +2 -2
  70. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.test.js +6 -0
  71. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsActions.test.js +2 -18
  72. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetails.test.js.snap +77 -27
  73. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetailsActions.test.js.snap +14 -101
  74. data/webpack/ForemanTasks/Components/TaskDetails/index.js +6 -3
  75. data/webpack/ForemanTasks/Components/common/urlHelpers.js +7 -0
  76. data/webpack/ForemanTasks/ForemanTasksReducers.js +0 -2
  77. data/webpack/__mocks__/foremanReact/common/helpers.js +2 -0
  78. data/webpack/__mocks__/foremanReact/redux/API/APISelectors.js +10 -0
  79. data/webpack/__mocks__/foremanReact/redux/API/index.js +10 -0
  80. data/webpack/__mocks__/foremanReact/redux/middlewares/IntervalMiddleware.js +5 -0
  81. metadata +17 -14
  82. data/.travis.yml +0 -7
  83. data/script/travis_run_js_tests.sh +0 -7
  84. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js +0 -38
  85. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsReducer.test.js +0 -33
  86. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetailsReducer.test.js.snap +0 -26
  87. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/integration.test.js.snap +0 -122
  88. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/integration.test.js +0 -72
  89. data/webpack/__mocks__/foremanReact/redux/API.js +0 -7
@@ -31,12 +31,12 @@ module ForemanTasks
31
31
  if value
32
32
  task.update!(:start_at => next_occurrence_time) if task.start_at < Time.zone.now
33
33
  update(:state => 'active')
34
+ else
35
+ update(:state => 'disabled')
34
36
  end
35
- elsif value
37
+ else
36
38
  raise RecurringLogicCancelledException
37
39
  end
38
-
39
- update(:state => 'disabled') unless value
40
40
  end
41
41
 
42
42
  def enabled?
@@ -95,7 +95,7 @@ module ForemanTasks
95
95
  :start_at => next_occurrence_time(time),
96
96
  :start_before => options['start_before'],
97
97
  :recurring_logic_id => id,
98
- :frozen => disabled?
98
+ :frozen => disabled?,
99
99
  }
100
100
  end
101
101
 
@@ -70,6 +70,17 @@ module ForemanTasks
70
70
  end)
71
71
  scope :for_action_types, (->(action_types) { where('foreman_tasks_tasks.label IN (?)', Array(action_types)) })
72
72
 
73
+ apipie :class, "A class representing #{model_name.human} object" do
74
+ name 'Task'
75
+ refs 'Task'
76
+ sections only: %w[all additional]
77
+ property :main_action, object_of: 'Dynflow::Action', desc: 'Returns the main action of the task, e.g. Actions::RemoteExecution::RunHostJob'
78
+ property :label, String, desc: 'Returns the label of the task'
79
+ property :state, String, desc: 'Returns state of the task execution, e.g. "stopped"'
80
+ property :result, String, desc: 'Returns result of the task execution, e.g. "success"'
81
+ property :started_at, ActiveSupport::TimeWithZone, desc: 'Returns date with time the task started at'
82
+ property :ended_at, ActiveSupport::TimeWithZone, desc: 'Returns date with time the task ended at'
83
+ end
73
84
  class Jail < Safemode::Jail
74
85
  allow :started_at, :ended_at, :result, :state, :label, :main_action
75
86
  end
@@ -102,32 +102,28 @@ module ForemanTasks
102
102
 
103
103
  def input_output_failed_steps
104
104
  failed_steps.map do |f|
105
- begin
106
- f_action = f.action(execution_plan)
107
- {
108
- error: ({ exception_class: f.error.exception_class, message: f.error.message, backtrace: f.error.backtrace } if f.error),
109
- action_class: f.action_class.name,
110
- state: f.state,
111
- input: f_action.input.pretty_inspect,
112
- output: f_action.output.pretty_inspect
113
- }
114
- end
105
+ f_action = f.action(execution_plan)
106
+ {
107
+ error: ({ exception_class: f.error.exception_class, message: f.error.message, backtrace: f.error.backtrace } if f.error),
108
+ action_class: f.action_class.name,
109
+ state: f.state,
110
+ input: f_action.input.pretty_inspect,
111
+ output: f_action.output.pretty_inspect,
112
+ }
115
113
  end
116
114
  end
117
115
 
118
116
  def input_output_running_steps
119
117
  running_steps.map do |f|
120
- begin
121
- f_action = f.action(execution_plan)
122
- {
123
- id: f_action.id,
124
- action_class: f.action_class.name,
125
- state: f.state,
126
- input: f_action.input.pretty_inspect,
127
- output: f_action.output.pretty_inspect,
128
- cancellable: cancellable_action?(f_action)
129
- }
130
- end
118
+ f_action = f.action(execution_plan)
119
+ {
120
+ id: f_action.id,
121
+ action_class: f.action_class.name,
122
+ state: f.state,
123
+ input: f_action.input.pretty_inspect,
124
+ output: f_action.output.pretty_inspect,
125
+ cancellable: cancellable_action?(f_action),
126
+ }
131
127
  end
132
128
  end
133
129
 
@@ -220,19 +216,17 @@ module ForemanTasks
220
216
  fixed_count = 0
221
217
  logger = Foreman::Logging.logger('foreman-tasks')
222
218
  running.each do |task|
223
- begin
224
- changes = task.update_from_dynflow(task.execution_plan.to_hash)
225
- unless changes.empty?
226
- fixed_count += 1
227
- logger.warn('Task %s updated at consistency check: %s' % [task.id, changes.inspect])
228
- end
229
- rescue => e
230
- # if we fail updating the data from dynflow, it usually means there is something
231
- # odd with the data consistency and at this point it is not possible to resume, switching
232
- # the task to stopped/error
233
- task.update(:state => 'stopped', :result => 'error')
234
- Foreman::Logging.exception("Failed at consistency check for task #{task.id}", e, :logger => 'foreman-tasks')
219
+ changes = task.update_from_dynflow(task.execution_plan.to_hash)
220
+ unless changes.empty?
221
+ fixed_count += 1
222
+ logger.warn('Task %s updated at consistency check: %s' % [task.id, changes.inspect])
235
223
  end
224
+ rescue => e
225
+ # if we fail updating the data from dynflow, it usually means there is something
226
+ # odd with the data consistency and at this point it is not possible to resume, switching
227
+ # the task to stopped/error
228
+ task.update(:state => 'stopped', :result => 'error')
229
+ Foreman::Logging.exception("Failed at consistency check for task #{task.id}", e, :logger => 'foreman-tasks')
236
230
  end
237
231
  fixed_count
238
232
  end
@@ -4,7 +4,7 @@ module ForemanTasks
4
4
  ERRONEOUS_STATUSES = [
5
5
  { :state => 'paused', :result => ANY },
6
6
  { :state => ANY, :result => 'error' },
7
- { :state => ANY, :result => 'warning' }
7
+ { :state => ANY, :result => 'warning' },
8
8
  ].freeze
9
9
  def is_erroneous(task)
10
10
  remainder = ERRONEOUS_STATUSES.select do |status|
@@ -75,7 +75,7 @@ module ForemanTasks
75
75
  def delay_options
76
76
  {
77
77
  :start_at => start_at.utc,
78
- :start_before => start_before.try(:utc)
78
+ :start_before => start_before.try(:utc),
79
79
  }
80
80
  end
81
81
 
@@ -17,7 +17,7 @@ class Setting::ForemanTasks < Setting
17
17
  N_('Polling multiplier which is used to multiply the default polling intervals. '\
18
18
  'This can be used to prevent polling too frequently for long running tasks.'),
19
19
  1,
20
- N_("Polling intervals multiplier"))
20
+ N_("Polling intervals multiplier")),
21
21
  ]
22
22
  end
23
23
 
@@ -0,0 +1,2 @@
1
+ collection @tasks
2
+ extends "foreman_tasks/api/tasks/show"
@@ -37,6 +37,7 @@
37
37
 
38
38
  <table class="<%= table_css_classes('table-condensed table-fixed') %>">
39
39
  <thead>
40
+ <th class="col-md-1"><%= N_("ID") %></th>
40
41
  <th><%= N_("Cron line") %></th>
41
42
  <th><%= N_("Task count") %></th>
42
43
  <th><%= N_("Action") %></th>
@@ -50,7 +51,8 @@
50
51
  </thead>
51
52
  <% @recurring_logics.each do |recurring_logic| %>
52
53
  <tr>
53
- <td><%= link_to(recurring_logic.cron_line, foreman_tasks_recurring_logic_path(recurring_logic)) %></td>
54
+ <td><%= link_to(recurring_logic.id, foreman_tasks_recurring_logic_path(recurring_logic)) %></td>
55
+ <td><%= recurring_logic.cron_line %></td>
54
56
  <td><%= link_to(recurring_logic.tasks.count, foreman_tasks_tasks_url(:search => "task_group.id = #{recurring_logic.task_group.id}")) %></td>
55
57
  <td><%= format_task_input(recurring_logic.tasks.first) %></td>
56
58
  <td><%= recurring_logic.tasks.order(:started_at).where('started_at IS NOT NULL').last.try(:started_at) || "-" %></td>
data/config/routes.rb CHANGED
@@ -7,6 +7,7 @@ Foreman::Application.routes.draw do
7
7
  put :disable
8
8
  end
9
9
  collection do
10
+ get 'auto_complete_search'
10
11
  post :clear_cancelled
11
12
  end
12
13
  end
@@ -50,7 +51,6 @@ Foreman::Application.routes.draw do
50
51
  resources :tasks, :only => [:show, :index] do
51
52
  member do
52
53
  get :details
53
- get :sub_tasks
54
54
  end
55
55
  collection do
56
56
  post :bulk_search
@@ -58,6 +58,7 @@ Foreman::Application.routes.draw do
58
58
  post :bulk_cancel
59
59
  post :bulk_stop
60
60
  get :summary
61
+ get '/:parent_task_id/sub_tasks', action: 'index'
61
62
  get '/summary/:id/sub_tasks/', action: 'summary_sub_tasks'
62
63
  post :callback
63
64
  end
@@ -3,7 +3,7 @@ class RenameBookmarksController < ActiveRecord::Migration[5.2]
3
3
  original_controller = 'foreman_tasks_tasks'
4
4
  original_bookmarks = Bookmark.where(controller: original_controller)
5
5
  original_bookmarks_names = Hash[original_bookmarks.pluck(:name, :id)]
6
-
6
+
7
7
  new_controller = 'foreman_tasks/tasks'
8
8
  new_bookmarks = Bookmark.where(controller: new_controller)
9
9
  new_bookmarks.find_each do |new_bookmark|
@@ -18,7 +18,7 @@ class RenameBookmarksController < ActiveRecord::Migration[5.2]
18
18
  original_bookmark.public == new_bookmark.public
19
19
 
20
20
  if is_duplicated
21
- original_bookmark.destroy
21
+ original_bookmark.destroy
22
22
  else
23
23
  modified_name = "#{name}_#{generate_token}"
24
24
  original_bookmark.update(name: modified_name)
@@ -9,9 +9,9 @@ blueprints = [
9
9
  links:
10
10
  [
11
11
  href: "/foreman_tasks/tasks?search=#{CGI.escape('state=paused')}",
12
- title: N_('List of tasks')
13
- ]
14
- }
12
+ title: N_('List of tasks'),
13
+ ],
14
+ },
15
15
  },
16
16
 
17
17
  {
@@ -24,9 +24,9 @@ blueprints = [
24
24
  links:
25
25
  [
26
26
  path_method: :foreman_tasks_task_path,
27
- title: N_('Task Details')
28
- ]
29
- }
27
+ title: N_('Task Details'),
28
+ ],
29
+ },
30
30
  },
31
31
 
32
32
  {
@@ -48,7 +48,7 @@ blueprints = [
48
48
  name: 'tasks_bulk_stop',
49
49
  level: 'info',
50
50
  message: "DYNAMIC",
51
- }
51
+ },
52
52
  ]
53
53
 
54
54
  blueprints.each { |blueprint| UINotifications::Seed.new(blueprint).configure }
@@ -1,7 +1,7 @@
1
1
  Bookmark.without_auditing do
2
2
  [
3
3
  { :name => 'running', :query => 'state = running' },
4
- { :name => 'failed', :query => 'state = paused or result = error or result = warning' }
4
+ { :name => 'failed', :query => 'state = paused or result = error or result = warning' },
5
5
 
6
6
  ].each do |item|
7
7
  next if Bookmark.where(:name => item[:name]).first
@@ -30,12 +30,10 @@ module ForemanTasks
30
30
  actions_with_periods = {}
31
31
  if cleanup_settings[:actions]
32
32
  cleanup_settings[:actions].each do |action|
33
- begin
34
- action_class = action[:name].constantize
35
- actions_with_periods[action_class] = action[:after]
36
- rescue => e
37
- Foreman::Logging.exception("Error handling #{action} cleanup settings", e)
38
- end
33
+ action_class = action[:name].constantize
34
+ actions_with_periods[action_class] = action[:after]
35
+ rescue => e
36
+ Foreman::Logging.exception("Error handling #{action} cleanup settings", e)
39
37
  end
40
38
  end
41
39
  (ForemanTasks.dynflow.world.action_classes - actions_with_periods.keys).each do |action_class|
@@ -15,7 +15,7 @@ module ForemanTasks
15
15
  return @backup_settings if @backup_settings
16
16
  backup_options = {
17
17
  :backup_deleted_plans => true,
18
- :backup_dir => default_backup_dir
18
+ :backup_dir => default_backup_dir,
19
19
  }
20
20
  settings = SETTINGS[:'foreman-tasks'] && SETTINGS[:'foreman-tasks'][:backup]
21
21
  backup_options.merge!(settings) if settings
@@ -8,12 +8,10 @@ module ForemanTasks
8
8
  # clear connection only if not running in some active record transaction already
9
9
  clear_connections = ActiveRecord::Base.connection.open_transactions.zero?
10
10
  super.tap do
11
- begin
12
- on_execution_plan_save(execution_plan_id, value)
13
- rescue => e
14
- Foreman::Logging.exception('Error on on_execution_plan_save event', e,
15
- :logger => 'dynflow')
16
- end
11
+ on_execution_plan_save(execution_plan_id, value)
12
+ rescue => e
13
+ Foreman::Logging.exception('Error on on_execution_plan_save event', e,
14
+ :logger => 'dynflow')
17
15
  end
18
16
  ensure
19
17
  ::ActiveRecord::Base.clear_active_connections! if clear_connections
@@ -34,7 +34,7 @@ module ForemanTasks
34
34
 
35
35
  initializer 'foreman_tasks.register_plugin', :before => :finisher_hook do |_app|
36
36
  Foreman::Plugin.register :"foreman-tasks" do
37
- requires_foreman '>= 2.1.0'
37
+ requires_foreman '>= 2.2.0'
38
38
  divider :top_menu, :parent => :monitor_menu, :last => true, :caption => N_('Foreman Tasks')
39
39
  menu :top_menu, :tasks,
40
40
  :url_hash => { :controller => 'foreman_tasks/tasks', :action => :index },
@@ -57,7 +57,7 @@ module ForemanTasks
57
57
 
58
58
  permission :create_recurring_logics, {}, :resource_type => ForemanTasks::RecurringLogic.name
59
59
 
60
- permission :view_recurring_logics, { :'foreman_tasks/recurring_logics' => [:index, :show],
60
+ permission :view_recurring_logics, { :'foreman_tasks/recurring_logics' => [:auto_complete_search, :index, :show],
61
61
  :'foreman_tasks/api/recurring_logics' => [:index, :show] }, :resource_type => ForemanTasks::RecurringLogic.name
62
62
 
63
63
  permission :edit_recurring_logics, { :'foreman_tasks/recurring_logics' => [:cancel, :enable, :disable, :clear_cancelled],
@@ -1,3 +1,3 @@
1
1
  module ForemanTasks
2
- VERSION = '2.0.3'.freeze
2
+ VERSION = '3.0.0'.freeze
3
3
  end
data/package.json CHANGED
@@ -28,7 +28,6 @@
28
28
  "dependencies": {
29
29
  "c3": "^0.4.11",
30
30
  "humanize-duration": "^3.20.1",
31
- "react-html-parser": "^2.0.2",
32
31
  "react-intl": "^2.8.0"
33
32
  },
34
33
  "devDependencies": {
@@ -44,7 +44,7 @@ module ForemanRecurringLogic
44
44
  post :cancel, params: { :id => @recurring_logic.id }
45
45
  assert_response :success
46
46
  @recurring_logic.reload
47
- assert @recurring_logic.state == 'cancelled'
47
+ assert_equal @recurring_logic.state, 'cancelled'
48
48
  end
49
49
  end
50
50
  end
@@ -115,7 +115,7 @@ module ForemanTasks
115
115
  assert_response :success
116
116
  response = JSON.parse(@response.body)
117
117
  assert_kind_of Array, response
118
- assert response.empty?
118
+ assert_empty response
119
119
  end
120
120
  end
121
121
  end
@@ -135,18 +135,18 @@ module ForemanTasks
135
135
  wait_for { ForemanTasks::Task.find_by(external_id: triggered.id).state == 'running' }
136
136
 
137
137
  task = ForemanTasks::Task.where(:external_id => triggered.id).first
138
- task.state.must_equal 'running'
139
- task.result.must_equal 'pending'
138
+ _(task.state).must_equal 'running'
139
+ _(task.result).must_equal 'pending'
140
140
 
141
141
  callback = Support::DummyProxyAction.proxy.log[:trigger_task].first[1][:callback]
142
142
  post :callback, params: { 'callback' => callback, 'data' => { 'result' => 'success' } }
143
143
  triggered.finished.wait(5)
144
144
 
145
145
  task.reload
146
- task.state.must_equal 'stopped'
147
- task.result.must_equal 'success'
148
- task.main_action.output['proxy_task_id'].must_equal Support::DummyProxyAction.proxy.uuid
149
- task.main_action.output['proxy_output'].must_equal('result' => 'success')
146
+ _(task.state).must_equal 'stopped'
147
+ _(task.result).must_equal 'success'
148
+ _(task.main_action.output['proxy_task_id']).must_equal Support::DummyProxyAction.proxy.uuid
149
+ _(task.main_action.output['proxy_output']).must_equal('result' => 'success')
150
150
  end
151
151
  end
152
152
  end
@@ -120,30 +120,30 @@ module ForemanTasks
120
120
  @controller.stubs(:params).returns(:search => "id = #{task.id}")
121
121
  in_taxonomy_scope(organizations.first) do |_o, _l|
122
122
  results = @controller.send(:filter, ForemanTasks::Task)
123
- results.map(&:id).sort.must_equal [task.id]
123
+ _(results.map(&:id).sort).must_equal [task.id]
124
124
  end
125
125
  end
126
126
 
127
127
  it 'does not scope by taxonomy if unset' do
128
128
  organizations
129
129
  tasks
130
- @controller.send(:current_taxonomy_search).must_equal ''
130
+ _(@controller.send(:current_taxonomy_search)).must_equal ''
131
131
  results = @controller.send(:filter, ForemanTasks::Task)
132
- results.map(&:id).sort.must_equal tasks.map(&:id).sort
132
+ _(results.map(&:id).sort).must_equal tasks.map(&:id).sort
133
133
  end
134
134
 
135
135
  it 'scopes by organization if set' do
136
136
  scoped, _, unscoped = tasks
137
137
  in_taxonomy_scope(organizations.first) do |o, _l|
138
- @controller.send(:current_taxonomy_search).must_equal "(organization_id = #{o.id})"
138
+ _(@controller.send(:current_taxonomy_search)).must_equal "(organization_id = #{o.id})"
139
139
  results = @controller.send(:filter, ForemanTasks::Task)
140
- results.map(&:id).sort.must_equal [scoped, unscoped].map(&:id).sort
140
+ _(results.map(&:id).sort).must_equal [scoped, unscoped].map(&:id).sort
141
141
  end
142
142
  end
143
143
 
144
144
  it 'scopes by org and location if set' do
145
145
  in_taxonomy_scope(organizations.first, FactoryBot.create(:location)) do |o, l|
146
- @controller.send(:current_taxonomy_search).must_equal "(organization_id = #{o.id} AND location_id = #{l.id})"
146
+ _(@controller.send(:current_taxonomy_search)).must_equal "(organization_id = #{o.id} AND location_id = #{l.id})"
147
147
  end
148
148
  end
149
149
  end
@@ -14,7 +14,7 @@ module ForemanTasksCore
14
14
 
15
15
  describe '#generate_updates' do
16
16
  it 'returns empty hash when there are no outputs' do
17
- runner.generate_updates.must_be :empty?
17
+ _(runner.generate_updates).must_be :empty?
18
18
  end
19
19
 
20
20
  it 'returns a hash with outputs' do
@@ -22,10 +22,10 @@ module ForemanTasksCore
22
22
  type = 'stdout'
23
23
  runner.publish_data(message, type)
24
24
  updates = runner.generate_updates
25
- updates.keys.must_equal [suspended_action]
25
+ _(updates.keys).must_equal [suspended_action]
26
26
  update = updates.values.first
27
- update.exit_status.must_be :nil?
28
- update.continuous_output.raw_outputs.count.must_equal 1
27
+ _(update.exit_status).must_be :nil?
28
+ _(update.continuous_output.raw_outputs.count).must_equal 1
29
29
  end
30
30
 
31
31
  it 'works in compatibility mode' do
@@ -34,10 +34,10 @@ module ForemanTasksCore
34
34
  type = 'stdout'
35
35
  runner.publish_data(message, type)
36
36
  updates = runner.generate_updates
37
- updates.keys.must_equal [nil]
37
+ _(updates.keys).must_equal [nil]
38
38
  update = updates.values.first
39
- update.exit_status.must_be :nil?
40
- update.continuous_output.raw_outputs.count.must_equal 1
39
+ _(update.exit_status).must_be :nil?
40
+ _(update.continuous_output.raw_outputs.count).must_equal 1
41
41
  end
42
42
  end
43
43
  end
@@ -53,38 +53,38 @@ module ForemanTasksCore
53
53
  describe '#initialize_continuous_outputs' do
54
54
  it 'initializes outputs for targets and parent' do
55
55
  outputs = runner.initialize_continuous_outputs
56
- outputs.keys.count.must_equal 3
57
- outputs.values.each { |output| output.must_be_instance_of ContinuousOutput }
56
+ _(outputs.keys.count).must_equal 3
57
+ outputs.values.each { |output| _(output).must_be_instance_of ContinuousOutput }
58
58
  end
59
59
  end
60
60
 
61
61
  describe '#generate_updates' do
62
62
  it 'returns only updates for hosts with pending outputs' do
63
- runner.generate_updates.must_equal({})
63
+ _(runner.generate_updates).must_equal({})
64
64
  runner.publish_data_for('foo', 'something', 'something')
65
65
  updates = runner.generate_updates
66
- updates.keys.count.must_equal 1
66
+ _(updates.keys.count).must_equal 1
67
67
  end
68
68
 
69
69
  it 'works in compatibility mode' do
70
70
  runner = Parent.new targets
71
- runner.generate_updates.must_equal({})
71
+ _(runner.generate_updates).must_equal({})
72
72
  runner.broadcast_data('something', 'stdout')
73
73
  updates = runner.generate_updates
74
- updates.keys.count.must_equal 3
74
+ _(updates.keys.count).must_equal 3
75
75
  # One of the keys is nil in compatibility mode
76
- updates.keys.compact.count.must_equal 2
76
+ _(updates.keys.compact.count).must_equal 2
77
77
  updates.keys.compact.each do |key|
78
- key.must_be_instance_of ::Dynflow::Action::Suspended
78
+ _(key).must_be_instance_of ::Dynflow::Action::Suspended
79
79
  end
80
80
  end
81
81
 
82
82
  it 'works without compatibility mode' do
83
83
  runner.broadcast_data('something', 'stdout')
84
84
  updates = runner.generate_updates
85
- updates.keys.count.must_equal 3
85
+ _(updates.keys.count).must_equal 3
86
86
  updates.keys.each do |key|
87
- key.must_be_instance_of ::Dynflow::Action::Suspended
87
+ _(key).must_be_instance_of ::Dynflow::Action::Suspended
88
88
  end
89
89
  end
90
90
  end
@@ -92,14 +92,14 @@ module ForemanTasksCore
92
92
  describe '#publish_data_for' do
93
93
  it 'publishes data for a single host' do
94
94
  runner.publish_data_for('foo', 'message', 'stdout')
95
- runner.generate_updates.keys.count.must_equal 1
95
+ _(runner.generate_updates.keys.count).must_equal 1
96
96
  end
97
97
  end
98
98
 
99
99
  describe '#broadcast_data' do
100
100
  it 'publishes data for all hosts' do
101
101
  runner.broadcast_data('message', 'stdout')
102
- runner.generate_updates.keys.count.must_equal 3
102
+ _(runner.generate_updates.keys.count).must_equal 3
103
103
  end
104
104
  end
105
105
 
@@ -115,7 +115,7 @@ module ForemanTasksCore
115
115
  it 'broadcasts the exception to all targets' do
116
116
  runner.expects(:publish_exit_status).never
117
117
  runner.publish_exception('general failure', exception, false)
118
- runner.generate_updates.keys.count.must_equal 3
118
+ _(runner.generate_updates.keys.count).must_equal 3
119
119
  end
120
120
 
121
121
  it 'publishes exit status if fatal' do