Auto register Forems on Discover (#14962)

This commit is contained in:
Alex 2021-10-06 10:51:15 -04:00 committed by GitHub
parent 8e220dc97f
commit eed3c12f4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 0 deletions

View file

@ -9,6 +9,7 @@ module Api
cover_image_url: Settings::General.main_social_image,
description: Settings::Community.community_description,
display_in_directory: Settings::UserExperience.display_in_directory,
domain: Settings::General.app_domain,
logo_image_url: Settings::General.logo_png,
name: Settings::Community.community_name,
registered_users_count: User.registered.estimated_count,

View file

@ -46,6 +46,7 @@ class RegistrationsController < Devise::RegistrationsController
resource.skip_confirmation!
Settings::General.waiting_on_first_user = false
Users::CreateMascotAccount.call
Discover::RegisterWorker.perform_async # Register Forem instance on https://discover.forem.com
end
def recaptcha_verified?

View file

@ -10,6 +10,7 @@ RSpec.describe "Api::V0::Instances", type: :request do
expect(response.parsed_body["cover_image_url"]).to eq Settings::General.main_social_image
expect(response.parsed_body["description"]).to eq Settings::Community.community_description
expect(response.parsed_body["display_in_directory"]).to eq Settings::UserExperience.display_in_directory
expect(response.parsed_body["domain"]).to eq Settings::General.app_domain
expect(response.parsed_body["logo_image_url"]).to eq Settings::General.logo_png
expect(response.parsed_body["name"]).to eq Settings::Community.community_name
expect(response.parsed_body["registered_users_count"]).to eq User.registered.estimated_count

View file

@ -407,6 +407,18 @@ RSpec.describe "Registrations", type: :request do
expect(User.first).to be nil
end.to raise_error Pundit::NotAuthorizedError
end
it "enqueues Discover::RegisterWorker" do
sidekiq_assert_enqueued_with(job: Discover::RegisterWorker) do
post "/users", params:
{ user: { name: "test #{rand(10)}",
username: "haha_#{rand(10)}",
email: "yoooo#{rand(100)}@yo.co",
password: "PaSSw0rd_yo000",
forem_owner_secret: "test",
password_confirmation: "PaSSw0rd_yo000" } }
end
end
end
context "with the creator_onboarding feature flag" do