to cover [ ] case as well I'd modify the condition and I'd make it shorter
```ruby
user.usergroups<< groups if groups.present?
```