diff --git a/app/models/account.rb b/app/models/account.rb index 0c730a937..8efc6ae32 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -22,7 +22,7 @@ class Account < ApplicationRecord end def slug - "/#{tenant}" + "/#{external_account_id}" end private diff --git a/config/initializers/tenanting/account_slug.rb b/config/initializers/tenanting/account_slug.rb index f8f693f59..edf67b383 100644 --- a/config/initializers/tenanting/account_slug.rb +++ b/config/initializers/tenanting/account_slug.rb @@ -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 diff --git a/test/fixtures/accounts.yml b/test/fixtures/accounts.yml index ced04edf6..78f618790 100644 --- a/test/fixtures/accounts.yml +++ b/test/fixtures/accounts.yml @@ -1,2 +1,3 @@ 37s: name: 37signals + external_account_id: <%= ActiveRecord::FixtureSet.identify("37signals") %> diff --git a/test/fixtures/memberships.yml b/test/fixtures/memberships.yml index 59433062d..4d1cdb512 100644 --- a/test/fixtures/memberships.yml +++ b/test/fixtures/memberships.yml @@ -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 diff --git a/test/test_helper.rb b/test/test_helper.rb index 9fc0f35b3..7a1274f52 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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__)