Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def email_params
end

def update_user_email
@user.update({email: email_params[:email]})
@user.update({email: email_params[:email]&.strip})
@user.filter_old_emails!(@user.email)
end

Expand Down
12 changes: 12 additions & 0 deletions spec/requests/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,18 @@
expect(ActionMailer::Base.deliveries.last.body.encoded)
.to match("Click here to confirm your email")
end

it "strips whitespace from email" do
patch update_email_users_path(user),
params: {
user: {
current_password: "12345678",
email: " newemail@example.com "
}
}
user.confirm
expect(user.email).to eq("newemail@example.com")
end
end

context "when failure" do
Expand Down
Loading