diff options
| author | Brice Figureau <brice-puppet@daysofwonder.com> | 2009-06-06 12:58:26 +0200 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-06-11 08:05:36 +1000 |
| commit | 607b01e82ea294068fdd554e59bc8e5fe3f9761a (patch) | |
| tree | 67065307f00a4bb1082cbb5aeb752d4cebf3e579 /spec/unit/parser | |
| parent | 06b919ddb7d635abfe7855336e0e5af67675b44e (diff) | |
| download | puppet-607b01e82ea294068fdd554e59bc8e5fe3f9761a.tar.gz puppet-607b01e82ea294068fdd554e59bc8e5fe3f9761a.tar.xz puppet-607b01e82ea294068fdd554e59bc8e5fe3f9761a.zip | |
Fix #2246 - take2: make sure we run the rails tag query only when needed
Adding the tags to the rails collect query can reduce performance
because there are 2 more tables to join with.
So we make sure to include tags in the query only when it is
necessary.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec/unit/parser')
| -rwxr-xr-x | spec/unit/parser/collector.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/spec/unit/parser/collector.rb b/spec/unit/parser/collector.rb index c2d5a991b..926033c68 100755 --- a/spec/unit/parser/collector.rb +++ b/spec/unit/parser/collector.rb @@ -505,7 +505,17 @@ describe Puppet::Parser::Collector, "when building its ActiveRecord query for co @collector.evaluate.should == [@resource] end - it "should return parameter names, parameter values and tags when querying ActiveRecord" do + it "should return parameter names, parameter values when querying ActiveRecord" do + Puppet::Rails::Resource.stubs(:find).with { |*arguments| + options = arguments[3] + options[:include] == {:param_values => :param_name} + }.returns([@resource]) + + @collector.evaluate.should == [@resource] + end + + it "should return tags when querying ActiveRecord with a tag exported query" do + @collector.equery = "puppet_tags.name = test" Puppet::Rails::Resource.stubs(:find).with { |*arguments| options = arguments[3] options[:include] == {:param_values => :param_name, :puppet_tags => :resource_tags} |
