Hi, In a controler, how can we check that we are running a test (rake test). Is there a connection object? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 26 Aug 2008, at 10:54, Robert Plagnard wrote:> > Hi, > In a controler, how can we check that we are running a test (rake > test). > Is there a connection object?Check the value of RAILS_ENV Fred> > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 26 Aug 2008, at 10:54, Robert Plagnard wrote: > >> >> Hi, >> In a controler, how can we check that we are running a test (rake >> test). >> Is there a connection object? > > Check the value of RAILS_ENV > > FredSuper, Thanks Robert -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Tue, Aug 26, 2008 at 2:54 AM, Robert Plagnard <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi, > In a controler, how can we check that we are running a test (rake test). > Is there a connection object?I can''t help but ask... why? Curious, Robby -- Robby Russell Chief Evangelist, Partner PLANET ARGON, LLC design // development // hosting http://www.planetargon.com/ http://www.robbyonrails.com/ aim: planetargon +1 503 445 2457 +1 877 55 ARGON [toll free] +1 815 642 4068 [fax] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Robby Russell wrote:> On Tue, Aug 26, 2008 at 2:54 AM, Robert Plagnard > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> >> Hi, >> In a controler, how can we check that we are running a test (rake test). >> Is there a connection object? > > I can''t help but ask... why? > > Curious, > Robby > > -- > Robby Russell > Chief Evangelist, Partner > > PLANET ARGON, LLC > design // development // hosting > > http://www.planetargon.com/ > http://www.robbyonrails.com/ > aim: planetargon >Hi, I am studying Noel Rappin''s "Professional Ruby on Rails" excellent book. I met the problem of update user.is_active attribute p 83. In users_controller : def activate find_user @is_valid = Token.is_valid_for_user(@user, param[:token]) @user.update_attributes(:is_active=>@is_valid) end Everything was fine except that user.is_active was staying desperatly false! After replacing update_attributes by update_attributes! I found the reason why. The user record was not valid because of the constraint : validates_length_of :password, :minimum => 6 But the password is not stored in user, we only have encrypted_password. It will not be a problem in production because we will have the password at this moment. But during the test, it''s not the case. And then you have 2 solutions : One used by NR which is to comment the constraint to pass the test. I don''t like it to much. The other idea was, when in test, to set a password just before update the user record : if RAILS_ENV = ''test'' @user.password= ''123456'' end @user.update_attributes(:is_active=>@is_valid) I don''t know if I was understandable, but it works as I want. Robert -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Robert Plagnard wrote:>>> In a controler, how can we check that we are running a test (rake >>> test).>>> Is there a connection object?>> Check the value of RAILS_ENVNow confess why your code needs to know that. You should either write the code to work no matter what its environment, or you should use a mock. If you want to use Mocha, use any_instance if you don''t know which instance your controller will construct... -- Phlip --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---