diff options
author | Marin Jankovski <marin@gitlab.com> | 2019-04-17 20:23:31 +0000 |
---|---|---|
committer | Marin Jankovski <marin@gitlab.com> | 2019-04-17 20:23:31 +0000 |
commit | 807bb47f950f04f8d65764794bf72095d55480ab (patch) | |
tree | 80b9e0773cd7c3b391f9d544c4382a55efa6d14c /spec | |
parent | 2d82633fdd95e0b7b1ea79bc12514ab4f6e71a88 (diff) | |
parent | a364be88a4f4b2a7efafda7d04881b7adde941c7 (diff) | |
download | gitlab-ce-807bb47f950f04f8d65764794bf72095d55480ab.tar.gz |
Merge branch '11-10-stable-prepare-rc8' into '11-10-stable'
Prepare 11.10.0-rc8 release
See merge request gitlab-org/gitlab-ce!27449
Diffstat (limited to 'spec')
-rw-r--r-- | spec/fixtures/api/schemas/entities/merge_request_widget.json | 3 | ||||
-rw-r--r-- | spec/javascripts/diffs/components/diff_file_header_spec.js | 3 | ||||
-rw-r--r-- | spec/javascripts/vue_mr_widget/components/mr_widget_alert_message_spec.js | 63 | ||||
-rw-r--r-- | spec/javascripts/vue_mr_widget/mock_data.js | 1 | ||||
-rw-r--r-- | spec/javascripts/vue_mr_widget/mr_widget_options_spec.js | 79 | ||||
-rw-r--r-- | spec/lib/banzai/filter/suggestion_filter_spec.rb | 27 | ||||
-rw-r--r-- | spec/models/ci/build_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/ci/pipeline_spec.rb | 24 | ||||
-rw-r--r-- | spec/requests/api/merge_requests_spec.rb | 26 | ||||
-rw-r--r-- | spec/services/ci/prepare_build_service_spec.rb | 16 | ||||
-rw-r--r-- | spec/services/ci/retry_build_service_spec.rb | 2 |
11 files changed, 218 insertions, 30 deletions
diff --git a/spec/fixtures/api/schemas/entities/merge_request_widget.json b/spec/fixtures/api/schemas/entities/merge_request_widget.json index 6b1cd60c25d..7018cb9a305 100644 --- a/spec/fixtures/api/schemas/entities/merge_request_widget.json +++ b/spec/fixtures/api/schemas/entities/merge_request_widget.json @@ -125,6 +125,7 @@ "test_reports_path": { "type": ["string", "null"] }, "can_receive_suggestion": { "type": "boolean" }, "source_branch_protected": { "type": "boolean" }, - "conflicts_docs_path": { "type": ["string", "null"] } + "conflicts_docs_path": { "type": ["string", "null"] }, + "merge_request_pipelines_docs_path": { "type": ["string", "null"] } } } diff --git a/spec/javascripts/diffs/components/diff_file_header_spec.js b/spec/javascripts/diffs/components/diff_file_header_spec.js index e1170c9762e..596a1ba5ad2 100644 --- a/spec/javascripts/diffs/components/diff_file_header_spec.js +++ b/spec/javascripts/diffs/components/diff_file_header_spec.js @@ -611,6 +611,9 @@ describe('diff_file_header', () => { vm = mountComponentWithStore(Component, { props, store }); expect(viewFileButton().getAttribute('href')).toBe('view-path'); + expect(viewFileButton().getAttribute('data-original-title')).toEqual( + `View file @ ${props.diffFile.content_sha.substr(0, 8)}`, + ); }); it('should not render external url view link if diff file has no external url', () => { diff --git a/spec/javascripts/vue_mr_widget/components/mr_widget_alert_message_spec.js b/spec/javascripts/vue_mr_widget/components/mr_widget_alert_message_spec.js new file mode 100644 index 00000000000..f115cb457e5 --- /dev/null +++ b/spec/javascripts/vue_mr_widget/components/mr_widget_alert_message_spec.js @@ -0,0 +1,63 @@ +import { shallowMount, createLocalVue } from '@vue/test-utils'; +import MrWidgetAlertMessage from '~/vue_merge_request_widget/components/mr_widget_alert_message.vue'; +import { GlLink } from '@gitlab/ui'; + +describe('MrWidgetAlertMessage', () => { + let wrapper; + + beforeEach(() => { + const localVue = createLocalVue(); + + wrapper = shallowMount(localVue.extend(MrWidgetAlertMessage), { + propsData: {}, + localVue, + }); + }); + + afterEach(() => { + wrapper.destroy(); + }); + + describe('when type is not provided', () => { + it('should render a red message', () => { + expect(wrapper.classes()).toContain('danger_message'); + expect(wrapper.classes()).not.toContain('warning_message'); + }); + }); + + describe('when type === "danger"', () => { + it('should render a red message', () => { + wrapper.setProps({ type: 'danger' }); + + expect(wrapper.classes()).toContain('danger_message'); + expect(wrapper.classes()).not.toContain('warning_message'); + }); + }); + + describe('when type === "warning"', () => { + it('should render a red message', () => { + wrapper.setProps({ type: 'warning' }); + + expect(wrapper.classes()).toContain('warning_message'); + expect(wrapper.classes()).not.toContain('danger_message'); + }); + }); + + describe('when helpPath is not provided', () => { + it('should not render a help icon/link', () => { + const link = wrapper.find(GlLink); + + expect(link.exists()).toBe(false); + }); + }); + + describe('when helpPath is provided', () => { + it('should render a help icon/link', () => { + wrapper.setProps({ helpPath: '/path/to/help/docs' }); + const link = wrapper.find(GlLink); + + expect(link.exists()).toBe(true); + expect(link.attributes().href).toBe('/path/to/help/docs'); + }); + }); +}); diff --git a/spec/javascripts/vue_mr_widget/mock_data.js b/spec/javascripts/vue_mr_widget/mock_data.js index 7ab203a6011..dda16375103 100644 --- a/spec/javascripts/vue_mr_widget/mock_data.js +++ b/spec/javascripts/vue_mr_widget/mock_data.js @@ -233,6 +233,7 @@ export default { merge_commit_path: 'http://localhost:3000/root/acets-app/commit/53027d060246c8f47e4a9310fb332aa52f221775', troubleshooting_docs_path: 'help', + merge_request_pipelines_docs_path: '/help/ci/merge_request_pipelines/index.md', squash: true, }; diff --git a/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js b/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js index 3e8f73646c8..690fcd3e224 100644 --- a/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js +++ b/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js @@ -183,6 +183,85 @@ describe('mrWidgetOptions', () => { }); }); }); + + describe('showMergePipelineForkWarning', () => { + describe('when the source project and target project are the same', () => { + beforeEach(done => { + Vue.set(vm.mr, 'mergePipelinesEnabled', true); + Vue.set(vm.mr, 'sourceProjectId', 1); + Vue.set(vm.mr, 'targetProjectId', 1); + vm.$nextTick(done); + }); + + it('should be false', () => { + expect(vm.showMergePipelineForkWarning).toEqual(false); + }); + }); + + describe('when merge pipelines are not enabled', () => { + beforeEach(done => { + Vue.set(vm.mr, 'mergePipelinesEnabled', false); + Vue.set(vm.mr, 'sourceProjectId', 1); + Vue.set(vm.mr, 'targetProjectId', 2); + vm.$nextTick(done); + }); + + it('should be false', () => { + expect(vm.showMergePipelineForkWarning).toEqual(false); + }); + }); + + describe('when merge pipelines are enabled _and_ the source project and target project are different', () => { + beforeEach(done => { + Vue.set(vm.mr, 'mergePipelinesEnabled', true); + Vue.set(vm.mr, 'sourceProjectId', 1); + Vue.set(vm.mr, 'targetProjectId', 2); + vm.$nextTick(done); + }); + + it('should be true', () => { + expect(vm.showMergePipelineForkWarning).toEqual(true); + }); + }); + }); + + describe('showTargetBranchAdvancedError', () => { + describe(`when the pipeline's target_sha property doesn't exist`, () => { + beforeEach(done => { + Vue.set(vm.mr.pipeline, 'target_sha', undefined); + Vue.set(vm.mr, 'targetBranchSha', 'abcd'); + vm.$nextTick(done); + }); + + it('should be false', () => { + expect(vm.showTargetBranchAdvancedError).toEqual(false); + }); + }); + + describe(`when the pipeline's target_sha matches the target branch's sha`, () => { + beforeEach(done => { + Vue.set(vm.mr.pipeline, 'target_sha', 'abcd'); + Vue.set(vm.mr, 'targetBranchSha', 'abcd'); + vm.$nextTick(done); + }); + + it('should be false', () => { + expect(vm.showTargetBranchAdvancedError).toEqual(false); + }); + }); + + describe(`when the pipeline's target_sha does not match the target branch's sha`, () => { + beforeEach(done => { + Vue.set(vm.mr.pipeline, 'target_sha', 'abcd'); + Vue.set(vm.mr, 'targetBranchSha', 'bcde'); + vm.$nextTick(done); + }); + + it('should be true', () => { + expect(vm.showTargetBranchAdvancedError).toEqual(true); + }); + }); + }); }); describe('methods', () => { diff --git a/spec/lib/banzai/filter/suggestion_filter_spec.rb b/spec/lib/banzai/filter/suggestion_filter_spec.rb index af6f002fa30..9c4650b73de 100644 --- a/spec/lib/banzai/filter/suggestion_filter_spec.rb +++ b/spec/lib/banzai/filter/suggestion_filter_spec.rb @@ -28,30 +28,11 @@ describe Banzai::Filter::SuggestionFilter do let(:data_attr) { Banzai::Filter::SyntaxHighlightFilter::LANG_PARAMS_ATTR } let(:input) { %(<pre class="code highlight js-syntax-highlight suggestion" #{data_attr}="-3+2"><code>foo\n</code></pre>) } - context 'feature disabled' do - before do - stub_feature_flags(multi_line_suggestions: false) - end + it 'element has correct data-lang-params' do + doc = filter(input, default_context) + pre = doc.css('pre').first - it 'removes data-lang-params if it matches a multi-line suggestion param' do - doc = filter(input, default_context) - pre = doc.css('pre').first - - expect(pre[data_attr]).to be_nil - end - end - - context 'feature enabled' do - before do - stub_feature_flags(multi_line_suggestions: true) - end - - it 'keeps data-lang-params' do - doc = filter(input, default_context) - pre = doc.css('pre').first - - expect(pre[data_attr]).to eq('-3+2') - end + expect(pre[data_attr]).to eq('-3+2') end end end diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 1352a2de2d7..66be192ab21 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -166,8 +166,8 @@ describe Ci::Build do end end - describe '.with_test_reports' do - subject { described_class.with_test_reports } + describe '.with_reports' do + subject { described_class.with_reports(Ci::JobArtifact.test_reports) } context 'when build has a test report' do let!(:build) { create(:ci_build, :success, :test_reports) } diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 83b0f172f03..f34aa0d9b03 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -426,6 +426,26 @@ describe Ci::Pipeline, :mailer do end end + describe '.with_reports' do + subject { described_class.with_reports(Ci::JobArtifact.test_reports) } + + context 'when pipeline has a test report' do + let!(:pipeline_with_report) { create(:ci_pipeline, :with_test_reports) } + + it 'selects the pipeline' do + is_expected.to eq([pipeline_with_report]) + end + end + + context 'when pipeline does not have metrics reports' do + let!(:pipeline_without_report) { create(:ci_empty_pipeline) } + + it 'does not select the pipeline' do + is_expected.to be_empty + end + end + end + describe '.merge_request_event' do subject { described_class.merge_request_event } @@ -2728,8 +2748,8 @@ describe Ci::Pipeline, :mailer do end end - describe '#has_test_reports?' do - subject { pipeline.has_test_reports? } + describe '#has_reports?' do + subject { pipeline.has_reports?(Ci::JobArtifact.test_reports) } context 'when pipeline has builds with test reports' do before do diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 7ffa365c651..e148f6033a3 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -1527,6 +1527,32 @@ describe API::MergeRequests do end describe "PUT /projects/:id/merge_requests/:merge_request_iid" do + context 'updates force_remove_source_branch properly' do + it 'sets to false' do + merge_request.update(merge_params: { 'force_remove_source_branch' => true } ) + + expect(merge_request.force_remove_source_branch?).to be_truthy + + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { state_event: "close", remove_source_branch: false } + + expect(response).to have_gitlab_http_status(200) + expect(json_response['state']).to eq('closed') + expect(json_response['force_remove_source_branch']).to be_falsey + end + + it 'sets to true' do + merge_request.update(merge_params: { 'force_remove_source_branch' => false } ) + + expect(merge_request.force_remove_source_branch?).to be_falsey + + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { state_event: "close", remove_source_branch: true } + + expect(response).to have_gitlab_http_status(200) + expect(json_response['state']).to eq('closed') + expect(json_response['force_remove_source_branch']).to be_truthy + end + end + context "to close a MR" do it "returns merge_request" do put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { state_event: "close" } diff --git a/spec/services/ci/prepare_build_service_spec.rb b/spec/services/ci/prepare_build_service_spec.rb index 1797f8f964f..2d027f13e52 100644 --- a/spec/services/ci/prepare_build_service_spec.rb +++ b/spec/services/ci/prepare_build_service_spec.rb @@ -38,7 +38,21 @@ describe Ci::PrepareBuildService do end it 'drops the build' do - expect(build).to receive(:drop!).with(:unmet_prerequisites).once + expect(build).to receive(:drop).with(:unmet_prerequisites).once + + subject + end + end + + context 'prerequisites raise an error' do + before do + allow(prerequisite).to receive(:complete!).and_raise Kubeclient::HttpError.new(401, 'unauthorized', nil) + end + + it 'drops the build and notifies Sentry' do + expect(build).to receive(:drop).with(:unmet_prerequisites).once + expect(Gitlab::Sentry).to receive(:track_acceptable_exception) + .with(instance_of(Kubeclient::HttpError), hash_including(extra: { build_id: build.id })) subject end diff --git a/spec/services/ci/retry_build_service_spec.rb b/spec/services/ci/retry_build_service_spec.rb index 87185891470..7817d6b521a 100644 --- a/spec/services/ci/retry_build_service_spec.rb +++ b/spec/services/ci/retry_build_service_spec.rb @@ -28,7 +28,7 @@ describe Ci::RetryBuildService do job_artifacts_sast job_artifacts_dependency_scanning job_artifacts_container_scanning job_artifacts_dast job_artifacts_license_management job_artifacts_performance - job_artifacts_codequality scheduled_at].freeze + job_artifacts_codequality job_artifacts_metrics scheduled_at].freeze IGNORE_ACCESSORS = %i[type lock_version target_url base_tags trace_sections |