From a2746c4e9b238476df5e4e884b3adfa77978a19a Mon Sep 17 00:00:00 2001 From: Justin Sherrill Date: Thu, 7 Sep 2017 15:19:05 -0400 Subject: [PATCH] Fixes #20874 - check both host and hostgroup for RedHat os --- app/helpers/katello/hosts_and_hostgroups_helper.rb | 3 ++- test/helpers/hosts_and_hostgroups_helper_test.rb | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/helpers/katello/hosts_and_hostgroups_helper.rb b/app/helpers/katello/hosts_and_hostgroups_helper.rb index feaf6247f0a..87208917db8 100644 --- a/app/helpers/katello/hosts_and_hostgroups_helper.rb +++ b/app/helpers/katello/hosts_and_hostgroups_helper.rb @@ -191,12 +191,13 @@ def kickstart_repository_options(param_host, options = {}) # case 1 selected_host_group = options.fetch(:selected_host_group, nil) host = selected_host_group.present? ? selected_host_group : param_host - return [] unless host.operatingsystem.is_a?(Redhat) new_host = ::Host.new new_host.operatingsystem = param_host.operatingsystem.present? ? param_host.operatingsystem : host.operatingsystem new_host.architecture = param_host.architecture.present? ? param_host.architecture : host.architecture + return [] unless new_host.operatingsystem.is_a?(Redhat) + if (host.is_a? Hostgroup) new_host.content_facet = ::Katello::Host::ContentFacet.new(:lifecycle_environment_id => host.inherited_lifecycle_environment_id, :content_view_id => host.inherited_content_view_id, diff --git a/test/helpers/hosts_and_hostgroups_helper_test.rb b/test/helpers/hosts_and_hostgroups_helper_test.rb index 627bbd154c2..5a6ab50124d 100644 --- a/test/helpers/hosts_and_hostgroups_helper_test.rb +++ b/test/helpers/hosts_and_hostgroups_helper_test.rb @@ -113,6 +113,17 @@ def setup assert_equal ret.first[:name], options.first.name end + test "kickstart_repository_options should_handle_non_redhat_host" do + hostgroup = Hostgroup.new(:operatingsystem => @os) + host = ::Host.new(:architecture => @arch, :operatingsystem => operatingsystems(:opensuse), :hostgroup => hostgroup, + :content_facet_attributes => {:lifecycle_environment_id => @env.id, + :content_view_id => @cv.id, + :content_source_id => @content_source.id}) + + options = kickstart_repository_options(host, :selected_host_group => hostgroup) + assert_empty options + end + test "kickstart_repository_options should provide options for a populated hostgroup" do self.params = {} hostgroup = ::Hostgroup.new(:lifecycle_environment_id => @env.id,