diff options
Diffstat (limited to 'spec/lib/gitlab/git/patches/collection_spec.rb')
-rw-r--r-- | spec/lib/gitlab/git/patches/collection_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/lib/gitlab/git/patches/collection_spec.rb b/spec/lib/gitlab/git/patches/collection_spec.rb new file mode 100644 index 00000000000..080be141c59 --- /dev/null +++ b/spec/lib/gitlab/git/patches/collection_spec.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true +require 'spec_helper' + +describe Gitlab::Git::Patches::Collection do + let(:patches_folder) { Rails.root.join('spec/fixtures/patchfiles') } + let(:patch_content1) do + File.read(File.join(patches_folder, "0001-This-does-not-apply-to-the-feature-branch.patch")) + end + let(:patch_content2) do + File.read(File.join(patches_folder, "0001-A-commit-from-a-patch.patch")) + end + + subject(:collection) { described_class.new([patch_content1, patch_content2]) } + + describe '#size' do + it 'combines the size of the patches' do + expect(collection.size).to eq(549.bytes + 424.bytes) + end + end + + describe '#valid_size?' do + it 'is not valid if the total size is bigger than 2MB' do + expect(collection).to receive(:size).and_return(2500.kilobytes) + + expect(collection).not_to be_valid_size + end + end +end |