Skip to content

Commit

Permalink
Merge branch 'following-users'
Browse files Browse the repository at this point in the history
  • Loading branch information
mhartl committed May 22, 2015
2 parents 876eb86 + 2107be2 commit e501642
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 4 additions & 6 deletions app/controllers/password_resets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ def edit
end

def update
if @user.update_attributes(user_params)
if params[:user][:password].empty?
@user.errors.add(:password, "can't be empty")
render 'edit'
elsif @user.update_attributes(user_params)
log_in @user
flash[:success] = "Password has been reset."
redirect_to @user
Expand All @@ -38,11 +41,6 @@ def user_params
params.require(:user).permit(:password, :password_confirmation)
end

# Returns true if password is blank.
def password_blank?
params[:user][:password].blank?
end

# Before filters

def get_user
Expand Down
6 changes: 6 additions & 0 deletions test/integration/password_resets_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ def setup
user: { password: "foobaz",
password_confirmation: "barquux" }
assert_select 'div#error_explanation'
# Empty password
patch password_reset_path(user.reset_token),
email: user.email,
user: { password: "",
password_confirmation: "" }
assert_select 'div#error_explanation'
# Valid password & confirmation
patch password_reset_path(user.reset_token),
email: user.email,
Expand Down

0 comments on commit e501642

Please sign in to comment.