Commit 571a889d authored by Mehmet Emin INAC's avatar Mehmet Emin INAC

Add regression test for leaking scope of each_batch

parent 1ddc8297
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment