|
107 | 107 | expect(cursor.tiebreak_id).to eq record['_id']
|
108 | 108 | end
|
109 | 109 | it 'can scroll back with the previous cursor' do
|
110 |
| - cursor = nil |
111 |
| - first_previous_cursor = nil |
112 |
| - second_previous_cursor = nil |
| 110 | + first_iterator = nil |
| 111 | + second_iterator = nil |
| 112 | + third_iterator = nil |
113 | 113 |
|
114 | 114 | Mongoid.default_client['feed_items'].find.sort(field_name => 1).limit(2).scroll(cursor_type, field_type: field_type) do |_, iterator|
|
115 |
| - cursor = iterator.next_cursor |
| 115 | + first_iterator = iterator |
116 | 116 | end
|
117 | 117 |
|
118 |
| - Mongoid.default_client['feed_items'].find.sort(field_name => 1).limit(2).scroll(cursor, field_type: field_type) do |_, iterator| |
119 |
| - cursor = iterator.next_cursor |
120 |
| - first_previous_cursor = iterator.previous_cursor |
| 118 | + Mongoid.default_client['feed_items'].find.sort(field_name => 1).limit(2).scroll(first_iterator.next_cursor, field_type: field_type) do |_, iterator| |
| 119 | + second_iterator = iterator |
121 | 120 | end
|
122 | 121 |
|
123 |
| - Mongoid.default_client['feed_items'].find.sort(field_name => 1).limit(2).scroll(cursor, field_type: field_type) do |_, iterator| |
124 |
| - second_previous_cursor = iterator.previous_cursor |
| 122 | + Mongoid.default_client['feed_items'].find.sort(field_name => 1).limit(2).scroll(second_iterator.next_cursor, field_type: field_type) do |_, iterator| |
| 123 | + third_iterator = iterator |
125 | 124 | end
|
126 | 125 |
|
127 | 126 | records = Mongoid.default_client['feed_items'].find.sort(field_name => 1)
|
128 |
| - expect(Mongoid.default_client['feed_items'].find.sort(field_name => 1).limit(2).scroll(first_previous_cursor, field_type: field_type).to_a).to eq(records.limit(2).to_a) |
129 |
| - expect(Mongoid.default_client['feed_items'].find.sort(field_name => 1).limit(2).scroll(second_previous_cursor, field_type: field_type).to_a).to eq(records.skip(2).limit(2).to_a) |
| 127 | + expect(Mongoid.default_client['feed_items'].find.sort(field_name => 1).limit(2).scroll(second_iterator.previous_cursor, field_type: field_type).to_a).to eq(records.limit(2).to_a) |
| 128 | + expect(Mongoid.default_client['feed_items'].find.sort(field_name => 1).limit(2).scroll(third_iterator.previous_cursor, field_type: field_type).to_a).to eq(records.skip(2).limit(2).to_a) |
130 | 129 | end
|
131 | 130 | end
|
132 | 131 | end
|
|
0 commit comments