diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-07-07 14:49:05 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-07-07 16:39:36 +0200 |
commit | ff78af152cc3054a7bb76af718943dca7a69a3c5 (patch) | |
tree | 098a917c696179405026a0f59c9cc43c53a4459b /spec/rubocop | |
parent | d40445e4c9964ae0ab793bfdd7ba530de4259716 (diff) | |
download | gitlab-ce-ff78af152cc3054a7bb76af718943dca7a69a3c5.tar.gz |
Added EachBatch for iterating tables in batchesactive-record-each-batch
This module provides a class method called `each_batch` that can be used
to iterate tables in batches in a more efficient way compared to Rails'
`in_batches` method. This commit also includes a RuboCop cop to
blacklist the use of `in_batches` in favour of this new method.
Diffstat (limited to 'spec/rubocop')
-rw-r--r-- | spec/rubocop/cop/in_batches_spec.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/rubocop/cop/in_batches_spec.rb b/spec/rubocop/cop/in_batches_spec.rb new file mode 100644 index 00000000000..072481984c6 --- /dev/null +++ b/spec/rubocop/cop/in_batches_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' +require 'rubocop' +require 'rubocop/rspec/support' +require_relative '../../../rubocop/cop/in_batches' + +describe RuboCop::Cop::InBatches do + include CopHelper + + subject(:cop) { described_class.new } + + it 'registers an offense when in_batches is used' do + inspect_source(cop, 'foo.in_batches do; end') + + aggregate_failures do + expect(cop.offenses.size).to eq(1) + expect(cop.offenses.map(&:line)).to eq([1]) + end + end +end |