diff options
| author | Brice Figureau <brice-puppet@daysofwonder.com> | 2008-10-18 12:53:27 +0200 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2008-10-21 21:14:23 +1100 |
| commit | ec2b4619d3c90b09e1b9fda0020552d5a2d6061f (patch) | |
| tree | c8b11e31644362cbace552214512fffcd61949a9 | |
| parent | 356d8cab14ce9600b39b8fdf48beea7c7fbcf345 (diff) | |
Fix #1115 - part2 - fix tests and add all_tags
Up until this patch, TemplateWrapper.tags was returning all the tags
defined in the catalog. I think this is wrong and tags shoul only
return the defined tags in the current scope.
Hence, I defined a all_tags method that returns the list of tags defined
in the whole catalog.
| -rw-r--r-- | lib/puppet/parser/templatewrapper.rb | 7 | ||||
| -rwxr-xr-x | spec/unit/parser/templatewrapper.rb | 8 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/puppet/parser/templatewrapper.rb b/lib/puppet/parser/templatewrapper.rb index 824fc48ef..00f364088 100644 --- a/lib/puppet/parser/templatewrapper.rb +++ b/lib/puppet/parser/templatewrapper.rb @@ -42,8 +42,13 @@ class Puppet::Parser::TemplateWrapper return scope.catalog.classes end - # Allow templates to access the defined tags + # Allow templates to access the tags defined in the current scope def tags + return scope.tags + end + + # Allow templates to access the all the defined tags + def all_tags return scope.catalog.tags end diff --git a/spec/unit/parser/templatewrapper.rb b/spec/unit/parser/templatewrapper.rb index a8c464771..6dbfbe266 100755 --- a/spec/unit/parser/templatewrapper.rb +++ b/spec/unit/parser/templatewrapper.rb @@ -62,10 +62,16 @@ describe Puppet::Parser::TemplateWrapper do tw.classes().should == ["class1", "class2"] end - it "should allow you to retrieve the defined tags with tags" do + it "should allow you to retrieve all the tags with all_tags" do catalog = mock 'catalog', :tags => ["tag1", "tag2"] @scope.expects(:catalog).returns( catalog ) tw = Puppet::Parser::TemplateWrapper.new(@scope, @file) + tw.all_tags().should == ["tag1","tag2"] + end + + it "should allow you to retrieve the tags defined in the current scope" do + @scope.expects(:tags).returns( ["tag1", "tag2"] ) + tw = Puppet::Parser::TemplateWrapper.new(@scope, @file) tw.tags().should == ["tag1","tag2"] end |
