foreman_expire_hosts 2.1.1 → 2.1.2

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
  SHA1:
3
- metadata.gz: bf158e1beab470ea6dc171ed30d7e11b7194dcd4
4
- data.tar.gz: 026d9ba320a50dc94c2cb336e869ce5b22a1b912
3
+ metadata.gz: b51017605d1e78a328d639736c4fba5367f872ba
4
+ data.tar.gz: 00aaff59e5242156824203423ece81d2f213f415
5
5
  SHA512:
6
- metadata.gz: 777d04912617e0a33c2dc932e3456b73a7b7fbf9d3a4ffee980f5bcba33b1cca574f4a18c7c5c8a74dd9d50cd5aa345bea75403f3043f56940cf7b06f06dff3e
7
- data.tar.gz: d99b1ac558856087474aa314e433ed54ca584b2411d12ad3c0697465febdc6defd9743ab35a79cb913312b89c1c0bb7f9d5a2d66709b708e5f1dd33d09c51c8c
6
+ metadata.gz: a56ee4a45d47db3650f9e311a54c055fb200a84a7d6640f20532a8920660a42f39c47e702869174bf30a6462877a5583e6f5bdb5377e7f6637b51713afc20854
7
+ data.tar.gz: 50bea00b635d7fa753a43b81e1f6b8402d3f331fbaca61c7eb57c6add02e6f2287f143ccb7b50d61c1e74cd4d6055746f9c9eaa144fd1fe290618da7652a893a
@@ -62,14 +62,10 @@ module ForemanExpireHosts
62
62
  expiration_grace_period_end_date <= Date.today
63
63
  end
64
64
 
65
- def pending_expiration_start_date
66
- Date.today - Setting['notify1_days_before_host_expiry'].to_i
67
- end
68
-
69
65
  def pending_expiration?
70
66
  return false unless expires?
71
67
  return false if expired?
72
- pending_expiration_start_date <= expired_on
68
+ expired_on - Setting['notify1_days_before_host_expiry'].to_i <= Date.today
73
69
  end
74
70
 
75
71
  def can_modify_expiry_date?
@@ -1,3 +1,3 @@
1
1
  module ForemanExpireHosts
2
- VERSION = '2.1.1'.freeze
2
+ VERSION = '2.1.2'.freeze
3
3
  end
@@ -5,6 +5,10 @@ FactoryGirl.modify do
5
5
  to_create { |instance| instance.save(validate: false) }
6
6
  end
7
7
 
8
+ trait :expires_in_a_year do
9
+ expired_on Date.today + 365
10
+ end
11
+
8
12
  trait :expires_in_a_week do
9
13
  expired_on Date.today + 7
10
14
  end
@@ -2,7 +2,7 @@ require 'test_plugin_helper'
2
2
 
3
3
  class HostsControllerTest < ActionController::TestCase
4
4
  setup do
5
- User.current = FactoryGirl.build(:user, :admin)
5
+ User.current = users(:admin)
6
6
  disable_orchestration
7
7
  setup_settings
8
8
  end
@@ -157,6 +157,37 @@ class ForemanExpireHostsHostExtTest < ActiveSupport::TestCase
157
157
  end
158
158
  end
159
159
 
160
+ context 'a host expiring in a year' do
161
+ setup do
162
+ @host = FactoryGirl.build(:host, :expires_in_a_year)
163
+ end
164
+
165
+ test 'should expire' do
166
+ assert_equal (Date.today + 365), @host.expired_on
167
+ assert @host.expires?
168
+ end
169
+
170
+ test 'should not expire today' do
171
+ refute @host.expires_today?
172
+ end
173
+
174
+ test 'should not be expired' do
175
+ refute @host.expired?
176
+ end
177
+
178
+ test 'should not be expired past grace period' do
179
+ refute @host.expired_past_grace_period?
180
+ end
181
+
182
+ test 'should not be pending expiration' do
183
+ refute @host.pending_expiration?
184
+ end
185
+
186
+ test 'should only exist in correct scopes' do
187
+ exists_only_in_scopes(@host, ['expiring'])
188
+ end
189
+ end
190
+
160
191
  context 'a host in grace period' do
161
192
  setup do
162
193
  @host = FactoryGirl.build(:host, :expired_grace)
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: 2.1.1
4
+ version: 2.1.2
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: 2016-10-21 00:00:00.000000000 Z
12
+ date: 2016-12-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: deface