foreman_custom_tab 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -11
- data/Rakefile +2 -2
- data/app/controllers/concerns/foreman_custom_tab/hosts_controller_extensions.rb +6 -6
- data/app/helpers/concerns/foreman_custom_tab/hosts_helper_extensions.rb +12 -9
- data/app/overrides/add_tab.rb +6 -7
- data/app/overrides/add_tab_link.rb +8 -8
- data/app/views/foreman_custom_tab/hosts/{_summary.html.erb → _custom_tab.html.erb} +2 -2
- data/config/foreman_custom_tab.yaml.example +11 -0
- data/config/routes.rb +5 -7
- data/lib/foreman_custom_tab/engine.rb +13 -15
- data/lib/foreman_custom_tab/version.rb +1 -1
- data/lib/tasks/foreman_custom_tab_tasks.rake +40 -0
- data/locale/gemspec.rb +1 -1
- data/test/functional/concerns/hosts_controller_extensions_test.rb +74 -0
- data/test/helpers/concerns/foreman_custom_tab/hosts_helper_extensions_test.rb +37 -0
- data/test/test_plugin_helper.rb +20 -3
- data/test/unit/foreman_custom_tab_test.rb +1 -1
- data/test/views/foreman_custom_tab/hosts/_custom_tab_test.rb +30 -0
- metadata +38 -12
- data/config/tab.yaml +0 -1
- data/test/factories/foreman_custom_tab_factories.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 193542ee87777c74b898096451c7dfb169441eb3
|
4
|
+
data.tar.gz: 5fc5dd2d13b1be5ac4b9559dbffbe72e5bb5cc4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c985a2f2e0e4c5bcc7b7142964b3109ca9ef582752e46bd6d306d755e394e724141059a96b38412dc45e92ec829102ef0e67eb222551a755beb49f22e98d4432
|
7
|
+
data.tar.gz: 5c9ff283052091fd658c7eafd219d9ebf10b11997e362b4c5139225330026cc00ef1871a8952d9b29f492428349de40ede5cbf6df20f3514bde139d2c3e0d505
|
data/README.md
CHANGED
@@ -18,23 +18,38 @@ If there is no configuration file then the tab should not appear on the detailed
|
|
18
18
|
there is one and it is empty then it will appear without any fields. To setup the configuration file create
|
19
19
|
a new file named 'foreman_custom_tab.yaml' at the location /etc/foreman/plugins/
|
20
20
|
|
21
|
-
The
|
21
|
+
The keys are the display title and the values are the methods that are actually called to produce the value.
|
22
22
|
|
23
|
-
|
24
|
-
:custom_tab:
|
25
|
-
:fields:
|
26
|
-
IP Address, ip
|
27
|
-
MAC Address, mac
|
23
|
+
Example configuration:
|
28
24
|
|
29
|
-
|
25
|
+
```
|
26
|
+
:custom_tab:
|
27
|
+
:fields:
|
28
|
+
'Host Name': name
|
29
|
+
'MAC Address': mac
|
30
|
+
'IP Address': ip
|
31
|
+
'Architecture': arch
|
32
|
+
'Certificate Name': certname
|
33
|
+
'OS Title': operatingsystem.title
|
34
|
+
'OS Type': operatingsystem.type
|
35
|
+
:title: foo
|
36
|
+
```
|
30
37
|
|
31
|
-
|
38
|
+
## Verify the Custom Tab is loaded
|
39
|
+
Navigate to /hosts/, click on one of the listed host. There should be tabs: 'Properties', 'Metrics', 'Templates', 'NICs' and 'custom_tab.title or Custom Tab'
|
40
|
+
|
41
|
+
## Development mode
|
42
|
+
Add the custom_tab config to <foreman_repo>/config/settings.yaml
|
43
|
+
|
44
|
+
Note: foreman running locally (i.e not installed via rpm/debian package) does not use settings from /etc/foreman/plugins/
|
45
|
+
|
46
|
+
## TODO
|
47
|
+
|
48
|
+
* add plugin settings file
|
32
49
|
|
33
50
|
## Notes
|
34
51
|
|
35
|
-
This project is still incomplete and in development.
|
36
|
-
to the list in foreman then this plugin will probably not work with any other plugins. As of now the only fields
|
37
|
-
that work are ones in the form "host.'field'"
|
52
|
+
This project is still incomplete and in development.
|
38
53
|
|
39
54
|
Copyright (c) 2017 Joe Lyons Stannard III
|
40
55
|
|
data/Rakefile
CHANGED
@@ -30,7 +30,7 @@ Rake::TestTask.new(:test) do |t|
|
|
30
30
|
t.libs << 'lib'
|
31
31
|
t.libs << 'test'
|
32
32
|
t.pattern = 'test/**/*_test.rb'
|
33
|
-
t.verbose =
|
33
|
+
t.verbose = true
|
34
34
|
end
|
35
35
|
|
36
36
|
task default: :test
|
@@ -38,7 +38,7 @@ task default: :test
|
|
38
38
|
begin
|
39
39
|
require 'rubocop/rake_task'
|
40
40
|
RuboCop::RakeTask.new
|
41
|
-
rescue => _
|
41
|
+
rescue StandardError => _
|
42
42
|
puts 'Rubocop not loaded.'
|
43
43
|
end
|
44
44
|
|
@@ -3,20 +3,20 @@ module ForemanCustomTab
|
|
3
3
|
module HostsControllerExtensions
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
-
def
|
6
|
+
def custom_tab
|
7
7
|
# We can't add a before_filter :find_resource for Cockpit actions as
|
8
8
|
# it'll override the default find_resource filter.
|
9
9
|
find_resource
|
10
|
-
render :partial => 'foreman_custom_tab/hosts/
|
10
|
+
render :partial => 'foreman_custom_tab/hosts/custom_tab', :locals => { :host => @host }
|
11
11
|
rescue ActionView::Template::Error => exception
|
12
|
-
process_ajax_error exception, 'fetch
|
12
|
+
process_ajax_error exception, 'fetch custom tab information'
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
private
|
16
|
-
|
16
|
+
|
17
17
|
def action_permission
|
18
18
|
case params[:action]
|
19
|
-
when '
|
19
|
+
when 'custom_tab'
|
20
20
|
:view
|
21
21
|
else
|
22
22
|
super
|
@@ -1,20 +1,23 @@
|
|
1
1
|
module ForemanCustomTab
|
2
2
|
module HostsHelperExtensions
|
3
3
|
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
|
6
|
-
def summary_fields(host)
|
4
|
+
|
5
|
+
def custom_tab_fields(host)
|
7
6
|
fields = []
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
config_fields = SETTINGS[:custom_tab][:fields] || []
|
8
|
+
config_fields.each do |key, value|
|
9
|
+
host_attr_val = nil
|
10
|
+
# chain the method calls for attibutes like operatingsystem.title
|
11
11
|
value.split('.').each_with_index do |method, index|
|
12
|
-
|
12
|
+
host_attr_val = index.eql?(0) ? host.try(method) : host_attr_val.try(method)
|
13
13
|
end
|
14
|
-
fields += [[_(
|
14
|
+
fields += [[_(key.to_s), host_attr_val]] if host_attr_val.present?
|
15
15
|
end
|
16
16
|
fields
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
|
+
def custom_tab_title
|
20
|
+
SETTINGS[:custom_tab][:title] || 'Custom Tab'
|
21
|
+
end
|
19
22
|
end
|
20
23
|
end
|
data/app/overrides/add_tab.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
if SETTINGS[:custom_tab]
|
2
|
-
Deface::Override.new(
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
2
|
+
Deface::Override.new(:virtual_path => 'hosts/show',
|
3
|
+
:name => 'add_tab_link',
|
4
|
+
:insert_bottom => 'ul#myTab',
|
5
|
+
:text =>
|
6
|
+
"<li><a href='#custom_tab' data-toggle='tab'><%= _(custom_tab_title) %></a></li>")
|
7
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
if SETTINGS[:custom_tab]
|
2
|
-
Deface::Override.new(
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
Deface::Override.new(:virtual_path => 'hosts/show',
|
3
|
+
:name => 'create_link',
|
4
|
+
:insert_bottom => 'div#myTabContent',
|
5
|
+
:text =>
|
6
|
+
"\n <div id='custom_tab' class='tab-pane'
|
7
|
+
data-ajax-url='<%= custom_tab_host_path(@host)%>' data-on-complete='onContentLoad'>
|
8
|
+
<%= spinner(_('Loading Custom Tab information ...')) %>
|
9
|
+
</div>")
|
10
10
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
<table id="custom_table" class="<%= table_css_classes %>">
|
2
2
|
<thead>
|
3
3
|
<tr>
|
4
|
-
<th colspan="2"><%= _(
|
4
|
+
<th colspan="2"><%= _(custom_tab_title) %></th>
|
5
5
|
</tr>
|
6
6
|
</thead>
|
7
7
|
<tbody>
|
8
|
-
<%
|
8
|
+
<% custom_tab_fields(host).each do |name, value| %>
|
9
9
|
<tr>
|
10
10
|
<td><%= name %></td>
|
11
11
|
<td><%= value %></td>
|
data/config/routes.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
get 'summary'
|
7
|
-
end
|
2
|
+
constraints(:id => %r{[^\/]+}) do
|
3
|
+
resources :hosts do
|
4
|
+
member do
|
5
|
+
get 'custom_tab'
|
8
6
|
end
|
9
7
|
end
|
10
|
-
|
8
|
+
end
|
11
9
|
end
|
@@ -9,35 +9,33 @@ module ForemanCustomTab
|
|
9
9
|
config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
|
10
10
|
config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
|
11
11
|
config.autoload_paths += Dir["#{config.root}/app/overrides"]
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
|
13
|
+
# requires_foreman version as per
|
14
|
+
# http://projects.theforeman.org/projects/foreman/wiki/How_to_Create_a_Plugin#Requiring-Foreman-version
|
15
|
+
|
16
|
+
# Adding permission to controller action
|
17
|
+
# http://projects.theforeman.org/projects/foreman/wiki/How_to_Create_a_Plugin#Adding-permission
|
18
18
|
initializer('foreman_custom_tab.register_plugin', :before => :finisher_hook) do
|
19
19
|
Foreman::Plugin.register :foreman_custom_tab do
|
20
20
|
requires_foreman '>= 1.7'
|
21
|
-
|
21
|
+
|
22
22
|
security_block :foreman_custom_tab do
|
23
23
|
permission :view_hosts,
|
24
|
-
|
25
|
-
|
24
|
+
{ :hosts => [:custom_tab] },
|
25
|
+
:resource_type => 'Host'
|
26
26
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
27
|
end
|
31
28
|
end
|
32
|
-
|
33
|
-
|
29
|
+
|
30
|
+
# Extending a controller
|
34
31
|
# Include concerns in this config.to_prepare block
|
32
|
+
# http://projects.theforeman.org/projects/foreman/wiki/How_to_Create_a_Plugin#Extending-a-Controller
|
35
33
|
config.to_prepare do
|
36
34
|
begin
|
37
35
|
HostsHelper.send(:include, ForemanCustomTab::HostsHelperExtensions)
|
38
36
|
::HostsController.send(:include,
|
39
37
|
ForemanCustomTab::HostsControllerExtensions)
|
40
|
-
rescue => e
|
38
|
+
rescue StandardError => e
|
41
39
|
Rails.logger.warn "ForemanCustomTab: skipping engine hook (#{e})"
|
42
40
|
end
|
43
41
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Tests
|
2
|
+
namespace :test do
|
3
|
+
desc 'Test Foreman Custom Tab'
|
4
|
+
Rake::TestTask.new(:foreman_custom_tab) do |t|
|
5
|
+
test_dir = File.join(File.dirname(__FILE__), '../..', 'test')
|
6
|
+
t.libs << ['test', test_dir]
|
7
|
+
t.pattern = "#{test_dir}/**/*_test.rb"
|
8
|
+
t.verbose = true
|
9
|
+
t.warning = false
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
namespace :foreman_custom_tab do
|
14
|
+
task :rubocop do
|
15
|
+
begin
|
16
|
+
require 'rubocop/rake_task'
|
17
|
+
RuboCop::RakeTask.new(:rubocop_foreman_custom_tab) do |task|
|
18
|
+
task.patterns = ["#{ForemanCustomTab::Engine.root}/app/**/*.rb",
|
19
|
+
"#{ForemanCustomTab::Engine.root}/lib/**/*.rb",
|
20
|
+
"#{ForemanCustomTab::Engine.root}/test/**/*.rb"]
|
21
|
+
end
|
22
|
+
rescue StandardError => e
|
23
|
+
puts "Rubocop not loaded #{e.message}"
|
24
|
+
end
|
25
|
+
|
26
|
+
Rake::Task['rubocop_foreman_custom_tab'].invoke
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
Rake::Task[:test].enhance do
|
31
|
+
Rake::Task['test:foreman_custom_tab'].invoke
|
32
|
+
end
|
33
|
+
|
34
|
+
load 'tasks/jenkins.rake'
|
35
|
+
if Rake::Task.task_defined?(:'jenkins:unit')
|
36
|
+
Rake::Task['jenkins:unit'].enhance do
|
37
|
+
Rake::Task['test:foreman_custom_tab'].invoke
|
38
|
+
Rake::Task['foreman_custom_tab:rubocop'].invoke
|
39
|
+
end
|
40
|
+
end
|
data/locale/gemspec.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
# Matches foreman_custom_tab.gemspec
|
2
|
-
_('
|
2
|
+
_('Foreman Plugin that makes a new tab with different fields depending on the settings file')
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'test_plugin_helper'
|
2
|
+
|
3
|
+
class HostsControllerTest < ActionController::TestCase
|
4
|
+
let(:os) { FactoryBot.create(:operatingsystem, name: 'CentOS', major: '7', type: 'Redhat') }
|
5
|
+
let(:arch) { FactoryBot.create(:architecture) }
|
6
|
+
let(:host_id) { 'foreman.example.com' }
|
7
|
+
# rubocop:disable Metrics/LineLength
|
8
|
+
let(:host) { FactoryBot.create(:host, id: host_id, mac: '00:00:00:00:00:00', ip: '127.0.0.1', operatingsystem: os, arch: arch) }
|
9
|
+
# rubocop:enable Metrics/LineLength
|
10
|
+
let(:custom_tab_title) { SETTINGS[:custom_tab][:title] }
|
11
|
+
|
12
|
+
# rubocop:disable Metrics/LineLength, Style/StringLiterals, HttpPositionalArguments
|
13
|
+
test 'GET hosts/:id displays tabs' do
|
14
|
+
get :show, { :id => host.id }, set_session_user
|
15
|
+
assert_includes response.headers['Content-Type'], 'text/html'
|
16
|
+
assert_equal response.status, 200
|
17
|
+
assert_includes response.body, "ul id=\"myTab\""
|
18
|
+
end
|
19
|
+
|
20
|
+
test "host overview displays tabs 'Properties', 'Metrics', 'NICs'" do
|
21
|
+
get :show, { :id => host.id }, set_session_user
|
22
|
+
assert_includes response.headers['Content-Type'], 'text/html'
|
23
|
+
assert_equal response.status, 200
|
24
|
+
assert_includes response.body, "<ul id=\"myTab\""
|
25
|
+
assert_includes response.body, "<li class=\"active\"><a href=\"#properties\" data-toggle=\"tab\">Properties</a></li>"
|
26
|
+
assert_includes response.body, "<li><a href=\"#metrics\" data-toggle=\"tab\">Metrics</a></li>"
|
27
|
+
assert_includes response.body, "<li><a href=\"#nics\" data-toggle=\"tab\">NICs</a></li>"
|
28
|
+
end
|
29
|
+
|
30
|
+
test "host overview displays the Custom Tab" do
|
31
|
+
get :show, { :id => host.id }, set_session_user
|
32
|
+
assert_includes response.headers['Content-Type'], 'text/html'
|
33
|
+
assert_includes response.body, "<ul id=\"myTab\""
|
34
|
+
assert_equal response.status, 200
|
35
|
+
assert_includes response.body, "<li><a href=\"#custom_tab\" data-toggle=\"tab\">#{custom_tab_title}</a></li>"
|
36
|
+
end
|
37
|
+
|
38
|
+
test "host/:id contains custom_tab ajax link" do
|
39
|
+
get :show, { :id => host.id }, set_session_user
|
40
|
+
|
41
|
+
assert_equal response.status, 200
|
42
|
+
assert_includes response.headers['Content-Type'], 'text/html'
|
43
|
+
assert_includes response.body, "<ul id=\"myTab\""
|
44
|
+
assert_includes response.body, "<li><a href=\"#custom_tab\" data-toggle=\"tab\">#{custom_tab_title}</a></li>"
|
45
|
+
assert_includes response.body, "<div id=\"custom_tab\" class=\"tab-pane\" data-ajax-url=\"/hosts/#{host.name}/custom_tab\" data-on-complete=\"onContentLoad\">"
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'When hosts#show' do
|
49
|
+
before do
|
50
|
+
host_id = 'foreman.example.com'
|
51
|
+
Rails.application.routes.draw do
|
52
|
+
get "/hosts/#{host_id}/custom_tab" => 'hosts_controller#custom_tab'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
after do
|
56
|
+
Rails.application.reload_routes!
|
57
|
+
end
|
58
|
+
|
59
|
+
test 'AJAX request hosts/:id/custom_tab displays custom host data' do
|
60
|
+
skip("xhr route missing: ActionController::UrlGenerationError:
|
61
|
+
No route matches {:action=>'/hosts/host6/custom_tab', :controller=>'hosts'}")
|
62
|
+
# get "/hosts/#{host.name}/custom_tab", xhr: true
|
63
|
+
# xhr :get, custom_tab_host_path(host), delivery_method: :deliver, status: :pending, format: 'js'
|
64
|
+
get custom_tab_host_path(host), params: { xhr: true }
|
65
|
+
# get "/hosts/#{host_id}/custom_tab"
|
66
|
+
|
67
|
+
SETTINGS[:custom_tab][:fields].each do |title, attr|
|
68
|
+
assert_includes response.body, "<td>#{title}</td>"
|
69
|
+
assert_includes response.body, "<td>#{host.get_chained_attr_val(attr)}</td>"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
# rubocop:enable Metrics/LineLength, Style/StringLiterals, HttpPositionalArguments
|
74
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'test_plugin_helper'
|
2
|
+
|
3
|
+
class HostsHelperExtensionsTest < ActiveSupport::TestCase
|
4
|
+
include ForemanCustomTab::HostsHelperExtensions
|
5
|
+
|
6
|
+
let(:os) { FactoryBot.create(:operatingsystem, name: 'CentOS', major: '7', type: 'Redhat') }
|
7
|
+
let(:arch) { FactoryBot.create(:architecture) }
|
8
|
+
# rubocop:disable Metrics/LineLength
|
9
|
+
let(:host) { FactoryBot.create(:host, id: 'foreman.example.com', mac: '00:00:00:00:00:00', ip: '127.0.0.1', operatingsystem: os, arch: arch) }
|
10
|
+
# rubocop:enable Metrics/LineLength
|
11
|
+
let(:expected_fields) do
|
12
|
+
fields = []
|
13
|
+
SETTINGS[:custom_tab][:fields].each do |title, host_attr|
|
14
|
+
fields << [title, host.get_chained_attr_val(host_attr)]
|
15
|
+
end
|
16
|
+
fields
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#custom_tab_fields(host)' do
|
20
|
+
test 'returns fields as expected' do
|
21
|
+
assert_equal custom_tab_fields(host), expected_fields
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#custom_tab_title' do
|
26
|
+
title_orig = SETTINGS[:custom_tab][:title]
|
27
|
+
test 'returns correct title' do
|
28
|
+
assert_equal custom_tab_title, title_orig
|
29
|
+
end
|
30
|
+
|
31
|
+
test 'settings title is not present' do
|
32
|
+
SETTINGS[:custom_tab][:title] = nil
|
33
|
+
assert_equal custom_tab_title, 'Custom Tab'
|
34
|
+
SETTINGS[:custom_tab][:title] = title_orig
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/test/test_plugin_helper.rb
CHANGED
@@ -1,6 +1,23 @@
|
|
1
|
+
# populate custom tab settings for test env
|
2
|
+
# NOTE: this needs to be updated before calling foreman test_helper
|
3
|
+
SETTINGS[:custom_tab] = { fields: { 'Host Name' => 'name',
|
4
|
+
'MAC Address' => 'mac',
|
5
|
+
'IP Address' => 'ip',
|
6
|
+
'Architecture' => 'arch',
|
7
|
+
'Certificate Name' => 'certname',
|
8
|
+
'OS Title' => 'operatingsystem.title',
|
9
|
+
'OS Type' => 'operatingsystem.type' },
|
10
|
+
title: 'foo' }
|
11
|
+
|
1
12
|
# This calls the main test_helper in Foreman-core
|
2
13
|
require 'test_helper'
|
3
14
|
|
4
|
-
|
5
|
-
|
6
|
-
|
15
|
+
class Object
|
16
|
+
def get_chained_attr_val(attrs)
|
17
|
+
attr_val = nil
|
18
|
+
attrs.split('.').each_with_index do |method, index|
|
19
|
+
attr_val = index.eql?(0) ? try(method) : attr_val.try(method)
|
20
|
+
end
|
21
|
+
attr_val
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'test_plugin_helper'
|
2
|
+
|
3
|
+
class CustomTabTest < ActionView::TestCase
|
4
|
+
let(:os) { FactoryBot.create(:operatingsystem, name: 'CentOS', major: '7', type: 'Redhat') }
|
5
|
+
let(:arch) { FactoryBot.create(:architecture) }
|
6
|
+
# rubocop:disable Metrics/LineLength
|
7
|
+
let(:host) { FactoryBot.create(:host, id: 'foreman.example.com', mac: '00:00:00:00:00:00', ip: '127.0.0.1', operatingsystem: os, arch: arch) }
|
8
|
+
# rubocop:enable Metrics/LineLength
|
9
|
+
let(:custom_tab_title) { SETTINGS[:custom_tab][:title] }
|
10
|
+
|
11
|
+
class FakeHostsController < ActionController::Base
|
12
|
+
include ForemanCustomTab::HostsHelperExtensions
|
13
|
+
include LayoutHelper
|
14
|
+
|
15
|
+
def index
|
16
|
+
os = FactoryBot.create(:operatingsystem, name: 'CentOS', major: '7', type: 'Redhat')
|
17
|
+
# rubocop:disable Metrics/LineLength
|
18
|
+
@host = FactoryBot.create(:host, id: 'foreman.example.com', mac: '00:00:00:00:00:00', ip: '127.0.0.1', operatingsystem: os, arch: FactoryBot.create(:architecture))
|
19
|
+
# rubocop:enable Metrics/LineLength
|
20
|
+
render :partial => 'foreman_custom_tab/hosts/custom_tab', :locals => { :host => @host }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
test 'successfully render custom_tab partial' do
|
25
|
+
skip("NoMethodError: undefined method 'content_type' for nil:NilClass")
|
26
|
+
get FakeHostsController.new.index
|
27
|
+
|
28
|
+
assert_select 'custom_table'
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_custom_tab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Stannard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rdoc
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rubocop
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -38,7 +38,28 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: deface
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.2.0
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '2.0'
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 1.2.0
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '2.0'
|
61
|
+
description: Foreman Plugin that makes a new tab with different fields depending on
|
62
|
+
the settings file
|
42
63
|
email:
|
43
64
|
- stannajl@miamioh.edu
|
44
65
|
executables: []
|
@@ -52,20 +73,23 @@ files:
|
|
52
73
|
- app/helpers/concerns/foreman_custom_tab/hosts_helper_extensions.rb
|
53
74
|
- app/overrides/add_tab.rb
|
54
75
|
- app/overrides/add_tab_link.rb
|
55
|
-
- app/views/foreman_custom_tab/hosts/
|
76
|
+
- app/views/foreman_custom_tab/hosts/_custom_tab.html.erb
|
77
|
+
- config/foreman_custom_tab.yaml.example
|
56
78
|
- config/routes.rb
|
57
|
-
- config/tab.yaml
|
58
79
|
- lib/foreman_custom_tab.rb
|
59
80
|
- lib/foreman_custom_tab/engine.rb
|
60
81
|
- lib/foreman_custom_tab/version.rb
|
82
|
+
- lib/tasks/foreman_custom_tab_tasks.rake
|
61
83
|
- locale/Makefile
|
62
84
|
- locale/en/foreman_custom_tab.po
|
63
85
|
- locale/foreman_custom_tab.pot
|
64
86
|
- locale/gemspec.rb
|
65
|
-
- test/
|
87
|
+
- test/functional/concerns/hosts_controller_extensions_test.rb
|
88
|
+
- test/helpers/concerns/foreman_custom_tab/hosts_helper_extensions_test.rb
|
66
89
|
- test/test_plugin_helper.rb
|
67
90
|
- test/unit/foreman_custom_tab_test.rb
|
68
|
-
|
91
|
+
- test/views/foreman_custom_tab/hosts/_custom_tab_test.rb
|
92
|
+
homepage: https://github.com/MiamiOH/foreman_custom_tab
|
69
93
|
licenses:
|
70
94
|
- GPL-3.0
|
71
95
|
metadata: {}
|
@@ -85,11 +109,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
109
|
version: '0'
|
86
110
|
requirements: []
|
87
111
|
rubyforge_project:
|
88
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.6.11
|
89
113
|
signing_key:
|
90
114
|
specification_version: 4
|
91
|
-
summary:
|
115
|
+
summary: Creates custom tab for hosts in Foreman
|
92
116
|
test_files:
|
93
|
-
- test/factories/foreman_custom_tab_factories.rb
|
94
117
|
- test/test_plugin_helper.rb
|
118
|
+
- test/functional/concerns/hosts_controller_extensions_test.rb
|
95
119
|
- test/unit/foreman_custom_tab_test.rb
|
120
|
+
- test/views/foreman_custom_tab/hosts/_custom_tab_test.rb
|
121
|
+
- test/helpers/concerns/foreman_custom_tab/hosts_helper_extensions_test.rb
|
data/config/tab.yaml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
IP Address, ip
|