Fix missing registration data change (#11008)

* Fix missing registration acknowledgment

* Add backfill script and seeds adjustment

* Update lib/data_update_scripts/20201022161311_backfill_user_registrations_in_registrations_controller_path.rb

Co-authored-by: Molly Struve <mollylbs@gmail.com>

Co-authored-by: Molly Struve <mollylbs@gmail.com>
This commit is contained in:
Ben Halpern 2020-10-22 19:21:03 -04:00 committed by GitHub
parent 1733c88a07
commit 2d75d6d5ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 0 deletions

View file

@ -22,6 +22,8 @@ class RegistrationsController < Devise::RegistrationsController
if recaptcha_disabled? || recaptcha_verified?
build_resource(sign_up_params)
resource.saw_onboarding = false
resource.registered = true
resource.registered_at = Time.current
resource.editor_version = "v2"
resource.save if resource.email.present?
yield resource if block_given?

View file

@ -94,6 +94,8 @@ users_in_random_order = seeder.create_if_none(User, num_users) do
# Emails limited to 50 characters
email: Faker::Internet.email(name: name, separators: "+", domain: Faker::Internet.domain_word.first(20)),
confirmed_at: Time.current,
registered_at: Time.current,
registered: true,
password: "password",
password_confirmation: "password",
)

View file

@ -0,0 +1,10 @@
module DataUpdateScripts
class BackfillUserRegistrationsInRegistrationsControllerPath
def run
# Users who _were not invited_ should by definition have registered already in order to exist
User.where(registered_at: nil, invitation_sent_at: nil).find_each do |user|
user.update_columns(registered_at: user.created_at, registered: true)
end
end
end
end

View file

@ -179,6 +179,17 @@ RSpec.describe "Registrations", type: :request do
expect(User.all.size).to be 1
end
it "marks as registerd" do
post "/users", params:
{ user: { name: "test #{rand(10)}",
username: "haha_#{rand(10)}",
email: "yoooo#{rand(100)}@yo.co",
password: "PaSSw0rd_yo000",
password_confirmation: "PaSSw0rd_yo000" } }
expect(User.last.registered).to be true
expect(User.last.registered_at).not_to be nil
end
it "does not create user with password confirmation mismatch" do
post "/users", params:
{ user: { name: "test #{rand(100)}",