Project

General

Profile

« Previous | Next » 

Revision d4b8428f

Added by Amir Fefer over 8 years ago

Fixes #12180 - lookup_value presence validation moved from lookup_key

Global parameters can have empty values so smart variables that are also global should be allowed to accept empty values too.
The validation on lookup_value to make sure it isn't empty is in the LookupKey class therefore affecting both VariableLookupKey and PuppetClassLookupKey.
This validation should affect on the child class - PuppetClassLookupKey.

View differences:

test/unit/lookup_value_test.rb
refute_valid @value
end
end
context "when key type is puppetclass lookup and value is empty" do
def setup
@key = FactoryGirl.create(:puppetclass_lookup_key, :as_smart_class_param,
:with_override, :with_use_puppet_default,
:key_type => 'string',
:puppetclass => puppetclasses(:one))
@value = FactoryGirl.build_stubbed(:lookup_value, :value => "",
:match => "hostgroup=Common",
:lookup_key_id => @key.id,
:use_puppet_default => true)
end
test "value is validated if use_puppet_default is true" do
assert_valid @value
end
test "value is not validated if use_puppet_default is false" do
@value.use_puppet_default = false
refute_valid @value
end
end
end

Also available in: Unified diff