diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-04 00:17:41 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-04 00:17:41 +0000 |
commit | b301036d090d8a7365f98a0444d09f8a09664834 (patch) | |
tree | a0e106f732756b6b3e373b64890ffbf89a748e54 /spec/models | |
parent | 456ab418aad4faa85ad1ad442d0745e6cfe160d6 (diff) | |
download | gitlab-ce-b301036d090d8a7365f98a0444d09f8a09664834.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/environment_status_spec.rb | 1 | ||||
-rw-r--r-- | spec/models/namespace_spec.rb | 33 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 25 |
3 files changed, 58 insertions, 1 deletions
diff --git a/spec/models/environment_status_spec.rb b/spec/models/environment_status_spec.rb index cb14d98da72..dbd769d7fdc 100644 --- a/spec/models/environment_status_spec.rb +++ b/spec/models/environment_status_spec.rb @@ -17,6 +17,7 @@ RSpec.describe EnvironmentStatus do it { is_expected.to delegate_method(:name).to(:environment) } it { is_expected.to delegate_method(:deployed_at).to(:deployment) } it { is_expected.to delegate_method(:status).to(:deployment) } + it { is_expected.to delegate_method(:deployable).to(:deployment) } describe '#project' do subject { environment_status.project } diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index dd522018e52..d628812e081 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -504,7 +504,6 @@ RSpec.describe Namespace, feature_category: :subgroups do it { is_expected.to delegate_method(:runner_registration_enabled).to(:namespace_settings) } it { is_expected.to delegate_method(:runner_registration_enabled?).to(:namespace_settings) } it { is_expected.to delegate_method(:allow_runner_registration_token).to(:namespace_settings) } - it { is_expected.to delegate_method(:allow_runner_registration_token?).to(:namespace_settings) } it { is_expected.to delegate_method(:maven_package_requests_forwarding).to(:package_settings) } it { is_expected.to delegate_method(:pypi_package_requests_forwarding).to(:package_settings) } it { is_expected.to delegate_method(:npm_package_requests_forwarding).to(:package_settings) } @@ -523,6 +522,38 @@ RSpec.describe Namespace, feature_category: :subgroups do is_expected.to delegate_method(:allow_runner_registration_token=).to(:namespace_settings) .with_arguments(:args) end + + describe '#allow_runner_registration_token?' do + subject { namespace.allow_runner_registration_token? } + + context 'when namespace_settings is nil' do + let_it_be(:namespace) { create(:namespace) } + + it { is_expected.to eq false } + end + + context 'when namespace_settings is not nil' do + let_it_be(:namespace) { create(:namespace, :with_namespace_settings) } + + it { is_expected.to eq true } + + context 'when namespace_settings.allow_runner_registration_token? is false' do + before do + namespace.allow_runner_registration_token = false + end + + it { is_expected.to eq false } + end + + context 'when namespace_settings.allow_runner_registration_token? is true' do + before do + namespace.allow_runner_registration_token = true + end + + it { is_expected.to eq true } + end + end + end end describe "Respond to" do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 0e432edebb0..db981c832ac 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -291,6 +291,31 @@ RSpec.describe User, feature_category: :user_profile do end end + describe '#abuse_metadata' do + let_it_be(:user) { create(:user) } + let_it_be(:contribution_calendar) { Gitlab::ContributionsCalendar.new(user) } + + before do + allow(Gitlab::ContributionsCalendar).to receive(:new).and_return(contribution_calendar) + allow(contribution_calendar).to receive(:activity_dates).and_return({ first: 3, second: 5, third: 4 }) + + allow(user).to receive_messages( + account_age_in_days: 10, + two_factor_enabled?: true + ) + end + + it 'returns the expected hash' do + abuse_metadata = user.abuse_metadata + + expect(abuse_metadata.length).to eq 2 + expect(abuse_metadata).to include( + account_age: 10, + two_factor_enabled: 1 + ) + end + end + describe '#group_members' do it 'does not include group memberships for which user is a requester' do user = create(:user) |