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.
This commit is contained in:
parent
a230763879
commit
c816a1f78e
2 changed files with 7 additions and 11 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue