diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c00259e8c..49a52d4ff2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ * [#98](https://github.com/rubocop-hq/rubocop-rails/pull/98): Mark `Rails/ActiveRecordAliases` as `SafeAutoCorrect` false and disable autocorrect by default. ([@prathamesh-sonpatki][]) * [#101](https://github.com/rubocop-hq/rubocop-rails/pull/101): Mark `Rails/SaveBang` as `SafeAutoCorrect` false and disable autocorrect by default. ([@prathamesh-sonpatki][]) +* [#102](https://github.com/rubocop-hq/rubocop-rails/pull/102): Include `create_or_find_by` in `Rails/SaveBang` cop. ([@MaximeLaurenty][]) ## 2.2.1 (2019-07-13) @@ -60,3 +61,4 @@ [@brunvez]: https://github.com/brunvez [@santib]: https://github.com/santib [@prathamesh-sonpatki]: https://github.com/prathamesh-sonpatki +[@MaximeLaurenty]: https://github.com/MaximeLaurenty diff --git a/lib/rubocop/cop/rails/save_bang.rb b/lib/rubocop/cop/rails/save_bang.rb index 38a1e4140b..e301023469 100644 --- a/lib/rubocop/cop/rails/save_bang.rb +++ b/lib/rubocop/cop/rails/save_bang.rb @@ -108,7 +108,7 @@ class SaveBang < Cop CREATE_CONDITIONAL_MSG = '`%s` returns a model which is ' \ 'always truthy.' - CREATE_PERSIST_METHODS = %i[create + CREATE_PERSIST_METHODS = %i[create create_or_find_by first_or_create find_or_create_by].freeze MODIFY_PERSIST_METHODS = %i[save update update_attributes destroy].freeze