lib/puppet/feature/rails.rb already has a check to make sure we've got at
least Rails 2.1, and both Puppet::Rails and the specs check
Puppet.features.rails? before running this code.

On Mon, Nov 9, 2009 at 10:34 AM, Luke Kanies <[email protected]> wrote:

>
> I seem to remember something about these constants not always existing
> in different versions of Rails.  I assume they're in every version
> since 2.1, but this might fail in interesting and unhelpful ways in
> older releases.  It might be worth throwing a 'defined?' in there,
> although you don't have to take my word for it that this is a real
> problem.
>
> On Nov 8, 2009, at 4:01 PM, Jesse Wolfe wrote:
>
> >
> > Suprisingly, I found that setting allow_concurrency made the
> > "MySQL server has gone away" stop occuring even if the MySQL server
> > drops connections.
> > This may be the only change needed to restore compatibility with
> > ActiveRecord 2.1.x
> >
> > Signed-off-by: Jesse Wolfe <[email protected]>
> > ---
> > lib/puppet/rails.rb |    4 ++++
> > spec/unit/rails.rb  |   11 +++++++++++
> > 2 files changed, 15 insertions(+), 0 deletions(-)
> >
> > diff --git a/lib/puppet/rails.rb b/lib/puppet/rails.rb
> > index fc8eacd..87f1bb1 100644
> > --- a/lib/puppet/rails.rb
> > +++ b/lib/puppet/rails.rb
> > @@ -22,6 +22,10 @@ module Puppet::Rails
> >             ActiveRecord::Base.logger.level = Logger::DEBUG
> >         end
> >
> > +        if (::ActiveRecord::VERSION::MAJOR == 2
> > and ::ActiveRecord::VERSION::MINOR <= 1)
> > +            ActiveRecord::Base.allow_concurrency = true
> > +        end
> > +
> >         ActiveRecord::Base.verify_active_connections!
> >
> >         begin
> > diff --git a/spec/unit/rails.rb b/spec/unit/rails.rb
> > index d98c887..6dee55b 100755
> > --- a/spec/unit/rails.rb
> > +++ b/spec/unit/rails.rb
> > @@ -39,6 +39,7 @@ describe Puppet::Rails, "when initializing any
> > connection" do
> >         ActiveRecord::Base.stubs(:logger).returns(logger)
> >         logger.expects(:level=).with(Logger::DEBUG)
> >
> > +        ActiveRecord::Base.stubs(:allow_concurrency=)
> >         ActiveRecord::Base.stubs(:verify_active_connections!)
> >         ActiveRecord::Base.stubs(:establish_connection)
> >         Puppet::Rails.stubs(:database_arguments)
> > @@ -46,6 +47,16 @@ describe Puppet::Rails, "when initializing any
> > connection" do
> >         Puppet::Rails.connect
> >     end
> >
> > +    describe "on ActiveRecord 2.1.x" do
> > +        confine "ActiveRecord 2.1.x" =>
> > (::ActiveRecord::VERSION::MAJOR == 2
> > and ::ActiveRecord::VERSION::MINOR <= 1)
> > +
> > +        it "should set ActiveRecord::Base.allow_concurrency" do
> > +
> > ActiveRecord::Base.expects(:allow_concurrency=).with(true)
> > +
> > +            Puppet::Rails.connect
> > +        end
> > +    end
> > +
> >     it "should call ActiveRecord::Base.verify_active_connections!" do
> >         ActiveRecord::Base.expects(:verify_active_connections!)
> >
> > --
> > 1.6.3.3
> >
> >
> > >
>
>
> --
> SELF-EVIDENT, adj. Evident to one's self and to nobody else.
>     -- Ambrose Bierce
> ---------------------------------------------------------------------
> Luke Kanies | http://reductivelabs.com | http://madstop.com
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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