Guest User

Untitled

a guest
Aug 29th, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. Render 'edit' page test not working..not sure what else to try
  2. Failures:
  3. 1) UsersController PUT 'update' failure should render the 'edit' page
  4. Failure/Error: put :udpate, :id => @user, :user => @attr
  5. No route matches {:id=>#<User id: 1, name: "User_Name", email: "USER@gmail.com", created_at: "2011-05-29 03:26:30", updated_at: "2011-05-29 03:26:30", encrypted_password: "fc70fcb4b094b388d87c5054ed9b0bfa06f53431d44c527e852...", salt: nil>, :user=>{:email=>"", :name=>"", :password=>"", :password_confirmation=>""}, :controller=>"users", :action=>"udpate"}
  6. # ./spec/controllers/users_controller_spec.rb:164:in `block (4 levels) in <top (required)>'
  7.  
  8. def update
  9. @user = User.find(params[:id])
  10. if @user.update_attributes(params[:user])
  11. flash[:success] = "Profile updated."
  12. redirect_to @user
  13. else
  14. @title = "Edit user"
  15. render 'edit'
  16. end
  17. end
  18.  
  19. describe "PUT 'update'" do
  20. before do
  21. @user = Factory(:user)
  22. test_sign_in(@user)
  23. end
  24.  
  25. describe "failure" do
  26. before do
  27. @attr = { :name => "", :email => "", :password => "", :password_confirmation => "" }
  28. end
  29.  
  30. it "should render the 'edit' page" do
  31. put :update, :id => @user, :user => @attr
  32. response.should render_template('users/edit')
  33. end
  34.  
  35. it "should have the right title" do
  36. put :update, :id => @user, :user => @attr
  37. response.should have_selector("title", :content => "Edit user")
  38. end
  39.  
  40. end
  41.  
  42. describe "success" do
  43. before do
  44. @attr = { :name => "Other User", :email => "other_user@example.com", :password => "barfoo", :password_confirmation => "barfoo" }
  45. end
  46.  
  47. it "should change the users attributes" do
  48. put :update, :id => @user, :users => @attr
  49. user = assigns(:user)
  50. @user.reload
  51. @user.name.should == user.name
  52. @user.email.should == user.email
  53. @user.encrypted_password == user.encrypted_password
  54. end
  55.  
  56. it "should have a flash message" do
  57. put :update, :id => @user, :user => @attr
  58. flash[:success].should =~ /updated/
  59. end
  60.  
  61. end
Add Comment
Please, Sign In to add comment