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.
@@ -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
- _(FactoryBot.build(:triggering)).must_be :valid?
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
- _(triggering).must_be :valid?
11
+ assert_predicate(triggering, :valid?)
12
12
  triggering.start_before = triggering.start_at - 120
13
- _(triggering).wont_be :valid?
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
- _(triggering).must_be :valid?
18
+ assert_predicate(triggering, :valid?)
19
19
  triggering.recurring_logic.stubs(:valid?).returns(false)
20
- _(triggering).wont_be :valid?
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
- _(triggering).must_be :valid?
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
- _(triggering).wont_be :valid?
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
- _(triggering).must_be :valid?
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
- _(triggering).must_be :valid?
49
- _(proc { triggering.mode = 'bogus' }).must_raise ArgumentError
50
- _(proc { triggering.mode = 27 }).must_raise ArgumentError
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
- _(generated_html).must_include "A paused task represents a process that has not finished properly"
32
- _(generated_html).must_include %(See <a href="#{expected_troubleshooting_url}">troubleshooting documentation</a> for more details on how to resolve the issue)
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
- _(generated_html).must_include 'A paused task represents a process that has not finished properly'
51
- _(generated_html).must_match %r{See <a href=".*">troubleshooting documentation</a> for more details on how to resolve the issue}
52
- _(generated_html).must_include 'This task requires special handling'
53
- _(generated_html).must_include 'Investigate <a href="/additional_troubleshooting_page">custom link</a> on more details for this custom error'
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
- _(notification.message).must_equal "There is 1 paused task in the system that need attention"
25
+ assert_equal "There is 1 paused task in the system that need attention", notification.message
26
26
  links = notification.actions['links']
27
- _(links).must_include('href' => '/foreman_tasks/tasks?search=state%3Dpaused',
28
- 'title' => 'List of tasks')
29
- _(links).must_include('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)
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
- _(recipient1.notification.message).must_match(/1 paused task/)
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
- _(NotificationRecipient.find_by(id: recipient1.id)).must_be_nil
46
- _(Notification.find_by(id: recipient1.notification.id)).must_be_nil
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
- _(recipient2.notification.message).must_match(/2 paused tasks/)
48
+ assert_match(/2 paused tasks/, recipient2.notification.message)
49
49
 
50
50
  new_recipient = NotificationRecipient.find_by(user_id: new_admin_user)
51
- _(new_recipient.notification).must_equal recipient2.notification
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
- _(notification.message).must_equal "The task 'Dummy pause action' got paused"
61
+ assert_equal "The task 'Dummy pause action' got paused", notification.message
62
62
  links = notification.actions['links']
63
- _(links).must_include("href" => "/foreman_tasks/tasks/#{task.id}",
64
- "title" => "Task Details")
65
- _(links).must_include('name' => 'troubleshooting',
66
- 'title' => 'Troubleshooting Documentation',
67
- 'description' => 'See %{link} for more details on how to resolve the issue',
68
- 'href' => "https://theforeman.org/manuals/#{SETTINGS[:version].short}/tasks_troubleshooting.html#Support::DummyPauseAction",
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.0
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-02-14 00:00:00.000000000 Z
11
+ date: 2024-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dynflow