From eed3c12f4d231e8d3796cd6d01671f3141b7988e Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 6 Oct 2021 10:51:15 -0400 Subject: [PATCH] Auto register Forems on Discover (#14962) --- app/controllers/api/v0/instances_controller.rb | 1 + app/controllers/registrations_controller.rb | 1 + spec/requests/api/v0/instances_spec.rb | 1 + spec/requests/registrations_spec.rb | 12 ++++++++++++ 4 files changed, 15 insertions(+) diff --git a/app/controllers/api/v0/instances_controller.rb b/app/controllers/api/v0/instances_controller.rb index 79f4dc022..673609cfa 100644 --- a/app/controllers/api/v0/instances_controller.rb +++ b/app/controllers/api/v0/instances_controller.rb @@ -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, diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 0edbe7905..0d698277e 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -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? diff --git a/spec/requests/api/v0/instances_spec.rb b/spec/requests/api/v0/instances_spec.rb index cdb4ae267..6f4980a16 100644 --- a/spec/requests/api/v0/instances_spec.rb +++ b/spec/requests/api/v0/instances_spec.rb @@ -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 diff --git a/spec/requests/registrations_spec.rb b/spec/requests/registrations_spec.rb index 8b2def88d..52db4d10f 100644 --- a/spec/requests/registrations_spec.rb +++ b/spec/requests/registrations_spec.rb @@ -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