diff options
Diffstat (limited to 'spec/requests/api/repositories_spec.rb')
-rw-r--r-- | spec/requests/api/repositories_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb index 8853eff0b3e..a94ed63bf47 100644 --- a/spec/requests/api/repositories_spec.rb +++ b/spec/requests/api/repositories_spec.rb @@ -37,6 +37,52 @@ RSpec.describe API::Repositories, feature_category: :source_code_management do end end + context 'when path does not exist' do + let(:path) { 'bogus' } + + context 'when handle_structured_gitaly_errors feature is disabled' do + before do + stub_feature_flags(handle_structured_gitaly_errors: false) + end + + it 'returns an empty array' do + get api("#{route}?path=#{path}", current_user) + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to include_pagination_headers + expect(json_response).to be_an(Array) + expect(json_response).to be_an_empty + end + end + + context 'when handle_structured_gitaly_errors feature is enabled' do + before do + stub_feature_flags(handle_structured_gitaly_errors: true) + end + + it_behaves_like '404 response' do + let(:request) { get api("#{route}?path=#{path}", current_user) } + let(:message) { '404 invalid revision or path Not Found' } + end + end + end + + context 'when path is empty directory ' do + context 'when handle_structured_gitaly_errors feature is disabled' do + before do + stub_feature_flags(handle_structured_gitaly_errors: false) + end + + it 'returns an empty array' do + get api(route, current_user) + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to include_pagination_headers + expect(json_response).to be_an(Array) + end + end + end + context 'when repository is disabled' do include_context 'disabled repository' |