diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-10 03:11:55 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-10 03:11:55 +0300 |
commit | 3f22924df411018ba665ecf72ab0768d61173477 (patch) | |
tree | 511da0ef74e33f241ecc50d50c7a57a1ac51a06f /spec | |
parent | d183d2d76bcc25f983c0836805c712af096bcc2f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
5 files changed, 102 insertions, 5 deletions
diff --git a/spec/features/callouts/registration_enabled_spec.rb b/spec/features/callouts/registration_enabled_spec.rb index ac7b68876da..15c900592a1 100644 --- a/spec/features/callouts/registration_enabled_spec.rb +++ b/spec/features/callouts/registration_enabled_spec.rb @@ -50,7 +50,7 @@ RSpec.describe 'Registration enabled callout', feature_category: :authentication visit root_dashboard_path end - it 'does not display callout' do + it 'does not display callout', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/391192' do expect(page).not_to have_content callout_title end end diff --git a/spec/features/merge_request/batch_comments_spec.rb b/spec/features/merge_request/batch_comments_spec.rb index 5d2fcea5096..cfa1a1fbbe4 100644 --- a/spec/features/merge_request/batch_comments_spec.rb +++ b/spec/features/merge_request/batch_comments_spec.rb @@ -210,7 +210,8 @@ RSpec.describe 'Merge request > Batch comments', :js, feature_category: :code_re page.find('.js-diff-comment-avatar').click end - it 'publishes comment right away and unresolves the thread' do + it 'publishes comment right away and unresolves the thread', + quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/337931' do expect(active_discussion.resolved?).to eq(true) write_reply_to_discussion(button_text: 'Add comment now', unresolve: true) diff --git a/spec/features/merge_request/user_sees_diff_spec.rb b/spec/features/merge_request/user_sees_diff_spec.rb index daeeaa1bd88..12fdcf4859e 100644 --- a/spec/features/merge_request/user_sees_diff_spec.rb +++ b/spec/features/merge_request/user_sees_diff_spec.rb @@ -32,7 +32,7 @@ RSpec.describe 'Merge request > User sees diff', :js, feature_category: :code_re visit "#{diffs_project_merge_request_path(project, merge_request)}#{fragment}" end - it 'shows expanded note' do + it 'shows expanded note', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/391239' do expect(page).to have_selector(fragment, visible: true) end end diff --git a/spec/finders/concerns/finder_with_group_hierarchy_spec.rb b/spec/finders/concerns/finder_with_group_hierarchy_spec.rb index 8c2026a00a1..c96e35372d6 100644 --- a/spec/finders/concerns/finder_with_group_hierarchy_spec.rb +++ b/spec/finders/concerns/finder_with_group_hierarchy_spec.rb @@ -40,7 +40,7 @@ RSpec.describe FinderWithGroupHierarchy do let_it_be(:private_group) { create(:group, :private) } let_it_be(:private_subgroup) { create(:group, :private, parent: private_group) } - let(:user) { create(:user) } + let!(:user) { create(:user) } context 'when specifying group' do it 'returns only the group by default' do @@ -109,4 +109,100 @@ RSpec.describe FinderWithGroupHierarchy do expect(finder.execute(skip_authorization: true)).to match_array([private_group.id, private_subgroup.id]) end end + + context 'with N+1 query check' do + def run_query(group) + finder_class + .new(user, group: group, include_descendant_groups: true) + .execute + .to_a + + RequestStore.clear! + end + + it 'does not produce N+1 query', :request_store do + private_group.add_developer(user) + + run_query(private_subgroup) # warmup + control = ActiveRecord::QueryRecorder.new { run_query(private_subgroup) } + + expect { run_query(private_group) }.not_to exceed_query_limit(control) + end + end + + context 'when preload_max_access_levels_for_labels_finder is disabled' do + # All test cases were copied from above, these will be removed once the FF is removed. + + before do + stub_feature_flags(preload_max_access_levels_for_labels_finder: false) + end + + context 'when specifying group' do + it 'returns only the group by default' do + finder = finder_class.new(user, group: group) + + expect(finder.execute).to match_array([group.id]) + end + end + + context 'when specifying group_id' do + it 'returns only the group by default' do + finder = finder_class.new(user, group_id: group.id) + + expect(finder.execute).to match_array([group.id]) + end + end + + context 'when including items from group ancestors' do + before do + private_subgroup.add_developer(user) + end + + it 'returns group and its ancestors' do + private_group.add_developer(user) + + finder = finder_class.new(user, group: private_subgroup, include_ancestor_groups: true) + + expect(finder.execute).to match_array([private_group.id, private_subgroup.id]) + end + + it 'ignores groups which user can not read' do + finder = finder_class.new(user, group: private_subgroup, include_ancestor_groups: true) + + expect(finder.execute).to match_array([private_subgroup.id]) + end + + it 'returns them all when skip_authorization is true' do + finder = finder_class.new(user, group: private_subgroup, include_ancestor_groups: true) + + expect(finder.execute(skip_authorization: true)).to match_array([private_group.id, private_subgroup.id]) + end + end + + context 'when including items from group descendants' do + before do + private_subgroup.add_developer(user) + end + + it 'returns items from group and its descendants' do + private_group.add_developer(user) + + finder = finder_class.new(user, group: private_group, include_descendant_groups: true) + + expect(finder.execute).to match_array([private_group.id, private_subgroup.id]) + end + + it 'ignores items from groups which user can not read' do + finder = finder_class.new(user, group: private_group, include_descendant_groups: true) + + expect(finder.execute).to match_array([private_subgroup.id]) + end + + it 'returns them all when skip_authorization is true' do + finder = finder_class.new(user, group: private_group, include_descendant_groups: true) + + expect(finder.execute(skip_authorization: true)).to match_array([private_group.id, private_subgroup.id]) + end + end + end end diff --git a/spec/support/shared_examples/features/sidebar/sidebar_labels_shared_examples.rb b/spec/support/shared_examples/features/sidebar/sidebar_labels_shared_examples.rb index 95b306fdaaa..a332fdec963 100644 --- a/spec/support/shared_examples/features/sidebar/sidebar_labels_shared_examples.rb +++ b/spec/support/shared_examples/features/sidebar/sidebar_labels_shared_examples.rb @@ -95,7 +95,7 @@ RSpec.shared_examples 'labels sidebar widget' do end end - it 'creates new label' do + it 'creates new label', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/391240' do page.within(labels_widget) do fill_in 'Name new label', with: 'wontfix' page.find('.suggest-colors a', match: :first).click |