From 82082005ba88e588cc9e66ffe770f48ccb443cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabi=C3=A1n=20Rodr=C3=ADguez?= <fabianrbz@gmail.com> Date: Thu, 11 Oct 2012 19:47:04 -0200 Subject: [PATCH] redirect users back on registration failure --- app/controllers/registrations_controller.rb | 6 +++--- spec/controllers/registrations_controller_spec.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index da18aeaa7f..2823b4659e 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -18,10 +18,10 @@ class RegistrationsController < Devise::RegistrationsController Rails.logger.info("event=registration status=successful user=#{@user.diaspora_handle}") else @user.errors.delete(:person) - + flash[:error] = @user.errors.full_messages.join(" - ") Rails.logger.info("event=registration status=failure errors='#{@user.errors.full_messages.join(', ')}'") - render :new + redirect_to :back end end @@ -50,6 +50,6 @@ class RegistrationsController < Devise::RegistrationsController @invite ||= InvitationCode.find_by_token(params[:invite][:token]) end end - + helper_method :invite end diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index 524aef41ec..69a5f6059b 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -112,9 +112,9 @@ describe RegistrationsController do flash[:error].should_not be_blank end - it "re-renders the form" do + it "redirects back" do get :create, @invalid_params - response.should render_template("registrations/new") + response.should be_redirect end end end -- GitLab