Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error when email missing from registration params #220

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def create

# honor devise configuration for case_insensitive_keys
if resource_class.case_insensitive_keys.include?(:email)
@resource.email = sign_up_params[:email].downcase
@resource.email = sign_up_params[:email].try :downcase
else
@resource.email = sign_up_params[:email]
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,35 @@ class DeviseTokenAuth::RegistrationsControllerTest < ActionDispatch::Integration
end
end

describe 'missing email' do
before do
post '/auth', {
password: "secret123",
password_confirmation: "secret123",
confirm_success_url: Faker::Internet.url
}

@resource = assigns(:resource)
@data = JSON.parse(response.body)
end

test "request should not be successful" do
assert_equal 403, response.status
end

test "user should not have been created" do
assert_nil @resource.id
end

test "error should be returned in the response" do
assert @data['errors'].length
end

test "full_messages should be included in error hash" do
assert @data['errors']['full_messages'].length
end
end

describe "Mismatched passwords" do
before do
post '/auth', {
Expand Down