Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Render 'edit' page test not working..not sure what else to try
- Failures:
- 1) UsersController PUT 'update' failure should render the 'edit' page
- Failure/Error: put :udpate, :id => @user, :user => @attr
- 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"}
- # ./spec/controllers/users_controller_spec.rb:164:in `block (4 levels) in <top (required)>'
- def update
- @user = User.find(params[:id])
- if @user.update_attributes(params[:user])
- flash[:success] = "Profile updated."
- redirect_to @user
- else
- @title = "Edit user"
- render 'edit'
- end
- end
- describe "PUT 'update'" do
- before do
- @user = Factory(:user)
- test_sign_in(@user)
- end
- describe "failure" do
- before do
- @attr = { :name => "", :email => "", :password => "", :password_confirmation => "" }
- end
- it "should render the 'edit' page" do
- put :update, :id => @user, :user => @attr
- response.should render_template('users/edit')
- end
- it "should have the right title" do
- put :update, :id => @user, :user => @attr
- response.should have_selector("title", :content => "Edit user")
- end
- end
- describe "success" do
- before do
- @attr = { :name => "Other User", :email => "other_user@example.com", :password => "barfoo", :password_confirmation => "barfoo" }
- end
- it "should change the users attributes" do
- put :update, :id => @user, :users => @attr
- user = assigns(:user)
- @user.reload
- @user.name.should == user.name
- @user.email.should == user.email
- @user.encrypted_password == user.encrypted_password
- end
- it "should have a flash message" do
- put :update, :id => @user, :user => @attr
- flash[:success].should =~ /updated/
- end
- end
Add Comment
Please, Sign In to add comment