From c816a1f78e5cf8e0ceb8fbde6cc0210a47cf4bdd Mon Sep 17 00:00:00 2001 From: Sarah Mei <sarahmei@gmail.com> Date: Thu, 4 Nov 2010 22:51:30 -0700 Subject: [PATCH] RegistrationsController#create re-renders the form instead of redirecting, so user doesn't lose what they've entered. Took out RegistrationsController#update, since all it was doing was calling super. Took out stubbing of user save, because I actually want to check that save is doing the right thing. --- app/controllers/registrations_controller.rb | 6 +----- spec/controllers/registrations_controller_spec.rb | 12 ++++++------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 75ee3b7f74..5ba0fb3c52 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -11,11 +11,7 @@ class RegistrationsController < Devise::RegistrationsController sign_in_and_redirect(:user, @user) else flash[:error] = @user.errors.full_messages.join(', ') - redirect_to new_user_registration_path + render :new end end - - def update - super - end end diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index 5bfb3cd265..9b4e6f768e 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -41,15 +41,15 @@ describe RegistrationsController do end context "with invalid parameters" do before do - @valid_params["user"]["password_confirmation"] = "baddword" @invalid_params = @valid_params - user = Factory.build(:user) - user.stub!(:save){user.errors.add(:base, "hello"); false} - User.stub!(:build).and_return(user) + @invalid_params["user"]["password_confirmation"] = "baddword" end it "does not create a user" do lambda { get :create, @invalid_params }.should_not change(User, :count) end + it "does not create a person" do + lambda { get :create, @invalid_params }.should_not change(Person, :count) + end it "assigns @user" do get :create, @invalid_params assigns(:user).should_not be_nil @@ -58,9 +58,9 @@ describe RegistrationsController do get :create, @invalid_params flash[:error].should_not be_blank end - it "goes back to the form" do + it "re-renders the form" do get :create, @invalid_params - response.should redirect_to new_user_registration_path + response.should render_template("registrations/new") end end end -- GitLab