diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/projects/jobs_controller_spec.rb | 16 | ||||
-rw-r--r-- | spec/fixtures/api/schemas/job/job_details.json | 6 | ||||
-rw-r--r-- | spec/javascripts/jobs/components/empty_state_spec.js | 2 | ||||
-rw-r--r-- | spec/javascripts/jobs/components/erased_block_spec.js | 8 | ||||
-rw-r--r-- | spec/javascripts/jobs/components/job_log_controllers_spec.js | 167 | ||||
-rw-r--r-- | spec/javascripts/jobs/components/job_log_spec.js | 6 | ||||
-rw-r--r-- | spec/models/clusters/applications/jupyter_spec.rb | 7 | ||||
-rw-r--r-- | spec/requests/api/commits_spec.rb | 80 | ||||
-rw-r--r-- | spec/services/files/multi_service_spec.rb | 36 |
9 files changed, 218 insertions, 110 deletions
diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb index c82c85970dc..fd11cb31a2a 100644 --- a/spec/controllers/projects/jobs_controller_spec.rb +++ b/spec/controllers/projects/jobs_controller_spec.rb @@ -337,6 +337,22 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do end end end + + context 'when no trace is available' do + it 'has_trace is false' do + expect(response).to match_response_schema('job/job_details') + expect(json_response['has_trace']).to be false + end + end + + context 'when job has trace' do + let(:job) { create(:ci_build, :running, :trace_live, pipeline: pipeline) } + + it "has_trace is true" do + expect(response).to match_response_schema('job/job_details') + expect(json_response['has_trace']).to be true + end + end end context 'when requesting JSON job is triggered' do diff --git a/spec/fixtures/api/schemas/job/job_details.json b/spec/fixtures/api/schemas/job/job_details.json index cd67d3e4160..70d59c6e621 100644 --- a/spec/fixtures/api/schemas/job/job_details.json +++ b/spec/fixtures/api/schemas/job/job_details.json @@ -3,12 +3,16 @@ { "$ref": "job.json" } ], "description": "An extension of job.json with more detailed information", + "required": [ + "has_trace" + ], "properties": { "artifact": { "$ref": "artifact.json" }, "terminal_path": { "type": "string" }, "trigger": { "$ref": "trigger.json" }, "deployment_status": { "$ref": "deployment_status.json" }, "runner": { "$ref": "runner.json" }, - "runners": { "type": "runners.json" } + "runners": { "type": "runners.json" }, + "has_trace": { "type": "boolean" } } } diff --git a/spec/javascripts/jobs/components/empty_state_spec.js b/spec/javascripts/jobs/components/empty_state_spec.js index dcc2b3d8a20..872cc1e3864 100644 --- a/spec/javascripts/jobs/components/empty_state_spec.js +++ b/spec/javascripts/jobs/components/empty_state_spec.js @@ -66,7 +66,7 @@ describe('Empty State', () => { ...props, content, action: { - link: 'runner', + path: 'runner', title: 'Check runner', method: 'post', }, diff --git a/spec/javascripts/jobs/components/erased_block_spec.js b/spec/javascripts/jobs/components/erased_block_spec.js index a4ae0c7c81e..8e0433d3fb7 100644 --- a/spec/javascripts/jobs/components/erased_block_spec.js +++ b/spec/javascripts/jobs/components/erased_block_spec.js @@ -18,9 +18,10 @@ describe('Erased block', () => { describe('with job erased by user', () => { beforeEach(() => { vm = mountComponent(Component, { - erasedByUser: true, - username: 'root', - linkToUser: 'gitlab.com/root', + user: { + username: 'root', + web_url: 'gitlab.com/root', + }, erasedAt, }); }); @@ -40,7 +41,6 @@ describe('Erased block', () => { describe('with erased job', () => { beforeEach(() => { vm = mountComponent(Component, { - erasedByUser: false, erasedAt, }); }); diff --git a/spec/javascripts/jobs/components/job_log_controllers_spec.js b/spec/javascripts/jobs/components/job_log_controllers_spec.js index 416dfab8a48..099aca602c4 100644 --- a/spec/javascripts/jobs/components/job_log_controllers_spec.js +++ b/spec/javascripts/jobs/components/job_log_controllers_spec.js @@ -10,50 +10,51 @@ describe('Job log controllers', () => { vm.$destroy(); }); - describe('Truncate information', () => { + const props = { + rawPath: '/raw', + erasePath: '/erase', + size: 511952, + isScrollTopDisabled: false, + isScrollBottomDisabled: false, + isScrollingDown: true, + isTraceSizeVisible: true, + }; - beforeEach(() => { - vm = mountComponent(Component, { - rawTracePath: '/raw', - canEraseJob: true, - size: 511952, - canScrollToTop: true, - canScrollToBottom: true, + describe('Truncate information', () => { + describe('with isTraceSizeVisible', () => { + beforeEach(() => { + vm = mountComponent(Component, props); + }); + it('renders size information', () => { + expect(vm.$el.querySelector('.js-truncated-info').textContent).toContain('499.95 KiB'); }); - }); - - it('renders size information', () => { - expect(vm.$el.querySelector('.js-truncated-info').textContent).toContain('499.95 KiB'); - }); - it('renders link to raw trace', () => { - expect(vm.$el.querySelector('.js-raw-link').getAttribute('href')).toEqual('/raw'); + it('renders link to raw trace', () => { + expect(vm.$el.querySelector('.js-raw-link').getAttribute('href')).toEqual('/raw'); + }); }); - }); describe('links section', () => { describe('with raw trace path', () => { it('renders raw trace link', () => { - vm = mountComponent(Component, { - rawTracePath: '/raw', - canEraseJob: true, - size: 511952, - canScrollToTop: true, - canScrollToBottom: true, - }); + vm = mountComponent(Component, props); - expect(vm.$el.querySelector('.js-raw-link-controller').getAttribute('href')).toEqual('/raw'); + expect(vm.$el.querySelector('.js-raw-link-controller').getAttribute('href')).toEqual( + '/raw', + ); }); }); describe('without raw trace path', () => { it('does not render raw trace link', () => { vm = mountComponent(Component, { - canEraseJob: true, + erasePath: '/erase', size: 511952, - canScrollToTop: true, - canScrollToBottom: true, + isScrollTopDisabled: true, + isScrollBottomDisabled: true, + isScrollingDown: false, + isTraceSizeVisible: true, }); expect(vm.$el.querySelector('.js-raw-link-controller')).toBeNull(); @@ -62,52 +63,23 @@ describe('Job log controllers', () => { describe('when is erasable', () => { beforeEach(() => { - vm = mountComponent(Component, { - rawTracePath: '/raw', - canEraseJob: true, - size: 511952, - canScrollToTop: true, - canScrollToBottom: true, - }); + vm = mountComponent(Component, props); }); - it('renders erase job button', () => { + it('renders erase job link', () => { expect(vm.$el.querySelector('.js-erase-link')).not.toBeNull(); }); - - describe('on click', () => { - describe('when user confirms action', () => { - it('emits eraseJob event', () => { - spyOn(window, 'confirm').and.returnValue(true); - spyOn(vm, '$emit'); - - vm.$el.querySelector('.js-erase-link').click(); - - expect(vm.$emit).toHaveBeenCalledWith('eraseJob'); - }); - }); - - describe('when user does not confirm action', () => { - it('does not emit eraseJob event', () => { - spyOn(window, 'confirm').and.returnValue(false); - spyOn(vm, '$emit'); - - vm.$el.querySelector('.js-erase-link').click(); - - expect(vm.$emit).not.toHaveBeenCalledWith('eraseJob'); - }); - }); - }); }); describe('when it is not erasable', () => { it('does not render erase button', () => { vm = mountComponent(Component, { - rawTracePath: '/raw', - canEraseJob: false, + rawPath: '/raw', size: 511952, - canScrollToTop: true, - canScrollToBottom: true, + isScrollTopDisabled: true, + isScrollBottomDisabled: true, + isScrollingDown: false, + isTraceSizeVisible: true, }); expect(vm.$el.querySelector('.js-erase-link')).toBeNull(); @@ -119,13 +91,7 @@ describe('Job log controllers', () => { describe('scroll top button', () => { describe('when user can scroll top', () => { beforeEach(() => { - vm = mountComponent(Component, { - rawTracePath: '/raw', - canEraseJob: true, - size: 511952, - canScrollToTop: true, - canScrollToBottom: true, - }); + vm = mountComponent(Component, props); }); it('renders enabled scroll top button', () => { @@ -143,16 +109,20 @@ describe('Job log controllers', () => { describe('when user can not scroll top', () => { beforeEach(() => { vm = mountComponent(Component, { - rawTracePath: '/raw', - canEraseJob: true, + rawPath: '/raw', + erasePath: '/erase', size: 511952, - canScrollToTop: false, - canScrollToBottom: true, + isScrollTopDisabled: true, + isScrollBottomDisabled: false, + isScrollingDown: false, + isTraceSizeVisible: true, }); }); it('renders disabled scroll top button', () => { - expect(vm.$el.querySelector('.js-scroll-top').getAttribute('disabled')).toEqual('disabled'); + expect(vm.$el.querySelector('.js-scroll-top').getAttribute('disabled')).toEqual( + 'disabled', + ); }); it('does not emit scrollJobLogTop event on click', () => { @@ -167,13 +137,7 @@ describe('Job log controllers', () => { describe('scroll bottom button', () => { describe('when user can scroll bottom', () => { beforeEach(() => { - vm = mountComponent(Component, { - rawTracePath: '/raw', - canEraseJob: true, - size: 511952, - canScrollToTop: true, - canScrollToBottom: true, - }); + vm = mountComponent(Component, props); }); it('renders enabled scroll bottom button', () => { @@ -191,17 +155,20 @@ describe('Job log controllers', () => { describe('when user can not scroll bottom', () => { beforeEach(() => { vm = mountComponent(Component, { - rawTracePath: '/raw', - canEraseJob: true, + rawPath: '/raw', + erasePath: '/erase', size: 511952, - canScrollToTop: true, - canScrollToBottom: false, + isScrollTopDisabled: false, + isScrollBottomDisabled: true, + isScrollingDown: false, + isTraceSizeVisible: true, }); }); it('renders disabled scroll bottom button', () => { - expect(vm.$el.querySelector('.js-scroll-bottom').getAttribute('disabled')).toEqual('disabled'); - + expect(vm.$el.querySelector('.js-scroll-bottom').getAttribute('disabled')).toEqual( + 'disabled', + ); }); it('does not emit scrollJobLogBottom event on click', () => { @@ -211,7 +178,29 @@ describe('Job log controllers', () => { expect(vm.$emit).not.toHaveBeenCalledWith('scrollJobLogBottom'); }); }); + + describe('while isScrollingDown is true', () => { + it('renders animate class for the scroll down button', () => { + vm = mountComponent(Component, props); + + expect(vm.$el.querySelector('.js-scroll-bottom').className).toContain('animate'); + }); + }); + + describe('while isScrollingDown is false', () => { + it('does not render animate class for the scroll down button', () => { + vm = mountComponent(Component, { + rawPath: '/raw', + erasePath: '/erase', + size: 511952, + isScrollTopDisabled: true, + isScrollBottomDisabled: false, + isScrollingDown: false, + isTraceSizeVisible: true, + }); + expect(vm.$el.querySelector('.js-scroll-bottom').className).not.toContain('animate'); + }); + }); }); }); }); - diff --git a/spec/javascripts/jobs/components/job_log_spec.js b/spec/javascripts/jobs/components/job_log_spec.js index 6a5b375a26c..1011512360d 100644 --- a/spec/javascripts/jobs/components/job_log_spec.js +++ b/spec/javascripts/jobs/components/job_log_spec.js @@ -15,7 +15,7 @@ describe('Job Log', () => { it('renders provided trace', () => { vm = mountComponent(Component, { trace, - isReceivingBuildTrace: true, + isComplete: true, }); expect(vm.$el.querySelector('code').textContent).toContain('Running with gitlab-runner 11.1.0 (081978aa)'); @@ -25,7 +25,7 @@ describe('Job Log', () => { it('renders animation', () => { vm = mountComponent(Component, { trace, - isReceivingBuildTrace: true, + isComplete: true, }); expect(vm.$el.querySelector('.js-log-animation')).not.toBeNull(); @@ -36,7 +36,7 @@ describe('Job Log', () => { it('does not render animation', () => { vm = mountComponent(Component, { trace, - isReceivingBuildTrace: false, + isComplete: false, }); expect(vm.$el.querySelector('.js-log-animation')).toBeNull(); diff --git a/spec/models/clusters/applications/jupyter_spec.rb b/spec/models/clusters/applications/jupyter_spec.rb index 591a01d78a9..9c4396731eb 100644 --- a/spec/models/clusters/applications/jupyter_spec.rb +++ b/spec/models/clusters/applications/jupyter_spec.rb @@ -108,8 +108,15 @@ describe Clusters::Applications::Jupyter do expect(values).to include('rbac') expect(values).to include('proxy') expect(values).to include('auth') + expect(values).to include('singleuser') expect(values).to match(/clientId: '?#{application.oauth_application.uid}/) expect(values).to match(/callbackUrl: '?#{application.callback_url}/) end + + context 'when cluster belongs to a project' do + it 'sets GitLab project id' do + expect(values).to match(/GITLAB_CLUSTER_ID: '?#{application.cluster.id}/) + end + end end end diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb index d5b31610dad..f3fb88474a4 100644 --- a/spec/requests/api/commits_spec.rb +++ b/spec/requests/api/commits_spec.rb @@ -238,7 +238,7 @@ describe API::Commits do describe 'create' do let(:message) { 'Created file' } - let!(:invalid_c_params) do + let(:invalid_c_params) do { branch: 'master', commit_message: message, @@ -251,7 +251,7 @@ describe API::Commits do ] } end - let!(:valid_c_params) do + let(:valid_c_params) do { branch: 'master', commit_message: message, @@ -264,7 +264,7 @@ describe API::Commits do ] } end - let!(:valid_utf8_c_params) do + let(:valid_utf8_c_params) do { branch: 'master', commit_message: message, @@ -315,7 +315,7 @@ describe API::Commits do describe 'delete' do let(:message) { 'Deleted file' } - let!(:invalid_d_params) do + let(:invalid_d_params) do { branch: 'markdown', commit_message: message, @@ -327,7 +327,7 @@ describe API::Commits do ] } end - let!(:valid_d_params) do + let(:valid_d_params) do { branch: 'markdown', commit_message: message, @@ -356,7 +356,7 @@ describe API::Commits do describe 'move' do let(:message) { 'Moved file' } - let!(:invalid_m_params) do + let(:invalid_m_params) do { branch: 'feature', commit_message: message, @@ -370,7 +370,7 @@ describe API::Commits do ] } end - let!(:valid_m_params) do + let(:valid_m_params) do { branch: 'feature', commit_message: message, @@ -401,7 +401,7 @@ describe API::Commits do describe 'update' do let(:message) { 'Updated file' } - let!(:invalid_u_params) do + let(:invalid_u_params) do { branch: 'master', commit_message: message, @@ -414,7 +414,7 @@ describe API::Commits do ] } end - let!(:valid_u_params) do + let(:valid_u_params) do { branch: 'master', commit_message: message, @@ -442,9 +442,57 @@ describe API::Commits do end end + describe 'chmod' do + let(:message) { 'Chmod +x file' } + let(:file_path) { 'files/ruby/popen.rb' } + let(:execute_filemode) { true } + let(:params) do + { + branch: 'master', + commit_message: message, + actions: [ + { + action: 'chmod', + file_path: file_path, + execute_filemode: execute_filemode + } + ] + } + end + + it 'responds with success' do + post api(url, user), params + + expect(response).to have_gitlab_http_status(201) + expect(json_response['title']).to eq(message) + end + + context 'when execute_filemode is false' do + let(:execute_filemode) { false } + + it 'responds with success' do + post api(url, user), params + + expect(response).to have_gitlab_http_status(201) + expect(json_response['title']).to eq(message) + end + end + + context "when the file doesn't exists" do + let(:file_path) { 'foo/bar.baz' } + + it "responds with 400" do + post api(url, user), params + + expect(response).to have_gitlab_http_status(400) + expect(json_response['message']).to eq("A file with this name doesn't exist") + end + end + end + describe 'multiple operations' do let(:message) { 'Multiple actions' } - let!(:invalid_mo_params) do + let(:invalid_mo_params) do { branch: 'master', commit_message: message, @@ -468,11 +516,16 @@ describe API::Commits do action: 'update', file_path: 'foo/bar.baz', content: 'puts 8' + }, + { + action: 'chmod', + file_path: 'files/ruby/popen.rb', + execute_filemode: true } ] } end - let!(:valid_mo_params) do + let(:valid_mo_params) do { branch: 'master', commit_message: message, @@ -496,6 +549,11 @@ describe API::Commits do action: 'update', file_path: 'files/ruby/popen.rb', content: 'puts 8' + }, + { + action: 'chmod', + file_path: 'files/ruby/popen.rb', + execute_filemode: true } ] } diff --git a/spec/services/files/multi_service_spec.rb b/spec/services/files/multi_service_spec.rb index 3bdedaf3770..5f3c8e82715 100644 --- a/spec/services/files/multi_service_spec.rb +++ b/spec/services/files/multi_service_spec.rb @@ -11,6 +11,7 @@ describe Files::MultiService do let(:new_file_path) { 'files/ruby/popen.rb' } let(:file_content) { 'New content' } let(:action) { 'update' } + let(:commit_message) { 'Update File' } let!(:original_commit_id) do Gitlab::Git::Commit.last_for_path(project.repository, branch_name, original_file_path).sha @@ -30,7 +31,7 @@ describe Files::MultiService do let(:commit_params) do { - commit_message: "Update File", + commit_message: commit_message, branch_name: branch_name, start_branch: branch_name, actions: actions @@ -84,6 +85,39 @@ describe Files::MultiService do end end + describe 'changing execute_filemode of a file' do + let(:commit_message) { 'Chmod +x file' } + let(:file_path) { original_file_path } + let(:default_action) do + { + action: 'chmod', + file_path: file_path, + execute_filemode: true + } + end + + it 'accepts the commit' do + results = subject.execute + + expect(results[:status]).to eq(:success) + end + + it 'updates the execute_filemode of the file' do + expect { subject.execute }.to change { repository.blob_at_branch(branch_name, file_path).mode }.from('100644').to('100755') + end + + context "when the file doesn't exists" do + let(:file_path) { 'files/wrong_path.rb' } + + it 'rejects the commit' do + results = subject.execute + + expect(results[:status]).to eq(:error) + expect(results[:message]).to eq("A file with this name doesn't exist") + end + end + end + context 'when moving a file' do let(:action) { 'move' } let(:new_file_path) { 'files/ruby/new_popen.rb' } |