Test Code: def setup @controller = SettingsController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new @request.session[:user_id] = User.find(1) @request.session[:time_of_last_action] = (Time.now - 30*60) end def test_turn_wysiwyg_off post ''index'', {:settings => {:wysiwyg => 0}} assert_equal(nil, session[:user_id].settings) assert_equal(false, session[:user_id].settings.wysiwyg, ''Session was not updated'') assert_equal(false, UserSetting.find(1).wysiwyg, ''Database was not updated'') assert_equal ''Your settings have been successfully updated'', flash[:notice] end ======================================================================== Action Code: def index if request.post? if (session[:user_id].settings.update_attributes(params[:settings])) if(session[:user_id].settings.save) flash[:notice] = ''Your settings have been successfully updated'' else flash[:notice] = ''Your settings could not be updated'' end end end @settings = session[:user_id].settings end =========================================================================== The action passes when tested manually. It appears as though I don''t have access to any changes to the session Does any one know how to make the magic happen? -- 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 -~----------~----~----~----~------~----~------~--~---
Keynan Pratt wrote:> Test Code: > > def setup > @controller = SettingsController.new > @request = ActionController::TestRequest.new > @response = ActionController::TestResponse.new > > @request.session[:user_id] = User.find(1) > @request.session[:time_of_last_action] = (Time.now - 30*60) > end > > def test_turn_wysiwyg_off > post ''index'', {:settings => {:wysiwyg => 0}} > assert_equal(nil, session[:user_id].settings) > assert_equal(false, session[:user_id].settings.wysiwyg, > ''Session was not updated'') > assert_equal(false, UserSetting.find(1).wysiwyg, ''Database was not > updated'') > > assert_equal ''Your settings have been successfully updated'', > flash[:notice] > end > > ========================================================================> > Action Code: > > def index > if request.post? > if (session[:user_id].settings.update_attributes(params[:settings])) > if(session[:user_id].settings.save) > flash[:notice] = ''Your settings have been successfully updated'' > else > flash[:notice] = ''Your settings could not be updated'' > end > end > end > @settings = session[:user_id].settings > end > > ===========================================================================> > The action passes when tested manually. > It appears as though I don''t have access to any changes to the session > > Does any one know how to make the magic happen?You haven''t told us which assert you think is supposed to be failing and why. If you want to track the changes to the session object, you can just print out its contents in your code and see if things are getting set as they should be. -- Michael Wang --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
the purpose of the first assert is to print the session in the fail message all the assertions fail. the assigns hash seems to be working but information from session and flash does not change with the request -- 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 -~----------~----~----~----~------~----~------~--~---
Keynan Pratt wrote:> the purpose of the first assert is to print the session in the fail > message > > all the assertions fail. > > the assigns hash seems to be working but information from session and > flash does not change with the request >In Ruby false != 0 -- Michael Wang --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
actually the problem was a security filter was interupting. p.s. in rails checkboxes 0 is submited and false is stored in the model attribute -- 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 -~----------~----~----~----~------~----~------~--~---