foreman-tasks 0.17.3 → 0.17.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95c9f8364b129d0fcaccad4e7f8673deb1ff18ab1d5e47b74f2c85fe366af7a3
4
- data.tar.gz: c36bb9f6aedcab3dc1c590797c09b470dd3097c0295a00f9e61dd1b695a011dd
3
+ metadata.gz: 6d2cab32dfa0f863a101a5d4e6edfe28bc25c5f76c4fac5718856de5a7a4c489
4
+ data.tar.gz: 1ecc4c1acc4f1b02a7915602a6248b0b0523ff678f60e7d2b51020c3182996a4
5
5
  SHA512:
6
- metadata.gz: 453f74187dd7bc334ff64dfc0544a317dd60b06e23c83057577a8f346f70281f2a8b71749d200f5edbb09c810f8ec241965a2a5311a7fb849d26166f14a391ae
7
- data.tar.gz: 3a256485bd5f4c92a39cad572c8b402105c0fb5768c173390ea33e75fbfc590899e8c73f455c157f69d48328308e8c88da0a14038f07d659fd8cd46597943d21
6
+ metadata.gz: a6e35951542561fa3adff4efd4e92f519b0d4b723599d587bcb29b0575f1f46aa941c76500b91c71749478888615f0eacd4e11a1f170e92cd06a2dbdf7733ae3
7
+ data.tar.gz: bad6ba1e5959c8b8ab28e4461f36e0a1294bfc286c333b60e575ae7c2df12a92a8ebaabb27a5843012f4378bf64687b1d26f9f7ea7ec3b6347d0c3c8985d38d0
data/.rubocop.yml CHANGED
@@ -1,3 +1,5 @@
1
+ require: rubocop-rails
2
+
1
3
  # TODO: remove this file by either moving cops here or fixing code
2
4
  inherit_from:
3
5
  - .rubocop_todo.yml
@@ -34,9 +36,6 @@ Style/StringLiterals:
34
36
  Style/FrozenStringLiteralComment:
35
37
  Enabled: false
36
38
 
37
- Style/FormatStringToken:
38
- EnforcedStyle: template
39
-
40
39
  Rails/SkipsModelValidations:
41
40
  Enabled: false
42
41
 
@@ -87,9 +86,6 @@ Style/IfUnlessModifier:
87
86
  Style/NumericPredicate:
88
87
  Enabled: false
89
88
 
90
- Style/IfUnlessModifier:
91
- Enabled: false
92
-
93
89
  Style/SafeNavigation:
94
90
  Enabled: false
95
91
 
@@ -116,3 +112,6 @@ Rails/HelperInstanceVariable:
116
112
 
117
113
  Naming/RescuedExceptionsVariableName:
118
114
  Enabled: false
115
+
116
+ Style/WordArray:
117
+ Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -190,3 +190,6 @@ Style/GuardClause:
190
190
  Style/RedundantReturn:
191
191
  Exclude:
192
192
  - 'app/models/foreman_tasks/concerns/action_triggering.rb'
193
+
194
+ Lint/SendWithMixinArgument:
195
+ Enabled: false
@@ -240,7 +240,7 @@ module ForemanTasks
240
240
  sort_by = ordering_params[:sort_by] || 'started_at'
241
241
  sort_order = ordering_params[:sort_order] || 'DESC'
242
242
  scope = scope.select("*, coalesce(ended_at, current_timestamp) - coalesce(coalesce(started_at, ended_at), current_timestamp) as duration")
243
- scope.order("#{sort_by} #{sort_order}")
243
+ scope.order(sort_by => sort_order)
244
244
  end
245
245
 
246
246
  def task_hash(task)
@@ -46,9 +46,9 @@ module Actions
46
46
 
47
47
  def delegated_action
48
48
  # TODO: make it easier in dynflow to load action data
49
- delegated_step = task.execution_plan.steps.values.find_all do |step|
49
+ delegated_step = task.execution_plan.steps.values.reverse.find do |step|
50
50
  step.action_id == input[:delegated_action_id]
51
- end.last
51
+ end
52
52
  return unless delegated_step
53
53
  world.persistence.load_action(delegated_step)
54
54
  end
@@ -19,7 +19,7 @@ module ForemanTasks
19
19
  | #{_('Required lock: %s') % required_lock.name}
20
20
  | #{_('Conflicts with tasks:')}
21
21
  HEADER
22
- url_helpers = Rails.application.routes.url_helpers
22
+ url_helpers = Rails.application.routes.url_helpers
23
23
  conflicting_tasks = conflicting_locks
24
24
  .map(&:task)
25
25
  .uniq
@@ -3,4 +3,4 @@ object @task if @task
3
3
  attributes :id, :label, :pending, :action
4
4
  attributes :username, :started_at, :ended_at, :state, :result, :progress
5
5
  attributes :input, :output, :humanized, :cli_example
6
- node(:available_actions) { |t| {cancellable: t.execution_plan&.cancellable?, resumable: t.resumable? }}
6
+ node(:available_actions) { |t| { cancellable: t.execution_plan&.cancellable?, resumable: t.resumable? } }
@@ -1,4 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
+
2
3
  $LOAD_PATH.push File.expand_path("../lib", __FILE__)
3
4
 
4
5
  # Maintain your gem's version:
@@ -4,15 +4,15 @@ namespace :foreman_tasks do
4
4
  Clean tasks based on filter and age. ENV variables:
5
5
 
6
6
  * TASK_SEARCH : scoped search filter (example: 'label = "Actions::Foreman::Host::ImportFacts"')
7
- * AFTER : delete tasks created after *AFTER* period. Expected format is a number followed by the time unit (s,h,m,y), such as '10d' for 10 days
7
+ * AFTER : delete tasks started after *AFTER* period. Expected format is a number followed by the time unit (s = seconds, m = minutes, h = hours, d = days, y = years), such as '10d' for 10 days
8
8
  * STATES : comma separated list of task states to touch with the cleanup, by default only stopped tasks are covered, special value all can be used to clean the tasks, disregarding their states
9
9
  * NOOP : set to "true" if the task should not actually perform the deletion
10
10
  * VERBOSE : set to "true" for more verbose output
11
11
  * BATCH_SIZE : the size of batches the tasks get processed in (1000 by default)
12
12
  * TASK_BACKUP : set to "true" or "false" to enable/disable task backup
13
13
 
14
- If none of TASK_SEARCH, BEFORE, STATES is specified, the tasks will be cleaned based
15
- configuration in settings
14
+ If TASK_SEARCH is set then AFTER, STATES can be set and it's used for cleanup. If TASK_SEARCH is not set then
15
+ the cleanup respects the configuration file and setting AFTER or STATES will throw exception.
16
16
  DESC
17
17
  task :run => 'environment' do
18
18
  options = {}
@@ -1,3 +1,3 @@
1
1
  module ForemanTasks
2
- VERSION = '0.17.3'.freeze
2
+ VERSION = '0.17.4'.freeze
3
3
  end
@@ -11,6 +11,24 @@ module ForemanTasks
11
11
  @request.env['CONTENT_TYPE'] = 'application/json'
12
12
  end
13
13
 
14
+ describe 'GET /api/tasks' do
15
+ it 'lists all tasks with default sorting' do
16
+ FactoryBot.create_list(:dynflow_task, 5, :user_create_task)
17
+ get :index
18
+ assert_response :success
19
+ data = JSON.parse(response.body)
20
+ _(data['results'].count).must_equal 5
21
+ end
22
+
23
+ it 'supports searching' do
24
+ FactoryBot.create_list(:dynflow_task, 5, :user_create_task)
25
+ get :index, params: { :search => 'label = Actions::User::Create' }
26
+ assert_response :success
27
+ data = JSON.parse(response.body)
28
+ _(data['results'].count).must_equal 5
29
+ end
30
+ end
31
+
14
32
  describe 'GET /api/tasks/show' do
15
33
  it 'searches for task' do
16
34
  task = FactoryBot.create(:dynflow_task, :user_create_task)
@@ -79,10 +79,10 @@ class TasksTest < ActiveSupport::TestCase
79
79
  tasks_to_delete = [FactoryBot.create(:dynflow_task, :user_create_task),
80
80
  FactoryBot.create(:dynflow_task, :product_create_task)]
81
81
 
82
- tasks_to_keep = [FactoryBot.create(:dynflow_task, :user_create_task) do |task|
83
- task.started_at = task.ended_at = Time.zone.now
84
- task.save
85
- end]
82
+ tasks_to_keep = [FactoryBot.create(:dynflow_task, :user_create_task) do |task|
83
+ task.started_at = task.ended_at = Time.zone.now
84
+ task.save
85
+ end]
86
86
  cleaner.expects(:tasks_to_csv)
87
87
  cleaner.delete
88
88
  ForemanTasks::Task.where(id: tasks_to_delete).must_be_empty
@@ -44,9 +44,9 @@ class RecurringLogicsTest < ActiveSupport::TestCase
44
44
  days = '11'
45
45
  days_of_week = { '1' => '1', '2' => '0', '3' => '0', '4' => '1', '5' => '0', '6' => '1', '7' => '0' }
46
46
  time_hash = { '0' => '2015', '1' => '12', '2' => '10', '3' => hours, '4' => minutes }
47
- expected_result_hourly = { :minutes => minutes }
48
- expected_result_daily = { :minutes => minutes, :hours => hours }
49
- expected_result_weekly = { :minutes => minutes, :hours => hours, :days_of_week => '1,4,6' }
47
+ expected_result_hourly = { :minutes => minutes }
48
+ expected_result_daily = { :minutes => minutes, :hours => hours }
49
+ expected_result_weekly = { :minutes => minutes, :hours => hours, :days_of_week => '1,4,6' }
50
50
  expected_result_monthly = { :minutes => minutes, :hours => hours, :days => days }
51
51
  ForemanTasks::RecurringLogic.cronline_hash(:hourly, time_hash, days, days_of_week).must_equal expected_result_hourly
52
52
  ForemanTasks::RecurringLogic.cronline_hash(:daily, time_hash, days, days_of_week).must_equal expected_result_daily
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.3
4
+ version: 0.17.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-21 00:00:00.000000000 Z
11
+ date: 2019-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foreman-tasks-core