summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2019-05-10 14:45:09 +0000
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2019-05-10 14:45:09 +0000
commit9dc41a0993a38f99eeda9c2e8bb3ace070003496 (patch)
tree85d223ad978f16c19b107fa4acc4574aa6156e88 /spec
parente09b609f0e41879a80e32c1e682f433d5318b89c (diff)
parente67481e079023e1319e91fabfb90b88c9a2b2655 (diff)
downloadgitlab-ce-9dc41a0993a38f99eeda9c2e8bb3ace070003496.tar.gz
Merge branch 'sh-fix-lfs-download-errors' into 'master'
Properly handle LFS Batch API response in project import Closes #61624 See merge request gitlab-org/gitlab-ce!28223
Diffstat (limited to 'spec')
-rw-r--r--spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb b/spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb
index d8427d0bf78..80debcd3a7a 100644
--- a/spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb
+++ b/spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb
@@ -33,7 +33,10 @@ describe Projects::LfsPointers::LfsDownloadLinkListService do
before do
allow(project).to receive(:lfs_enabled?).and_return(true)
- allow(Gitlab::HTTP).to receive(:post).and_return(objects_response)
+ response = instance_double(HTTParty::Response)
+ allow(response).to receive(:body).and_return(objects_response.to_json)
+ allow(response).to receive(:success?).and_return(true)
+ allow(Gitlab::HTTP).to receive(:post).and_return(response)
end
describe '#execute' do
@@ -89,6 +92,21 @@ describe Projects::LfsPointers::LfsDownloadLinkListService do
expect { subject.send(:get_download_links, new_oids) }.to raise_error(described_class::DownloadLinksError)
end
+
+ shared_examples 'JSON parse errors' do |body|
+ it 'raises error' do
+ response = instance_double(HTTParty::Response)
+ allow(response).to receive(:body).and_return(body)
+ allow(response).to receive(:success?).and_return(true)
+ allow(Gitlab::HTTP).to receive(:post).and_return(response)
+
+ expect { subject.send(:get_download_links, new_oids) }.to raise_error(described_class::DownloadLinksError)
+ end
+ end
+
+ it_behaves_like 'JSON parse errors', '{'
+ it_behaves_like 'JSON parse errors', '{}'
+ it_behaves_like 'JSON parse errors', '{ foo: 123 }'
end
describe '#parse_response_links' do