diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-22 21:08:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-22 21:08:47 +0300 |
commit | 3832718d895bf8268f3e3aac85948e2792769345 (patch) | |
tree | 4a322399af568b6203e732ae2e2f3efc39b23a67 /spec/requests/api | |
parent | 180cd023a11c0eb413ad0de124d9758ea25672bd (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/api')
-rw-r--r-- | spec/requests/api/applications_spec.rb | 11 | ||||
-rw-r--r-- | spec/requests/api/repositories_spec.rb | 23 |
2 files changed, 34 insertions, 0 deletions
diff --git a/spec/requests/api/applications_spec.rb b/spec/requests/api/applications_spec.rb index 438d5dbf018..d110751e661 100644 --- a/spec/requests/api/applications_spec.rb +++ b/spec/requests/api/applications_spec.rb @@ -21,6 +21,7 @@ describe API::Applications, :api do expect(json_response['application_id']).to eq application.uid expect(json_response['secret']).to eq application.secret expect(json_response['callback_url']).to eq application.redirect_uri + expect(json_response['confidential']).to eq application.confidential end it 'does not allow creating an application with the wrong redirect_uri format' do @@ -72,6 +73,16 @@ describe API::Applications, :api do expect(json_response).to be_a Hash expect(json_response['error']).to eq('scopes is missing') end + + it 'does not allow creating an application with confidential set to nil' do + expect do + post api('/applications', admin_user), params: { name: 'application_name', redirect_uri: 'http://application.url', scopes: '', confidential: nil } + end.not_to change { Doorkeeper::Application.count } + + expect(response).to have_gitlab_http_status(400) + expect(json_response).to be_a Hash + expect(json_response['message']['confidential'].first).to eq('is not included in the list') + end end context 'authorized user without authorization' do diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb index ba301147d43..8bca458bece 100644 --- a/spec/requests/api/repositories_spec.rb +++ b/spec/requests/api/repositories_spec.rb @@ -362,6 +362,29 @@ describe API::Repositories do expect(json_response['diffs']).to be_empty expect(json_response['compare_same_ref']).to be_truthy end + + it "returns an empty string when the diff overflows" do + stub_const('Gitlab::Git::DiffCollection::DEFAULT_LIMITS', { max_files: 2, max_lines: 2 }) + + get api(route, current_user), params: { from: 'master', to: 'feature' } + + expect(response).to have_gitlab_http_status(200) + expect(json_response['commits']).to be_present + expect(json_response['diffs']).to be_present + expect(json_response['diffs'].first['diff']).to be_empty + end + + it "returns a 404 when from ref is unknown" do + get api(route, current_user), params: { from: 'unknown_ref', to: 'master' } + + expect(response).to have_gitlab_http_status(404) + end + + it "returns a 404 when to ref is unknown" do + get api(route, current_user), params: { from: 'master', to: 'unknown_ref' } + + expect(response).to have_gitlab_http_status(404) + end end context 'when unauthenticated', 'and project is public' do |