foreman_expire_hosts 5.0.0 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/concerns/foreman_expire_hosts/hosts_helper_extensions.rb +15 -7
- data/app/services/foreman_expire_hosts/safe_destroy.rb +18 -1
- data/app/services/foreman_expire_hosts/ui_notifications/hosts/base.rb +1 -1
- data/foreman_expire_hosts.gemspec +2 -2
- data/lib/foreman_expire_hosts/engine.rb +1 -1
- data/lib/foreman_expire_hosts/version.rb +1 -1
- data/test/helpers/hosts_helper_test.rb +12 -0
- data/test/unit/safe_destroy_test.rb +10 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a87b2c303a78750274b73d20e3d7113d0431353a699f80b6e86ef7e07ab179f
|
4
|
+
data.tar.gz: 3a93c88e92b00b7348c326546beab99e9d5655b859d72fbed82f250b6ad74f5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74d7b446ffaac6353b3b82c29dc3f6474d161e00d2ecbd4231e15257b9589e6f7159a7badc141f97d05f0f035ee7236685faf0ef6c03603c771032edf6c99597
|
7
|
+
data.tar.gz: b6e522f9a6311a5d2abb3547b08625e1666479ed538f3757dd2a2fd50658a86d42914cda9f0d47d53773d3ab8058f80fc84cd8a5aeaf7f67f9bc2842bb920864
|
@@ -1,9 +1,17 @@
|
|
1
1
|
module ForemanExpireHosts
|
2
2
|
module HostsHelperExtensions
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
module Overrides
|
6
|
+
def multiple_actions
|
7
|
+
actions = super
|
8
|
+
actions << [_('Change Expiration'), select_multiple_expiration_hosts_path] if authorized_for(:controller => :hosts, :action => :select_multiple_expiration)
|
9
|
+
actions
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
included do
|
14
|
+
prepend Overrides
|
7
15
|
end
|
8
16
|
|
9
17
|
def host_expiry_warning_message(host)
|
@@ -30,10 +38,10 @@ module ForemanExpireHosts
|
|
30
38
|
end
|
31
39
|
end
|
32
40
|
|
33
|
-
def datepicker_f(
|
34
|
-
field(
|
41
|
+
def datepicker_f(form, attr, options = {})
|
42
|
+
field(form, attr, options) do
|
35
43
|
addClass options, 'form-control'
|
36
|
-
date =
|
44
|
+
date = form.text_field attr, options
|
37
45
|
addon = input_group_addon('', :class => 'glyphicon glyphicon-calendar')
|
38
46
|
input_group date, addon
|
39
47
|
end
|
@@ -8,7 +8,15 @@ module ForemanExpireHosts
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def destroy!
|
11
|
-
|
11
|
+
# If Katello is installed, we can't just destroy the host
|
12
|
+
# but have to ask ForemanTasks to do this for us.
|
13
|
+
# See https://community.theforeman.org/t/how-to-properly-destroy-a-content-host/8621
|
14
|
+
# for reasoning.
|
15
|
+
if with_katello?
|
16
|
+
ForemanTasks.sync_task(::Actions::Katello::Host::Destroy, subject)
|
17
|
+
else
|
18
|
+
subject.destroy!
|
19
|
+
end
|
12
20
|
rescue ActiveRecord::RecordNotDestroyed => invalid
|
13
21
|
message = _('Failed to delete %{class_name} %{subject}: %{message} - Errors: %{errors}') % {
|
14
22
|
:class_name => subject.class.name,
|
@@ -19,5 +27,14 @@ module ForemanExpireHosts
|
|
19
27
|
Foreman::Logging.exception(message, invalid)
|
20
28
|
false
|
21
29
|
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def with_katello?
|
34
|
+
Katello # rubocop:disable Lint/Void
|
35
|
+
true
|
36
|
+
rescue StandardError
|
37
|
+
false
|
38
|
+
end
|
22
39
|
end
|
23
40
|
end
|
@@ -40,7 +40,7 @@ module ForemanExpireHosts
|
|
40
40
|
|
41
41
|
def update_notification
|
42
42
|
find_notification
|
43
|
-
.
|
43
|
+
.update(expired_at: blueprint.expired_at, :message => parsed_message)
|
44
44
|
end
|
45
45
|
|
46
46
|
def redeliver!
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path('
|
1
|
+
require File.expand_path('lib/foreman_expire_hosts/version', __dir__)
|
2
2
|
require 'date'
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
@@ -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.
|
25
|
+
s.add_development_dependency 'rubocop', '0.54.0'
|
26
26
|
end
|
@@ -19,7 +19,7 @@ module ForemanExpireHosts
|
|
19
19
|
end
|
20
20
|
|
21
21
|
initializer 'foreman_expire_hosts.load_default_settings', :before => :load_config_initializers do
|
22
|
-
require_dependency File.expand_path('
|
22
|
+
require_dependency File.expand_path('../../app/models/setting/expire_hosts.rb', __dir__) if (Setting.table_exists? rescue(false))
|
23
23
|
end
|
24
24
|
|
25
25
|
initializer 'foreman_expire_hosts.register_plugin', :before => :finisher_hook do |_app|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'test_plugin_helper'
|
2
|
+
|
3
|
+
class HostsHelperTest < ActionView::TestCase
|
4
|
+
include HostsHelper
|
5
|
+
include ApplicationHelper
|
6
|
+
|
7
|
+
describe '#multiple_actions' do
|
8
|
+
test 'includes expire bulk action' do
|
9
|
+
assert_includes multiple_actions.map(&:first), 'Change Expiration'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -22,5 +22,15 @@ module ForemanExpireHosts
|
|
22
22
|
assert_equal 1, HostWithFailingCallbacks.all.count
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
describe 'with a host' do
|
27
|
+
let(:host) { FactoryBot.create(:host, :managed) }
|
28
|
+
|
29
|
+
test 'deletes a host' do
|
30
|
+
assert Host::Managed.find_by(id: host.id)
|
31
|
+
assert SafeDestroy.new(host).destroy!
|
32
|
+
refute Host::Managed.find_by(id: host.id)
|
33
|
+
end
|
34
|
+
end
|
25
35
|
end
|
26
36
|
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: 5.
|
4
|
+
version: 5.1.0
|
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: 2018-
|
12
|
+
date: 2018-04-26 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.
|
62
|
+
version: 0.54.0
|
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.
|
69
|
+
version: 0.54.0
|
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:
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- test/factories/foreman_expire_hosts_factories.rb
|
137
137
|
- test/functional/api/v2/hosts_controller_test.rb
|
138
138
|
- test/functional/concerns/hosts_controller_extensions_test.rb
|
139
|
+
- test/helpers/hosts_helper_test.rb
|
139
140
|
- test/lib/expire_hosts_notifications_test.rb
|
140
141
|
- test/test_plugin_helper.rb
|
141
142
|
- test/unit/concerns/host_extensions_test.rb
|
@@ -171,6 +172,7 @@ test_files:
|
|
171
172
|
- test/factories/foreman_expire_hosts_factories.rb
|
172
173
|
- test/functional/api/v2/hosts_controller_test.rb
|
173
174
|
- test/functional/concerns/hosts_controller_extensions_test.rb
|
175
|
+
- test/helpers/hosts_helper_test.rb
|
174
176
|
- test/lib/expire_hosts_notifications_test.rb
|
175
177
|
- test/test_plugin_helper.rb
|
176
178
|
- test/unit/concerns/host_extensions_test.rb
|