Tests need to set up the script_name properly

which requires tweaking fixtures for the memberships and the account
This commit is contained in:
Mike Dalessio
2025-11-10 12:46:17 -05:00
parent 65f97babd9
commit 006aa4d6b3
5 changed files with 16 additions and 16 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ class Account < ApplicationRecord
end
def slug
"/#{tenant}"
"/#{external_account_id}"
end
private
@@ -16,7 +16,7 @@ module AccountSlug
# $1, $2, $' == script_name, slug, path_info
if request.script_name && request.script_name =~ PATH_INFO_MATCH
# Likely due to restarting the action cable connection after upgrade
AccountSlug.decode($2)
env["fizzy.external_account_id"] = AccountSlug.decode($2)
elsif request.path_info =~ PATH_INFO_MATCH
# Yanks the prefix off PATH_INFO and move it to SCRIPT_NAME
request.engine_script_name = request.script_name = $1
+1
View File
@@ -1,2 +1,3 @@
37s:
name: 37signals
external_account_id: <%= ActiveRecord::FixtureSet.identify("37signals") %>
+3 -3
View File
@@ -1,12 +1,12 @@
# TODO:PLANB: not sure what to set membership tenant to right now
david_in_37signals:
identity: david
tenant: 1 # <%# Rails.application.config.active_record_tenanted.default_tenant %>
tenant: <%= ActiveRecord::FixtureSet.identify("37signals") %> # matches the external_account_id
jz_in_37signals:
identity: jz
tenant: 2 # <%# Rails.application.config.active_record_tenanted.default_tenant %>
tenant: <%= ActiveRecord::FixtureSet.identify("37signals") %> # matches the external_account_id
kevin_in_37signals:
identity: kevin
tenant: 3 # <%# Rails.application.config.active_record_tenanted.default_tenant %>
tenant: <%= ActiveRecord::FixtureSet.identify("37signals") %> # matches the external_account_id
+10 -11
View File
@@ -47,18 +47,17 @@ module ActiveSupport
end
end
# # TODO:PLANB: not sure if we need these anymore
# class ActionDispatch::IntegrationTest
# setup do
# integration_session.default_url_options[:script_name] = "/#{Current.account.slug}"
# end
# end
class ActionDispatch::IntegrationTest
setup do
integration_session.default_url_options[:script_name] = "/#{ActiveRecord::FixtureSet.identify("37signals")}"
end
end
# class ActionDispatch::SystemTestCase
# setup do
# self.default_url_options[:script_name] = "/#{ApplicationRecord.current_tenant}"
# end
# end
class ActionDispatch::SystemTestCase
setup do
self.default_url_options[:script_name] = "/#{ActiveRecord::FixtureSet.identify("37signals")}"
end
end
unless Rails.application.config.x.oss_config
load File.expand_path("../gems/fizzy-saas/test/test_helper.rb", __dir__)