diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-23 18:09:25 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-23 18:09:25 +0000 |
commit | 967812838c7e7742729a4c7aeb9859f98a509622 (patch) | |
tree | 22db2e6642be51cb12535db7863331457e5523c3 /spec | |
parent | 074d013e1eb3f6e0c27f96a3be8b9361254c8a98 (diff) | |
download | gitlab-ce-967812838c7e7742729a4c7aeb9859f98a509622.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/frontend/cycle_analytics/banner_spec.js (renamed from spec/javascripts/cycle_analytics/banner_spec.js) | 4 | ||||
-rw-r--r-- | spec/frontend/cycle_analytics/total_time_component_spec.js (renamed from spec/javascripts/cycle_analytics/total_time_component_spec.js) | 2 | ||||
-rw-r--r-- | spec/frontend/diffs/components/diff_file_header_spec.js | 6 | ||||
-rw-r--r-- | spec/frontend/vue_shared/components/file_row_spec.js | 13 | ||||
-rw-r--r-- | spec/lib/gitlab/http_spec.rb | 123 | ||||
-rw-r--r-- | spec/models/project_services/teamcity_service_spec.rb | 22 | ||||
-rw-r--r-- | spec/services/ci/create_cross_project_pipeline_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/workers/authorized_keys_worker_spec.rb | 12 | ||||
-rw-r--r-- | spec/workers/gitlab_shell_worker_spec.rb | 6 |
9 files changed, 177 insertions, 13 deletions
diff --git a/spec/javascripts/cycle_analytics/banner_spec.js b/spec/frontend/cycle_analytics/banner_spec.js index 06fbaa68ffc..f0b8cb18a90 100644 --- a/spec/javascripts/cycle_analytics/banner_spec.js +++ b/spec/frontend/cycle_analytics/banner_spec.js @@ -1,5 +1,5 @@ import Vue from 'vue'; -import mountComponent from 'spec/helpers/vue_mount_component_helper'; +import mountComponent from 'helpers/vue_mount_component_helper'; import banner from '~/cycle_analytics/components/banner.vue'; describe('Cycle analytics banner', () => { @@ -36,7 +36,7 @@ describe('Cycle analytics banner', () => { }); it('should emit an event when close button is clicked', () => { - spyOn(vm, '$emit'); + jest.spyOn(vm, '$emit').mockImplementation(() => {}); vm.$el.querySelector('.js-ca-dismiss-button').click(); diff --git a/spec/javascripts/cycle_analytics/total_time_component_spec.js b/spec/frontend/cycle_analytics/total_time_component_spec.js index 0269fc1b002..0f7f2628aca 100644 --- a/spec/javascripts/cycle_analytics/total_time_component_spec.js +++ b/spec/frontend/cycle_analytics/total_time_component_spec.js @@ -1,5 +1,5 @@ import Vue from 'vue'; -import mountComponent from 'spec/helpers/vue_mount_component_helper'; +import mountComponent from 'helpers/vue_mount_component_helper'; import component from '~/cycle_analytics/components/total_time_component.vue'; describe('Total time component', () => { diff --git a/spec/frontend/diffs/components/diff_file_header_spec.js b/spec/frontend/diffs/components/diff_file_header_spec.js index e0b7e0bc0f3..8e6a5576015 100644 --- a/spec/frontend/diffs/components/diff_file_header_spec.js +++ b/spec/frontend/diffs/components/diff_file_header_spec.js @@ -61,6 +61,7 @@ describe('DiffFileHeader component', () => { const findTitleLink = () => wrapper.find({ ref: 'titleWrapper' }); const findExpandButton = () => wrapper.find({ ref: 'expandDiffToFullFileButton' }); const findFileActions = () => wrapper.find('.file-actions'); + const findActiveHeader = () => wrapper.find('.is-active'); const findModeChangedLine = () => wrapper.find({ ref: 'fileMode' }); const findLfsLabel = () => wrapper.find('.label-lfs'); const findToggleDiscussionsButton = () => wrapper.find({ ref: 'toggleDiscussionsButton' }); @@ -143,6 +144,11 @@ describe('DiffFileHeader component', () => { expect(wrapper.find(ClipboardButton).exists()).toBe(true); }); + it('contains a active header class if this is the active file header', () => { + createComponent({ isActive: true }); + expect(findActiveHeader().exists()).toBe(true); + }); + describe('for submodule', () => { const submoduleDiffFile = { ...diffFile, diff --git a/spec/frontend/vue_shared/components/file_row_spec.js b/spec/frontend/vue_shared/components/file_row_spec.js index b3ced84ddb5..75d1ce9cc5b 100644 --- a/spec/frontend/vue_shared/components/file_row_spec.js +++ b/spec/frontend/vue_shared/components/file_row_spec.js @@ -72,6 +72,19 @@ describe('File row component', () => { }); }); + it('is marked as viewed if clicked', () => { + createComponent({ + file: { + ...file(), + type: 'blob', + fileHash: '#123456789', + }, + level: 0, + viewedFiles: ['#123456789'], + }); + expect(wrapper.classes()).toContain('is-viewed'); + }); + it('indents row based on level', () => { createComponent({ file: file('t4'), diff --git a/spec/lib/gitlab/http_spec.rb b/spec/lib/gitlab/http_spec.rb index 192816ad057..85cfc8e2852 100644 --- a/spec/lib/gitlab/http_spec.rb +++ b/spec/lib/gitlab/http_spec.rb @@ -100,4 +100,127 @@ describe Gitlab::HTTP do expect { described_class.head('http://example.org') }.to raise_error(Gitlab::HTTP::RedirectionTooDeep) end end + + describe '.try_get' do + let(:path) { 'http://example.org' } + + let(:extra_log_info_proc) do + proc do |error, url, options| + { klass: error.class, url: url, options: options } + end + end + + let(:request_options) do + { + verify: false, + basic_auth: { username: 'user', password: 'pass' } + } + end + + described_class::HTTP_ERRORS.each do |exception_class| + context "with #{exception_class}" do + let(:klass) { exception_class } + + context 'with path' do + before do + expect(described_class).to receive(:get) + .with(path, {}) + .and_raise(klass) + end + + it 'handles requests without extra_log_info' do + expect(Gitlab::ErrorTracking) + .to receive(:log_exception) + .with(instance_of(klass), {}) + + expect(described_class.try_get(path)).to be_nil + end + + it 'handles requests with extra_log_info as hash' do + expect(Gitlab::ErrorTracking) + .to receive(:log_exception) + .with(instance_of(klass), { a: :b }) + + expect(described_class.try_get(path, extra_log_info: { a: :b })).to be_nil + end + + it 'handles requests with extra_log_info as proc' do + expect(Gitlab::ErrorTracking) + .to receive(:log_exception) + .with(instance_of(klass), { url: path, klass: klass, options: {} }) + + expect(described_class.try_get(path, extra_log_info: extra_log_info_proc)).to be_nil + end + end + + context 'with path and options' do + before do + expect(described_class).to receive(:get) + .with(path, request_options) + .and_raise(klass) + end + + it 'handles requests without extra_log_info' do + expect(Gitlab::ErrorTracking) + .to receive(:log_exception) + .with(instance_of(klass), {}) + + expect(described_class.try_get(path, request_options)).to be_nil + end + + it 'handles requests with extra_log_info as hash' do + expect(Gitlab::ErrorTracking) + .to receive(:log_exception) + .with(instance_of(klass), { a: :b }) + + expect(described_class.try_get(path, **request_options, extra_log_info: { a: :b })).to be_nil + end + + it 'handles requests with extra_log_info as proc' do + expect(Gitlab::ErrorTracking) + .to receive(:log_exception) + .with(instance_of(klass), { klass: klass, url: path, options: request_options }) + + expect(described_class.try_get(path, **request_options, extra_log_info: extra_log_info_proc)).to be_nil + end + end + + context 'with path, options, and block' do + let(:block) do + proc {} + end + + before do + expect(described_class).to receive(:get) + .with(path, request_options, &block) + .and_raise(klass) + end + + it 'handles requests without extra_log_info' do + expect(Gitlab::ErrorTracking) + .to receive(:log_exception) + .with(instance_of(klass), {}) + + expect(described_class.try_get(path, request_options, &block)).to be_nil + end + + it 'handles requests with extra_log_info as hash' do + expect(Gitlab::ErrorTracking) + .to receive(:log_exception) + .with(instance_of(klass), { a: :b }) + + expect(described_class.try_get(path, **request_options, extra_log_info: { a: :b }, &block)).to be_nil + end + + it 'handles requests with extra_log_info as proc' do + expect(Gitlab::ErrorTracking) + .to receive(:log_exception) + .with(instance_of(klass), { klass: klass, url: path, options: request_options }) + + expect(described_class.try_get(path, **request_options, extra_log_info: extra_log_info_proc, &block)).to be_nil + end + end + end + end + end end diff --git a/spec/models/project_services/teamcity_service_spec.rb b/spec/models/project_services/teamcity_service_spec.rb index 3d875bc49e7..0dd77b68588 100644 --- a/spec/models/project_services/teamcity_service_spec.rb +++ b/spec/models/project_services/teamcity_service_spec.rb @@ -7,6 +7,7 @@ describe TeamcityService, :use_clean_rails_memory_store_caching do include StubRequests let(:teamcity_url) { 'http://gitlab.com/teamcity' } + let(:teamcity_full_url) { 'http://gitlab.com/teamcity/httpAuth/app/rest/builds/branch:unspecified:any,revision:123' } let(:project) { create(:project) } subject(:service) do @@ -165,6 +166,16 @@ describe TeamcityService, :use_clean_rails_memory_store_caching do is_expected.to eq('http://gitlab.com/teamcity/viewLog.html?buildId=666&buildTypeId=foo') end end + + it 'returns the teamcity_url when teamcity is unreachable' do + stub_full_request(teamcity_full_url).to_raise(Errno::ECONNREFUSED) + + expect(Gitlab::ErrorTracking) + .to receive(:log_exception) + .with(instance_of(Errno::ECONNREFUSED), project_id: project.id) + + is_expected.to eq(teamcity_url) + end end context 'commit_status' do @@ -205,6 +216,16 @@ describe TeamcityService, :use_clean_rails_memory_store_caching do is_expected.to eq(:error) end + + it 'sets commit status to :error when teamcity is unreachable' do + stub_full_request(teamcity_full_url).to_raise(Errno::ECONNREFUSED) + + expect(Gitlab::ErrorTracking) + .to receive(:log_exception) + .with(instance_of(Errno::ECONNREFUSED), project_id: project.id) + + is_expected.to eq(:error) + end end end @@ -300,7 +321,6 @@ describe TeamcityService, :use_clean_rails_memory_store_caching do end def stub_request(status: 200, body: nil, build_status: 'success') - teamcity_full_url = 'http://gitlab.com/teamcity/httpAuth/app/rest/builds/branch:unspecified:any,revision:123' auth = %w(mic password) body ||= %Q({"build":{"status":"#{build_status}","id":"666"}}) diff --git a/spec/services/ci/create_cross_project_pipeline_service_spec.rb b/spec/services/ci/create_cross_project_pipeline_service_spec.rb index 99c44c3aa17..a411244e57f 100644 --- a/spec/services/ci/create_cross_project_pipeline_service_spec.rb +++ b/spec/services/ci/create_cross_project_pipeline_service_spec.rb @@ -215,7 +215,7 @@ describe Ci::CreateCrossProjectPipelineService, '#execute' do pipeline = service.execute(bridge) pipeline.reload - expect(pipeline.builds.map(&:name)).to eq %w[rspec echo] + expect(pipeline.builds.map(&:name)).to match_array(%w[rspec echo]) expect(pipeline.user).to eq bridge.user expect(pipeline.project).to eq bridge.project expect(bridge.sourced_pipelines.first.pipeline).to eq pipeline diff --git a/spec/workers/authorized_keys_worker_spec.rb b/spec/workers/authorized_keys_worker_spec.rb index 2aaa6fb2ddf..4f1dde0bfc0 100644 --- a/spec/workers/authorized_keys_worker_spec.rb +++ b/spec/workers/authorized_keys_worker_spec.rb @@ -17,7 +17,7 @@ describe AuthorizedKeysWorker do expect(instance).to receive(:add_key).with('foo', 'bar') end - worker.perform(:add_key, 'foo', 'bar') + worker.perform('add_key', 'foo', 'bar') end end @@ -27,15 +27,17 @@ describe AuthorizedKeysWorker do expect(instance).to receive(:remove_key).with('foo', 'bar') end - worker.perform(:remove_key, 'foo', 'bar') + worker.perform('remove_key', 'foo', 'bar') end end describe 'all other commands' do - it 'does nothing' do + it 'raises an error' do expect(Gitlab::AuthorizedKeys).not_to receive(:new) - worker.perform(:foo, 'bar', 'baz') + expect do + worker.perform('foo', 'bar', 'baz') + end.to raise_error('Unknown action: "foo"') end end end @@ -48,7 +50,7 @@ describe AuthorizedKeysWorker do it 'does nothing' do expect(Gitlab::AuthorizedKeys).not_to receive(:new) - worker.perform(:add_key, 'foo', 'bar') + worker.perform('add_key', 'foo', 'bar') end end end diff --git a/spec/workers/gitlab_shell_worker_spec.rb b/spec/workers/gitlab_shell_worker_spec.rb index f5884e5e8f8..0e63f48d3e8 100644 --- a/spec/workers/gitlab_shell_worker_spec.rb +++ b/spec/workers/gitlab_shell_worker_spec.rb @@ -12,7 +12,7 @@ describe GitlabShellWorker do expect(instance).to receive(:add_key).with('foo', 'bar') end - worker.perform(:add_key, 'foo', 'bar') + worker.perform('add_key', 'foo', 'bar') end end @@ -22,7 +22,7 @@ describe GitlabShellWorker do expect(instance).to receive(:remove_key).with('foo', 'bar') end - worker.perform(:remove_key, 'foo', 'bar') + worker.perform('remove_key', 'foo', 'bar') end end @@ -32,7 +32,7 @@ describe GitlabShellWorker do expect(instance).to receive(:foo).with('bar', 'baz') end - worker.perform(:foo, 'bar', 'baz') + worker.perform('foo', 'bar', 'baz') end end end |