diff options
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/internal/base_spec.rb | 18 | ||||
-rw-r--r-- | spec/requests/api/release/links_spec.rb | 33 |
2 files changed, 40 insertions, 11 deletions
diff --git a/spec/requests/api/internal/base_spec.rb b/spec/requests/api/internal/base_spec.rb index 4249ce105c9..fe0a3ffebd3 100644 --- a/spec/requests/api/internal/base_spec.rb +++ b/spec/requests/api/internal/base_spec.rb @@ -409,7 +409,7 @@ describe API::Internal::Base do it do pull(key, project) - expect(response).to have_gitlab_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:unauthorized) expect(json_response["status"]).to be_falsey expect(user.reload.last_activity_on).to be_nil end @@ -419,7 +419,7 @@ describe API::Internal::Base do it do push(key, project) - expect(response).to have_gitlab_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:unauthorized) expect(json_response["status"]).to be_falsey expect(user.reload.last_activity_on).to be_nil end @@ -518,7 +518,7 @@ describe API::Internal::Base do it do pull(key, personal_project) - expect(response).to have_gitlab_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:unauthorized) expect(json_response["status"]).to be_falsey expect(user.reload.last_activity_on).to be_nil end @@ -528,7 +528,7 @@ describe API::Internal::Base do it do push(key, personal_project) - expect(response).to have_gitlab_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:unauthorized) expect(json_response["status"]).to be_falsey expect(user.reload.last_activity_on).to be_nil end @@ -572,7 +572,7 @@ describe API::Internal::Base do it do push(key, project) - expect(response).to have_gitlab_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:unauthorized) expect(json_response["status"]).to be_falsey end end @@ -654,7 +654,7 @@ describe API::Internal::Base do it 'rejects the SSH push' do push(key, project) - expect(response).to have_gitlab_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:unauthorized) expect(json_response['status']).to be_falsey expect(json_response['message']).to eq 'Git access over SSH is not allowed' end @@ -662,7 +662,7 @@ describe API::Internal::Base do it 'rejects the SSH pull' do pull(key, project) - expect(response).to have_gitlab_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:unauthorized) expect(json_response['status']).to be_falsey expect(json_response['message']).to eq 'Git access over SSH is not allowed' end @@ -676,7 +676,7 @@ describe API::Internal::Base do it 'rejects the HTTP push' do push(key, project, 'http') - expect(response).to have_gitlab_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:unauthorized) expect(json_response['status']).to be_falsey expect(json_response['message']).to eq 'Git access over HTTP is not allowed' end @@ -684,7 +684,7 @@ describe API::Internal::Base do it 'rejects the HTTP pull' do pull(key, project, 'http') - expect(response).to have_gitlab_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:unauthorized) expect(json_response['status']).to be_falsey expect(json_response['message']).to eq 'Git access over HTTP is not allowed' end diff --git a/spec/requests/api/release/links_spec.rb b/spec/requests/api/release/links_spec.rb index 3a59052bb29..cf2043ecc74 100644 --- a/spec/requests/api/release/links_spec.rb +++ b/spec/requests/api/release/links_spec.rb @@ -135,16 +135,44 @@ describe API::Release::Links do end end end + + describe '#direct_asset_url' do + let!(:link) { create(:release_link, release: release, url: url, filepath: filepath) } + let(:url) { 'https://google.com/-/jobs/140463678/artifacts/download' } + + context 'when filepath is provided' do + let(:filepath) { '/bin/bigfile.exe' } + + specify do + get api("/projects/#{project.id}/releases/v0.1/assets/links/#{link.id}", maintainer) + + expect(json_response['direct_asset_url']).to eq("http://localhost/#{project.namespace.path}/#{project.name}/-/releases/#{release.tag}/bin/bigfile.exe") + end + end + + context 'when filepath is not provided' do + let(:filepath) { nil } + + specify do + get api("/projects/#{project.id}/releases/v0.1/assets/links/#{link.id}", maintainer) + + expect(json_response['direct_asset_url']).to eq(url) + end + end + end end describe 'POST /projects/:id/releases/:tag_name/assets/links' do let(:params) do { name: 'awesome-app.dmg', + filepath: '/binaries/awesome-app.dmg', url: 'https://example.com/download/awesome-app.dmg' } end + let(:last_release_link) { release.links.last } + it 'accepts the request' do post api("/projects/#{project.id}/releases/v0.1/assets/links", maintainer), params: params @@ -157,8 +185,9 @@ describe API::Release::Links do end.to change { Releases::Link.count }.by(1) release.reload - expect(release.links.last.name).to eq('awesome-app.dmg') - expect(release.links.last.url).to eq('https://example.com/download/awesome-app.dmg') + expect(last_release_link.name).to eq('awesome-app.dmg') + expect(last_release_link.filepath).to eq('/binaries/awesome-app.dmg') + expect(last_release_link.url).to eq('https://example.com/download/awesome-app.dmg') end it 'matches response schema' do |