Skip to content
Extraits de code Groupes Projets
Valider c816a1f7 rédigé par Sarah Mei's avatar Sarah Mei
Parcourir les fichiers

RegistrationsController#create re-renders the form instead of redirecting, so...

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.
parent a2307638
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -11,11 +11,7 @@ class RegistrationsController < Devise::RegistrationsController ...@@ -11,11 +11,7 @@ class RegistrationsController < Devise::RegistrationsController
sign_in_and_redirect(:user, @user) sign_in_and_redirect(:user, @user)
else else
flash[:error] = @user.errors.full_messages.join(', ') flash[:error] = @user.errors.full_messages.join(', ')
redirect_to new_user_registration_path render :new
end end
end end
def update
super
end
end end
...@@ -41,15 +41,15 @@ describe RegistrationsController do ...@@ -41,15 +41,15 @@ describe RegistrationsController do
end end
context "with invalid parameters" do context "with invalid parameters" do
before do before do
@valid_params["user"]["password_confirmation"] = "baddword"
@invalid_params = @valid_params @invalid_params = @valid_params
user = Factory.build(:user) @invalid_params["user"]["password_confirmation"] = "baddword"
user.stub!(:save){user.errors.add(:base, "hello"); false}
User.stub!(:build).and_return(user)
end end
it "does not create a user" do it "does not create a user" do
lambda { get :create, @invalid_params }.should_not change(User, :count) lambda { get :create, @invalid_params }.should_not change(User, :count)
end end
it "does not create a person" do
lambda { get :create, @invalid_params }.should_not change(Person, :count)
end
it "assigns @user" do it "assigns @user" do
get :create, @invalid_params get :create, @invalid_params
assigns(:user).should_not be_nil assigns(:user).should_not be_nil
...@@ -58,9 +58,9 @@ describe RegistrationsController do ...@@ -58,9 +58,9 @@ describe RegistrationsController do
get :create, @invalid_params get :create, @invalid_params
flash[:error].should_not be_blank flash[:error].should_not be_blank
end end
it "goes back to the form" do it "re-renders the form" do
get :create, @invalid_params get :create, @invalid_params
response.should redirect_to new_user_registration_path response.should render_template("registrations/new")
end end
end end
end end
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter