From cefe554b7ce2d0b52f9de855be832a47c2bc24ab Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 18 Feb 2020 06:09:06 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../projects/pipelines_controller_spec.rb | 12 ++++- .../installing_applications_shared_examples.rb | 2 + spec/features/dashboard/projects_spec.rb | 55 ---------------------- .../stores/modules/file_templates/getters_spec.js | 6 +-- .../ide/components/activity_bar_spec.js | 10 ++-- .../ide/components/commit_sidebar/form_spec.js | 8 ++-- .../ide/components/ide_side_bar_spec.js | 4 +- .../javascripts/ide/components/repo_editor_spec.js | 6 +-- .../ide/stores/actions/merge_request_spec.js | 4 +- spec/serializers/pipeline_details_entity_spec.rb | 39 +++++++++++++++ 10 files changed, 71 insertions(+), 75 deletions(-) (limited to 'spec') diff --git a/spec/controllers/projects/pipelines_controller_spec.rb b/spec/controllers/projects/pipelines_controller_spec.rb index fbb77304ce9..fd33f32e877 100644 --- a/spec/controllers/projects/pipelines_controller_spec.rb +++ b/spec/controllers/projects/pipelines_controller_spec.rb @@ -171,7 +171,17 @@ describe Projects::PipelinesController do def create_build(pipeline, stage, stage_idx, name, user = nil) status = %w[created running pending success failed canceled].sample - create(:ci_build, pipeline: pipeline, stage: stage, stage_idx: stage_idx, name: name, status: status, user: user) + create( + :ci_build, + :artifacts, + artifacts_expire_at: 2.days.from_now, + pipeline: pipeline, + stage: stage, + stage_idx: stage_idx, + name: name, + status: status, + user: user + ) end end diff --git a/spec/features/clusters/installing_applications_shared_examples.rb b/spec/features/clusters/installing_applications_shared_examples.rb index 20648ed3d46..ff44ce46213 100644 --- a/spec/features/clusters/installing_applications_shared_examples.rb +++ b/spec/features/clusters/installing_applications_shared_examples.rb @@ -187,6 +187,8 @@ shared_examples "installing applications on a cluster" do page.within('.js-cluster-application-row-elastic_stack') do click_button 'Install' end + + wait_for_requests end it 'shows status transition' do diff --git a/spec/features/dashboard/projects_spec.rb b/spec/features/dashboard/projects_spec.rb index 73f759f8a54..9bd2e85e3b8 100644 --- a/spec/features/dashboard/projects_spec.rb +++ b/spec/features/dashboard/projects_spec.rb @@ -152,61 +152,6 @@ describe 'Dashboard Projects' do end end - describe 'with a pipeline', :clean_gitlab_redis_shared_state do - let(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit.sha, ref: project.default_branch) } - - before do - # Since the cache isn't updated when a new pipeline is created - # we need the pipeline to advance in the pipeline since the cache was created - # by visiting the login page. - pipeline.succeed - end - - it 'shows that the last pipeline passed' do - visit dashboard_projects_path - - page.within('.controls') do - expect(page).to have_xpath("//a[@href='#{pipelines_project_commit_path(project, project.commit, ref: pipeline.ref)}']") - expect(page).to have_css('.ci-status-link') - expect(page).to have_css('.ci-status-icon-success') - expect(page).to have_link('Pipeline: passed') - end - end - - shared_examples 'hidden pipeline status' do - it 'does not show the pipeline status' do - visit dashboard_projects_path - - page.within('.controls') do - expect(page).not_to have_xpath("//a[@href='#{pipelines_project_commit_path(project, project.commit, ref: pipeline.ref)}']") - expect(page).not_to have_css('.ci-status-link') - expect(page).not_to have_css('.ci-status-icon-success') - expect(page).not_to have_link('Pipeline: passed') - end - end - end - - context 'guest user of project and project has private pipelines' do - let(:guest_user) { create(:user) } - - before do - project.update(public_builds: false) - project.add_guest(guest_user) - sign_in(guest_user) - end - - it_behaves_like 'hidden pipeline status' - end - - context 'when dashboard_pipeline_status is disabled' do - before do - stub_feature_flags(dashboard_pipeline_status: false) - end - - it_behaves_like 'hidden pipeline status' - end - end - context 'last push widget', :use_clean_rails_memory_store_caching do before do event = create(:push_event, project: project, author: user) diff --git a/spec/frontend/ide/stores/modules/file_templates/getters_spec.js b/spec/frontend/ide/stores/modules/file_templates/getters_spec.js index 17cb457881f..5855496a330 100644 --- a/spec/frontend/ide/stores/modules/file_templates/getters_spec.js +++ b/spec/frontend/ide/stores/modules/file_templates/getters_spec.js @@ -1,5 +1,5 @@ import createState from '~/ide/stores/state'; -import { activityBarViews } from '~/ide/constants'; +import { leftSidebarViews } from '~/ide/constants'; import * as getters from '~/ide/stores/modules/file_templates/getters'; describe('IDE file templates getters', () => { @@ -17,7 +17,7 @@ describe('IDE file templates getters', () => { }); it('returns true if template is found and currentActivityView is edit', () => { - rootState.currentActivityView = activityBarViews.edit; + rootState.currentActivityView = leftSidebarViews.edit.name; expect( getters.showFileTemplatesBar( @@ -31,7 +31,7 @@ describe('IDE file templates getters', () => { }); it('returns false if template is found and currentActivityView is not edit', () => { - rootState.currentActivityView = activityBarViews.commit; + rootState.currentActivityView = leftSidebarViews.commit.name; expect( getters.showFileTemplatesBar( diff --git a/spec/javascripts/ide/components/activity_bar_spec.js b/spec/javascripts/ide/components/activity_bar_spec.js index 4d878e633fe..823ca29dab9 100644 --- a/spec/javascripts/ide/components/activity_bar_spec.js +++ b/spec/javascripts/ide/components/activity_bar_spec.js @@ -1,6 +1,6 @@ import Vue from 'vue'; import store from '~/ide/stores'; -import { activityBarViews } from '~/ide/constants'; +import { leftSidebarViews } from '~/ide/constants'; import ActivityBar from '~/ide/components/activity_bar.vue'; import { createComponentWithStore } from '../../helpers/vue_mount_component_helper'; import { resetStore } from '../helpers'; @@ -34,19 +34,19 @@ describe('IDE activity bar', () => { it('calls updateActivityBarView with edit value on click', () => { vm.$el.querySelector('.js-ide-edit-mode').click(); - expect(vm.updateActivityBarView).toHaveBeenCalledWith(activityBarViews.edit); + expect(vm.updateActivityBarView).toHaveBeenCalledWith(leftSidebarViews.edit.name); }); it('calls updateActivityBarView with commit value on click', () => { vm.$el.querySelector('.js-ide-commit-mode').click(); - expect(vm.updateActivityBarView).toHaveBeenCalledWith(activityBarViews.commit); + expect(vm.updateActivityBarView).toHaveBeenCalledWith(leftSidebarViews.commit.name); }); it('calls updateActivityBarView with review value on click', () => { vm.$el.querySelector('.js-ide-review-mode').click(); - expect(vm.updateActivityBarView).toHaveBeenCalledWith(activityBarViews.review); + expect(vm.updateActivityBarView).toHaveBeenCalledWith(leftSidebarViews.review.name); }); }); @@ -60,7 +60,7 @@ describe('IDE activity bar', () => { }); it('sets commit item active', done => { - vm.$store.state.currentActivityView = activityBarViews.commit; + vm.$store.state.currentActivityView = leftSidebarViews.commit.name; vm.$nextTick(() => { expect(vm.$el.querySelector('.js-ide-commit-mode').classList).toContain('active'); diff --git a/spec/javascripts/ide/components/commit_sidebar/form_spec.js b/spec/javascripts/ide/components/commit_sidebar/form_spec.js index 9ee0cbdd3d4..5cb804938ed 100644 --- a/spec/javascripts/ide/components/commit_sidebar/form_spec.js +++ b/spec/javascripts/ide/components/commit_sidebar/form_spec.js @@ -4,7 +4,7 @@ import getSetTimeoutPromise from 'spec/helpers/set_timeout_promise_helper'; import { projectData } from 'spec/ide/mock_data'; import store from '~/ide/stores'; import CommitForm from '~/ide/components/commit_sidebar/form.vue'; -import { activityBarViews } from '~/ide/constants'; +import { leftSidebarViews } from '~/ide/constants'; import { resetStore } from '../../helpers'; describe('IDE commit form', () => { @@ -71,7 +71,7 @@ describe('IDE commit form', () => { vm.$el.querySelector('.btn-primary').click(); vm.$nextTick(() => { - expect(store.state.currentActivityView).toBe(activityBarViews.commit); + expect(store.state.currentActivityView).toBe(leftSidebarViews.commit.name); done(); }); @@ -79,7 +79,7 @@ describe('IDE commit form', () => { it('collapses if lastCommitMsg is set to empty and current view is not commit view', done => { store.state.lastCommitMsg = 'abc'; - store.state.currentActivityView = activityBarViews.edit; + store.state.currentActivityView = leftSidebarViews.edit.name; vm.$nextTick(() => { // if commit message is set, form is uncollapsed @@ -133,7 +133,7 @@ describe('IDE commit form', () => { vm.$el.querySelector('.btn-primary').click(); vm.$nextTick(() => { - expect(store.state.currentActivityView).toBe(activityBarViews.commit); + expect(store.state.currentActivityView).toBe(leftSidebarViews.commit.name); expect(vm.isCompact).toBe(false); done(); diff --git a/spec/javascripts/ide/components/ide_side_bar_spec.js b/spec/javascripts/ide/components/ide_side_bar_spec.js index a2d15462ac5..28f127a61c0 100644 --- a/spec/javascripts/ide/components/ide_side_bar_spec.js +++ b/spec/javascripts/ide/components/ide_side_bar_spec.js @@ -2,7 +2,7 @@ import Vue from 'vue'; import { createComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; import store from '~/ide/stores'; import ideSidebar from '~/ide/components/ide_side_bar.vue'; -import { activityBarViews } from '~/ide/constants'; +import { leftSidebarViews } from '~/ide/constants'; import { resetStore } from '../helpers'; import { projectData } from '../mock_data'; @@ -45,7 +45,7 @@ describe('IdeSidebar', () => { }); it('renders commit component', done => { - vm.$store.state.currentActivityView = activityBarViews.commit; + vm.$store.state.currentActivityView = leftSidebarViews.commit.name; vm.$nextTick(() => { expect(vm.$el.querySelector('.multi-file-commit-panel-section')).not.toBeNull(); diff --git a/spec/javascripts/ide/components/repo_editor_spec.js b/spec/javascripts/ide/components/repo_editor_spec.js index 8935d8f56fc..ef0299f0d56 100644 --- a/spec/javascripts/ide/components/repo_editor_spec.js +++ b/spec/javascripts/ide/components/repo_editor_spec.js @@ -5,7 +5,7 @@ import axios from '~/lib/utils/axios_utils'; import store from '~/ide/stores'; import repoEditor from '~/ide/components/repo_editor.vue'; import Editor from '~/ide/lib/editor'; -import { activityBarViews, FILE_VIEW_MODE_EDITOR, FILE_VIEW_MODE_PREVIEW } from '~/ide/constants'; +import { leftSidebarViews, FILE_VIEW_MODE_EDITOR, FILE_VIEW_MODE_PREVIEW } from '~/ide/constants'; import { createComponentWithStore } from '../../helpers/vue_mount_component_helper'; import setTimeoutPromise from '../../helpers/set_timeout_promise_helper'; import { file, resetStore } from '../helpers'; @@ -359,7 +359,7 @@ describe('RepoEditor', () => { }); it('hides tabs in review mode', done => { - vm.$store.state.currentActivityView = activityBarViews.review; + vm.$store.state.currentActivityView = leftSidebarViews.review.name; vm.$nextTick(() => { expect(vm.$el.querySelector('.nav-links')).toBe(null); @@ -369,7 +369,7 @@ describe('RepoEditor', () => { }); it('hides tabs in commit mode', done => { - vm.$store.state.currentActivityView = activityBarViews.commit; + vm.$store.state.currentActivityView = leftSidebarViews.commit.name; vm.$nextTick(() => { expect(vm.$el.querySelector('.nav-links')).toBe(null); diff --git a/spec/javascripts/ide/stores/actions/merge_request_spec.js b/spec/javascripts/ide/stores/actions/merge_request_spec.js index 4917984cd42..ce09cf51ac5 100644 --- a/spec/javascripts/ide/stores/actions/merge_request_spec.js +++ b/spec/javascripts/ide/stores/actions/merge_request_spec.js @@ -8,7 +8,7 @@ import actions, { openMergeRequest, } from '~/ide/stores/actions/merge_request'; import service from '~/ide/services'; -import { activityBarViews, PERMISSION_READ_MR } from '~/ide/constants'; +import { leftSidebarViews, PERMISSION_READ_MR } from '~/ide/constants'; import { resetStore } from '../../helpers'; const TEST_PROJECT = 'abcproject'; @@ -470,7 +470,7 @@ describe('IDE store merge request actions', () => { .then(() => { expect(store.dispatch).toHaveBeenCalledWith( 'updateActivityBarView', - activityBarViews.review, + leftSidebarViews.review.name, ); testMergeRequestChanges.changes.forEach((change, i) => { diff --git a/spec/serializers/pipeline_details_entity_spec.rb b/spec/serializers/pipeline_details_entity_spec.rb index 9ce7c265e43..f270f9fd4cb 100644 --- a/spec/serializers/pipeline_details_entity_spec.rb +++ b/spec/serializers/pipeline_details_entity_spec.rb @@ -173,5 +173,44 @@ describe PipelineDetailsEntity do expect(subject[:triggered].first[:project]).not_to be_nil end end + + context 'when pipeline has expiring archive artifacts' do + let(:pipeline) { create(:ci_empty_pipeline) } + let!(:build_1) { create(:ci_build, :artifacts, pipeline: pipeline, artifacts_expire_at: 2.days.from_now, name: 'build_1') } + let!(:build_2) { create(:ci_build, :artifacts, pipeline: pipeline, artifacts_expire_at: 2.days.from_now, name: 'build_2') } + let!(:build_3) { create(:ci_build, :artifacts, pipeline: pipeline, artifacts_expire_at: 2.days.from_now, name: 'build_3') } + + let(:names) { subject[:details][:artifacts].map { |a| a[:name] } } + + context 'and preload_job_artifacts_archive is not defined in the options' do + it 'defaults to true and eager loads the job_artifacts_archive' do + recorder = ActiveRecord::QueryRecorder.new do + expect(names).to match_array(%w[build_1 build_2 build_3]) + end + + expected_queries = Gitlab.ee? ? 42 : 29 + + # This makes only one query to fetch all job artifacts + expect(recorder.count).to eq(expected_queries) + end + end + + context 'and preload_job_artifacts_archive is set to false' do + let(:entity) do + described_class.represent(pipeline, request: request, preload_job_artifacts_archive: false) + end + + it 'does not eager load the job_artifacts_archive' do + recorder = ActiveRecord::QueryRecorder.new do + expect(names).to match_array(%w[build_1 build_2 build_3]) + end + + expected_queries = Gitlab.ee? ? 44 : 31 + + # This makes one query for each job artifact + expect(recorder.count).to eq(expected_queries) + end + end + end end end -- cgit v1.2.3