diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-22 18:12:49 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-22 18:12:49 +0300 |
commit | c60010859638f577dab891358e83945561b35ad2 (patch) | |
tree | 6badf09d24d14aa03bf265f4ba7dcc368ac9fa78 /spec/models | |
parent | 26fa51816ab94df9c2f3db8c93da4d57f7bd6fc4 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/application_setting_spec.rb | 1 | ||||
-rw-r--r-- | spec/models/container_repository_spec.rb | 18 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 60 |
3 files changed, 77 insertions, 2 deletions
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index d16a78be533..1e70653c628 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -27,6 +27,7 @@ RSpec.describe ApplicationSetting, feature_category: :shared, type: :model do it { expect(setting.max_decompressed_archive_size).to eq(25600) } it { expect(setting.decompress_archive_file_timeout).to eq(210) } it { expect(setting.bulk_import_concurrent_pipeline_batch_limit).to eq(25) } + it { expect(setting.allow_project_creation_for_guest_and_below).to eq(true) } end describe 'validations' do diff --git a/spec/models/container_repository_spec.rb b/spec/models/container_repository_spec.rb index dc53c420704..25c28399abc 100644 --- a/spec/models/container_repository_spec.rb +++ b/spec/models/container_repository_spec.rb @@ -693,7 +693,7 @@ RSpec.describe ContainerRepository, :aggregate_failures, feature_category: :cont it 'calls GitlabApiClient#tags and passes parameters' do allow(repository.gitlab_api_client).to receive(:tags).and_return({}) expect(repository.gitlab_api_client).to receive(:tags).with( - repository.path, page_size: page_size, before: before, last: last, sort: sort, name: name) + repository.path, page_size: page_size, before: before, last: last, sort: sort, name: name, referrers: nil) subject end @@ -708,7 +708,13 @@ RSpec.describe ContainerRepository, :aggregate_failures, feature_category: :cont media_type: 'application/vnd.oci.image.manifest.v1+json', size_bytes: 1234567890, created_at: 5.minutes.ago, - updated_at: 5.minutes.ago + updated_at: 5.minutes.ago, + referrers: [ + { + artifactType: 'application/vnd.example+type', + digest: 'sha256:57d3be92c2f857566ecc7f9306a80021c0a7fa631e0ef5146957235aea859961' + } + ] }, { name: 'latest', @@ -755,6 +761,14 @@ RSpec.describe ContainerRepository, :aggregate_failures, feature_category: :cont created_at: DateTime.rfc3339(tags_response[index][:created_at].rfc3339), updated_at: DateTime.rfc3339(tags_response[index][:updated_at].rfc3339) ) + + Array(tag.referrers).each_with_index do |ref, ref_index| + expect(ref.is_a?(ContainerRegistry::Referrer)).to eq(true) + expect(ref).to have_attributes( + artifact_type: tags_response[index][:referrers][ref_index][:artifactType], + digest: tags_response[index][:referrers][ref_index][:digest] + ) + end end end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 77ceee3b1b0..68fdbeba84d 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -3669,6 +3669,66 @@ RSpec.describe User, feature_category: :user_profile do end end + describe '#can_create_project?' do + let(:user) { create(:user) } + + context "when projects_limit_left is 0" do + before do + allow(user).to receive(:projects_limit_left).and_return(0) + end + + it "returns false" do + expect(user.can_create_project?).to be_falsey + end + end + + context "when projects_limit_left is > 0" do + before do + allow(user).to receive(:projects_limit_left).and_return(1) + end + + context "with allow_project_creation_for_guest_and_below default value of true" do + it "returns true" do + expect(user.can_create_project?).to be_truthy + end + end + + context "when Gitlab::CurrentSettings.allow_project_creation_for_guest_and_below is false" do + before do + stub_application_setting(allow_project_creation_for_guest_and_below: false) + end + + [ + Gitlab::Access::NO_ACCESS, + Gitlab::Access::MINIMAL_ACCESS, + Gitlab::Access::GUEST + ].each do |role| + context "when users highest role is #{role}" do + it "returns false" do + allow(user).to receive(:highest_role).and_return(role) + expect(user.can_create_project?).to be_falsey + end + end + end + + [ + Gitlab::Access::REPORTER, + Gitlab::Access::DEVELOPER, + Gitlab::Access::MAINTAINER, + Gitlab::Access::OWNER, + Gitlab::Access::ADMIN + ].each do |role| + context "when users highest role is #{role}" do + it "returns true" do + allow(user).to receive(:highest_role).and_return(role) + expect(user.can_create_project?).to be_truthy + end + end + end + end + end + end + describe '#all_emails' do let(:user) { create(:user) } let!(:unconfirmed_secondary_email) { create(:email, user: user) } |