I have a Rails application that has models in multiple databases. It’s like an admin interface that doesn’t interact with a public API. Instead, it consumes the database directly.
For example, I have an Agent model that lives in the user database, and an Account model that lives in the account database.
class Agent < ApplicationRecord include Auditable self.establish_connection ENV['AGENTS_DATABASE_URL'] self.table_name = 'users' end class Account < ApplicationRecord include Auditable self.establish_connection ENV['SALDO_DATABASE_URL'] self.table_name = 'accounts' belongs_to :agent, foreign_key: :user_id end
What will be the best approach to testing these models?, I don’t have a way to replicate all these databases locally, since these are externals to my application.