Project

General

Profile

« Previous | Next » 

Revision ad2c9aa6

Added by Stephen Benjamin almost 10 years ago

fixes #6881 - check if in rake when validating template changes

View differences:

app/models/config_template.rb
validates :name, :presence => true, :uniqueness => true
validates :name, :template, :presence => true
validates :template_kind_id, :presence => true, :unless => Proc.new {|t| t.snippet }
validate :template_changes, :if => lambda { |template| template.locked? || template.locked_changed? }
validate :template_changes, :if => lambda { |template| (template.locked? || template.locked_changed?) && !Foreman.in_rake? }
before_destroy :check_if_template_is_locked
before_destroy EnsureNotUsedBy.new(:hostgroups, :environments, :os_default_templates)
has_many :hostgroups, :through => :template_combinations
test/unit/config_template_test.rb
assert_equal clone.operatingsystems, tmplt.operatingsystems
assert_equal clone.template_kind_id, tmplt.template_kind_id
assert_equal clone.template, tmplt.template
assert_equal tmplt.locked, true
assert_equal clone.locked, false
assert tmplt.locked
refute clone.locked
end
test "should not remove a locked template" do
......
refute_valid tmplt, :base, /Katello/
end
test "should change a locked template while in rake" do
Foreman.stubs(:in_rake?).returns(true)
tmplt = config_templates(:locked)
tmplt.template = "changing the template content"
tmplt.name = "giving it a new name too"
assert tmplt.locked
assert_valid tmplt
end
describe "Association cascading" do
setup do
@os1 = FactoryGirl.create(:operatingsystem)

Also available in: Unified diff