diff options
Diffstat (limited to 'spec')
14 files changed, 92 insertions, 28 deletions
diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index 1d1653e67e3..afe21c8b34a 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -123,7 +123,7 @@ describe Admin::UsersController do put :deactivate, params: { id: user.username } user.reload expect(user.deactivated?).to be_falsey - expect(flash[:notice]).to eq("The user you are trying to deactivate has been active in the past 14 days and cannot be deactivated") + expect(flash[:notice]).to eq("The user you are trying to deactivate has been active in the past #{::User::MINIMUM_INACTIVE_DAYS} days and cannot be deactivated") end end end diff --git a/spec/controllers/uploads_controller_spec.rb b/spec/controllers/uploads_controller_spec.rb index dd7ab4f9d47..1bcf3bb106b 100644 --- a/spec/controllers/uploads_controller_spec.rb +++ b/spec/controllers/uploads_controller_spec.rb @@ -7,9 +7,9 @@ shared_examples 'content 5 min private cached with revalidation' do end end -shared_examples 'content long term private cached with revalidation' do +shared_examples 'content not cached' do it 'ensures content will not be cached without revalidation' do - expect(subject['Cache-Control']).to eq('max-age=15778476, private, must-revalidate') + expect(subject['Cache-Control']).to eq('max-age=0, private, must-revalidate') end end @@ -490,7 +490,7 @@ describe UploadsController do expect(response).to have_gitlab_http_status(200) end - it_behaves_like 'content long term private cached with revalidation' do + it_behaves_like 'content not cached' do subject do get :show, params: { model: 'note', mounted_as: 'attachment', id: note.id, filename: 'dk.png' } @@ -510,7 +510,7 @@ describe UploadsController do expect(response).to have_gitlab_http_status(200) end - it_behaves_like 'content long term private cached with revalidation' do + it_behaves_like 'content not cached' do subject do get :show, params: { model: 'note', mounted_as: 'attachment', id: note.id, filename: 'dk.png' } @@ -563,7 +563,7 @@ describe UploadsController do expect(response).to have_gitlab_http_status(200) end - it_behaves_like 'content long term private cached with revalidation' do + it_behaves_like 'content not cached' do subject do get :show, params: { model: 'note', mounted_as: 'attachment', id: note.id, filename: 'dk.png' } diff --git a/spec/features/projects/show/user_interacts_with_auto_devops_banner_spec.rb b/spec/features/projects/show/user_interacts_with_auto_devops_banner_spec.rb index baf715000a3..df63856492e 100644 --- a/spec/features/projects/show/user_interacts_with_auto_devops_banner_spec.rb +++ b/spec/features/projects/show/user_interacts_with_auto_devops_banner_spec.rb @@ -57,5 +57,18 @@ describe 'Project > Show > User interacts with auto devops implicitly enabled ba expect(page).not_to have_css('.auto-devops-implicitly-enabled-banner') end end + + context 'when AutoDevOps enabled but container registry is disabled' do + before do + stub_application_setting(auto_devops_enabled: true) + stub_container_registry_config(enabled: false) + + visit project_path(project) + end + + it 'shows message that container registry is disabled' do + expect(page).to have_content('Container registry is not enabled on this GitLab instance') + end + end end end diff --git a/spec/fixtures/lib/gitlab/import_export/project.json b/spec/fixtures/lib/gitlab/import_export/project.json index 7d9c8cdef8f..fbd752b7403 100644 --- a/spec/fixtures/lib/gitlab/import_export/project.json +++ b/spec/fixtures/lib/gitlab/import_export/project.json @@ -6226,7 +6226,9 @@ "job_id": null, "name": "test build 1", "deploy": false, - "options": null, + "options": { + "image": "busybox:latest" + }, "allow_failure": false, "stage": "test", "trigger_request_id": null, diff --git a/spec/frontend/lib/utils/forms_spec.js b/spec/frontend/lib/utils/forms_spec.js index cac17235f0d..07ba7c29dfc 100644 --- a/spec/frontend/lib/utils/forms_spec.js +++ b/spec/frontend/lib/utils/forms_spec.js @@ -70,5 +70,27 @@ describe('lib/utils/forms', () => { bar: ['bar-value2', 'bar-value1'], }); }); + + it('handles Microsoft Edge FormData.getAll() bug', () => { + const formData = [ + { type: 'checkbox', name: 'foo', value: 'foo-value1' }, + { type: 'text', name: 'bar', value: 'bar-value2' }, + ]; + + const form = createDummyForm(formData); + + jest + .spyOn(FormData.prototype, 'getAll') + .mockImplementation(name => + formData.map(elem => (elem.name === name ? elem.value : undefined)), + ); + + const data = serializeForm(form); + + expect(data).toEqual({ + foo: 'foo-value1', + bar: 'bar-value2', + }); + }); }); }); diff --git a/spec/frontend/releases/list/components/release_block_spec.js b/spec/frontend/releases/list/components/release_block_spec.js index 0b908d7d6bc..ac51c3af11a 100644 --- a/spec/frontend/releases/list/components/release_block_spec.js +++ b/spec/frontend/releases/list/components/release_block_spec.js @@ -39,13 +39,25 @@ describe('Release block', () => { const milestoneListLabel = () => wrapper.find('.js-milestone-list-label'); const editButton = () => wrapper.find('.js-edit-button'); + const RealDate = Date; beforeEach(() => { + // timeago.js calls Date(), so let's mock that case to avoid time-dependent test failures. + const constantDate = new Date('2019-10-25T00:12:00'); + + /* eslint no-global-assign:off */ + global.Date = jest.fn((...props) => + props.length ? new RealDate(...props) : new RealDate(constantDate), + ); + + Object.assign(Date, RealDate); + releaseClone = JSON.parse(JSON.stringify(release)); }); afterEach(() => { wrapper.destroy(); + global.Date = RealDate; }); describe('with default props', () => { diff --git a/spec/javascripts/jobs/components/job_log_spec.js b/spec/javascripts/jobs/components/job_log_spec.js index dd58f234394..4d782e5bd0e 100644 --- a/spec/javascripts/jobs/components/job_log_spec.js +++ b/spec/javascripts/jobs/components/job_log_spec.js @@ -10,7 +10,7 @@ describe('Job Log', () => { let vm; const trace = - '<span>Running with gitlab-runner 12.1.0 (de7731dd)<br/></span><span> on docker-auto-scale-com d5ae8d25<br/></span><div class="js-section-start fa fa-caret-down append-right-8 cursor-pointer" data-timestamp="1565502765" data-section="prepare-executor" role="button"></div><span class="section js-section-header section-header js-s-prepare-executor">Using Docker executor with image ruby:2.6 ...<br/></span>'; + '<span>Running with gitlab-runner 12.1.0 (de7731dd)<br/></span><span> on docker-auto-scale-com d5ae8d25<br/></span><div class="append-right-8" data-timestamp="1565502765" data-section="prepare-executor" role="button"></div><span class="section section-header js-s-prepare-executor">Using Docker executor with image ruby:2.6 ...<br/></span>'; beforeEach(() => { store = createStore(); diff --git a/spec/javascripts/jobs/mock_data.js b/spec/javascripts/jobs/mock_data.js index c5022d3e93d..3d40e94d219 100644 --- a/spec/javascripts/jobs/mock_data.js +++ b/spec/javascripts/jobs/mock_data.js @@ -1189,18 +1189,3 @@ export const jobsInStage = { path: '/gitlab-org/gitlab-shell/pipelines/27#build', dropdown_path: '/gitlab-org/gitlab-shell/pipelines/27/stage.json?stage=build', }; - -export const logWithCollapsibleSections = { - append: false, - complete: true, - html: - '<div class="js-section-start fa fa-caret-down append-right-8 cursor-pointer" data-timestamp="1559571405" data-section="after-script" role="button"></div><span class="term-fg-l-green term-bold section js-section-header js-s-after-script">Running after script...</span><span class="section js-section-header js-s-after-script"><br /></span><span class="section s_after-script line"></span><span class="section js-s-after-script"></span><span class="term-fg-l-green term-bold section js-s-after-script">$ date</span><span class="section js-s-after-script"><br /></span><span class="section s_after-script line"></span><span class="section js-s-after-script">Mon Jun 3 14:16:46 UTC 2019<br /></span><span class="section s_after-script line"></span><span class="section js-s-after-script"></span><div class="section-end" data-section="after-script"></div><div class="js-section-start fa fa-caret-down append-right-8 cursor-pointer"data-timestamp="1559571408" data-section="archive-cache" role="button" ></div><span class="term-fg-l-green term-bold section js-section-header js-s-archive-cache">Not uploading cache debian-stretch-ruby-2.6.3-node-10.x-3 due to policy</span><span class="section js-section-header js-s-archive-cache"><br /></span><span class="section s_archive-cache line"></span><span class="section js-s-archive-cache"></span><div class="section-end" data-section="archive-cache"></div><div class="js-section-start fa fa-caret-down append-right-8 cursor-pointer" data-timestamp="1559571409" data-section="upload-artifacts-on-success" role="button"></div><span class="term-fg-l-green term-bold section js-section-header js-s-upload-artifacts-on-success">Uploading artifacts...</span><span class="section js-section-header js-s-upload-artifacts-on-success"><br /></span><span class="section s_upload-artifacts-on-success line"></span><span class="section js-s-upload-artifacts-on-success">coverage/: found 5 matching files </span><span class="section js-s-upload-artifacts-on-success"> <br /></span><span class="section s_upload-artifacts-on-success line"></span><span class="section js-s-upload-artifacts-on-success">knapsack/: found 4 matching files </span><span class="section js-s-upload-artifacts-on-success"> <br /></span><span class="section s_upload-artifacts-on-success line"></span><span class="section js-s-upload-artifacts-on-success">rspec_flaky/: found 4 matching files </span><span class="section js-s-upload-artifacts-on-success"> <br /></span><span class="section s_upload-artifacts-on-success line"></span><span class="section js-s-upload-artifacts-on-success">rspec_profiling/: found 1 matching files </span><span class="section js-s-upload-artifacts-on-success"> <br /></span><span class="section s_upload-artifacts-on-success line"></span><span class="section js-s-upload-artifacts-on-success"></span><span class="term-fg-yellow section js-s-upload-artifacts-on-success">WARNING: tmp/capybara/: no matching files </span><span class="section js-s-upload-artifacts-on-success"> <br /></span><span class="section s_upload-artifacts-on-success line"></span><span class="section js-s-upload-artifacts-on-success">Uploading artifacts to coordinator... ok </span><span class="section js-s-upload-artifacts-on-success"> id</span><span class="section js-s-upload-artifacts-on-success">=224162288 responseStatus</span><span class="section js-s-upload-artifacts-on-success">=201 Created token</span><span class="section js-s-upload-artifacts-on-success">=bBmyXJNW<br /></span><span class="section s_upload-artifacts-on-success line"></span><span class="section js-s-upload-artifacts-on-success"></span><span class="term-fg-l-green term-bold section js-s-upload-artifacts-on-success">Uploading artifacts...</span><span class="section js-s-upload-artifacts-on-success"><br /></span><span class="section s_upload-artifacts-on-success line"></span><span class="section js-s-upload-artifacts-on-success">junit_rspec.xml: found 1 matching files </span><span class="section js-s-upload-artifacts-on-success"> <br /></span><span class="section s_upload-artifacts-on-success line"></span><span class="section js-s-upload-artifacts-on-success">Uploading artifacts to coordinator... ok </span><span class="section js-s-upload-artifacts-on-success"> id</span><span class="section js-s-upload-artifacts-on-success">=224162288 responseStatus</span><span class="section js-s-upload-artifacts-on-success">=201 Created token</span><span class="section js-s-upload-artifacts-on-success">=bBmyXJNW<br /></span><span class="section s_upload-artifacts-on-success line"></span><span class="section js-s-upload-artifacts-on-success"></span><div class="section-end" data-section="upload-artifacts-on-success"></div><span class="term-fg-l-green term-bold">Job succeeded<br /><span class="term-fg-l-green term-bold"></span></span>', - id: 1385, - offset: 0, - size: 78815, - state: - 'eyJvZmZzZXQiOjc4ODE1LCJuX29wZW5fdGFncyI6MCwiZmdfY29sb3IiOm51bGwsImJnX2NvbG9yIjpudWxsLCJzdHlsZV9tYXNrIjowLCJzZWN0aW9ucyI6W10sImxpbmVub19pbl9zZWN0aW9uIjoxMX0=', - status: 'success', - total: 78815, - truncated: false, -}; diff --git a/spec/lib/gitlab/ci/ansi2html_spec.rb b/spec/lib/gitlab/ci/ansi2html_spec.rb index c8afcbd053d..ee789995bc2 100644 --- a/spec/lib/gitlab/ci/ansi2html_spec.rb +++ b/spec/lib/gitlab/ci/ansi2html_spec.rb @@ -209,7 +209,7 @@ describe Gitlab::Ci::Ansi2html do let(:section_start) { "section_start:#{section_start_time.to_i}:#{section_name}\r\033[0K"} let(:section_end) { "section_end:#{section_end_time.to_i}:#{section_name}\r\033[0K"} let(:section_start_html) do - '<div class="js-section-start section-start fa fa-caret-down pr-2 cursor-pointer"' \ + '<div class="section-start"' \ " data-timestamp=\"#{section_start_time.to_i}\" data-section=\"#{class_name(section_name)}\"" \ ' role="button"></div>' end @@ -233,8 +233,8 @@ describe Gitlab::Ci::Ansi2html do it 'prints light red' do text = "#{section_start}\e[91mHello\e[0m\nLine 1\nLine 2\nLine 3\n#{section_end}" - header = %{<span class="term-fg-l-red section js-section-header section-header cursor-pointer js-s-#{class_name(section_name)}">Hello</span>} - line_break = %{<span class="section js-section-header section-header cursor-pointer js-s-#{class_name(section_name)}"><br/></span>} + header = %{<span class="term-fg-l-red section section-header js-s-#{class_name(section_name)}">Hello</span>} + line_break = %{<span class="section section-header js-s-#{class_name(section_name)}"><br/></span>} output_line = %{<span class="section line js-s-#{class_name(section_name)}">Line 1<br/>Line 2<br/>Line 3<br/></span>} html = "#{section_start_html}#{header}#{line_break}#{output_line}#{section_end_html}" diff --git a/spec/lib/gitlab/gitaly_client_spec.rb b/spec/lib/gitlab/gitaly_client_spec.rb index ea3bb12d049..b8df9ad642a 100644 --- a/spec/lib/gitlab/gitaly_client_spec.rb +++ b/spec/lib/gitlab/gitaly_client_spec.rb @@ -17,6 +17,28 @@ describe Gitlab::GitalyClient do }) end + describe '.long_timeout' do + context 'default case' do + it { expect(subject.long_timeout).to eq(6.hours) } + end + + context 'running in Unicorn' do + before do + stub_const('Unicorn', 1) + end + + it { expect(subject.long_timeout).to eq(55) } + end + + context 'running in Puma' do + before do + stub_const('Puma', 1) + end + + it { expect(subject.long_timeout).to eq(55) } + end + end + describe '.filesystem_id_from_disk' do it 'catches errors' do [Errno::ENOENT, Errno::EACCES, JSON::ParserError].each do |error| diff --git a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb index 676973ff5e7..ebd2c6089ce 100644 --- a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb @@ -283,6 +283,10 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do it 'correctly restores association between a pipeline and a job' do expect(CommitStatus.all).to all(have_attributes(pipeline_id: a_value > 0)) end + + it 'restores a Hash for CommitStatus options' do + expect(CommitStatus.all.map(&:options).compact).to all(be_a(Hash)) + end end end end diff --git a/spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb b/spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb index 66ea390a2bf..f48cd096a98 100644 --- a/spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb +++ b/spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb @@ -69,7 +69,7 @@ describe Gitlab::Metrics::RequestsRackMiddleware do expected_labels = [] described_class::HTTP_METHODS.each do |method, statuses| statuses.each do |status| - expected_labels << { method: method, status: status } + expected_labels << { method: method, status: status.to_i } end end diff --git a/spec/migrations/sync_issuables_state_id_spec.rb b/spec/migrations/sync_issuables_state_id_spec.rb index 8d1f8a36ac3..c6e4b504bbb 100644 --- a/spec/migrations/sync_issuables_state_id_spec.rb +++ b/spec/migrations/sync_issuables_state_id_spec.rb @@ -19,19 +19,23 @@ describe SyncIssuablesStateId, :migration, :sidekiq do it 'migrates state column to state_id as integer' do opened_issue = issues.create!(description: 'first', state: 'opened') closed_issue = issues.create!(description: 'second', state: 'closed') + unknown_state_issue = issues.create!(description: 'second', state: 'unknown') opened_merge_request = merge_requests.create!(state: 'opened', target_project_id: project.id, target_branch: 'feature1', source_branch: 'master') closed_merge_request = merge_requests.create!(state: 'closed', target_project_id: project.id, target_branch: 'feature2', source_branch: 'master') merged_merge_request = merge_requests.create!(state: 'merged', target_project_id: project.id, target_branch: 'feature3', source_branch: 'master') locked_merge_request = merge_requests.create!(state: 'locked', target_project_id: project.id, target_branch: 'feature4', source_branch: 'master') + unknown_state_merge_request = merge_requests.create!(state: 'unknown', target_project_id: project.id, target_branch: 'feature4', source_branch: 'master') migrate! expect(opened_issue.reload.state_id).to eq(state_ids[:opened]) expect(closed_issue.reload.state_id).to eq(state_ids[:closed]) + expect(unknown_state_issue.reload.state_id).to eq(state_ids[:closed]) expect(opened_merge_request.reload.state_id).to eq(state_ids[:opened]) expect(closed_merge_request.reload.state_id).to eq(state_ids[:closed]) expect(merged_merge_request.reload.state_id).to eq(state_ids[:merged]) expect(locked_merge_request.reload.state_id).to eq(state_ids[:locked]) + expect(unknown_state_merge_request.reload.state_id).to eq(state_ids[:closed]) end end end diff --git a/spec/support/shared_examples/models/concern/issuable_shared_examples.rb b/spec/support/shared_examples/models/concern/issuable_shared_examples.rb index 4ebb5e35e0e..4978a403324 100644 --- a/spec/support/shared_examples/models/concern/issuable_shared_examples.rb +++ b/spec/support/shared_examples/models/concern/issuable_shared_examples.rb @@ -4,7 +4,7 @@ shared_examples_for 'matches_cross_reference_regex? fails fast' do it 'fails fast for long strings' do # took well under 1 second in CI https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/3267#note_172823 expect do - Timeout.timeout(3.seconds) { mentionable.matches_cross_reference_regex? } + Timeout.timeout(6.seconds) { mentionable.matches_cross_reference_regex? } end.not_to raise_error end end |