File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -329,6 +329,42 @@ Console does not allow read across tenant by default. But you have several ways
329329 $ irb(main):001:0> MultiTenantSupport.allow_read_across_tenant
330330 ` ` `
331331
332+ # # Testing
333+ # ## Minitest (Rails default)
334+
335+ ` ` ` ruby
336+ # test/test_helper.rb
337+ require 'multi_tenant_support/minitet'
338+ ` ` `
339+ # ## RSpec (with Capybara)
340+
341+ ` ` ` ruby
342+ # spec/rails_helper.rb or spec/spec_helper.rb
343+ require 'multi_tenant_support/rspec'
344+ ` ` `
345+
346+ Above code will make sure the ` MultiTenantSupport.current_tenant` won' t accidentally be reset during integration and system tests. For example:
347+
348+ With above testing requre code
349+
350+ ```ruby
351+ setup do
352+ MultiTenantSupport::Current.tenant_account = account
353+ end
354+
355+ test "a integration test" do
356+ assert_no_changes "MultiTenantSupport.current_tenant" do
357+ get users_path
358+ end
359+ end
360+
361+ test "a system test" do
362+ assert_no_changes "MultiTenantSupport.current_tenant" do
363+ visit users_path
364+ end
365+ end
366+ ```
367+
332368## Code Example
333369
334370### Database Schema
You can’t perform that action at this time.
0 commit comments