diff options
Diffstat (limited to 'spec/models/commit_spec.rb')
-rw-r--r-- | spec/models/commit_spec.rb | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb index 693e754c53d..8ffc198fc4d 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -672,6 +672,92 @@ eos it_behaves_like '#uri_type' end + describe '.diff_max_files' do + subject(:diff_max_files) { described_class.diff_max_files } + + let(:increased_diff_limits) { false } + let(:configurable_diff_limits) { false } + + before do + stub_feature_flags(increased_diff_limits: increased_diff_limits, configurable_diff_limits: configurable_diff_limits) + end + + context 'when increased_diff_limits is enabled' do + let(:increased_diff_limits) { true } + + it 'returns 3000' do + expect(diff_max_files).to eq(3000) + end + end + + context 'when configurable_diff_limits is enabled' do + let(:configurable_diff_limits) { true } + + it 'returns the current settings' do + Gitlab::CurrentSettings.update!(diff_max_files: 1234) + expect(diff_max_files).to eq(1234) + end + end + + context 'when neither feature flag is enabled' do + it 'returns 1000' do + expect(diff_max_files).to eq(1000) + end + end + end + + describe '.diff_max_lines' do + subject(:diff_max_lines) { described_class.diff_max_lines } + + let(:increased_diff_limits) { false } + let(:configurable_diff_limits) { false } + + before do + stub_feature_flags(increased_diff_limits: increased_diff_limits, configurable_diff_limits: configurable_diff_limits) + end + + context 'when increased_diff_limits is enabled' do + let(:increased_diff_limits) { true } + + it 'returns 100000' do + expect(diff_max_lines).to eq(100000) + end + end + + context 'when configurable_diff_limits is enabled' do + let(:configurable_diff_limits) { true } + + it 'returns the current settings' do + Gitlab::CurrentSettings.update!(diff_max_lines: 65321) + expect(diff_max_lines).to eq(65321) + end + end + + context 'when neither feature flag is enabled' do + it 'returns 50000' do + expect(diff_max_lines).to eq(50000) + end + end + end + + describe '.diff_safe_max_files' do + subject(:diff_safe_max_files) { described_class.diff_safe_max_files } + + it 'returns the commit diff max divided by the limit factor of 10' do + expect(::Commit).to receive(:diff_max_files).and_return(10) + expect(diff_safe_max_files).to eq(1) + end + end + + describe '.diff_safe_max_lines' do + subject(:diff_safe_max_lines) { described_class.diff_safe_max_lines } + + it 'returns the commit diff max divided by the limit factor of 10' do + expect(::Commit).to receive(:diff_max_lines).and_return(100) + expect(diff_safe_max_lines).to eq(10) + end + end + describe '.from_hash' do subject { described_class.from_hash(commit.to_hash, container) } |