Project

General

Profile

« Previous | Next » 

Revision 7cc2816a

Added by Stephen Benjamin over 8 years ago

fixes #11619 - only check template changes when persisted

(cherry picked from commit bf5f18013ad224a93d917d696d94952965a8968d)

View differences:

app/models/template.rb
validates :name, :presence => true
validates :template, :presence => true
validates :audit_comment, :length => {:maximum => 255}
validate :template_changes, :if => lambda { |template| (template.locked? || template.locked_changed?) && !Foreman.in_rake? }
validate :template_changes, :if => lambda { |template| (template.locked? || template.locked_changed?) && template.persisted? && !Foreman.in_rake? }
before_destroy :check_if_template_is_locked
test/unit/provisioning_template_test.rb
assert_equal clone.template, tmplt.template
end
test "can instantiate a locked template" do
assert FactoryGirl.create(:provisioning_template, :locked => true)
end
test "should not edit a locked template" do
tmplt = templates(:locked)
tmplt.name = "something else"

Also available in: Unified diff