diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-29 15:08:55 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-29 15:08:55 +0300 |
commit | 2dedd78ef505a0ab0a379c7340a3fcba56ada663 (patch) | |
tree | ef05626056122d4e07145c9c043484764f1267e8 /spec/lib/gitlab/checks/single_change_access_spec.rb | |
parent | f931527bc5120097db15737f8594a431bcad9116 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/checks/single_change_access_spec.rb')
-rw-r--r-- | spec/lib/gitlab/checks/single_change_access_spec.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/lib/gitlab/checks/single_change_access_spec.rb b/spec/lib/gitlab/checks/single_change_access_spec.rb index 8b235005b3e..e81e4951539 100644 --- a/spec/lib/gitlab/checks/single_change_access_spec.rb +++ b/spec/lib/gitlab/checks/single_change_access_spec.rb @@ -58,5 +58,52 @@ RSpec.describe Gitlab::Checks::SingleChangeAccess do expect { access.validate! }.to raise_error(Gitlab::Checks::TimedLogger::TimeoutError) end end + + describe '#commits' do + let(:expected_commits) { [Gitlab::Git::Commit.new(project.repository, { id: "1234" })] } + + let(:access) do + described_class.new(changes, + project: project, + user_access: user_access, + protocol: protocol, + logger: logger, + commits: provided_commits) + end + + shared_examples '#commits' do + it 'returns expected commits' do + expect(access.commits).to eq(expected_commits) + end + + it 'returns expected commits on repeated calls' do + expect(access.commits).to eq(expected_commits) + expect(access.commits).to eq(expected_commits) + end + end + + context 'with provided commits' do + let(:provided_commits) { expected_commits } + + before do + expect(project.repository).not_to receive(:new_commits) + end + + it_behaves_like '#commits' + end + + context 'without provided commits' do + let(:provided_commits) { nil } + + before do + expect(project.repository) + .to receive(:new_commits) + .once + .and_return(expected_commits) + end + + it_behaves_like '#commits' + end + end end end |