Fix profile image bug on email registration (#14991)

This commit is contained in:
Ben Halpern 2021-10-08 14:30:57 -04:00 committed by GitHub
parent baeabc058a
commit 3f921ec9c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View file

@ -71,7 +71,7 @@ class RegistrationsController < Devise::RegistrationsController
build_resource(sign_up_params)
resource.registered_at = Time.current
resource.build_setting(editor_version: "v2")
resource.remote_profile_image_url = Users::ProfileImageGenerator.call if resource.remote_profile_image_url.blank?
resource.remote_profile_image_url = Users::ProfileImageGenerator.call if resource.profile_image.blank?
if FeatureFlag.enabled?(:creator_onboarding)
resource.password_confirmation = resource.password
end

View file

@ -79,6 +79,22 @@ RSpec.describe "Registrations", type: :request do
expect(response.body).to include("Already have an account? <a href=\"/enter\">Log in</a>")
end
it "persists uploaded image" do
name = "test"
image_path = Rails.root.join("spec/support/fixtures/images/image1.jpeg")
post users_path, params: {
user: {
name: name,
username: "username",
email: "yo@whatup.com",
password: "password",
password_confirmation: "password",
profile_image: Rack::Test::UploadedFile.new(image_path, "image/jpeg")
}
}
expect(File.read(User.last.profile_image.file.file)).to eq(File.read(image_path))
end
it "creates a user with a random profile image if none was uploaded" do
name = "test"
post users_path, params: {