diff options
Diffstat (limited to 'spec/support/shared_examples/namespaces/traversal_scope_examples.rb')
-rw-r--r-- | spec/support/shared_examples/namespaces/traversal_scope_examples.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/support/shared_examples/namespaces/traversal_scope_examples.rb b/spec/support/shared_examples/namespaces/traversal_scope_examples.rb index 3d52ed30c62..b43b7946e69 100644 --- a/spec/support/shared_examples/namespaces/traversal_scope_examples.rb +++ b/spec/support/shared_examples/namespaces/traversal_scope_examples.rb @@ -124,6 +124,18 @@ RSpec.shared_examples 'namespace traversal scopes' do it { expect(subject[0, 2]).to contain_exactly(group_1, group_2) } it { expect(subject[2, 2]).to contain_exactly(nested_group_1, nested_group_2) } end + + 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 } + + it { is_expected.to contain_exactly(group_2, nested_group_2, deep_nested_group_2) } + end + + context 'with upto' do + subject { described_class.where(id: deep_nested_group_1).self_and_ancestors(upto: nested_group_1.id) } + + it { is_expected.to contain_exactly(deep_nested_group_1) } + end end describe '.self_and_ancestors' do @@ -168,6 +180,19 @@ RSpec.shared_examples 'namespace traversal scopes' do it { is_expected.to contain_exactly(group_1.id, group_2.id) } end + + context 'with offset and limit' do + subject do + described_class + .where(id: [deep_nested_group_1, deep_nested_group_2]) + .limit(1) + .offset(1) + .self_and_ancestor_ids + .pluck(:id) + end + + it { is_expected.to contain_exactly(group_2.id, nested_group_2.id, deep_nested_group_2.id) } + end end describe '.self_and_ancestor_ids' do |