diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-03 18:09:37 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-03 18:09:37 +0300 |
commit | 388e0fbbd00e04a10e3ac1084945aa18a781c40c (patch) | |
tree | ff8dff4f52d2432f37726d92f2efb8957a8609b7 /spec/models | |
parent | aeee636c18f82107ec7a489f33c944c65ad5f34e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/application_setting_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/ci/runner_manager_spec.rb | 17 | ||||
-rw-r--r-- | spec/models/commit_collection_spec.rb | 20 | ||||
-rw-r--r-- | spec/models/merge_request_spec.rb | 23 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 3 |
5 files changed, 56 insertions, 11 deletions
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index 51e0d4f3b11..bc3974fb1ee 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -86,6 +86,10 @@ RSpec.describe ApplicationSetting, feature_category: :shared, type: :model do it { is_expected.not_to allow_value(['/example'] * 101).for(:protected_paths) } it { is_expected.not_to allow_value(nil).for(:protected_paths) } it { is_expected.to allow_value([]).for(:protected_paths) } + it { is_expected.to allow_value(['/example'] * 100).for(:protected_paths_for_get_request) } + it { is_expected.not_to allow_value(['/example'] * 101).for(:protected_paths_for_get_request) } + it { is_expected.not_to allow_value(nil).for(:protected_paths_for_get_request) } + it { is_expected.to allow_value([]).for(:protected_paths_for_get_request) } it { is_expected.to allow_value(3).for(:push_event_hooks_limit) } it { is_expected.not_to allow_value('three').for(:push_event_hooks_limit) } diff --git a/spec/models/ci/runner_manager_spec.rb b/spec/models/ci/runner_manager_spec.rb index 80cffb98dff..575064f0bea 100644 --- a/spec/models/ci/runner_manager_spec.rb +++ b/spec/models/ci/runner_manager_spec.rb @@ -331,4 +331,21 @@ RSpec.describe Ci::RunnerManager, feature_category: :runner_fleet, type: :model .and change { runner_manager.reload.read_attribute(:executor_type) } end end + + describe '#builds' do + let_it_be(:runner_manager) { create(:ci_runner_machine) } + + subject(:builds) { runner_manager.builds } + + it { is_expected.to be_empty } + + context 'with an existing build' do + let!(:build) { create(:ci_build) } + let!(:runner_machine_build) do + create(:ci_runner_machine_build, runner_manager: runner_manager, build: build) + end + + it { is_expected.to contain_exactly build } + end + end end diff --git a/spec/models/commit_collection_spec.rb b/spec/models/commit_collection_spec.rb index 1d2d89573bb..be80aced3fd 100644 --- a/spec/models/commit_collection_spec.rb +++ b/spec/models/commit_collection_spec.rb @@ -27,11 +27,23 @@ RSpec.describe CommitCollection, feature_category: :source_code_management do expect(collection.committers).to be_empty end - it 'excludes authors of merge commits' do - commit = project.commit("60ecb67744cb56576c30214ff52294f8ce2def98") - create(:user, email: commit.committer_email.upcase) + context 'when is with_merge_commits false' do + it 'excludes authors of merge commits' do + commit = project.commit("60ecb67744cb56576c30214ff52294f8ce2def98") + create(:user, email: commit.committer_email.upcase) - expect(collection.committers).to be_empty + expect(collection.committers).to be_empty + end + end + + context 'when is with_merge_commits true' do + let(:commit) { project.commit("60ecb67744cb56576c30214ff52294f8ce2def98") } + + it 'does not exclude authors of merge commits' do + user = create(:user, email: commit.committer_email.upcase) + + expect(collection.committers(with_merge_commits: true)).to contain_exactly(user) + end end context 'when committer email is nil' do diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 1dfd14c0993..b463199a85b 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -1869,16 +1869,25 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev end describe '#committers' do - it 'returns all the committers of every commit in the merge request' do - users = subject.commits.without_merge_commits.map(&:committer_email).uniq.map do |email| - create(:user, email: email) - end + let(:commits) { double } + let(:committers) { double } + + context 'when not given with_merge_commits' do + it 'calls committers on the commits object with the expected param' do + expect(subject).to receive(:commits).and_return(commits) + expect(commits).to receive(:committers).with(with_merge_commits: false).and_return(committers) - expect(subject.committers).to match_array(users) + expect(subject.committers).to eq(committers) + end end - it 'returns an empty array if no committer is associated with a user' do - expect(subject.committers).to be_empty + context 'when given with_merge_commits true' do + it 'calls committers on the commits object with the expected param' do + expect(subject).to receive(:commits).and_return(commits) + expect(commits).to receive(:committers).with(with_merge_commits: true).and_return(committers) + + expect(subject.committers(with_merge_commits: true)).to eq(committers) + end end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index b43b149157c..5d964044041 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -124,6 +124,9 @@ RSpec.describe User, feature_category: :user_profile do it { is_expected.to delegate_method(:organization).to(:user_detail).allow_nil } it { is_expected.to delegate_method(:organization=).to(:user_detail).with_arguments(:args).allow_nil } + + it { is_expected.to delegate_method(:email_reset_offered_at).to(:user_detail).allow_nil } + it { is_expected.to delegate_method(:email_reset_offered_at=).to(:user_detail).with_arguments(:args).allow_nil } end describe 'associations' do |