diff options
Diffstat (limited to 'spec/support/shared_examples/requests/api/ml_model_packages_shared_examples.rb')
-rw-r--r-- | spec/support/shared_examples/requests/api/ml_model_packages_shared_examples.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/spec/support/shared_examples/requests/api/ml_model_packages_shared_examples.rb b/spec/support/shared_examples/requests/api/ml_model_packages_shared_examples.rb index 81ff004779a..47cbd268a65 100644 --- a/spec/support/shared_examples/requests/api/ml_model_packages_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/ml_model_packages_shared_examples.rb @@ -27,7 +27,7 @@ RSpec.shared_examples 'creates model experiments package files' do end it 'returns bad request if package creation fails' do - allow_next_instance_of(::Packages::MlModel::CreatePackageFileService) do |instance| + expect_next_instance_of(::Packages::MlModel::CreatePackageFileService) do |instance| expect(instance).to receive(:execute).and_return(nil) end @@ -106,3 +106,19 @@ RSpec.shared_examples 'process ml model package upload' do end end end + +RSpec.shared_examples 'process ml model package download' do + context 'when package file exists' do + it { is_expected.to have_gitlab_http_status(:success) } + end + + context 'when record does not exist' do + it 'response is not found' do + expect_next_instance_of(::Packages::MlModel::PackageFinder) do |instance| + expect(instance).to receive(:execute!).and_raise(ActiveRecord::RecordNotFound) + end + + expect(api_response).to have_gitlab_http_status(:not_found) + end + end +end |