Skip to content

Commit 5b2b5d9

Browse files
committed
Update README
1 parent 7376c4d commit 5b2b5d9

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)