foreman_omaha 0.0.2 → 0.0.3

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
  SHA1:
3
- metadata.gz: c40493ee95139d2621cc06d655b33f261e4f9fa5
4
- data.tar.gz: 702a0818709f83f31d94f13e682565ca5d33105e
3
+ metadata.gz: d3ec4d257a6b23da8a778b2c6c7646bda239ed8a
4
+ data.tar.gz: 72996f1f0545e2c51e9bda9d0d1ec3c1765ff483
5
5
  SHA512:
6
- metadata.gz: c5f4835601a8843d36e0381ff3c0b0d6c36be09ae9013a6a5ac9fe277aa7e5c015ed2f8077d3d73c057abbdfaab792452b3f238ac6c167e6bdedc80dd9ebdaae
7
- data.tar.gz: 0c678a22af766c6cb3c1968ed3394e547efc9314f1e72bc32627ac7d5273fb406962bb9031b958c47c736fd57830f576d7c26eb2938559b63f36a0616673333f
6
+ metadata.gz: 49351ba242b536b61204bd5dde6f559a843e979c7de3e3fddb1a3e7c0e104bd5303fdcce6d7fcb4e3bb3a2d9639a6af872e14167289c5d02164b02a2b0acd314
7
+ data.tar.gz: afcc44fb7da39ece8712fd38d18d9dd1e7cff99e938284b90b5d2a4d0909924753f410a189b25f8b67ce8827ab64532917afa3677d73fb0084353f6bd24b3557
data/Rakefile CHANGED
File without changes
@@ -31,8 +31,7 @@ module Api
31
31
  api :GET, '/omaha_reports/:id/', N_('Show a omaha report')
32
32
  param :id, :identifier, :required => true
33
33
 
34
- def show
35
- end
34
+ def show; end
36
35
 
37
36
  api :POST, '/omaha_reports', N_('Create a omaha report')
38
37
  param_group :omaha_report, :as => :create
@@ -14,9 +14,13 @@ class OmahaReportsController < ApplicationController
14
14
  def show
15
15
  # are we searching for the last report?
16
16
  if params[:id] == 'last'
17
- conditions = {
18
- :host_id => resource_finder(Host.authorized(:view_hosts), params[:host_id]).try(:id)
19
- } if params[:host_id].present?
17
+ conditions = if params[:host_id].present?
18
+ {
19
+ :host_id => resource_finder(Host.authorized(:view_hosts), params[:host_id]).try(:id)
20
+ }
21
+ else
22
+ {}
23
+ end
20
24
  params[:id] = resource_base.where(conditions).maximum(:id)
21
25
  end
22
26
 
@@ -1,7 +1,7 @@
1
1
  module ForemanOmaha
2
2
  class FactName < ::FactName
3
3
  def origin
4
- 'Omaha'
4
+ 'foreman_omaha/Omaha'
5
5
  end
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module ForemanOmaha
2
2
  class OmahaReport < ::Report
3
3
  enum :status => [:unknown, :complete, :downloading, :downloaded,
4
- :installed, :instance_hold, :error]
4
+ :installed, :instance_hold, :error]
5
5
 
6
6
  scoped_search :on => :omaha_version, :rename => :version, :complete_value => true
7
7
  scoped_search :on => :status, :complete_value => statuses
@@ -34,7 +34,7 @@ module ForemanOmaha
34
34
  end
35
35
 
36
36
  def operatingsystem
37
- return unless omaha_version.present?
37
+ return if omaha_version.blank?
38
38
  args = { :type => 'Coreos', :major => osmajor, :minor => osminor }
39
39
  Operatingsystem.find_by(args)
40
40
  end
@@ -1,3 +1,3 @@
1
1
  object @omaha_report
2
2
 
3
- extends "api/v2/omaha_reports/show"
3
+ extends 'api/v2/omaha_reports/show'
@@ -1,3 +1,3 @@
1
1
  collection @omaha_reports
2
2
 
3
- extends "api/v2/omaha_reports/main"
3
+ extends 'api/v2/omaha_reports/main'
@@ -1,5 +1,5 @@
1
1
  object @omaha_report
2
2
 
3
- extends "api/v2/omaha_reports/base"
3
+ extends 'api/v2/omaha_reports/base'
4
4
 
5
5
  attributes :omaha_version, :created_at, :updated_at
@@ -1,3 +1,3 @@
1
1
  object @omaha_report
2
2
 
3
- extends "api/v2/omaha_reports/main"
3
+ extends 'api/v2/omaha_reports/main'
@@ -1,3 +1,3 @@
1
1
  object @omaha_report
2
2
 
3
- extends "api/v2/omaha_reports/show"
3
+ extends 'api/v2/omaha_reports/show'
@@ -27,7 +27,7 @@ module ForemanOmaha
27
27
  permission :view_omaha_reports, :omaha_reports => [:index, :show, :auto_complete_search],
28
28
  :'api/v2/omaha_reports' => [:index, :show, :last]
29
29
  permission :destroy_omaha_reports, :omaha_reports => [:destroy],
30
- :'api/v2/config_reports' => [:destroy]
30
+ :'api/v2/omaha_reports' => [:destroy]
31
31
  permission :upload_omaha_reports, :omaha_reports => [:create],
32
32
  :'api/v2/omaha_reports' => [:create]
33
33
  end
@@ -45,8 +45,8 @@ module ForemanOmaha
45
45
  after: :reports
46
46
  end
47
47
 
48
- if respond_to?(:hosts_controller_action_scope)
49
- hosts_controller_action_scope(:index) { |base_scope| base_scope.includes(:last_omaha_report_object) }
48
+ if respond_to?(:add_controller_action_scope)
49
+ add_controller_action_scope(HostsController, :index) { |base_scope| base_scope.includes(:last_omaha_report_object) }
50
50
  end
51
51
  end
52
52
 
@@ -63,6 +63,18 @@ module ForemanOmaha
63
63
  end
64
64
  end
65
65
 
66
+ initializer 'foreman_omaha.assets.precompile' do |app|
67
+ app.config.assets.precompile += %w[foreman_omaha/Omaha.png]
68
+ 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
+ }
76
+ end
77
+
66
78
  rake_tasks do
67
79
  Rake::Task['db:seed'].enhance do
68
80
  ForemanOmaha::Engine.load_seed
@@ -1,3 +1,3 @@
1
1
  module ForemanOmaha
2
- VERSION = '0.0.2'.freeze
2
+ VERSION = '0.0.3'.freeze
3
3
  end
@@ -34,7 +34,7 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
34
34
  delete :destroy, :id => report.to_param
35
35
  end
36
36
  assert_response :success
37
- refute Report.find_by_id(report.id)
37
+ refute Report.find_by(id: report.id)
38
38
  end
39
39
 
40
40
  test 'should get reports for given host only' do
@@ -85,15 +85,15 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
85
85
  end
86
86
 
87
87
  test 'cannot view the last report without hosts view permission' do
88
- setup_user('view', 'omaha_reports')
89
88
  report = FactoryGirl.create(:report)
89
+ setup_user('view', 'omaha_reports')
90
90
  get :last, { :host_id => report.host.id }, 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 = users(:one)
96
+ User.current = FactoryGirl.create(:user, :admin)
97
97
  end
98
98
 
99
99
  test 'hosts with a registered smart proxy on should create a report successfully' do
@@ -103,7 +103,9 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
103
103
  proxy = FactoryGirl.create(:smart_proxy, :omaha)
104
104
  host = URI.parse(proxy.url).host
105
105
  Resolv.any_instance.stubs(:getnames).returns([host])
106
- post :create, :omaha_report => create_report
106
+ as_user :one do
107
+ post :create, :omaha_report => create_report
108
+ end
107
109
  assert_equal proxy, @controller.detected_proxy
108
110
  assert_response :created
109
111
  end
@@ -2,57 +2,60 @@ require 'test_plugin_helper'
2
2
 
3
3
  class OmahaReportTest < ActiveSupport::TestCase
4
4
  setup do
5
- User.current = User.find_by_login 'admin'
6
- @report = FactoryGirl.create(:omaha_report)
5
+ User.current = FactoryGirl.create(:user, :admin)
7
6
  end
8
7
 
9
8
  context 'status' do
9
+ let(:report) { FactoryGirl.build(:omaha_report) }
10
+
10
11
  test 'should be complete' do
11
- @report.status = 'complete'
12
- assert_equal 'complete', @report.status
13
- assert_equal 'Complete', @report.to_label
12
+ report.status = 'complete'
13
+ assert_equal 'complete', report.status
14
+ assert_equal 'Complete', report.to_label
14
15
  end
15
16
 
16
17
  test 'should be downloading' do
17
- @report.status = 'downloading'
18
- assert_equal 'downloading', @report.status
19
- assert_equal 'Downloading', @report.to_label
18
+ report.status = 'downloading'
19
+ assert_equal 'downloading', report.status
20
+ assert_equal 'Downloading', report.to_label
20
21
  end
21
22
 
22
23
  test 'should be downloaded' do
23
- @report.status = 'downloaded'
24
- assert_equal 'downloaded', @report.status
25
- assert_equal 'Downloaded', @report.to_label
24
+ report.status = 'downloaded'
25
+ assert_equal 'downloaded', report.status
26
+ assert_equal 'Downloaded', report.to_label
26
27
  end
27
28
 
28
29
  test 'should be installed' do
29
- @report.status = 'installed'
30
- assert_equal 'installed', @report.status
31
- assert_equal 'Installed', @report.to_label
30
+ report.status = 'installed'
31
+ assert_equal 'installed', report.status
32
+ assert_equal 'Installed', report.to_label
32
33
  end
33
34
 
34
35
  test 'should be installed' do
35
- @report.status = 'instance_hold'
36
- assert_equal 'instance_hold', @report.status
37
- assert_equal 'Instance Hold', @report.to_label
36
+ report.status = 'instance_hold'
37
+ assert_equal 'instance_hold', report.status
38
+ assert_equal 'Instance Hold', report.to_label
38
39
  end
39
40
 
40
41
  test 'should be error' do
41
- @report.status = 'error'
42
- assert_equal 'error', @report.status
43
- assert_equal 'Error', @report.to_label
42
+ report.status = 'error'
43
+ assert_equal 'error', report.status
44
+ assert_equal 'Error', report.to_label
44
45
  end
45
46
  end
46
47
 
47
48
  context 'operatingsystem' do
49
+ let(:os) { FactoryGirl.create(:coreos, :major => '1068', :minor => '9.0') }
50
+ let(:report) { FactoryGirl.create(:omaha_report) }
51
+
48
52
  test 'should get operatingsystem' do
49
- os = FactoryGirl.create(:coreos, :major => '1068', :minor => '9.0')
50
- assert_equal os, @report.operatingsystem
53
+ assert_equal os, report.operatingsystem
51
54
  end
52
55
 
53
56
  test 'should parse major, minor' do
54
- assert_equal '1068', @report.osmajor
55
- assert_equal '9.0', @report.osminor
57
+ assert_equal '1068', report.osmajor
58
+ assert_equal '9.0', report.osminor
56
59
  end
57
60
  end
58
61
 
@@ -79,7 +82,7 @@ class OmahaReportTest < ActiveSupport::TestCase
79
82
  'reported_at' => Time.now.utc.to_s
80
83
  }
81
84
  assert_raise ArgumentError do
82
- ForemanOmaha::OmahaReport.import(report)
85
+ ForemanOmaha::OmahaReport.import(report)
83
86
  end
84
87
  end
85
88
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_omaha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timo Goebel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-21 00:00:00.000000000 Z
11
+ date: 2017-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.49.1
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 0.49.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rdoc
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ files:
49
49
  - LICENSE
50
50
  - README.md
51
51
  - Rakefile
52
- - app/assets/images/Omaha.png
52
+ - app/assets/images/foreman_omaha/Omaha.png
53
53
  - app/controllers/api/v2/omaha_reports_controller.rb
54
54
  - app/controllers/omaha_reports_controller.rb
55
55
  - app/helpers/concerns/foreman_omaha/hosts_helper_extensions.rb
@@ -90,7 +90,7 @@ files:
90
90
  - test/functional/omaha_reports_controller_test.rb
91
91
  - test/test_plugin_helper.rb
92
92
  - test/unit/omaha_report_test.rb
93
- homepage: http://github.com/timogoebel/foreman_omaha
93
+ homepage: http://github.com/theforeman/foreman_omaha
94
94
  licenses:
95
95
  - GPL-3
96
96
  metadata: {}
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  version: '0'
111
111
  requirements: []
112
112
  rubyforge_project:
113
- rubygems_version: 2.5.1
113
+ rubygems_version: 2.6.12
114
114
  signing_key:
115
115
  specification_version: 4
116
116
  summary: This plug-in adds support for the Omaha procotol to The Foreman.