diff options
Diffstat (limited to 'spec/models/concerns/each_batch_spec.rb')
-rw-r--r-- | spec/models/concerns/each_batch_spec.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/models/concerns/each_batch_spec.rb b/spec/models/concerns/each_batch_spec.rb index 5f4e5d4bd98..f1fb4fcbd03 100644 --- a/spec/models/concerns/each_batch_spec.rb +++ b/spec/models/concerns/each_batch_spec.rb @@ -9,6 +9,8 @@ RSpec.describe EachBatch do include EachBatch self.table_name = 'users' + + scope :never_signed_in, -> { where(sign_in_count: 0) } end end @@ -72,5 +74,16 @@ RSpec.describe EachBatch do expect(ids).to eq(ids.sort.reverse) end + + describe 'current scope' do + let(:entry) { create(:user, sign_in_count: 1) } + let(:ids_with_new_relation) { model.where(id: entry.id).pluck(:id) } + + it 'does not leak current scope to block being executed' do + model.never_signed_in.each_batch(of: 5) do |relation| + expect(ids_with_new_relation).to include(entry.id) + end + end + end end end |