foreman-tasks 9.1.0 → 9.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/foreman_tasks/remote_task.rb +3 -0
- data/lib/foreman_tasks/version.rb +1 -1
- data/test/controllers/api/tasks_controller_test.rb +17 -17
- data/test/controllers/tasks_controller_test.rb +6 -6
- data/test/helpers/foreman_tasks/foreman_tasks_helper_test.rb +7 -7
- data/test/helpers/foreman_tasks/tasks_helper_test.rb +3 -3
- data/test/lib/actions/middleware/keep_current_request_id_test.rb +3 -3
- data/test/lib/concerns/polling_action_extensions_test.rb +4 -4
- data/test/tasks/generate_task_actions_test.rb +1 -1
- data/test/unit/actions/action_with_sub_plans_test.rb +4 -4
- data/test/unit/actions/bulk_action_test.rb +9 -9
- data/test/unit/actions/proxy_action_test.rb +20 -20
- data/test/unit/actions/recurring_action_test.rb +15 -15
- data/test/unit/actions/trigger_proxy_batch_test.rb +4 -4
- data/test/unit/cleaner_test.rb +24 -24
- data/test/unit/locking_test.rb +8 -8
- data/test/unit/proxy_selector_test.rb +9 -9
- data/test/unit/recurring_logic_test.rb +31 -32
- data/test/unit/remote_task_test.rb +4 -4
- data/test/unit/task_groups_test.rb +4 -4
- data/test/unit/task_test.rb +51 -51
- data/test/unit/triggering_test.rb +11 -11
- data/test/unit/troubleshooting_help_generator_test.rb +6 -6
- data/test/unit/ui_notifications_test.rb +20 -21
- metadata +2 -2
@@ -3,34 +3,34 @@ require 'foreman_tasks_test_helper'
|
|
3
3
|
class TriggeringTest < ActiveSupport::TestCase
|
4
4
|
describe 'validation' do
|
5
5
|
it 'is valid when immediate' do
|
6
|
-
|
6
|
+
assert_predicate(FactoryBot.build(:triggering), :valid?)
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'is validates future execution' do
|
10
10
|
triggering = FactoryBot.build(:triggering, :future)
|
11
|
-
|
11
|
+
assert_predicate(triggering, :valid?)
|
12
12
|
triggering.start_before = triggering.start_at - 120
|
13
|
-
|
13
|
+
assert_not_predicate(triggering, :valid?)
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'is invalid when recurring logic is invalid' do
|
17
17
|
triggering = FactoryBot.build(:triggering, :recurring)
|
18
|
-
|
18
|
+
assert_predicate(triggering, :valid?)
|
19
19
|
triggering.recurring_logic.stubs(:valid?).returns(false)
|
20
|
-
|
20
|
+
assert_not_predicate(triggering, :valid?)
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'is valid when recurring logic has purpose' do
|
24
24
|
logic = FactoryBot.build(:recurring_logic, :purpose => 'test', :state => 'active')
|
25
25
|
triggering = FactoryBot.build(:triggering, :recurring_logic => logic, :mode => :recurring, :input_type => :cronline, :cronline => '* * * * *')
|
26
|
-
|
26
|
+
assert_predicate(triggering, :valid?)
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'is invalid when recurring logic with given purpose exists' do
|
30
30
|
FactoryBot.create(:recurring_logic, :purpose => 'test', :state => 'active')
|
31
31
|
logic = FactoryBot.build(:recurring_logic, :purpose => 'test', :state => 'active')
|
32
32
|
triggering = FactoryBot.build(:triggering, :recurring_logic => logic, :mode => :recurring, :input_type => :cronline, :cronline => '* * * * *')
|
33
|
-
|
33
|
+
assert_not_predicate(triggering, :valid?)
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'is valid when recurring logic with given purpose exists and is not active or disabled' do
|
@@ -39,14 +39,14 @@ class TriggeringTest < ActiveSupport::TestCase
|
|
39
39
|
end
|
40
40
|
logic = FactoryBot.build(:recurring_logic, :purpose => 'test')
|
41
41
|
triggering = FactoryBot.build(:triggering, :recurring_logic => logic, :mode => :recurring, :input_type => :cronline, :cronline => '* * * * *')
|
42
|
-
|
42
|
+
assert_predicate(triggering, :valid?)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'cannot have mode set to arbitrary value' do
|
47
47
|
triggering = FactoryBot.build(:triggering)
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
assert_predicate(triggering, :valid?)
|
49
|
+
assert_raises(ArgumentError) { triggering.mode = 'bogus' }
|
50
|
+
assert_raises(ArgumentError) { triggering.mode = 27 }
|
51
51
|
end
|
52
52
|
end
|
@@ -28,8 +28,8 @@ module ForemanTasks
|
|
28
28
|
|
29
29
|
it 'generates html from the main action troubleshooting_info' do
|
30
30
|
generated_html = subject.generate_html
|
31
|
-
|
32
|
-
|
31
|
+
assert_includes generated_html, "A paused task represents a process that has not finished properly"
|
32
|
+
assert_includes generated_html, %(See <a href="#{expected_troubleshooting_url}">troubleshooting documentation</a> for more details on how to resolve the issue)
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'exposes link details' do
|
@@ -47,10 +47,10 @@ module ForemanTasks
|
|
47
47
|
|
48
48
|
it 'includes additional description in generated html' do
|
49
49
|
generated_html = subject.generate_html
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
assert_includes generated_html, 'A paused task represents a process that has not finished properly'
|
51
|
+
assert_match %r{See <a href=".*">troubleshooting documentation</a> for more details on how to resolve the issue}, generated_html
|
52
|
+
assert_includes generated_html, 'This task requires special handling'
|
53
|
+
assert_includes generated_html, 'Investigate <a href="/additional_troubleshooting_page">custom link</a> on more details for this custom error'
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'includes additional links' do
|
@@ -22,33 +22,33 @@ module ForemanTasks
|
|
22
22
|
it 'notifies all admins about current amount of paused tasks when some paused task occurs' do
|
23
23
|
trigger_task
|
24
24
|
notification = user_notifications(admin_user).first
|
25
|
-
|
25
|
+
assert_equal "There is 1 paused task in the system that need attention", notification.message
|
26
26
|
links = notification.actions['links']
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
assert_includes(links, { 'href' => '/foreman_tasks/tasks?search=state%3Dpaused',
|
28
|
+
'title' => 'List of tasks' })
|
29
|
+
assert_includes(links, { 'name' => 'troubleshooting',
|
30
|
+
'title' => 'Troubleshooting Documentation',
|
31
|
+
'description' => 'See %{link} for more details on how to resolve the issue',
|
32
|
+
'href' => "https://theforeman.org/manuals/#{SETTINGS[:version].short}/tasks_troubleshooting.html#",
|
33
|
+
'external' => true })
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'aggregates the notification when multiple tasks get paused' do
|
37
37
|
trigger_task
|
38
38
|
recipient1 = NotificationRecipient.find_by(user_id: admin_user)
|
39
|
-
|
39
|
+
assert_match(/1 paused task/, recipient1.notification.message)
|
40
40
|
|
41
41
|
new_admin_user = FactoryBot.create(:user, :admin)
|
42
42
|
|
43
43
|
trigger_task
|
44
44
|
|
45
|
-
|
46
|
-
|
45
|
+
assert_nil NotificationRecipient.find_by(id: recipient1.id)
|
46
|
+
assert_nil Notification.find_by(id: recipient1.notification.id)
|
47
47
|
recipient2 = NotificationRecipient.find_by(user_id: admin_user)
|
48
|
-
|
48
|
+
assert_match(/2 paused tasks/, recipient2.notification.message)
|
49
49
|
|
50
50
|
new_recipient = NotificationRecipient.find_by(user_id: new_admin_user)
|
51
|
-
|
51
|
+
assert_equal recipient2.notification, new_recipient.notification
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -58,15 +58,14 @@ module ForemanTasks
|
|
58
58
|
notifications = user_notifications(task_owner)
|
59
59
|
assert_equal 1, notifications.size, 'Only notification for the main action should be triggered'
|
60
60
|
notification = notifications.first
|
61
|
-
|
61
|
+
assert_equal "The task 'Dummy pause action' got paused", notification.message
|
62
62
|
links = notification.actions['links']
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
'external' => true)
|
63
|
+
assert_includes(links, "href" => "/foreman_tasks/tasks/#{task.id}", "title" => "Task Details")
|
64
|
+
assert_includes(links, 'name' => 'troubleshooting',
|
65
|
+
'title' => 'Troubleshooting Documentation',
|
66
|
+
'description' => 'See %{link} for more details on how to resolve the issue',
|
67
|
+
'href' => "https://theforeman.org/manuals/#{SETTINGS[:version].short}/tasks_troubleshooting.html#Support::DummyPauseAction",
|
68
|
+
'external' => true)
|
70
69
|
end
|
71
70
|
end
|
72
71
|
|
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: 9.1.
|
4
|
+
version: 9.1.1
|
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: 2024-
|
11
|
+
date: 2024-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dynflow
|