diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-15 15:08:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-15 15:08:47 +0300 |
commit | 717436a767395d0ed850a16d07f19cd51c3d4551 (patch) | |
tree | 5c2d69721710081da88c8dcf097813e2f40c062c /spec | |
parent | 5a14a0fe63ac7dace9821be554ad3b3951529708 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/participants_autocomplete_spec.rb | 25 | ||||
-rw-r--r-- | spec/finders/releases_finder_spec.rb | 67 | ||||
-rw-r--r-- | spec/frontend/content_editor/services/markdown_serializer_spec.js | 15 | ||||
-rw-r--r-- | spec/lib/gitlab/lets_encrypt/challenge_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/lets_encrypt/client_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/lets_encrypt/order_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/lets_encrypt_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/release_spec.rb | 90 | ||||
-rw-r--r-- | spec/services/projects/participants_service_spec.rb | 12 | ||||
-rw-r--r-- | spec/support/formatters/json_formatter.rb | 3 |
10 files changed, 210 insertions, 10 deletions
diff --git a/spec/features/participants_autocomplete_spec.rb b/spec/features/participants_autocomplete_spec.rb index 272365ac7ee..084bf609a0d 100644 --- a/spec/features/participants_autocomplete_spec.rb +++ b/spec/features/participants_autocomplete_spec.rb @@ -2,12 +2,13 @@ require 'spec_helper' -RSpec.describe 'Member autocomplete', :js, feature_category: :team_planning do +RSpec.describe 'Member autocomplete', :js, feature_category: :groups_and_projects do let_it_be(:project) { create(:project, :public, :repository) } let_it_be(:user) { create(:user) } let_it_be(:author) { create(:user) } let(:note) { create(:note, noteable: noteable, project: noteable.project) } + let(:noteable) { create(:issue, author: author, project: project) } before do note # actually create the note @@ -29,9 +30,27 @@ RSpec.describe 'Member autocomplete', :js, feature_category: :team_planning do end end - context 'adding a new note on a Issue' do - let(:noteable) { create(:issue, author: author, project: project) } + context 'for a member of a private group invited to the project' do + let_it_be(:private_group) { create(:group, :private) } + let_it_be(:private_group_member) { create(:user, username: 'private-a') } + + before_all do + project.add_developer user + + private_group.add_developer private_group_member + create(:project_group_link, group: private_group, project: project) + end + + it 'suggests member of private group' do + visit project_issue_path(project, noteable) + fill_in 'Comment', with: '@priv' + + expect(find_autocomplete_menu).to have_text(private_group_member.username) + end + end + + context 'adding a new note on a Issue' do before do visit project_issue_path(project, noteable) end diff --git a/spec/finders/releases_finder_spec.rb b/spec/finders/releases_finder_spec.rb index f836b430f8c..bee0ae0d5c1 100644 --- a/spec/finders/releases_finder_spec.rb +++ b/spec/finders/releases_finder_spec.rb @@ -158,4 +158,71 @@ RSpec.describe ReleasesFinder, feature_category: :release_orchestration do end end end + + describe 'latest releases' do + let_it_be(:project2) { create(:project, :repository, group: group) } + let_it_be(:v2_0_0) { create(:release, project: project2) } + let_it_be(:v2_1_0) { create(:release, project: project2) } + + let(:params) { { latest: true } } + + subject { described_class.new([project, project2], user, params).execute(**args) } + + before do + v1_0_0.update!(released_at: 4.days.ago, created_at: 1.day.ago) + v1_1_0.update!(released_at: 3.days.ago, created_at: 2.days.ago) + v2_0_0.update!(released_at: 2.days.ago, created_at: 3.days.ago) + v2_1_0.update!(released_at: 1.day.ago, created_at: 4.days.ago) + end + + it_behaves_like 'when the user is not authorized' + + context 'when the user has guest privileges or higher on one project' do + before do + project.add_guest(user) + end + + it 'returns the latest release of only the authorized project' do + is_expected.to eq([v1_1_0]) + end + end + + context 'when the user has guest privileges or higher on all projects' do + before do + project.add_guest(user) + project2.add_guest(user) + end + + it 'returns the latest release by released date for each project' do + is_expected.to match_array([v1_1_0, v2_1_0]) + end + + context 'with order_by_for_latest: created' do + let(:params) { { latest: true, order_by_for_latest: 'created_at' } } + + it 'returns the latest release by created date for each project' do + is_expected.to match_array([v1_0_0, v2_0_0]) + end + end + + context 'when one project does not have releases' do + it 'returns the latest release of only the project with releases' do + project.releases.delete_all + + is_expected.to eq([v2_1_0]) + end + end + + context 'when all projects do not have releases' do + it 'returns empty response' do + project.releases.delete_all + project2.releases.delete_all + + is_expected.to be_empty + end + end + + it_behaves_like 'preload' + end + end end diff --git a/spec/frontend/content_editor/services/markdown_serializer_spec.js b/spec/frontend/content_editor/services/markdown_serializer_spec.js index 5ca85ae0697..4521822042c 100644 --- a/spec/frontend/content_editor/services/markdown_serializer_spec.js +++ b/spec/frontend/content_editor/services/markdown_serializer_spec.js @@ -366,8 +366,21 @@ hi text: '#456', }), ), + paragraph( + reference({ + referenceType: 'command', + originalText: '/assign_reviewer', + text: '/assign_reviewer', + }), + reference({ + referenceType: 'user', + originalText: '@johndoe', + href: '/johndoe', + text: '@johndoe', + }), + ), ), - ).toBe('#123 ~foo #456'); + ).toBe('#123 ~foo #456\n\n/assign_reviewer @johndoe'); }); it.each` diff --git a/spec/lib/gitlab/lets_encrypt/challenge_spec.rb b/spec/lib/gitlab/lets_encrypt/challenge_spec.rb index d853275520b..2418e93f105 100644 --- a/spec/lib/gitlab/lets_encrypt/challenge_spec.rb +++ b/spec/lib/gitlab/lets_encrypt/challenge_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe ::Gitlab::LetsEncrypt::Challenge do +RSpec.describe ::Gitlab::LetsEncrypt::Challenge, feature_category: :pages do include LetsEncryptHelpers let(:challenge) { described_class.new(acme_challenge_double) } diff --git a/spec/lib/gitlab/lets_encrypt/client_spec.rb b/spec/lib/gitlab/lets_encrypt/client_spec.rb index 2bed3d216e7..e109cf93f3f 100644 --- a/spec/lib/gitlab/lets_encrypt/client_spec.rb +++ b/spec/lib/gitlab/lets_encrypt/client_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe ::Gitlab::LetsEncrypt::Client do +RSpec.describe ::Gitlab::LetsEncrypt::Client, feature_category: :pages do include LetsEncryptHelpers let(:client) { described_class.new } diff --git a/spec/lib/gitlab/lets_encrypt/order_spec.rb b/spec/lib/gitlab/lets_encrypt/order_spec.rb index 419f9e28871..734afab6bb1 100644 --- a/spec/lib/gitlab/lets_encrypt/order_spec.rb +++ b/spec/lib/gitlab/lets_encrypt/order_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe ::Gitlab::LetsEncrypt::Order do +RSpec.describe ::Gitlab::LetsEncrypt::Order, feature_category: :pages do include LetsEncryptHelpers let(:acme_order) { acme_order_double } diff --git a/spec/lib/gitlab/lets_encrypt_spec.rb b/spec/lib/gitlab/lets_encrypt_spec.rb index 7597359847b..f07eac1e09a 100644 --- a/spec/lib/gitlab/lets_encrypt_spec.rb +++ b/spec/lib/gitlab/lets_encrypt_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe ::Gitlab::LetsEncrypt do +RSpec.describe ::Gitlab::LetsEncrypt, feature_category: :pages do include LetsEncryptHelpers before do diff --git a/spec/models/release_spec.rb b/spec/models/release_spec.rb index 880fb21b7af..863cc11f0b2 100644 --- a/spec/models/release_spec.rb +++ b/spec/models/release_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Release do +RSpec.describe Release, feature_category: :release_orchestration do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :public, :repository) } @@ -85,6 +85,94 @@ RSpec.describe Release do end end + describe 'latest releases' do + let_it_be(:yesterday) { Time.zone.now - 1.day } + let_it_be(:tomorrow) { Time.zone.now + 1.day } + + let_it_be(:project2) { create(:project) } + + let_it_be(:project_release1) do + create(:release, project: project, released_at: yesterday, created_at: tomorrow) + end + + let_it_be(:project_release2) do + create(:release, project: project, released_at: tomorrow, created_at: yesterday) + end + + let_it_be(:project2_release1) do + create(:release, project: project2, released_at: yesterday, created_at: tomorrow) + end + + let_it_be(:project2_release2) do + create(:release, project: project2, released_at: tomorrow, created_at: yesterday) + end + + let(:args) { {} } + + describe '.latest' do + subject(:latest) { project.releases.latest(**args) } + + context 'without order_by' do + it 'returns the latest release by released date' do + expect(latest).to eq(project_release2) + end + end + + context 'with order_by: created_at' do + let(:args) { { order_by: 'created_at' } } + + it 'returns the latest release by created date' do + expect(latest).to eq(project_release1) + end + end + + context 'when there are no releases' do + it 'returns nil' do + project.releases.delete_all + + expect(latest).to eq(nil) + end + end + end + + describe '.latest_for_projects' do + let(:projects) { [project, project2] } + + subject(:latest_for_projects) { described_class.latest_for_projects(projects, **args) } + + context 'without order_by' do + it 'returns the latest release by released date for each project' do + expect(latest_for_projects).to match_array([project_release2, project2_release2]) + end + end + + context 'with order_by: created_at' do + let(:args) { { order_by: 'created_at' } } + + it 'returns the latest release by created date for each project' do + expect(latest_for_projects).to match_array([project_release1, project2_release1]) + end + end + + context 'when no projects are provided' do + let(:projects) { [] } + + it 'returns empty response' do + expect(latest_for_projects).to be_empty + end + end + + context 'when there are no releases' do + it 'returns empty response' do + project.releases.delete_all + project2.releases.delete_all + + expect(latest_for_projects).to be_empty + end + end + end + end + describe '#assets_count' do subject { Release.find(release.id).assets_count } diff --git a/spec/services/projects/participants_service_spec.rb b/spec/services/projects/participants_service_spec.rb index 8c0f68dee4c..2f090577805 100644 --- a/spec/services/projects/participants_service_spec.rb +++ b/spec/services/projects/participants_service_spec.rb @@ -179,6 +179,18 @@ RSpec.describe Projects::ParticipantsService, feature_category: :groups_and_proj end end + context 'when public project maintainer is signed in' do + let(:service) { described_class.new(public_project, public_project_maintainer) } + + it 'returns private group members' do + expect(usernames).to include(private_group_member.username) + end + + it 'returns members of the ancestral groups of the private group' do + expect(usernames).to include(group_ancestor_owner.username) + end + end + context 'when private group owner is signed in' do let(:service) { described_class.new(public_project, private_group_owner) } diff --git a/spec/support/formatters/json_formatter.rb b/spec/support/formatters/json_formatter.rb index 9ca1a538293..10af5445b7a 100644 --- a/spec/support/formatters/json_formatter.rb +++ b/spec/support/formatters/json_formatter.rb @@ -73,7 +73,8 @@ module Support screenshot: example.metadata[:screenshot], product_group: example.metadata[:product_group], feature_category: example.metadata[:feature_category], - ci_job_url: ENV['CI_JOB_URL'] + ci_job_url: ENV['CI_JOB_URL'], + retry_attempts: example.metadata[:retry_attempts] } end |