... | @@ -114,3 +114,11 @@ user.role.text # User's manager |
... | @@ -114,3 +114,11 @@ user.role.text # User's manager |
|
user.role_text # User's manager
|
|
user.role_text # User's manager
|
|
Enum::Roles.manager.text # Manager
|
|
Enum::Roles.manager.text # Manager
|
|
```
|
|
```
|
|
|
|
|
|
|
|
### Testing
|
|
|
|
|
|
|
|
When testing models or creating records using factories, `Enum` provides an easy way to get a random value from the list of any enum types. Besides the normal `User.roles.sample`, you can also use:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
Enum.sample(:roles)
|
|
|
|
``` |
|
|
|
\ No newline at end of file |