diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-31 21:07:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-31 21:07:42 +0300 |
commit | 580622bdb3c762a8e89facd8a3946881ee480442 (patch) | |
tree | 3ac9d759da23f78f95f50684bd238a9f76839538 /spec/lib/gitlab/repository_size_error_message_spec.rb | |
parent | b211a4ea14d5e9ed9b0c248a4e8c5c1d85b542cb (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/repository_size_error_message_spec.rb')
-rw-r--r-- | spec/lib/gitlab/repository_size_error_message_spec.rb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/lib/gitlab/repository_size_error_message_spec.rb b/spec/lib/gitlab/repository_size_error_message_spec.rb new file mode 100644 index 00000000000..9e4d19cc572 --- /dev/null +++ b/spec/lib/gitlab/repository_size_error_message_spec.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::RepositorySizeErrorMessage do + let(:checker) do + Gitlab::RepositorySizeChecker.new( + current_size_proc: -> { 15.megabytes }, + limit: 10.megabytes + ) + end + + let(:message) { checker.error_message } + let(:base_message) { 'because this repository has exceeded its size limit of 10 MB by 5 MB' } + + describe 'error messages' do + describe '#commit_error' do + it 'returns the correct message' do + expect(message.commit_error).to eq("Your changes could not be committed, #{base_message}") + end + end + + describe '#merge_error' do + it 'returns the correct message' do + expect(message.merge_error).to eq("This merge request cannot be merged, #{base_message}") + end + end + + describe '#push_error' do + context 'with exceeded_limit value' do + let(:rejection_message) do + 'because this repository has exceeded its size limit of 10 MB by 15 MB' + end + + it 'returns the correct message' do + expect(message.push_error(10.megabytes)) + .to eq("Your push has been rejected, #{rejection_message}. #{message.more_info_message}") + end + end + + context 'without exceeded_limit value' do + it 'returns the correct message' do + expect(message.push_error) + .to eq("Your push has been rejected, #{base_message}. #{message.more_info_message}") + end + end + end + + describe '#new_changes_error' do + it 'returns the correct message' do + expect(message.new_changes_error).to eq("Your push to this repository would cause it to exceed the size limit of 10 MB so it has been rejected. #{message.more_info_message}") + end + end + end +end |