+1 You rock.

On Mon, Dec 21, 2009 at 3:26 PM, Jesse Wolfe <[email protected]> wrote:
> This logic had a bug where it would not insert data if it had just been
> deleted.
>
> Signed-off-by: Jesse Wolfe <[email protected]>
> ---
>  lib/puppet/rails/resource.rb |    2 +-
>  spec/unit/rails/resource.rb  |   20 ++++++++++++++++++++
>  2 files changed, 21 insertions(+), 1 deletions(-)
>
> diff --git a/lib/puppet/rails/resource.rb b/lib/puppet/rails/resource.rb
> index be28e37..7b37a52 100644
> --- a/lib/puppet/rails/resource.rb
> +++ b/lib/puppet/rails/resource.rb
> @@ -148,7 +148,7 @@ class Puppet::Rails::Resource < ActiveRecord::Base
>
>         # Lastly, add any new parameters.
>         catalog_params.each do |name, value|
> -            next if db_params.include?(name)
> +            next if db_params.include?(name) && ! db_params[name].find{ 
> |val| deletions.include?( val["id"] ) }
>             values = value.is_a?(Array) ? value : [value]
>
>             values.each do |v|
> diff --git a/spec/unit/rails/resource.rb b/spec/unit/rails/resource.rb
> index 9e2ff8c..e9162b9 100755
> --- a/spec/unit/rails/resource.rb
> +++ b/spec/unit/rails/resource.rb
> @@ -84,4 +84,24 @@ describe "Puppet::Rails::Resource" do
>             @resource.merge_parser_resource(@parser)
>         end
>     end
> +
> +    describe "merge_parameters" do
> +        it "should replace values that have changed" do
> +           �...@resource = Puppet::Rails::Resource.new
> +           �[email protected]_list = [{"name" => "replace", "value" => 1, 
> "id" => 100 }]
> +
> +            Puppet::Rails::ParamValue.expects(:delete).with([100])
> +            param_values = stub "param_values"
> +            param_values.expects(:build).with({:value=>nil, 
> :param_name=>nil, :line=>{"replace"=>2}})
> +           �[email protected](:param_values).returns(param_values)
> +
> +            Puppet::Rails::ParamName.stubs(:accumulate_by_name)
> +
> +            merge_resource = stub "merge_resource"
> +            merge_resource.expects(:line).returns({ "replace" => 2 })
> +            merge_resource.stubs(:each).yields([["replace", 2]])
> +
> +           �[email protected]_parameters(merge_resource)
> +        end
> +    end
>  end
> --
> 1.6.5
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "Puppet Developers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/puppet-dev?hl=en.
>
>
>



-- 
-----------------------------------------------------------
There is no absurdity so palpable but that it
may be firmly planted in the human head if
you only begin to inculcate it before the age
of five, by constantly repeating it with an air of
great solemnity.--Schopenhauer
------------------------------------------------------------

--

You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.


Reply via email to