summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/lib/gitlab/repository_size_checker_shared_examples.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/shared_examples/lib/gitlab/repository_size_checker_shared_examples.rb')
-rw-r--r--spec/support/shared_examples/lib/gitlab/repository_size_checker_shared_examples.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/support/shared_examples/lib/gitlab/repository_size_checker_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/repository_size_checker_shared_examples.rb
new file mode 100644
index 00000000000..bb909ffe82a
--- /dev/null
+++ b/spec/support/shared_examples/lib/gitlab/repository_size_checker_shared_examples.rb
@@ -0,0 +1,51 @@
+# frozen_string_literal: true
+
+RSpec.shared_examples 'checker size above limit' do
+ context 'when size is above the limit' do
+ let(:current_size) { 100 }
+
+ it 'returns true' do
+ expect(subject.above_size_limit?).to eq(true)
+ end
+ end
+end
+
+RSpec.shared_examples 'checker size not over limit' do
+ it 'returns false when not over the limit' do
+ expect(subject.above_size_limit?).to eq(false)
+ end
+end
+
+RSpec.shared_examples 'checker size exceeded' do
+ context 'when current size is below or equal to the limit' do
+ let(:current_size) { 50 }
+
+ it 'returns zero' do
+ expect(subject.exceeded_size).to eq(0)
+ end
+ end
+
+ context 'when current size is over the limit' do
+ let(:current_size) { 51 }
+
+ it 'returns zero' do
+ expect(subject.exceeded_size).to eq(1.megabytes)
+ end
+ end
+
+ context 'when change size will be over the limit' do
+ let(:current_size) { 50 }
+
+ it 'returns zero' do
+ expect(subject.exceeded_size(1.megabytes)).to eq(1.megabytes)
+ end
+ end
+
+ context 'when change size will not be over the limit' do
+ let(:current_size) { 49 }
+
+ it 'returns zero' do
+ expect(subject.exceeded_size(1.megabytes)).to eq(0)
+ end
+ end
+end