diff options
Diffstat (limited to 'spec/requests/api/ci/resource_groups_spec.rb')
-rw-r--r-- | spec/requests/api/ci/resource_groups_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/requests/api/ci/resource_groups_spec.rb b/spec/requests/api/ci/resource_groups_spec.rb index f5b68557a0d..864c363e6d3 100644 --- a/spec/requests/api/ci/resource_groups_spec.rb +++ b/spec/requests/api/ci/resource_groups_spec.rb @@ -9,6 +9,36 @@ RSpec.describe API::Ci::ResourceGroups do let(:user) { developer } + describe 'GET /projects/:id/resource_groups' do + subject { get api("/projects/#{project.id}/resource_groups", user) } + + let!(:resource_groups) { create_list(:ci_resource_group, 3, project: project) } + + it 'returns all resource groups for this project', :aggregate_failures do + subject + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to include_pagination_headers + resource_groups.each_index do |i| + expect(json_response[i]['id']).to eq(resource_groups[i].id) + expect(json_response[i]['key']).to eq(resource_groups[i].key) + expect(json_response[i]['process_mode']).to eq(resource_groups[i].process_mode) + expect(Time.parse(json_response[i]['created_at'])).to be_like_time(resource_groups[i].created_at) + expect(Time.parse(json_response[i]['updated_at'])).to be_like_time(resource_groups[i].updated_at) + end + end + + context 'when user is reporter' do + let(:user) { reporter } + + it 'returns forbidden' do + subject + + expect(response).to have_gitlab_http_status(:forbidden) + end + end + end + describe 'GET /projects/:id/resource_groups/:key' do subject { get api("/projects/#{project.id}/resource_groups/#{key}", user) } |