ruby - Testing in rails - First argument in form cannot contain nil or be empty -


I am trying my controller when I run the trial, "user should edit" , this error appears.

1) Error: UsersControllerTest # test_should_edit_user: ActionView :: Template :: Error:

user_controller_test

  Edit "user should edit": id: @user assert_response: sucess end   

users_controller

  class UsersController & lt; ApplicationController def index @users = User.all end def = user = user.new (user_params) if @ user.password == @ user.password_confirmation if @ user.save more parameters [User] [document] redirect_to root_path else " to render the new "end" new "end end def edit new @ user = Ughrknu and Diif user = Ughrkfind_bi_aidi (session [: Smrn_tokn]) and Diif edit_password @ user = Ughrkfind_bi_aidi (session [: Smrn_kokn] ] End def update @user = User.find_by_id (session [: remember_token]) If @username @ user.update_edit (user name, Rarem [: user] [: user name]) @ user.update_attribute (: email, params [: user] [: email]) redirect_to root_path and then "edit" end-end def update password @user session = User. Find_by_id (session [: remember_token]) # user = authenticate (@ user session.username, params [: user] [: password]) if the @ user parameter [: user] [: password_confirmation] == parameters [: user] [: New_password] If @ user.update_attribute (: password, parameter [: user] [: new_password]) redirect_to root_path else redirect_to edit _password_path end Put else redirect_to edit_password_path eliminating end else redirect_to edit_password_path end end def desactivate @user = User.find_by_id (session [: remember_token]) if @ user @ user.update_attribute (: account_status, false) redirect_to log_out_path other redirect_to root_path finally end Diaf @ User = user.find (params [: id]) @ user.destroy redirect_to (action: "index") end   

and edit.html.erb < / P>

  & lt;% = link_to "Countrywide conta", desactivate_account_path%> & gt; & Lt;% = link_to "Alterar senha", edit_password_path, category: 'button'% & gt; & Lt;% = User u for form_ | F | & Gt%; & Lt;% if @ user.errors.any? & Gt%; & Lt; Div id = "error_explanation" & gt; & Lt; H2 & gt; & lt;% = Multifunctional (@UserRoaders quote, "Error")%> Restricted from saving this user: & lt; / H2 & gt; & Lt; Ul & gt; & Lt;% @ user.errors.full_messages.each do | Message | & Gt%; & Lt; Li & gt; & lt;% = Message% & gt; & Lt; / li & gt; & Lt;% end% & gt; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt;% end% & gt; & Lt; Div class = "field" & gt; & Lt;% = f.label: Username% & gt; & Lt; Br> & Lt;% = f.text_field: Username% & gt; & Lt; / Div & gt; & Lt; Div class = "field" & gt; & Lt;% = f.label: email% & gt; & Lt; Br> & Lt;% = f.text_field: email% & gt; & Lt; / Div & gt; & Lt; Div class = "verb" & gt; & Lt;% = f.submit 'Salwar Ultra § Pound o'% ' & Lt; / Div & gt; & Lt;% end% & gt;    

There are two things:

First of all, To work in the exact same way, try this:

  test "user should edit" session [: remember_token] = @ user.id: edit assert_response: success end < / Code>  

Note the spelling of success, two "c"

This is because when you run your test, any Session does not occur

And it brings the other thing: you have session hash Rnb are? Session = Parameters [: User] should be anywhere in your controllers.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -