foreman_expire_hosts 6.0.0 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d016e02f798e790c84d0ff29badd0fbfbaf122b941787842dce237f19fcb0d9
4
- data.tar.gz: 361195ee1b65ac38de1bad8e9ff7ecd6172202f52d524c3729bfbff022fe0a85
3
+ metadata.gz: 66c086d3dc04916321804be89e8d5f027691b5aa5dc10b0cef317b7ac5d4ee9e
4
+ data.tar.gz: 84e16983231ab5651c03c5d56484c8645bd1c6910bd677aa7bcacefb139b06d2
5
5
  SHA512:
6
- metadata.gz: 55d8ac2d1ddb0b96effb841ce5b897ef3c583b3b5bd619b337015c35a0f4744f7db57e70919ec8c946ad0a2d3a424263d1fad0e01ded37e540ca220d258158c7
7
- data.tar.gz: 94c8f531186c1c55b70297e8c3905f17fb823326e3cf06c94c221aa7daa675deefc9f017161d8b0070d48164b58c8a6f8031eebf951d839990da24beeb656676
6
+ metadata.gz: b2990701bc9efa238f25f6a6a7def12d87e9403e4b6cf0f41b477c1d5cc16a467f2edcb211fabd724034b3c149d00d654087a42e4a8e323fd403a2030ac81492
7
+ data.tar.gz: 60a5e736f9e54223e5c62bcf426514e10aec9569708d3f58b672da60e41667b3537848c8fa6f00c8904c3c36aa87038304cdf44bc7d51e6a087d5c906ff3302d
@@ -4,11 +4,13 @@ module ForemanExpireHosts
4
4
 
5
5
  def destroyed_expired_host_audit_comment_in_list(audit)
6
6
  return unless audit.auditable_type.to_s == 'Host' && audit.action == 'destroy' && audit.comment.present?
7
+
7
8
  "<div style='color: #737373;font-size: 14px'>Comment: #{audit.comment}</div>".html_safe
8
9
  end
9
10
 
10
11
  def destroyed_expired_host_audit_comment_in_show(audit)
11
12
  return unless audit.auditable_type.to_s == 'Host' && audit.action == 'destroy' && audit.comment.present?
13
+
12
14
  "<tr><td>Comment</td><td>#{audit.comment}</td></tr>".html_safe
13
15
  end
14
16
  end
@@ -16,6 +16,7 @@ module ForemanExpireHosts
16
16
 
17
17
  def host_expiry_warning_message(host)
18
18
  return nil unless host.expires?
19
+
19
20
  if host.expired_past_grace_period?
20
21
  message = _('This host has expired %s ago and needs to be deleted manually.') % time_ago_in_words(host.expired_on)
21
22
  elsif host.expired?
@@ -1,6 +1,7 @@
1
1
  module ExpireHostsMailerHelper
2
2
  def relative_date(date, opts = {})
3
3
  return _('N/A') if date.blank?
4
+
4
5
  opts[:tense] ||= :future if Date.today < date
5
6
  opts[:tense] ||= :past if Date.today > date
6
7
 
@@ -80,6 +80,7 @@ class ExpireHostsMailer < ApplicationMailer
80
80
  def recipient_mail(recipient)
81
81
  return recipient if recipient.is_a?(Array)
82
82
  return recipient.mail if recipient.mail.present?
83
+
83
84
  admin_email
84
85
  end
85
86
 
@@ -40,27 +40,32 @@ module ForemanExpireHosts
40
40
 
41
41
  def expires_today?
42
42
  return false unless expires?
43
+
43
44
  expired_on.to_date == Date.today
44
45
  end
45
46
 
46
47
  def expired?
47
48
  return false unless expires?
49
+
48
50
  expired_on.to_date < Date.today
49
51
  end
50
52
 
51
53
  def expiration_grace_period_end_date
52
54
  return nil unless expires?
55
+
53
56
  expired_on + Setting[:days_to_delete_after_host_expiration].to_i
54
57
  end
55
58
 
56
59
  def expired_past_grace_period?
57
60
  return false unless expires?
61
+
58
62
  expiration_grace_period_end_date <= Date.today
59
63
  end
60
64
 
61
65
  def pending_expiration?
62
66
  return false unless expires?
63
67
  return false if expired?
68
+
64
69
  expired_on - Setting['notify1_days_before_host_expiry'].to_i <= Date.today
65
70
  end
66
71
 
@@ -70,6 +75,7 @@ module ForemanExpireHosts
70
75
  return true unless User.current
71
76
  return true if Authorizer.new(User.current).can?(:edit_host_expiry, self)
72
77
  return true if self.owner_type.nil? || self.owner.nil?
78
+
73
79
  Setting[:can_owner_modify_host_expiry_date] &&
74
80
  ((self.owner_type == 'User' && self.owner == User.current) ||
75
81
  (self.owner_type == 'Usergroup' && self.owner.all_users.include?(User.current)))
@@ -15,6 +15,7 @@ module HostStatus
15
15
  return EXPIRED if host.expired_past_grace_period?
16
16
  return IN_GRACE_PERIOD if host.expired?
17
17
  return PENDING if host.pending_expiration?
18
+
18
19
  OK
19
20
  end
20
21
 
@@ -1,6 +1,6 @@
1
1
  Deface::Override.new(
2
2
  :virtual_path => 'hosts/_form',
3
- :name => 'host_form_expired_on_field',
3
+ :name => 'host_form_expired_on_field',
4
4
  :insert_after => 'div#model_name',
5
- :partial => 'hosts/expired_on_field'
5
+ :partial => 'hosts/expired_on_field'
6
6
  )
@@ -1,6 +1,6 @@
1
1
  Deface::Override.new(
2
- :virtual_path => 'hosts/show',
3
- :name => 'host_expiry_waring_in_show',
2
+ :virtual_path => 'hosts/show',
3
+ :name => 'host_expiry_waring_in_show',
4
4
  :insert_before => '#host-show',
5
- :partial => 'hosts/expired_message.html.erb'
5
+ :partial => 'hosts/expired_message.html.erb'
6
6
  )
@@ -1,6 +1,6 @@
1
1
  Deface::Override.new(
2
- :virtual_path => 'hosts/_list',
3
- :name => 'host_list_expiration_js',
2
+ :virtual_path => 'hosts/_list',
3
+ :name => 'host_list_expiration_js',
4
4
  :insert_before => '#confirmation-modal',
5
- :text => "<%= stylesheet 'foreman_expire_hosts/application' %><%= javascript 'foreman_expire_hosts/application' %>"
5
+ :text => "<%= stylesheet 'foreman_expire_hosts/application' %><%= javascript 'foreman_expire_hosts/application' %>"
6
6
  )
@@ -1,13 +1,13 @@
1
1
  Deface::Override.new(
2
- :virtual_path => 'audits/_list',
3
- :name => 'deleted_expired_host_audit_comment_in_list',
2
+ :virtual_path => 'audits/_list',
3
+ :name => 'deleted_expired_host_audit_comment_in_list',
4
4
  :insert_bottom => 'div.row div.audit-content',
5
- :text => "\n <%= destroyed_expired_host_audit_comment_in_list(audit) %>"
5
+ :text => "\n <%= destroyed_expired_host_audit_comment_in_list(audit) %>"
6
6
  )
7
7
 
8
8
  Deface::Override.new(
9
- :virtual_path => 'audits/show',
10
- :name => 'deleted_expired_host_audit_comment_in_show',
9
+ :virtual_path => 'audits/show',
10
+ :name => 'deleted_expired_host_audit_comment_in_show',
11
11
  :insert_bottom => 'div#tab1 table',
12
- :text => "\n <%= destroyed_expired_host_audit_comment_in_show(@audit) %>"
12
+ :text => "\n <%= destroyed_expired_host_audit_comment_in_show(@audit) %>"
13
13
  )
@@ -17,7 +17,10 @@ module ForemanExpireHosts
17
17
 
18
18
  def process
19
19
  hosts.each do |host|
20
- if action(host)
20
+ result = action(host)
21
+ next if result.nil?
22
+
23
+ if result
21
24
  self.successful_hosts << host
22
25
  else
23
26
  self.failed_hosts << host
@@ -8,7 +8,9 @@ module ForemanExpireHosts
8
8
  end
9
9
 
10
10
  def action(host)
11
- return true unless host.supports_power_and_running?
11
+ return false unless host.supports_power?
12
+ return unless host.power.ready?
13
+
12
14
  logger.info "Powering down expired host in grace period #{host}"
13
15
  host.power.stop
14
16
  rescue StandardError
@@ -24,6 +24,8 @@ module ForemanExpireHosts
24
24
  end
25
25
 
26
26
  def deliver_mail_notification(recipient, hosts)
27
+ return true if hosts.empty?
28
+
27
29
  build_mail_notification(recipient, hosts).deliver_now
28
30
  rescue SocketError, Net::SMTPError => error
29
31
  message = _('Failed to deliver %{notification_name} for Hosts %{hosts}') % {
@@ -59,11 +61,13 @@ module ForemanExpireHosts
59
61
  return global_recipients if global_recipients.present?
60
62
  return [User.anonymous_admin] if host.owner.blank?
61
63
  return [host.owner] if host.owner_type == 'User'
64
+
62
65
  host.owner.all_users
63
66
  end
64
67
 
65
68
  def additional_recipients
66
69
  return [] if Setting[:host_expiry_email_recipients].nil?
70
+
67
71
  Setting[:host_expiry_email_recipients].split(',').compact.map(&:strip)
68
72
  end
69
73
  end
@@ -6,6 +6,7 @@ module ForemanExpireHosts
6
6
 
7
7
  def create
8
8
  return add_notification unless find_notification
9
+
9
10
  redeliver! if redeliver?
10
11
  find_notification
11
12
  end
@@ -22,5 +22,5 @@ Gem::Specification.new do |s|
22
22
  s.add_dependency 'deface'
23
23
 
24
24
  s.add_development_dependency 'rdoc'
25
- s.add_development_dependency 'rubocop', '0.54.0'
25
+ s.add_development_dependency 'rubocop', '0.59.2'
26
26
  end
@@ -10,6 +10,7 @@ module ExpireHostsNotifications
10
10
 
11
11
  def deliver_expiry_warning_notification(num = 1) # notify1_days_before_expiry
12
12
  return unless [1, 2].include?(num)
13
+
13
14
  days_before_expiry = Setting["notify#{num}_days_before_host_expiry"].to_i
14
15
  expiry_date = (Date.today + days_before_expiry)
15
16
  notifiable_hosts = Host.with_expire_date(expiry_date).preload(:owner)
@@ -1,3 +1,3 @@
1
1
  module ForemanExpireHosts
2
- VERSION = '6.0.0'.freeze
2
+ VERSION = '6.0.1'.freeze
3
3
  end
@@ -6,26 +6,26 @@ FactoryBot.modify do
6
6
  end
7
7
 
8
8
  trait :expires_in_a_year do
9
- expired_on Date.today + 365
9
+ expired_on { Date.today + 365 }
10
10
  end
11
11
 
12
12
  trait :expires_in_a_week do
13
- expired_on Date.today + 7
13
+ expired_on { Date.today + 7 }
14
14
  end
15
15
 
16
16
  trait :expires_today do
17
17
  without_validation
18
- expired_on Date.today
18
+ expired_on { Date.today }
19
19
  end
20
20
 
21
21
  trait :expired_grace do
22
22
  without_validation
23
- expired_on Date.today - 1
23
+ expired_on { Date.today - 1 }
24
24
  end
25
25
 
26
26
  trait :expired do
27
27
  without_validation
28
- expired_on Date.today - 356
28
+ expired_on { Date.today - 356 }
29
29
  end
30
30
  end
31
31
  end
@@ -11,7 +11,7 @@ class Api::V2::HostsControllerTest < ActionController::TestCase
11
11
  get :show, params: { :id => host.to_param }
12
12
  assert_response :success
13
13
  show_response = ActiveSupport::JSON.decode(@response.body)
14
- assert !show_response.empty?
14
+ assert_not_empty show_response
15
15
  assert_equal host.expired_on, show_response['expired_on'].to_date
16
16
  end
17
17
  end
@@ -61,17 +61,22 @@ class ExpireHostsNotificationsTest < ActiveSupport::TestCase
61
61
  context 'with additional recipients' do
62
62
  setup do
63
63
  Setting[:host_expiry_email_recipients] = 'test@example.com, test2.example.com'
64
- FactoryBot.create_list(:host, 2, :expired, :owner => user)
65
64
  end
66
65
 
67
66
  test 'should deliver notification to additional recipients' do
67
+ FactoryBot.create_list(:host, 2, :expired, :owner => user)
68
68
  ExpireHostsNotifications.delete_expired_hosts
69
- assert_equal 3, ActionMailer::Base.deliveries.count
69
+ assert_equal 2, ActionMailer::Base.deliveries.count
70
70
  assert_includes ActionMailer::Base.deliveries.first.subject, 'Deleted expired hosts'
71
71
  assert_includes ActionMailer::Base.deliveries.flat_map(&:to), user.mail
72
72
  assert_includes ActionMailer::Base.deliveries.flat_map(&:to), 'test@example.com'
73
73
  assert_includes ActionMailer::Base.deliveries.flat_map(&:to), 'test2.example.com'
74
74
  end
75
+
76
+ test 'should not deliver a mail notification for empty host list' do
77
+ ExpireHostsNotifications.delete_expired_hosts
78
+ assert_equal 0, ActionMailer::Base.deliveries.count
79
+ end
75
80
  end
76
81
  end
77
82
 
@@ -100,6 +105,12 @@ class ExpireHostsNotificationsTest < ActiveSupport::TestCase
100
105
  end
101
106
  end
102
107
 
108
+ test 'should send no message if host is already be stopped' do
109
+ power_mock.stubs(:ready?).returns(false)
110
+ ExpireHostsNotifications.stop_expired_hosts
111
+ assert_equal 0, ActionMailer::Base.deliveries.count
112
+ end
113
+
103
114
  test 'should send failure message if host cannot be stopped' do
104
115
  power_mock.expects(:stop).returns(false)
105
116
  ExpireHostsNotifications.stop_expired_hosts
@@ -114,59 +125,75 @@ class ExpireHostsNotificationsTest < ActiveSupport::TestCase
114
125
 
115
126
  setup do
116
127
  Setting['notify1_days_before_host_expiry'] = 7
117
- hosts
118
128
  end
119
129
 
120
- test 'should send a ui notification per host' do
121
- assert_difference('blueprint.notifications.count', 2) do
130
+ context 'with expired hosts' do
131
+ setup do
132
+ hosts
133
+ end
134
+
135
+ test 'should send a ui notification per host' do
136
+ assert_difference('blueprint.notifications.count', 2) do
137
+ ExpireHostsNotifications.deliver_expiry_warning_notification
138
+ end
139
+ hosts.each do |host|
140
+ notification = Notification.find_by(
141
+ notification_blueprint_id: blueprint.id,
142
+ subject_id: host.id,
143
+ subject_type: 'Host::Base'
144
+ )
145
+ assert_equal 1, notification.notification_recipients.where(user_id: user.id).count
146
+ end
147
+ end
148
+
149
+ test 'should redisplay read ui notification' do
122
150
  ExpireHostsNotifications.deliver_expiry_warning_notification
151
+ notification = Notification.find_by(notification_blueprint_id: blueprint.id, subject_id: hosts.first.id)
152
+ assert_not_nil notification
153
+ assert_equal 1, NotificationRecipient.where(notification_id: notification.id).update_all(seen: true) # rubocop:disable Rails/SkipsModelValidations
154
+ ExpireHostsNotifications.deliver_expiry_warning_notification
155
+ assert_equal 1, NotificationRecipient.where(notification_id: notification.id, seen: false).count
123
156
  end
124
- hosts.each do |host|
125
- notification = Notification.find_by(
126
- notification_blueprint_id: blueprint.id,
127
- subject_id: host.id,
128
- subject_type: 'Host::Base'
129
- )
130
- assert_equal 1, notification.notification_recipients.where(user_id: user.id).count
157
+
158
+ test 'should send a single notification' do
159
+ ExpireHostsNotifications.deliver_expiry_warning_notification
160
+ assert_equal 1, ActionMailer::Base.deliveries.count
161
+ assert_includes ActionMailer::Base.deliveries.first.subject, 'Expiring hosts in foreman'
131
162
  end
132
- end
133
163
 
134
- test 'should redisplay read ui notification' do
135
- ExpireHostsNotifications.deliver_expiry_warning_notification
136
- notification = Notification.find_by(notification_blueprint_id: blueprint.id, subject_id: hosts.first.id)
137
- assert_not_nil notification
138
- assert_equal 1, NotificationRecipient.where(notification_id: notification.id).update_all(seen: true) # rubocop:disable Rails/SkipsModelValidations
139
- ExpireHostsNotifications.deliver_expiry_warning_notification
140
- assert_equal 1, NotificationRecipient.where(notification_id: notification.id, seen: false).count
141
- end
164
+ test 'should send two notifications for two users' do
165
+ owner2 = FactoryBot.create(:user, :with_mail)
166
+ FactoryBot.create(:host, :expires_in_a_week, :owner => owner2)
167
+ ExpireHostsNotifications.deliver_expiry_warning_notification
168
+ assert_equal 2, ActionMailer::Base.deliveries.count
169
+ assert_includes ActionMailer::Base.deliveries.first.subject, 'Expiring hosts in foreman'
170
+ assert_includes ActionMailer::Base.deliveries.last.subject, 'Expiring hosts in foreman'
171
+ end
142
172
 
143
- test 'should send a single notification' do
144
- ExpireHostsNotifications.deliver_expiry_warning_notification
145
- assert_equal 1, ActionMailer::Base.deliveries.count
146
- assert_includes ActionMailer::Base.deliveries.first.subject, 'Expiring hosts in foreman'
173
+ test 'should send three notifications for three users' do
174
+ user2 = FactoryBot.create(:user, :with_mail)
175
+ user3 = FactoryBot.create(:user, :with_mail, :usergroups => [usergroup])
176
+ FactoryBot.create(:host, :expires_in_a_week, :owner => user2)
177
+ FactoryBot.create(:host, :expires_in_a_week, :owner => usergroup)
178
+ ExpireHostsNotifications.deliver_expiry_warning_notification
179
+ assert_equal 3, ActionMailer::Base.deliveries.count
180
+ assert_includes ActionMailer::Base.deliveries.first.subject, 'Expiring hosts in foreman'
181
+ assert_includes ActionMailer::Base.deliveries.flat_map(&:to), user.mail
182
+ assert_includes ActionMailer::Base.deliveries.flat_map(&:to), user2.mail
183
+ assert_includes ActionMailer::Base.deliveries.flat_map(&:to), user3.mail
184
+ assert_equal 1, ActionMailer::Base.deliveries.flat_map(&:subject).uniq.count
185
+ end
147
186
  end
148
187
 
149
- test 'should send two notifications for two users' do
150
- owner2 = FactoryBot.create(:user, :with_mail)
151
- FactoryBot.create(:host, :expires_in_a_week, :owner => owner2)
152
- ExpireHostsNotifications.deliver_expiry_warning_notification
153
- assert_equal 2, ActionMailer::Base.deliveries.count
154
- assert_includes ActionMailer::Base.deliveries.first.subject, 'Expiring hosts in foreman'
155
- assert_includes ActionMailer::Base.deliveries.last.subject, 'Expiring hosts in foreman'
156
- end
188
+ context 'with additional recipients' do
189
+ setup do
190
+ Setting[:host_expiry_email_recipients] = 'test@example.com, test2.example.com'
191
+ end
157
192
 
158
- test 'should send three notifications for three users' do
159
- user2 = FactoryBot.create(:user, :with_mail)
160
- user3 = FactoryBot.create(:user, :with_mail, :usergroups => [usergroup])
161
- FactoryBot.create(:host, :expires_in_a_week, :owner => user2)
162
- FactoryBot.create(:host, :expires_in_a_week, :owner => usergroup)
163
- ExpireHostsNotifications.deliver_expiry_warning_notification
164
- assert_equal 3, ActionMailer::Base.deliveries.count
165
- assert_includes ActionMailer::Base.deliveries.first.subject, 'Expiring hosts in foreman'
166
- assert_includes ActionMailer::Base.deliveries.flat_map(&:to), user.mail
167
- assert_includes ActionMailer::Base.deliveries.flat_map(&:to), user2.mail
168
- assert_includes ActionMailer::Base.deliveries.flat_map(&:to), user3.mail
169
- assert_equal 1, ActionMailer::Base.deliveries.flat_map(&:subject).uniq.count
193
+ test 'should not send empty reminders' do
194
+ ExpireHostsNotifications.deliver_expiry_warning_notification
195
+ assert_equal 0, ActionMailer::Base.deliveries.count
196
+ end
170
197
  end
171
198
  end
172
199
  end
@@ -26,7 +26,7 @@ class ForemanExpireHostsHostExtTest < ActiveSupport::TestCase
26
26
 
27
27
  test 'should require expired on' do
28
28
  host = FactoryBot.build(:host)
29
- refute host.valid?, "Can not be valid without expiration date: #{host.errors.messages}"
29
+ assert_not host.valid?, "Can not be valid without expiration date: #{host.errors.messages}"
30
30
  assert_includes host.errors.messages.keys, :expired_on
31
31
  end
32
32
  end
@@ -99,23 +99,23 @@ class ForemanExpireHostsHostExtTest < ActiveSupport::TestCase
99
99
  end
100
100
 
101
101
  test 'should not expire' do
102
- refute @host.expires?
102
+ assert_not @host.expires?
103
103
  end
104
104
 
105
105
  test 'should not expire today' do
106
- refute @host.expires_today?
106
+ assert_not @host.expires_today?
107
107
  end
108
108
 
109
109
  test 'should not be expired' do
110
- refute @host.expired?
110
+ assert_not @host.expired?
111
111
  end
112
112
 
113
113
  test 'should not be expired past grace period' do
114
- refute @host.expired_past_grace_period?
114
+ assert_not @host.expired_past_grace_period?
115
115
  end
116
116
 
117
117
  test 'should not be pending expiration' do
118
- refute @host.pending_expiration?
118
+ assert_not @host.pending_expiration?
119
119
  end
120
120
 
121
121
  test 'should not be in any expiration scopes' do
@@ -133,7 +133,7 @@ class ForemanExpireHostsHostExtTest < ActiveSupport::TestCase
133
133
  end
134
134
 
135
135
  test 'should not expire today' do
136
- refute @host.expires_today?
136
+ assert_not @host.expires_today?
137
137
  end
138
138
 
139
139
  test 'should be expired' do
@@ -145,7 +145,7 @@ class ForemanExpireHostsHostExtTest < ActiveSupport::TestCase
145
145
  end
146
146
 
147
147
  test 'should not be pending expiration' do
148
- refute @host.pending_expiration?
148
+ assert_not @host.pending_expiration?
149
149
  end
150
150
 
151
151
  test 'should only exist in correct scopes' do
@@ -168,11 +168,11 @@ class ForemanExpireHostsHostExtTest < ActiveSupport::TestCase
168
168
  end
169
169
 
170
170
  test 'should not be expired' do
171
- refute @host.expired?
171
+ assert_not @host.expired?
172
172
  end
173
173
 
174
174
  test 'should not be expired past grace period' do
175
- refute @host.expired_past_grace_period?
175
+ assert_not @host.expired_past_grace_period?
176
176
  end
177
177
 
178
178
  test 'should be pending expiration' do
@@ -195,19 +195,19 @@ class ForemanExpireHostsHostExtTest < ActiveSupport::TestCase
195
195
  end
196
196
 
197
197
  test 'should not expire today' do
198
- refute @host.expires_today?
198
+ assert_not @host.expires_today?
199
199
  end
200
200
 
201
201
  test 'should not be expired' do
202
- refute @host.expired?
202
+ assert_not @host.expired?
203
203
  end
204
204
 
205
205
  test 'should not be expired past grace period' do
206
- refute @host.expired_past_grace_period?
206
+ assert_not @host.expired_past_grace_period?
207
207
  end
208
208
 
209
209
  test 'should not be pending expiration' do
210
- refute @host.pending_expiration?
210
+ assert_not @host.pending_expiration?
211
211
  end
212
212
 
213
213
  test 'should only exist in correct scopes' do
@@ -225,7 +225,7 @@ class ForemanExpireHostsHostExtTest < ActiveSupport::TestCase
225
225
  end
226
226
 
227
227
  test 'should not expire today' do
228
- refute @host.expires_today?
228
+ assert_not @host.expires_today?
229
229
  end
230
230
 
231
231
  test 'should be expired' do
@@ -233,11 +233,11 @@ class ForemanExpireHostsHostExtTest < ActiveSupport::TestCase
233
233
  end
234
234
 
235
235
  test 'should not be expired past grace period' do
236
- refute @host.expired_past_grace_period?
236
+ assert_not @host.expired_past_grace_period?
237
237
  end
238
238
 
239
239
  test 'should not be pending expiration' do
240
- refute @host.pending_expiration?
240
+ assert_not @host.pending_expiration?
241
241
  end
242
242
 
243
243
  test 'should only exist in correct scopes' do
@@ -250,7 +250,7 @@ class ForemanExpireHostsHostExtTest < ActiveSupport::TestCase
250
250
  def exists_only_in_scopes(host, valid_scopes)
251
251
  host.save(validate: false)
252
252
  (EXPIRATION_SCOPES - valid_scopes).each do |scope|
253
- refute Host::Managed.send(scope).exists?(host.id), "Host should not exist in #{scope} scope"
253
+ assert_not Host::Managed.send(scope).exists?(host.id), "Host should not exist in #{scope} scope"
254
254
  end
255
255
  valid_scopes.each do |scope|
256
256
  assert Host::Managed.send(scope).exists?(host.id), "Host should exist in #{scope} scope"
@@ -23,6 +23,6 @@ class ExpirationStatusTest < ActiveSupport::TestCase
23
23
  assert @status.relevant?
24
24
 
25
25
  @host.expired_on = nil
26
- refute @status.relevant?
26
+ assert_not @status.relevant?
27
27
  end
28
28
  end
@@ -29,7 +29,7 @@ module ForemanExpireHosts
29
29
  test 'deletes a host' do
30
30
  assert Host::Managed.find_by(id: host.id)
31
31
  assert SafeDestroy.new(host).destroy!
32
- refute Host::Managed.find_by(id: host.id)
32
+ assert_not Host::Managed.find_by(id: host.id)
33
33
  end
34
34
  end
35
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_expire_hosts
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 6.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nagarjuna Rachaneni
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-03-08 00:00:00.000000000 Z
12
+ date: 2019-07-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bootstrap-datepicker-rails
@@ -59,14 +59,14 @@ dependencies:
59
59
  requirements:
60
60
  - - '='
61
61
  - !ruby/object:Gem::Version
62
- version: 0.54.0
62
+ version: 0.59.2
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - '='
68
68
  - !ruby/object:Gem::Version
69
- version: 0.54.0
69
+ version: 0.59.2
70
70
  description: This Plugin will add new column expired_on to hosts to limit the lifetime
71
71
  of a host.
72
72
  email:
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  version: '0'
165
165
  requirements: []
166
166
  rubyforge_project:
167
- rubygems_version: 2.7.3
167
+ rubygems_version: 2.7.6.2
168
168
  signing_key:
169
169
  specification_version: 4
170
170
  summary: Foreman plugin for limiting host lifetime