From d5a4239d1936cd280bbb1586283ad29077b0330b Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 15 Sep 2025 13:05:36 -0400 Subject: [PATCH] Rename the queenbee_id and signal_user_id columns to be more generic for the open-source release. Find the signal account via Account#external_account Find the signal user via User#external_user --- app/models/account.rb | 2 +- app/models/notification_pusher.rb | 8 +--- bin/dev | 4 +- .../20250915170056_rename_37id_columns.rb | 6 +++ db/schema.rb | 10 ++--- db/schema_cache.yml | 40 +++++++++---------- db/seeds.rb | 22 +++++----- .../sessions/launchpad_controller.rb | 2 +- .../app/controllers/signup/base_controller.rb | 2 +- .../app/models/account/signal_account.rb | 23 ++++++----- gems/fizzy-saas/app/models/launchpad.rb | 2 +- gems/fizzy-saas/app/models/signup.rb | 2 +- .../fizzy-saas/app/models/user/signal_user.rb | 11 ++++- .../sessions/launchpad_controller_test.rb | 4 +- .../signup/accounts_controller_test.rb | 2 +- .../models/account/signal_account_test.rb | 16 +++++--- gems/fizzy-saas/test/models/signup_test.rb | 4 +- .../test/models/user/signal_user_test.rb | 14 ++++++- gems/fizzy-saas/test/models/user_test.rb | 9 ----- gems/fizzy-saas/test/test_helper.rb | 2 +- test/fixtures/accounts.yml | 4 +- test/fixtures/users.yml | 12 +++--- test/models/account_test.rb | 2 +- 23 files changed, 111 insertions(+), 92 deletions(-) create mode 100644 db/migrate/20250915170056_rename_37id_columns.rb delete mode 100644 gems/fizzy-saas/test/models/user_test.rb diff --git a/app/models/account.rb b/app/models/account.rb index 3b84832b3..3473de25e 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -4,7 +4,7 @@ class Account < ApplicationRecord has_many_attached :uploads def slug - "/#{queenbee_id}" + "/#{tenant_id}" end def setup_basic_template diff --git a/app/models/notification_pusher.rb b/app/models/notification_pusher.rb index b5926e2be..a5784cf2e 100644 --- a/app/models/notification_pusher.rb +++ b/app/models/notification_pusher.rb @@ -17,10 +17,6 @@ class NotificationPusher end private - def account_prefix - "/#{Account.sole.queenbee_id}" - end - def should_push? notification.user.push_subscriptions.any? && !notification.creator.system? && @@ -91,7 +87,7 @@ class NotificationPusher { title: "New notification", body: "You have a new notification", - path: "#{account_prefix}#{notifications_path}" + path: "#{Account.sole.slug}#{notifications_path}" } end @@ -113,6 +109,6 @@ class NotificationPusher end def card_path(card) - "#{account_prefix}#{Rails.application.routes.url_helpers.card_path(card)}" + "#{Account.sole.slug}#{Rails.application.routes.url_helpers.card_path(card)}" end end diff --git a/bin/dev b/bin/dev index 81fdba092..9fe70d369 100755 --- a/bin/dev +++ b/bin/dev @@ -4,8 +4,8 @@ echo "Login with david@37signals.com / secret123456 to:" bin/rails runner - < { SignalId::Identity.count }, +1 do diff --git a/gems/fizzy-saas/test/models/account/signal_account_test.rb b/gems/fizzy-saas/test/models/account/signal_account_test.rb index cee8ba0bf..623f95610 100644 --- a/gems/fizzy-saas/test/models/account/signal_account_test.rb +++ b/gems/fizzy-saas/test/models/account/signal_account_test.rb @@ -9,20 +9,24 @@ class Account::SignalAccountTest < ActiveSupport::TestCase end test "belongs to a signal_account via a shared queenbee_id" do - assert_not_nil @account.queenbee_id - assert_equal @account.queenbee_id, Account.new(signal_account: @account.signal_account).queenbee_id - assert_equal @account.signal_account, Account.new(queenbee_id: @account.queenbee_id).signal_account + assert_not_nil @account.tenant_id + assert_equal @account.tenant_id, Account.new(external_account: @account.external_account).tenant_id + assert_equal @account.external_account, Account.new(tenant_id: @account.tenant_id).external_account + end + + test "peering" do + assert_equal @account, @account.external_account.peer end test ".create_with_admin_user creates a new local account and user peers" do ApplicationRecord.create_tenant("account-create-with-dependents") do signal_account = signal_accounts(:honcho_fizzy) - account = Account.create_with_admin_user(queenbee_id: signal_account.queenbee_id) + account = Account.create_with_admin_user(tenant_id: signal_account.queenbee_id) assert_not_nil account assert account.persisted? assert_equal 1, Account.count - assert_equal signal_account.queenbee_id, account.queenbee_id + assert_equal signal_account.queenbee_id, account.tenant_id assert_equal signal_account.name, account.name assert_equal account, signal_account.peer @@ -30,7 +34,7 @@ class Account::SignalAccountTest < ActiveSupport::TestCase User.first.tap do |user| assert signal_account.owner.name, user.name assert signal_account.owner.email_address, user.email_address - assert signal_account.owner.id, user.signal_user_id + assert signal_account.owner.id, user.external_user_id assert_equal "admin", user.role assert_equal user, signal_account.owner.peer end diff --git a/gems/fizzy-saas/test/models/signup_test.rb b/gems/fizzy-saas/test/models/signup_test.rb index 37d96bd6f..96e432840 100644 --- a/gems/fizzy-saas/test/models/signup_test.rb +++ b/gems/fizzy-saas/test/models/signup_test.rb @@ -42,7 +42,7 @@ class SignupTest < ActiveSupport::TestCase assert @signup.user assert @signup.user.persisted? - assert_equal @signup.user.signal_user, @signup.signal_account.owner + assert_equal @signup.user.external_user, @signup.signal_account.owner assert_equal @signup.queenbee_account.id.to_s, @signup.tenant_name assert_includes ApplicationRecord.tenants, @signup.tenant_name @@ -86,7 +86,7 @@ class SignupTest < ActiveSupport::TestCase assert @signup.user assert @signup.user.persisted? - assert_equal @signup.user.signal_user, @signup.signal_account.owner + assert_equal @signup.user.external_user, @signup.signal_account.owner assert_equal @signup.queenbee_account.id.to_s, @signup.tenant_name assert_includes ApplicationRecord.tenants, @signup.tenant_name diff --git a/gems/fizzy-saas/test/models/user/signal_user_test.rb b/gems/fizzy-saas/test/models/user/signal_user_test.rb index 81071517b..b244a587e 100644 --- a/gems/fizzy-saas/test/models/user/signal_user_test.rb +++ b/gems/fizzy-saas/test/models/user/signal_user_test.rb @@ -6,7 +6,17 @@ class User::SignalUserTest < ActiveSupport::TestCase end test "belongs to a Signal::User" do - assert_not_nil @user.signal_user_id - assert_equal signal_users("37s_fizzy_david"), @user.signal_user + assert_not_nil @user.external_user_id + assert_equal signal_users("37s_fizzy_david"), @user.external_user + end + + test "peering" do + assert_equal @user, @user.external_user.peer + end + + test "deactivate clears signal user" do + users(:jz).deactivate + + assert_nil users(:jz).reload.external_user end end diff --git a/gems/fizzy-saas/test/models/user_test.rb b/gems/fizzy-saas/test/models/user_test.rb deleted file mode 100644 index c57c9e1c6..000000000 --- a/gems/fizzy-saas/test/models/user_test.rb +++ /dev/null @@ -1,9 +0,0 @@ -require "test_helper" - -class UserTest < ActiveSupport::TestCase - test "deactivate clears signal user" do - users(:jz).deactivate - - assert_nil users(:jz).reload.signal_user - end -end diff --git a/gems/fizzy-saas/test/test_helper.rb b/gems/fizzy-saas/test/test_helper.rb index e2d653bbd..22d468a6c 100644 --- a/gems/fizzy-saas/test/test_helper.rb +++ b/gems/fizzy-saas/test/test_helper.rb @@ -6,7 +6,7 @@ module ActiveSupport include SignalId::Testing def saas_extension_sign_in_as(user) - put saas.session_launchpad_path, params: { sig: user.signal_user.perishable_signature } + put saas.session_launchpad_path, params: { sig: user.external_user.perishable_signature } end end end diff --git a/test/fixtures/accounts.yml b/test/fixtures/accounts.yml index 6a464a1c2..205eee369 100644 --- a/test/fixtures/accounts.yml +++ b/test/fixtures/accounts.yml @@ -1,6 +1,6 @@ 37s: name: 37signals join_code: "ejpP-THlQ-Cc2f" -<% if Account.reflect_on_association :signal_account %> - queenbee_id: <%= ActiveRecord::FixtureSet.identify :'37s_fizzy' %> +<% if Account.reflect_on_association :external_account %> + tenant_id: <%= ActiveRecord::FixtureSet.identify :'37s_fizzy' %> <% end %> diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 85f88c364..73c15ea65 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -5,8 +5,8 @@ david: email_address: david@37signals.com password_digest: <%= digest %> role: member -<% if User.reflect_on_association :signal_user %> - signal_user: 37s_fizzy_david +<% if User.reflect_on_association :external_user %> + external_user: 37s_fizzy_david <% end %> jz: @@ -14,8 +14,8 @@ jz: email_address: jz@37signals.com password_digest: <%= digest %> role: member -<% if User.reflect_on_association :signal_user %> - signal_user: 37s_fizzy_jzimdars +<% if User.reflect_on_association :external_user %> + external_user: 37s_fizzy_jzimdars <% end %> kevin: @@ -23,8 +23,8 @@ kevin: email_address: kevin@37signals.com password_digest: <%= digest %> role: admin -<% if User.reflect_on_association :signal_user %> - signal_user: 37s_fizzy_kevin +<% if User.reflect_on_association :external_user %> + external_user: 37s_fizzy_kevin <% end %> system: diff --git a/test/models/account_test.rb b/test/models/account_test.rb index 22fdc81dc..dbede16f2 100644 --- a/test/models/account_test.rb +++ b/test/models/account_test.rb @@ -3,6 +3,6 @@ require "test_helper" class AccountTest < ActiveSupport::TestCase test "slug" do account = Account.sole - assert_equal "/#{account.queenbee_id}", account.slug + assert_equal "/#{account.tenant_id}", account.slug end end