diff options
Diffstat (limited to 'spec/lib/gitlab/checks/changes_access_spec.rb')
-rw-r--r-- | spec/lib/gitlab/checks/changes_access_spec.rb | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/spec/lib/gitlab/checks/changes_access_spec.rb b/spec/lib/gitlab/checks/changes_access_spec.rb index 1cb4edd7337..41ec11c1055 100644 --- a/spec/lib/gitlab/checks/changes_access_spec.rb +++ b/spec/lib/gitlab/checks/changes_access_spec.rb @@ -49,10 +49,17 @@ RSpec.describe Gitlab::Checks::ChangesAccess do context 'when changes contain empty revisions' do let(:expected_commit) { instance_double(Commit) } + let(:expected_allow_quarantine) { allow_quarantine } shared_examples 'returns only commits with non empty revisions' do + before do + stub_feature_flags(filter_quarantined_commits: filter_quarantined_commits) + end + specify do - expect(project.repository).to receive(:new_commits).with([newrev], { allow_quarantine: allow_quarantine }) { [expected_commit] } + expect(project.repository) + .to receive(:new_commits) + .with([newrev], allow_quarantine: expected_allow_quarantine) { [expected_commit] } expect(subject.commits).to match_array([expected_commit]) end end @@ -60,13 +67,37 @@ RSpec.describe Gitlab::Checks::ChangesAccess do it_behaves_like 'returns only commits with non empty revisions' do let(:changes) { [{ oldrev: oldrev, newrev: newrev }, { newrev: '' }, { newrev: Gitlab::Git::BLANK_SHA }] } let(:allow_quarantine) { true } + let(:filter_quarantined_commits) { true } end context 'without oldrev' do - it_behaves_like 'returns only commits with non empty revisions' do - let(:changes) { [{ newrev: newrev }, { newrev: '' }, { newrev: Gitlab::Git::BLANK_SHA }] } - # The quarantine directory should not be used because we're lacking oldrev. + let(:changes) { [{ newrev: newrev }, { newrev: '' }, { newrev: Gitlab::Git::BLANK_SHA }] } + + context 'with disallowed quarantine' do + # The quarantine directory should not be used because we're lacking + # oldrev, and we're not filtering commits. let(:allow_quarantine) { false } + let(:filter_quarantined_commits) { false } + + it_behaves_like 'returns only commits with non empty revisions' + end + + context 'with allowed quarantine and :filter_quarantined_commits disabled' do + # When we allow usage of the quarantine but have no oldrev and we're + # not filtering commits then results returned by the quarantine aren't + # accurate. We thus mustn't try using it. + let(:allow_quarantine) { true } + let(:filter_quarantined_commits) { false } + let(:expected_allow_quarantine) { false } + + it_behaves_like 'returns only commits with non empty revisions' + end + + context 'with allowed quarantine and :filter_quarantined_commits enabled' do + let(:allow_quarantine) { true } + let(:filter_quarantined_commits) { true } + + it_behaves_like 'returns only commits with non empty revisions' end end end |