Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Edwards-Jones <jedwardsjones@gitlab.com>2018-03-15 02:45:57 +0300
committerJames Edwards-Jones <jedwardsjones@gitlab.com>2018-03-16 00:49:00 +0300
commit237a32cc90d7e2c4b96e3a9ba0fd9e77ff3fc166 (patch)
tree1ad0bd7901dd016f0bf4c63a76a9bff927a5a10c /spec/services/lfs/file_transformer_spec.rb
parent1baac9211238f60d2d2a50cccd0bea6979bfa6ba (diff)
Avoid failed integrity check by linking LfsObjectProjects sooner
Attempted commits were failing due to the pre-recieve LfsIntegrity check. This is skipped during tests making this failure silent.
Diffstat (limited to 'spec/services/lfs/file_transformer_spec.rb')
-rw-r--r--spec/services/lfs/file_transformer_spec.rb43
1 files changed, 11 insertions, 32 deletions
diff --git a/spec/services/lfs/file_transformer_spec.rb b/spec/services/lfs/file_transformer_spec.rb
index f469f5e76dd..6d17ab03ac3 100644
--- a/spec/services/lfs/file_transformer_spec.rb
+++ b/spec/services/lfs/file_transformer_spec.rb
@@ -55,44 +55,23 @@ describe Lfs::FileTransformer do
end
end
- it 'sets up after_transform! to link LfsObjects to project' do
- subject.new_file(file_path, file_content)
-
- expect { subject.after_transform! }.to change { project.lfs_objects.count }.by(1)
+ it 'links LfsObjects to project' do
+ expect do
+ subject.new_file(file_path, file_content)
+ end.to change { project.lfs_objects.count }.by(1)
end
- end
- end
- describe '.link_lfs_objects' do
- context 'with lfs enabled' do
- before do
- allow(project).to receive(:lfs_enabled?).and_return(true)
- end
+ context 'when LfsObject already exists' do
+ let(:lfs_pointer) { Gitlab::Git::LfsPointerFile.new(file_content) }
- context 'when given a block' do
- it 'links LfsObject to the project automatically' do
- expect do
- described_class.link_lfs_objects(project, branch_name) do |t|
- t.new_file(file_path, file_content)
- end
- end.to change { project.lfs_objects.count }.by(1)
+ before do
+ create(:lfs_object, oid: lfs_pointer.sha256, size: lfs_pointer.size)
end
- it 'skips linking LfsObjects if the block returns falsey' do
+ it 'links LfsObjects to project' do
expect do
- described_class.link_lfs_objects(project, branch_name) do |t|
- t.new_file(file_path, file_content)
- false
- end
- end.not_to change { project.lfs_objects.count }
- end
-
- it 'returns the result of the block' do
- result = described_class.link_lfs_objects(project, branch_name) do |t|
- :dummy_commit
- end
-
- expect(result).to eq :dummy_commit
+ subject.new_file(file_path, file_content)
+ end.to change { project.lfs_objects.count }.by(1)
end
end
end