Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeinrich Lee Yu <heinrich@gitlab.com>2019-07-24 17:36:39 +0300
committerHeinrich Lee Yu <heinrich@gitlab.com>2019-08-05 12:49:24 +0300
commit3f9b1ecdb3bbaab6ec35d28d066759985ce25e0e (patch)
tree32edef8386900cba11fbe38e53638ccfeb8134d5 /spec/support
parentafbe0b616b1e17f88bacc283a7a8fbe0bece580a (diff)
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.rb54
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