Revision 5081efd9
Added by Shimon Shtein almost 9 years ago
app/helpers/hosts_and_hostgroups_helper.rb | ||
---|---|---|
select_f f, :puppet_ca_proxy_id, proxies, :id, :name,
|
||
{ :include_blank => blank_or_inherit_f(f, :puppet_ca_proxy),
|
||
:disable_button => can_override ? _(INHERIT_TEXT) : nil,
|
||
:disable_button_enabled => override && !params[:host][:puppet_ca_proxy_id],
|
||
:disable_button_enabled => override && !explicit_value?(:puppet_ca_proxy_id),
|
||
:user_set => params[:host] && params[:host][:puppet_ca_proxy_id]
|
||
},
|
||
{ :label => _("Puppet CA"),
|
||
... | ... | |
select_f f, :puppet_proxy_id, proxies, :id, :name,
|
||
{ :include_blank => blank_or_inherit_f(f, :puppet_proxy),
|
||
:disable_button => can_override ? _(INHERIT_TEXT) : nil,
|
||
:disable_button_enabled => override && !params[:host][:puppet_proxy_id],
|
||
:disable_button_enabled => override && !explicit_value?(:puppet_proxy_id),
|
||
:user_set => params[:host] && params[:host][:puppet_proxy_id]
|
||
|
||
},
|
||
... | ... | |
:id, :to_label,
|
||
{ :include_blank => true,
|
||
:disable_button => can_override ? _(INHERIT_TEXT) : nil,
|
||
:disable_button_enabled => override && !params[:host][:realm_id],
|
||
:disable_button_enabled => override && !explicit_value?(:realm_id),
|
||
:user_set => params[:host] && params[:host][:realm_id]
|
||
},
|
||
{ :help_inline => :indicator }
|
||
... | ... | |
|
||
classes.where(:id => klasses)
|
||
end
|
||
|
||
def explicit_value?(field)
|
||
return true if params[:action] == 'clone'
|
||
return false unless params[:host]
|
||
!!params[:host][field]
|
||
end
|
||
end
|
app/helpers/hosts_helper.rb | ||
---|---|---|
:class => "btn btn-default btn-xs pull-right", :title => _("Edit %s" % type) )
|
||
end
|
||
end
|
||
|
||
def inherited_by_default?(field, host)
|
||
return false unless host.hostgroup && host.hostgroup_id_was.nil?
|
||
return false if params[:action] == 'clone'
|
||
return true unless params[:host]
|
||
!params[:host][field]
|
||
end
|
||
end
|
app/views/hosts/_form.html.erb | ||
---|---|---|
<div id="compute_profile" <%= display?(!@host.compute_resource_id) %> >
|
||
<%= select_f f, :compute_profile_id, ComputeProfile.visibles, :id, :name,
|
||
{ :disable_button => _(HostsAndHostgroupsHelper::INHERIT_TEXT),
|
||
:disable_button_enabled => @host.hostgroup && @host.hostgroup_id_was.nil? && !params[:host][:compute_profile_id],
|
||
:disable_button_enabled => inherited_by_default?(:compute_profile_id, @host),
|
||
:user_set => params[:host] && params[:host][:compute_profile_id]
|
||
},
|
||
{ :label => _("Compute profile"), :'data-url' => compute_resource_selected_hosts_path,
|
||
... | ... | |
|
||
<%= select_f f, :environment_id, Environment.with_taxonomy_scope_override(@location,@organization).order(:name), :id, :to_label, { :include_blank => true,
|
||
:disable_button => _(HostsAndHostgroupsHelper::INHERIT_TEXT),
|
||
:disable_button_enabled => @host.hostgroup && @host.hostgroup_id_was.nil? && !params[:host][:environment_id],
|
||
:disable_button_enabled => inherited_by_default?(:environment_id, @host),
|
||
:user_set => params[:host] && params[:host][:environment_id]
|
||
},
|
||
{:onchange => 'update_puppetclasses(this)', :'data-url' => hostgroup_or_environment_selected_hosts_path,
|
test/functional/hosts_controller_test.rb | ||
---|---|---|
refute assigns(:host).mac
|
||
end
|
||
|
||
def test_clone_with_hostgroup
|
||
ComputeResource.any_instance.stubs(:vm_compute_attributes_for).returns({})
|
||
host = FactoryGirl.create(:host, :with_hostgroup)
|
||
get :clone, {:id => host.id}, set_session_user
|
||
assert assigns(:clone_host)
|
||
assert_template 'clone'
|
||
assert_response :success
|
||
end
|
||
|
||
def setup_user(operation, type = 'hosts', filter = nil)
|
||
super
|
||
end
|
Also available in: Unified diff
Fixes #11255 - Fixed inheritance checks for explicit input on host clone