gitlab-org--gitlab-foss/spec/requests/api/deployments_spec.rb

56 lines
1.6 KiB
Ruby
Raw Normal View History

2016-08-16 02:45:23 -04:00
require 'spec_helper'
describe API::Deployments do
2016-08-16 02:45:23 -04:00
let(:user) { create(:user) }
let(:non_member) { create(:user) }
let(:project) { deployment.environment.project }
let!(:deployment) { create(:deployment) }
before do
project.team << [user, :master]
end
describe 'GET /projects/:id/deployments' do
context 'as member of the project' do
it 'returns projects deployments' do
get api("/projects/#{project.id}/deployments", user)
expect(response).to have_http_status(200)
2017-01-24 15:49:10 -05:00
expect(response).to include_pagination_headers
2016-08-16 02:45:23 -04:00
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
expect(json_response.first['iid']).to eq(deployment.iid)
expect(json_response.first['sha']).to match /\A\h{40}\z/
end
end
context 'as non member' do
it 'returns a 404 status code' do
get api("/projects/#{project.id}/deployments", non_member)
expect(response).to have_http_status(404)
end
end
end
describe 'GET /projects/:id/deployments/:deployment_id' do
context 'as a member of the project' do
it 'returns the projects deployment' do
get api("/projects/#{project.id}/deployments/#{deployment.id}", user)
expect(response).to have_http_status(200)
expect(json_response['sha']).to match /\A\h{40}\z/
2016-08-16 04:11:32 -04:00
expect(json_response['id']).to eq(deployment.id)
2016-08-16 02:45:23 -04:00
end
end
context 'as non member' do
it 'returns a 404 status code' do
get api("/projects/#{project.id}/deployments/#{deployment.id}", non_member)
expect(response).to have_http_status(404)
end
end
end
end