foreman_omaha 0.0.3 → 1.0.0

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.
Files changed (72) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +5 -2
  3. data/app/assets/javascripts/foreman_omaha/application.js +1 -0
  4. data/app/assets/stylesheets/foreman_omaha/version_breakdown.scss +13 -0
  5. data/app/controllers/api/v2/omaha_groups_controller.rb +29 -0
  6. data/app/controllers/api/v2/omaha_reports_controller.rb +9 -7
  7. data/app/controllers/omaha_groups_controller.rb +28 -0
  8. data/app/controllers/omaha_hosts_controller.rb +42 -0
  9. data/app/controllers/omaha_reports_controller.rb +0 -11
  10. data/app/helpers/concerns/foreman_omaha/hosts_helper_extensions.rb +15 -6
  11. data/app/helpers/foreman_omaha/application_helper.rb +7 -0
  12. data/app/helpers/foreman_omaha/omaha_groups_helper.rb +52 -0
  13. data/app/helpers/omaha_hosts_helper.rb +43 -0
  14. data/app/models/concerns/foreman_omaha/host_extensions.rb +16 -2
  15. data/app/models/concerns/foreman_omaha/omaha_facet_host_extensions.rb +23 -0
  16. data/app/models/foreman_omaha/omaha_facet.rb +40 -0
  17. data/app/models/foreman_omaha/omaha_group.rb +34 -0
  18. data/app/models/foreman_omaha/omaha_report.rb +13 -21
  19. data/app/models/host_status/omaha_status.rb +6 -16
  20. data/app/services/foreman_omaha/charts/oem_distribution.rb +24 -0
  21. data/app/services/foreman_omaha/charts/status_distribution.rb +57 -0
  22. data/app/services/foreman_omaha/charts/version_distribution.rb +24 -0
  23. data/app/services/foreman_omaha/container_linux_config_transpiler.rb +33 -0
  24. data/app/services/foreman_omaha/fact_parser.rb +19 -3
  25. data/app/services/foreman_omaha/group_version_breakdown.rb +30 -0
  26. data/app/services/foreman_omaha/omaha_report_importer.rb +52 -3
  27. data/app/services/foreman_omaha/renderer_methods.rb +7 -0
  28. data/app/services/foreman_omaha/status_mapper.rb +53 -0
  29. data/app/views/api/v2/omaha_groups/base.json.rabl +3 -0
  30. data/app/views/api/v2/omaha_groups/index.json.rabl +3 -0
  31. data/app/views/api/v2/omaha_groups/main.json.rabl +5 -0
  32. data/app/views/api/v2/omaha_groups/show.json.rabl +3 -0
  33. data/app/views/application/foreman_omaha/_toolbar.html.erb +11 -0
  34. data/app/views/foreman_omaha/api/v2/omaha_facets/base.json.rabl +5 -0
  35. data/app/views/foreman_omaha/api/v2/omaha_facets/base_with_root.json.rabl +3 -0
  36. data/app/views/foreman_omaha/api/v2/omaha_facets/show.json.rabl +3 -0
  37. data/app/views/hosts/_omaha_tab.html.erb +29 -0
  38. data/app/views/omaha_groups/index.html.erb +34 -0
  39. data/app/views/omaha_groups/show.html.erb +196 -0
  40. data/app/views/omaha_hosts/index.html.erb +51 -0
  41. data/app/views/omaha_hosts/welcome.html.erb +12 -0
  42. data/app/views/omaha_reports/_details.html.erb +5 -3
  43. data/app/views/omaha_reports/_list.html.erb +2 -2
  44. data/app/views/omaha_reports/show.html.erb +1 -1
  45. data/app/views/omaha_reports/welcome.html.erb +1 -1
  46. data/config/routes.rb +14 -1
  47. data/db/migrate/20160812083100_add_omaha_fields_to_reports.foreman_omaha.rb +1 -1
  48. data/db/migrate/20171101204100_create_omaha_facets.foreman_omaha.rb +22 -0
  49. data/db/seeds.d/200_omaha_groups.rb +6 -0
  50. data/lib/foreman_omaha/engine.rb +74 -21
  51. data/lib/foreman_omaha/version.rb +1 -1
  52. data/lib/tasks/foreman_omaha_tasks.rake +2 -4
  53. data/test/factories/feature.rb +1 -1
  54. data/test/factories/foreman_omaha_factories.rb +16 -1
  55. data/test/factories/host.rb +21 -0
  56. data/test/factories/smart_proxy.rb +1 -1
  57. data/test/functional/api/v2/omaha_groups_controller_test.rb +32 -0
  58. data/test/functional/api/v2/omaha_reports_controller_test.rb +24 -24
  59. data/test/functional/omaha_groups_controller_test.rb +18 -0
  60. data/test/functional/omaha_hosts_controller_test.rb +11 -0
  61. data/test/functional/omaha_reports_controller_test.rb +13 -13
  62. data/test/test_plugin_helper.rb +3 -3
  63. data/test/unit/charts/oem_distribution_test.rb +26 -0
  64. data/test/unit/charts/status_distribution_test.rb +28 -0
  65. data/test/unit/charts/version_distribution_test.rb +28 -0
  66. data/test/unit/group_version_breakdown_test.rb +65 -0
  67. data/test/unit/host_status/omaha_status_test.rb +19 -0
  68. data/test/unit/host_test.rb +55 -0
  69. data/test/unit/omaha_fact_parser_test.rb +77 -0
  70. data/test/unit/omaha_report_test.rb +63 -17
  71. data/test/unit/renderer_test.rb +21 -0
  72. metadata +80 -9
@@ -1,4 +1,4 @@
1
- class AddOmahaFieldsToReports < ActiveRecord::Migration
1
+ class AddOmahaFieldsToReports < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :reports, :omaha_version, :string
4
4
  end
@@ -0,0 +1,22 @@
1
+ class CreateOmahaFacets < ActiveRecord::Migration[4.2]
2
+ def change
3
+ create_table :omaha_groups do |t|
4
+ t.string :name, limit: 255, null: false, index: true
5
+ t.string :uuid, limit: 36, null: false, index: true
6
+
7
+ t.timestamps null: false
8
+ end
9
+
10
+ create_table :omaha_facets do |t|
11
+ t.references :host, null: false, foreign_key: true, index: true, unique: true
12
+ t.column :last_report, :datetime
13
+ t.string :version, limit: 255, index: true
14
+ t.string :machineid, limit: 32, index: true
15
+ t.integer :status, default: 1, index: true
16
+ t.string :oem, limit: 255, index: true
17
+ t.references :omaha_group, index: true, foreign_key: true
18
+
19
+ t.timestamps null: false
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,6 @@
1
+ default_groups = %w[Alpha Beta Stable]
2
+
3
+ default_groups.each do |group|
4
+ g = ForemanOmaha::OmahaGroup.where(:uuid => group.downcase, :name => group).first_or_create
5
+ raise "Unable to create built in Omaha group: #{format_errors g}" if g.nil? || g.errors.any?
6
+ end
@@ -1,3 +1,5 @@
1
+ require 'jquery-matchheight-rails'
2
+
1
3
  module ForemanOmaha
2
4
  class Engine < ::Rails::Engine
3
5
  engine_name 'foreman_omaha'
@@ -16,7 +18,7 @@ module ForemanOmaha
16
18
 
17
19
  initializer 'foreman_omaha.register_plugin', :before => :finisher_hook do |_app|
18
20
  Foreman::Plugin.register :foreman_omaha do
19
- requires_foreman '>= 1.12'
21
+ requires_foreman '>= 1.17'
20
22
 
21
23
  apipie_documented_controllers ["#{ForemanOmaha::Engine.root}/app/controllers/api/v2/*.rb"]
22
24
 
@@ -24,12 +26,25 @@ module ForemanOmaha
24
26
 
25
27
  # Add permissions
26
28
  security_block :foreman_omaha do
27
- permission :view_omaha_reports, :omaha_reports => [:index, :show, :auto_complete_search],
28
- :'api/v2/omaha_reports' => [:index, :show, :last]
29
- permission :destroy_omaha_reports, :omaha_reports => [:destroy],
30
- :'api/v2/omaha_reports' => [:destroy]
31
- permission :upload_omaha_reports, :omaha_reports => [:create],
32
- :'api/v2/omaha_reports' => [:create]
29
+ permission :view_omaha_reports, {
30
+ :omaha_reports => [:index, :show, :auto_complete_search],
31
+ :'api/v2/omaha_reports' => [:index, :show, :last]
32
+ }, :resource_type => 'ForemanOmaha::OmahaReport'
33
+
34
+ permission :destroy_omaha_reports, {
35
+ :omaha_reports => [:destroy],
36
+ :'api/v2/omaha_reports' => [:destroy]
37
+ }, :resource_type => 'ForemanOmaha::OmahaReport'
38
+
39
+ permission :upload_omaha_reports, {
40
+ :omaha_reports => [:create],
41
+ :'api/v2/omaha_reports' => [:create]
42
+ }, :resource_type => 'ForemanOmaha::OmahaReport'
43
+
44
+ permission :view_omaha_groups, {
45
+ :omaha_groups => [:index, :auto_complete_search, :show],
46
+ :'api/v2/omaha_groups' => [:index, :show]
47
+ }, :resource_type => 'ForemanOmaha::OmahaGroup'
33
48
  end
34
49
 
35
50
  role 'Omaha reports viewer',
@@ -40,14 +55,49 @@ module ForemanOmaha
40
55
  # add menu entry
41
56
  menu :top_menu, :omaha_reports,
42
57
  :url_hash => { controller: :omaha_reports, action: :index },
43
- :caption => N_('Omaha reports'),
58
+ :caption => N_('Omaha Reports'),
44
59
  :parent => :monitor_menu,
45
- after: :reports
46
- end
60
+ :after => :reports
47
61
 
48
- if respond_to?(:add_controller_action_scope)
49
- add_controller_action_scope(HostsController, :index) { |base_scope| base_scope.includes(:last_omaha_report_object) }
62
+ menu :top_menu, :omaha_hosts,
63
+ :url_hash => { :controller => :omaha_hosts, :action => :index },
64
+ :caption => N_('Omaha Hosts'),
65
+ :parent => :hosts_menu,
66
+ :after => :hosts
67
+
68
+ divider :top_menu, :caption => N_('Omaha'), :parent => :configure_menu, :last => true
69
+
70
+ menu :top_menu, :omaha_groups,
71
+ :url_hash => { :controller => :omaha_groups, :action => :index },
72
+ :caption => N_('Omaha Groups'),
73
+ :parent => :configure_menu,
74
+ :last => :true
75
+
76
+ # Omaha Facet
77
+ register_facet(ForemanOmaha::OmahaFacet, :omaha_facet) do
78
+ api_view :list => 'foreman_omaha/api/v2/omaha_facets/base_with_root', :single => 'foreman_omaha/api/v2/omaha_facets/show'
79
+ end
80
+
81
+ # extend host show page
82
+ extend_page('hosts/show') do |context|
83
+ context.add_pagelet :main_tabs,
84
+ :name => N_('Omaha'),
85
+ :partial => 'hosts/omaha_tab',
86
+ :onlyif => proc { |host| host.omaha_facet }
87
+ end
88
+
89
+ add_controller_action_scope(HostsController, :index) { |base_scope| base_scope.includes(:omaha_facet) }
90
+
91
+ # add renderer extensions
92
+ allowed_template_helpers :transpile_container_linux_config
93
+ extend_template_helpers ForemanOmaha::RendererMethods
50
94
  end
95
+
96
+ # Extend built in permissions
97
+ Foreman::AccessControl.permission(:view_hosts).actions.concat [
98
+ 'omaha_hosts/index',
99
+ 'omaha_hosts/auto_complete_search'
100
+ ]
51
101
  end
52
102
 
53
103
  # Include concerns in this config.to_prepare block
@@ -57,22 +107,25 @@ module ForemanOmaha
57
107
  ::FactParser.register_fact_parser(:foreman_omaha, ForemanOmaha::FactParser)
58
108
 
59
109
  Host::Managed.send(:include, ForemanOmaha::HostExtensions)
110
+ Host::Managed.send(:include, ForemanOmaha::OmahaFacetHostExtensions)
60
111
  HostsHelper.send(:include, ForemanOmaha::HostsHelperExtensions)
61
- rescue => e
112
+ rescue StandardError => e
62
113
  Rails.logger.warn "ForemanOmaha: skipping engine hook (#{e})"
63
114
  end
64
115
  end
65
116
 
117
+ # Precompile any JS, Stylesheet or Image files under app/assets/
118
+ assets_to_precompile =
119
+ Dir.chdir(root) do
120
+ Dir['app/assets/javascripts/**/*', 'app/assets/images/**/*', 'app/assets/stylesheets/**/*'].map do |f|
121
+ f.split(File::SEPARATOR, 4).last
122
+ end
123
+ end
66
124
  initializer 'foreman_omaha.assets.precompile' do |app|
67
- app.config.assets.precompile += %w[foreman_omaha/Omaha.png]
125
+ app.config.assets.precompile += assets_to_precompile
68
126
  end
69
-
70
- initializer 'foreman_omaha.configure_assets', :group => :assets do
71
- SETTINGS[:foreman_omaha] = {
72
- :assets => {
73
- :precompile => ['foreman_omaha/Omaha.png']
74
- }
75
- }
127
+ initializer 'foreman_omaha.configure_assets', group: :assets do
128
+ SETTINGS[:foreman_omaha] = { assets: { precompile: assets_to_precompile } }
76
129
  end
77
130
 
78
131
  rake_tasks do
@@ -1,3 +1,3 @@
1
1
  module ForemanOmaha
2
- VERSION = '0.0.3'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
@@ -29,7 +29,7 @@ namespace :foreman_omaha do
29
29
  "#{ForemanOmaha::Engine.root}/lib/**/*.rb",
30
30
  "#{ForemanOmaha::Engine.root}/test/**/*.rb"]
31
31
  end
32
- rescue
32
+ rescue StandardError
33
33
  puts 'Rubocop not loaded.'
34
34
  end
35
35
 
@@ -40,6 +40,4 @@ end
40
40
  Rake::Task[:test].enhance ['test:foreman_omaha']
41
41
 
42
42
  load 'tasks/jenkins.rake'
43
- if Rake::Task.task_defined?(:'jenkins:unit')
44
- Rake::Task['jenkins:unit'].enhance ['test:foreman_omaha', 'foreman_omaha:rubocop']
45
- end
43
+ Rake::Task['jenkins:unit'].enhance ['test:foreman_omaha', 'foreman_omaha:rubocop'] if Rake::Task.task_defined?(:'jenkins:unit')
@@ -1,4 +1,4 @@
1
- FactoryGirl.modify do
1
+ FactoryBot.modify do
2
2
  factory :feature do
3
3
  trait :omaha do
4
4
  name 'Omaha'
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :omaha_report, :class => 'ForemanOmaha::OmahaReport' do
3
3
  host
4
4
  sequence(:reported_at) { |n| n.minutes.ago }
@@ -6,4 +6,19 @@ FactoryGirl.define do
6
6
  omaha_version '1068.9.0'
7
7
  type 'ForemanOmaha::OmahaReport'
8
8
  end
9
+
10
+ factory :omaha_facet, :class => 'ForemanOmaha::OmahaFacet' do
11
+ sequence(:last_report) { |n| n.minutes.ago }
12
+ version '1068.9.0'
13
+ oem 'rackspace'
14
+ sequence(:machineid) { SecureRandom.hex }
15
+ status 1
16
+ host
17
+ omaha_group
18
+ end
19
+
20
+ factory :omaha_group, :class => 'ForemanOmaha::OmahaGroup' do
21
+ sequence(:name) { |n| "Omaha Group #{n}" }
22
+ sequence(:uuid) { SecureRandom.uuid }
23
+ end
9
24
  end
@@ -0,0 +1,21 @@
1
+ FactoryBot.modify do
2
+ factory :host do
3
+ trait :with_omaha_facet do
4
+ association :omaha_facet, :factory => :omaha_facet, :strategy => :build
5
+
6
+ transient do
7
+ omaha_status 1
8
+ omaha_version '1068.9.0'
9
+ omaha_oem 'rackspace'
10
+ omaha_group nil
11
+ end
12
+
13
+ after(:build) do |host, evaluator|
14
+ host.omaha_facet.status = evaluator.omaha_status
15
+ host.omaha_facet.version = evaluator.omaha_version
16
+ host.omaha_facet.oem = evaluator.omaha_oem
17
+ host.omaha_facet.omaha_group = evaluator.omaha_group if evaluator.omaha_group.present?
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,4 +1,4 @@
1
- FactoryGirl.modify do
1
+ FactoryBot.modify do
2
2
  factory :smart_proxy do
3
3
  trait :omaha do
4
4
  features { |sp| [sp.association(:feature, :omaha)] }
@@ -0,0 +1,32 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class Api::V2::OmahaGroupsControllerTest < ActionController::TestCase
4
+ context '#index' do
5
+ test 'should list omaha groups' do
6
+ omaha_group = FactoryBot.create(:omaha_group, :name => 'Stable', :uuid => 'stable')
7
+ get :index
8
+ assert_response :success
9
+ body = ActiveSupport::JSON.decode(@response.body)
10
+ results = body['results']
11
+ assert results
12
+ entry = results.detect { |e| e['id'] == omaha_group.id }
13
+ assert entry
14
+ assert_equal omaha_group.name, entry['name']
15
+ assert_equal omaha_group.uuid, entry['uuid']
16
+ end
17
+ end
18
+
19
+ context '#show' do
20
+ let(:omaha_group) { FactoryBot.create(:omaha_group) }
21
+
22
+ test 'should show individual record' do
23
+ get :show, params: { :id => omaha_group.to_param }
24
+ assert_response :success
25
+ body = ActiveSupport::JSON.decode(@response.body)
26
+ refute_empty body
27
+ assert_equal omaha_group.id, body['id']
28
+ assert_equal omaha_group.name, body['name']
29
+ assert_equal omaha_group.uuid, body['uuid']
30
+ end
31
+ end
32
+ end
@@ -2,18 +2,18 @@ require 'test_helper'
2
2
 
3
3
  class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
4
4
  test 'create valid' do
5
- post :create, { :omaha_report => create_report }, set_session_user
5
+ post :create, params: { :omaha_report => create_report }, session: set_session_user
6
6
  assert_response :success
7
7
  end
8
8
 
9
9
  test 'create invalid' do
10
- post :create, { :omaha_report => ['not a hash', 'throw an error'] }, set_session_user
10
+ post :create, params: { :omaha_report => ['not a hash', 'throw an error'] }, session: set_session_user
11
11
  assert_response :unprocessable_entity
12
12
  end
13
13
 
14
14
  test 'should get index' do
15
- FactoryGirl.create(:omaha_report)
16
- get :index, {}
15
+ FactoryBot.create(:omaha_report)
16
+ get :index
17
17
  assert_response :success
18
18
  assert_not_nil assigns(:omaha_reports)
19
19
  reports = ActiveSupport::JSON.decode(@response.body)
@@ -21,25 +21,25 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
21
21
  end
22
22
 
23
23
  test 'should show individual record' do
24
- report = FactoryGirl.create(:omaha_report)
25
- get :show, :id => report.to_param
24
+ report = FactoryBot.create(:omaha_report)
25
+ get :show, params: { :id => report.to_param }
26
26
  assert_response :success
27
27
  show_response = ActiveSupport::JSON.decode(@response.body)
28
28
  assert !show_response.empty?
29
29
  end
30
30
 
31
31
  test 'should destroy report' do
32
- report = FactoryGirl.create(:omaha_report)
32
+ report = FactoryBot.create(:omaha_report)
33
33
  assert_difference('ForemanOmaha::OmahaReport.count', -1) do
34
- delete :destroy, :id => report.to_param
34
+ delete :destroy, params: { :id => report.to_param }
35
35
  end
36
36
  assert_response :success
37
37
  refute Report.find_by(id: report.id)
38
38
  end
39
39
 
40
40
  test 'should get reports for given host only' do
41
- report = FactoryGirl.create(:omaha_report)
42
- get :index, :host_id => report.host.to_param
41
+ report = FactoryBot.create(:omaha_report)
42
+ get :index, params: { :host_id => report.host.to_param }
43
43
  assert_response :success
44
44
  assert_not_nil assigns(:omaha_reports)
45
45
  reports = ActiveSupport::JSON.decode(@response.body)
@@ -48,8 +48,8 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
48
48
  end
49
49
 
50
50
  test 'should return empty result for host with no reports' do
51
- host = FactoryGirl.create(:host)
52
- get :index, :host_id => host.to_param
51
+ host = FactoryBot.create(:host)
52
+ get :index, params: { :host_id => host.to_param }
53
53
  assert_response :success
54
54
  assert_not_nil assigns(:omaha_reports)
55
55
  reports = ActiveSupport::JSON.decode(@response.body)
@@ -58,8 +58,8 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
58
58
  end
59
59
 
60
60
  test 'should get last report' do
61
- reports = FactoryGirl.create_list(:omaha_report, 5)
62
- get :last, set_session_user
61
+ reports = FactoryBot.create_list(:omaha_report, 5)
62
+ get :last, session: set_session_user
63
63
  assert_response :success
64
64
  assert_not_nil assigns(:omaha_report)
65
65
  report = ActiveSupport::JSON.decode(@response.body)
@@ -68,9 +68,9 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
68
68
  end
69
69
 
70
70
  test 'should get last report for given host only' do
71
- main_report = FactoryGirl.create(:omaha_report)
72
- FactoryGirl.create_list(:omaha_report, 5)
73
- get :last, { :host_id => main_report.host.to_param }, set_session_user
71
+ main_report = FactoryBot.create(:omaha_report)
72
+ FactoryBot.create_list(:omaha_report, 5)
73
+ get :last, params: { :host_id => main_report.host.to_param }, session: set_session_user
74
74
  assert_response :success
75
75
  assert_not_nil assigns(:omaha_report)
76
76
  report = ActiveSupport::JSON.decode(@response.body)
@@ -79,32 +79,32 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
79
79
  end
80
80
 
81
81
  test 'should give error if no last report for given host' do
82
- host = FactoryGirl.create(:host)
83
- get :last, :host_id => host.to_param
82
+ host = FactoryBot.create(:host)
83
+ get :last, params: { :host_id => host.to_param }
84
84
  assert_response :not_found
85
85
  end
86
86
 
87
87
  test 'cannot view the last report without hosts view permission' do
88
- report = FactoryGirl.create(:report)
88
+ report = FactoryBot.create(:report)
89
89
  setup_user('view', 'omaha_reports')
90
- get :last, { :host_id => report.host.id }, set_session_user.merge(:user => User.current.id)
90
+ get :last, params: { :host_id => report.host.id }, session: set_session_user.merge(:user => User.current.id)
91
91
  assert_response :not_found
92
92
  end
93
93
 
94
94
  describe 'unpriveliged user' do
95
95
  def setup
96
- User.current = FactoryGirl.create(:user, :admin)
96
+ User.current = FactoryBot.create(:user, :admin)
97
97
  end
98
98
 
99
99
  test 'hosts with a registered smart proxy on should create a report successfully' do
100
100
  Setting[:restrict_registered_smart_proxies] = true
101
101
  Setting[:require_ssl_smart_proxies] = false
102
102
 
103
- proxy = FactoryGirl.create(:smart_proxy, :omaha)
103
+ proxy = FactoryBot.create(:smart_proxy, :omaha)
104
104
  host = URI.parse(proxy.url).host
105
105
  Resolv.any_instance.stubs(:getnames).returns([host])
106
106
  as_user :one do
107
- post :create, :omaha_report => create_report
107
+ post :create, params: { :omaha_report => create_report }
108
108
  end
109
109
  assert_equal proxy, @controller.detected_proxy
110
110
  assert_response :created
@@ -0,0 +1,18 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class OmahaGroupsControllerTest < ActionController::TestCase
4
+ test '#index' do
5
+ FactoryBot.create(:omaha_group)
6
+ get :index, session: set_session_user
7
+ assert_response :success
8
+ assert_not_nil assigns('omaha_groups')
9
+ assert_template 'index'
10
+ end
11
+
12
+ test '#show' do
13
+ omaha_group = FactoryBot.create(:omaha_group)
14
+ get :show, params: { :id => omaha_group.id }, session: set_session_user
15
+ assert_response :success
16
+ assert_template 'show'
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class OmahaHostsControllerTest < ActionController::TestCase
4
+ test '#index' do
5
+ FactoryBot.create(:host, :with_omaha_facet)
6
+ get :index, session: set_session_user
7
+ assert_response :success
8
+ assert_not_nil assigns('hosts')
9
+ assert_template 'index'
10
+ end
11
+ end