diff options
author | Heinrich Lee Yu <heinrich@gitlab.com> | 2019-07-24 22:36:39 +0800 |
---|---|---|
committer | Heinrich Lee Yu <heinrich@gitlab.com> | 2019-08-05 17:49:24 +0800 |
commit | 3f9b1ecdb3bbaab6ec35d28d066759985ce25e0e (patch) | |
tree | 32edef8386900cba11fbe38e53638ccfeb8134d5 /spec/support | |
parent | afbe0b616b1e17f88bacc283a7a8fbe0bece580a (diff) | |
download | gitlab-ce-3f9b1ecdb3bbaab6ec35d28d066759985ce25e0e.tar.gz |
Use SQL to find the gap instead of iterating
Also removes unnecessary methods causing extra queries
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/shared_examples/relative_positioning_shared_examples.rb | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/spec/support/shared_examples/relative_positioning_shared_examples.rb b/spec/support/shared_examples/relative_positioning_shared_examples.rb index 417ef4f315b..9837ba806db 100644 --- a/spec/support/shared_examples/relative_positioning_shared_examples.rb +++ b/spec/support/shared_examples/relative_positioning_shared_examples.rb @@ -110,46 +110,6 @@ RSpec.shared_examples 'a class that supports relative positioning' do end end - describe '#shift_after?' do - before do - [item1, item2].each do |item1| - item1.move_to_end && item1.save - end - end - - it 'returns true' do - item1.update(relative_position: item2.relative_position - 1) - - expect(item1.shift_after?).to be_truthy - end - - it 'returns false' do - item1.update(relative_position: item2.relative_position - 2) - - expect(item1.shift_after?).to be_falsey - end - end - - describe '#shift_before?' do - before do - [item1, item2].each do |item1| - item1.move_to_end && item1.save - end - end - - it 'returns true' do - item1.update(relative_position: item2.relative_position + 1) - - expect(item1.shift_before?).to be_truthy - end - - it 'returns false' do - item1.update(relative_position: item2.relative_position + 2) - - expect(item1.shift_before?).to be_falsey - end - end - describe '#move_between' do before do [item1, item2].each do |item1| @@ -297,13 +257,6 @@ RSpec.shared_examples 'a class that supports relative positioning' do positions = items.map { |item| item.reload.relative_position } expect(positions).to eq([50, 51, 102]) end - - it 'if raises an exception if gap is not found' do - stub_const('RelativePositioning::MAX_SEQUENCE_LIMIT', 2) - items = create_items_with_positions([100, 101, 102]) - - expect { items.last.move_sequence_before }.to raise_error(RelativePositioning::GapNotFound) - end end describe '#move_sequence_after' do @@ -326,12 +279,5 @@ RSpec.shared_examples 'a class that supports relative positioning' do positions = items.map { |item| item.reload.relative_position } expect(positions).to eq([100, 601, 602]) end - - it 'if raises an exception if gap is not found' do - stub_const('RelativePositioning::MAX_SEQUENCE_LIMIT', 2) - items = create_items_with_positions([100, 101, 102]) - - expect { items.first.move_sequence_after }.to raise_error(RelativePositioning::GapNotFound) - end end end |