diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-09-17 18:10:41 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-09-17 18:10:41 +0300 |
commit | 0a4b459d9c010998c7fdaf058bee4323a6f79973 (patch) | |
tree | 95b09dbcd34d458d70cf90f5aeeca29f6c2107b8 /spec/controllers | |
parent | 50cb63533ff4d90ae317b20157c3fd824783fd61 (diff) | |
parent | 5328f7d15d1d1d7baecb30d7dfa0f9ee160bc64a (diff) |
Merge branch '51093-add-runner-json-schema-and-factory' into 'master'
Resolve "Add runner JSON schema"
Closes #51093
See merge request gitlab-org/gitlab-ce!21525
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/projects/jobs_controller_spec.rb | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb index 706f801a285..19c46e2f309 100644 --- a/spec/controllers/projects/jobs_controller_spec.rb +++ b/spec/controllers/projects/jobs_controller_spec.rb @@ -229,6 +229,65 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do expect(json_response['deployment_status']["environment"]).not_to be_nil end end + + context 'when user can edit runner' do + context 'that belongs to the project' do + let(:runner) { create(:ci_runner, :project, projects: [project]) } + let(:job) { create(:ci_build, :success, pipeline: pipeline, runner: runner) } + + before do + project.add_maintainer(user) + sign_in(user) + + get_show(id: job.id, format: :json) + end + + it 'user can edit runner' do + expect(response).to have_gitlab_http_status(:ok) + expect(response).to match_response_schema('job/job_details') + expect(json_response['runner']).to have_key('edit_path') + end + end + + context 'that belongs to group' do + let(:group) { create(:group) } + let(:runner) { create(:ci_runner, :group, groups: [group]) } + let(:job) { create(:ci_build, :success, pipeline: pipeline, runner: runner) } + let(:user) { create(:user, :admin) } + + before do + project.add_maintainer(user) + sign_in(user) + + get_show(id: job.id, format: :json) + end + + it 'user can not edit runner' do + expect(response).to have_gitlab_http_status(:ok) + expect(response).to match_response_schema('job/job_details') + expect(json_response['runner']).not_to have_key('edit_path') + end + end + + context 'that belongs to instance' do + let(:runner) { create(:ci_runner, :instance) } + let(:job) { create(:ci_build, :success, pipeline: pipeline, runner: runner) } + let(:user) { create(:user, :admin) } + + before do + project.add_maintainer(user) + sign_in(user) + + get_show(id: job.id, format: :json) + end + + it 'user can not edit runner' do + expect(response).to have_gitlab_http_status(:ok) + expect(response).to match_response_schema('job/job_details') + expect(json_response['runner']).not_to have_key('edit_path') + end + end + end end context 'when requesting JSON job is triggered' do |