Commit fcc24a29 authored by Valerie Burton's avatar Valerie Burton

Fix flaky offset and limit for namespace_spec traversal_scope_examples

parent 968090db
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
RSpec.shared_examples 'namespace traversal scopes' do RSpec.shared_examples 'namespace traversal scopes' do
# Hierarchy 1 # Hierarchy 1
let_it_be(:group_1) { create(:group) } let_it_be(:group_1) { create(:group, path: 'group-1') }
let_it_be(:nested_group_1) { create(:group, parent: group_1) } let_it_be(:nested_group_1) { create(:group, path: 'nested-group-1', parent: group_1) }
let_it_be(:deep_nested_group_1) { create(:group, parent: nested_group_1) } let_it_be(:deep_nested_group_1) { create(:group, path: 'deep-nested-group-1', parent: nested_group_1) }
# Hierarchy 2 # Hierarchy 2
let_it_be(:group_2) { create(:group) } let_it_be(:group_2) { create(:group, path: 'group-2') }
let_it_be(:nested_group_2) { create(:group, parent: group_2) } let_it_be(:nested_group_2) { create(:group, path: 'nested-group-2', parent: group_2) }
let_it_be(:deep_nested_group_2) { create(:group, parent: nested_group_2) } let_it_be(:deep_nested_group_2) { create(:group, path: 'deep-nested-group-2', parent: nested_group_2) }
# All groups # All groups
let_it_be(:groups) do let_it_be(:groups) do
...@@ -126,7 +126,7 @@ RSpec.shared_examples 'namespace traversal scopes' do ...@@ -126,7 +126,7 @@ RSpec.shared_examples 'namespace traversal scopes' do
end end
context 'with offset and limit' do context 'with offset and limit' do
subject { described_class.where(id: [deep_nested_group_1, deep_nested_group_2]).offset(1).limit(1).self_and_ancestors } subject { described_class.where(id: [deep_nested_group_1, deep_nested_group_2]).order(:path).offset(1).limit(1).self_and_ancestors }
it { is_expected.to contain_exactly(group_2, nested_group_2, deep_nested_group_2) } it { is_expected.to contain_exactly(group_2, nested_group_2, deep_nested_group_2) }
end end
...@@ -185,6 +185,7 @@ RSpec.shared_examples 'namespace traversal scopes' do ...@@ -185,6 +185,7 @@ RSpec.shared_examples 'namespace traversal scopes' do
subject do subject do
described_class described_class
.where(id: [deep_nested_group_1, deep_nested_group_2]) .where(id: [deep_nested_group_1, deep_nested_group_2])
.order(:path)
.limit(1) .limit(1)
.offset(1) .offset(1)
.self_and_ancestor_ids .self_and_ancestor_ids
...@@ -240,7 +241,7 @@ RSpec.shared_examples 'namespace traversal scopes' do ...@@ -240,7 +241,7 @@ RSpec.shared_examples 'namespace traversal scopes' do
end end
context 'with offset and limit' do context 'with offset and limit' do
subject { described_class.where(id: [group_1, group_2]).offset(1).limit(1).self_and_descendants } subject { described_class.where(id: [group_1, group_2]).order(:path).offset(1).limit(1).self_and_descendants }
it { is_expected.to contain_exactly(group_2, nested_group_2, deep_nested_group_2) } it { is_expected.to contain_exactly(group_2, nested_group_2, deep_nested_group_2) }
end end
...@@ -288,6 +289,7 @@ RSpec.shared_examples 'namespace traversal scopes' do ...@@ -288,6 +289,7 @@ RSpec.shared_examples 'namespace traversal scopes' do
subject do subject do
described_class described_class
.where(id: [group_1, group_2]) .where(id: [group_1, group_2])
.order(:path)
.limit(1) .limit(1)
.offset(1) .offset(1)
.self_and_descendant_ids .self_and_descendant_ids
......
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