Skip to content

Commit

Permalink
[Fix rubocop#401] Fix an error for Rails/WhereEquals
Browse files Browse the repository at this point in the history
Fixes rubocop#401.

This PR fixes an error for `Rails/WhereEquals` when
using only named placeholder template without replacement argument.
  • Loading branch information
koic committed Dec 10, 2020
1 parent 209e963 commit 386e224
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master (unreleased)

### Bug fixes

* [#401](https://github.com/rubocop-hq/rubocop-rails/issues/401): Fix an error for `Rails/WhereEquals` using only named placeholder template without replacement argument. ([@koic][])

## 2.9.0 (2020-12-09)

### New features
Expand Down
8 changes: 8 additions & 0 deletions spec/rubocop/cop/rails/where_equals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,12 @@
User.where('name = ? AND age = ?', 'john', 19)
RUBY
end

it 'does not register an offense when using only named placeholder template without replacement argument' do
expect_no_offenses(<<~'RUBY')
sql = User.where('name = :name').select(:id).to_sql
User.where("id IN (#{sql})", name: 'Lastname').first
RUBY
end
end

0 comments on commit 386e224

Please sign in to comment.