Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-05-24 15:09:04 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-05-24 15:09:04 +0300
commit4b4c254b2cfaca26c2c8e2bda70d45c13e3a6f97 (patch)
treef30595f3879d12d6be5b75ac25bb0ad566153293 /spec
parent43c14d2d9245aea5964d52d3e4915be1126977cb (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/features/issues/user_comments_on_issue_spec.rb2
-rw-r--r--spec/features/markdown/math_spec.rb20
-rw-r--r--spec/features/merge_request/user_posts_notes_spec.rb2
-rw-r--r--spec/features/projects/environments/environment_spec.rb3
-rw-r--r--spec/frontend/notes/components/note_body_spec.js35
-rw-r--r--spec/models/environment_spec.rb24
-rw-r--r--spec/models/remote_mirror_spec.rb2
-rw-r--r--spec/services/deployments/update_environment_service_spec.rb2
-rw-r--r--spec/services/environments/auto_stop_service_spec.rb2
-rw-r--r--spec/services/environments/stop_service_spec.rb27
-rw-r--r--spec/workers/build_success_worker_spec.rb29
-rw-r--r--spec/workers/environments/auto_stop_worker_spec.rb2
-rw-r--r--spec/workers/every_sidekiq_worker_spec.rb1
-rw-r--r--spec/workers/repository_remove_remote_worker_spec.rb48
14 files changed, 129 insertions, 70 deletions
diff --git a/spec/features/issues/user_comments_on_issue_spec.rb b/spec/features/issues/user_comments_on_issue_spec.rb
index a719263f092..69c97741785 100644
--- a/spec/features/issues/user_comments_on_issue_spec.rb
+++ b/spec/features/issues/user_comments_on_issue_spec.rb
@@ -67,7 +67,7 @@ RSpec.describe "User comments on issue", :js do
it "edits comment" do
add_note("# Comment with a header")
- page.within(".note-body > .note-text") do
+ page.within(".note-body .note-text") do
expect(page).to have_content("Comment with a header").and have_no_css("#comment-with-a-header")
end
diff --git a/spec/features/markdown/math_spec.rb b/spec/features/markdown/math_spec.rb
index fa23fac2f96..1f219886818 100644
--- a/spec/features/markdown/math_spec.rb
+++ b/spec/features/markdown/math_spec.rb
@@ -67,4 +67,24 @@ RSpec.describe 'Math rendering', :js do
expect(page).to have_selector('.js-lazy-render-math')
end
end
+
+ it 'renders without any limits on wiki page', :js do
+ description = <<~MATH
+ ```math
+ \Huge \sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
+ ```
+ MATH
+
+ wiki_page = build(:wiki_page, { container: project, content: description })
+ wiki_page.create message: 'math test commit' # rubocop:disable Rails/SaveBang
+ wiki_page = project.wiki.find_page(wiki_page.slug)
+
+ visit project_wiki_path(project, wiki_page)
+
+ wait_for_requests
+
+ page.within '.js-wiki-page-content' do
+ expect(page).not_to have_selector('.js-lazy-render-math')
+ end
+ end
end
diff --git a/spec/features/merge_request/user_posts_notes_spec.rb b/spec/features/merge_request/user_posts_notes_spec.rb
index ad602afe68a..b0c52463b22 100644
--- a/spec/features/merge_request/user_posts_notes_spec.rb
+++ b/spec/features/merge_request/user_posts_notes_spec.rb
@@ -158,7 +158,7 @@ RSpec.describe 'Merge request > User posts notes', :js do
page.within("#note_#{note.id}") do
expect(find('.current-note-edit-form', visible: true)).to be_visible
expect(find('.note-edit-form', visible: true)).to be_visible
- expect(find(:css, '.note-body > .note-text', visible: false)).not_to be_visible
+ expect(find(:css, '.note-body .note-text', visible: false)).not_to be_visible
end
end
diff --git a/spec/features/projects/environments/environment_spec.rb b/spec/features/projects/environments/environment_spec.rb
index 124fc1e2086..6c1a338c656 100644
--- a/spec/features/projects/environments/environment_spec.rb
+++ b/spec/features/projects/environments/environment_spec.rb
@@ -284,7 +284,6 @@ RSpec.describe 'Environment' do
click_button('Stop')
click_button('Stop environment') # confirm modal
wait_for_all_requests
- expect(page).to have_button('Delete')
end
end
@@ -362,8 +361,6 @@ RSpec.describe 'Environment' do
end
visit_environment(environment)
-
- expect(page).not_to have_button('Stop')
end
##
diff --git a/spec/frontend/notes/components/note_body_spec.js b/spec/frontend/notes/components/note_body_spec.js
index 378dcb97fab..0481dd12c68 100644
--- a/spec/frontend/notes/components/note_body_spec.js
+++ b/spec/frontend/notes/components/note_body_spec.js
@@ -1,5 +1,5 @@
-import { shallowMount } from '@vue/test-utils';
import Vuex from 'vuex';
+import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { suggestionCommitMessage } from '~/diffs/store/getters';
import NoteBody from '~/notes/components/note_body.vue';
@@ -7,6 +7,7 @@ import NoteAwardsList from '~/notes/components/note_awards_list.vue';
import NoteForm from '~/notes/components/note_form.vue';
import createStore from '~/notes/stores';
import notes from '~/notes/stores/modules/index';
+import { CONFIDENTIAL_CLASSES } from '~/notes/constants';
import Suggestions from '~/vue_shared/components/markdown/suggestions.vue';
@@ -27,7 +28,7 @@ const createComponent = ({
mockStore.dispatch('setNotesData', notesData);
}
- return shallowMount(NoteBody, {
+ return shallowMountExtended(NoteBody, {
store: mockStore || store,
propsData: {
note,
@@ -58,6 +59,24 @@ describe('issue_note_body component', () => {
expect(wrapper.findComponent(NoteAwardsList).exists()).toBe(true);
});
+ it('should not have confidential classes', () => {
+ expect(wrapper.findByTestId('note-confidential-container').classes()).not.toEqual(
+ CONFIDENTIAL_CLASSES,
+ );
+ });
+
+ describe('isConfidential', () => {
+ beforeEach(() => {
+ wrapper = createComponent({ props: { isConfidential: true } });
+ });
+
+ it('should have confidential classes', () => {
+ expect(wrapper.findByTestId('note-confidential-container').classes()).toEqual(
+ CONFIDENTIAL_CLASSES,
+ );
+ });
+ });
+
describe('isEditing', () => {
beforeEach(() => {
wrapper = createComponent({ props: { isEditing: true } });
@@ -86,6 +105,18 @@ describe('issue_note_body component', () => {
// which is defined in `app/assets/javascripts/notes/mixins/autosave.js`
expect(wrapper.vm.autosave.key).toEqual(autosaveKey);
});
+
+ describe('isConfidential', () => {
+ beforeEach(() => {
+ wrapper.setProps({ isConfidential: true });
+ });
+
+ it('should not have confidential classes', () => {
+ expect(wrapper.findByTestId('note-confidential-container').classes()).not.toEqual(
+ CONFIDENTIAL_CLASSES,
+ );
+ });
+ });
});
describe('commitMessage', () => {
diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb
index 34dfc7a1fce..5a1697d2bb8 100644
--- a/spec/models/environment_spec.rb
+++ b/spec/models/environment_spec.rb
@@ -586,6 +586,24 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do
expect(action).to eq(close_action)
expect(action.user).to eq(user)
end
+
+ context 'env_stopped_on_stop_success feature flag' do
+ it 'environment is not stopped when flag is enabled' do
+ stub_feature_flags(env_stopped_on_stop_success: true)
+
+ subject
+
+ expect(environment).not_to be_stopped
+ end
+
+ it 'environment is stopped when flag is disabled' do
+ stub_feature_flags(env_stopped_on_stop_success: false)
+
+ subject
+
+ expect(environment).to be_stopped
+ end
+ end
end
context 'if action did finish' do
@@ -1730,17 +1748,17 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do
let!(:environment3) { create(:environment, project: project, state: 'stopped') }
it 'returns the environments count grouped by state' do
- expect(project.environments.count_by_state).to eq({ stopped: 2, available: 1 })
+ expect(project.environments.count_by_state).to eq({ stopped: 2, available: 1, stopping: 0 })
end
it 'returns the environments count grouped by state with zero value' do
environment2.update!(state: 'stopped')
- expect(project.environments.count_by_state).to eq({ stopped: 3, available: 0 })
+ expect(project.environments.count_by_state).to eq({ stopped: 3, available: 0, stopping: 0 })
end
end
it 'returns zero state counts when environments are empty' do
- expect(project.environments.count_by_state).to eq({ stopped: 0, available: 0 })
+ expect(project.environments.count_by_state).to eq({ stopped: 0, available: 0, stopping: 0 })
end
end
diff --git a/spec/models/remote_mirror_spec.rb b/spec/models/remote_mirror_spec.rb
index 9f1d1c84da3..d2d7859e726 100644
--- a/spec/models/remote_mirror_spec.rb
+++ b/spec/models/remote_mirror_spec.rb
@@ -254,8 +254,6 @@ RSpec.describe RemoteMirror, :mailer do
it 'does not remove the remote' do
mirror = create_mirror(url: 'http://foo:bar@test.com')
- expect(RepositoryRemoveRemoteWorker).not_to receive(:perform_async)
-
mirror.destroy!
end
end
diff --git a/spec/services/deployments/update_environment_service_spec.rb b/spec/services/deployments/update_environment_service_spec.rb
index fe246ce9d23..e2d7a80fde3 100644
--- a/spec/services/deployments/update_environment_service_spec.rb
+++ b/spec/services/deployments/update_environment_service_spec.rb
@@ -84,7 +84,7 @@ RSpec.describe Deployments::UpdateEnvironmentService do
context 'and environment is stopped' do
before do
- environment.stop
+ environment.stop_complete
end
it 'makes environment available' do
diff --git a/spec/services/environments/auto_stop_service_spec.rb b/spec/services/environments/auto_stop_service_spec.rb
index 8dad59cbefd..d688690c376 100644
--- a/spec/services/environments/auto_stop_service_spec.rb
+++ b/spec/services/environments/auto_stop_service_spec.rb
@@ -37,7 +37,7 @@ RSpec.describe Environments::AutoStopService, :clean_gitlab_redis_shared_state,
it 'stops environments and play stop jobs' do
expect { subject }
.to change { Environment.all.map(&:state).uniq }
- .from(['available']).to(['stopped'])
+ .from(['available']).to(['stopping'])
expect(Ci::Build.where(name: 'stop_review_app').map(&:status).uniq).to eq(['pending'])
end
diff --git a/spec/services/environments/stop_service_spec.rb b/spec/services/environments/stop_service_spec.rb
index afbc0ba70f9..727898274cb 100644
--- a/spec/services/environments/stop_service_spec.rb
+++ b/spec/services/environments/stop_service_spec.rb
@@ -29,14 +29,27 @@ RSpec.describe Environments::StopService do
review_job.success!
end
- it 'stops the environment' do
- expect { subject }.to change { environment.reload.state }.from('available').to('stopped')
+ context 'without stop action' do
+ let!(:environment) { create(:environment, :available, project: project) }
+
+ it 'stops the environment' do
+ expect { subject }.to change { environment.reload.state }.from('available').to('stopped')
+ end
end
it 'plays the stop action' do
expect { subject }.to change { stop_review_job.reload.status }.from('manual').to('pending')
end
+ context 'force option' do
+ let(:service) { described_class.new(project, user, { force: true }) }
+
+ it 'does not play the stop action when forced' do
+ expect { subject }.to change { environment.reload.state }.from('available').to('stopped')
+ expect(stop_review_job.reload.status).to eq('manual')
+ end
+ end
+
context 'when an environment has already been stopped' do
let!(:environment) { create(:environment, :stopped, project: project) }
@@ -77,7 +90,7 @@ RSpec.describe Environments::StopService do
context 'when environment is associated with removed branch' do
it 'stops environment' do
- expect_environment_stopped_on('feature')
+ expect_environment_stopping_on('feature')
end
end
@@ -195,8 +208,7 @@ RSpec.describe Environments::StopService do
it 'stops the active environment' do
subject
-
- expect(pipeline.environments_in_self_and_descendants.first).to be_stopped
+ expect(pipeline.environments_in_self_and_descendants.first).to be_stopping
end
context 'when pipeline is a branch pipeline for merge request' do
@@ -268,6 +280,11 @@ RSpec.describe Environments::StopService do
.to change { Environment.last.state }.from('available').to('stopped')
end
+ def expect_environment_stopping_on(branch)
+ expect { service.execute_for_branch(branch) }
+ .to change { Environment.last.state }.from('available').to('stopping')
+ end
+
def expect_environment_not_stopped_on(branch)
expect { service.execute_for_branch(branch) }
.not_to change { Environment.last.state }
diff --git a/spec/workers/build_success_worker_spec.rb b/spec/workers/build_success_worker_spec.rb
index 0583d79ed46..2456acef53f 100644
--- a/spec/workers/build_success_worker_spec.rb
+++ b/spec/workers/build_success_worker_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe BuildSuccessWorker do
context 'when build exists' do
context 'when the build will stop an environment' do
- let!(:build) { create(:ci_build, :stop_review_app, environment: environment.name, project: environment.project) }
+ let!(:build) { create(:ci_build, :stop_review_app, environment: environment.name, project: environment.project, status: :success) }
let(:environment) { create(:environment, state: :available) }
it 'stops the environment' do
@@ -18,6 +18,33 @@ RSpec.describe BuildSuccessWorker do
expect(environment.reload).to be_stopped
end
+
+ context 'when the build fails' do
+ before do
+ build.update!(status: :failed)
+ environment.update!(state: :available)
+ end
+
+ it 'does not stop the environment' do
+ expect(environment).to be_available
+
+ stub_feature_flags(env_stopped_on_stop_success: true)
+
+ subject
+
+ expect(environment.reload).not_to be_stopped
+ end
+
+ it 'does stop the environment when feature flag is disabled' do
+ expect(environment).to be_available
+
+ stub_feature_flags(env_stopped_on_stop_success: false)
+
+ subject
+
+ expect(environment.reload).to be_stopped
+ end
+ end
end
end
diff --git a/spec/workers/environments/auto_stop_worker_spec.rb b/spec/workers/environments/auto_stop_worker_spec.rb
index 1983cfa18ea..cb162b5a01c 100644
--- a/spec/workers/environments/auto_stop_worker_spec.rb
+++ b/spec/workers/environments/auto_stop_worker_spec.rb
@@ -23,7 +23,7 @@ RSpec.describe Environments::AutoStopWorker do
it 'stops the environment' do
expect { subject }
.to change { Environment.find_by_name('review/feature').state }
- .from('available').to('stopped')
+ .from('available').to('stopping')
end
it 'executes the stop action' do
diff --git a/spec/workers/every_sidekiq_worker_spec.rb b/spec/workers/every_sidekiq_worker_spec.rb
index 0c83a692ca8..a940c6be417 100644
--- a/spec/workers/every_sidekiq_worker_spec.rb
+++ b/spec/workers/every_sidekiq_worker_spec.rb
@@ -410,7 +410,6 @@ RSpec.describe 'Every Sidekiq worker' do
'RepositoryCleanupWorker' => 3,
'RepositoryForkWorker' => 5,
'RepositoryImportWorker' => false,
- 'RepositoryRemoveRemoteWorker' => 3,
'RepositoryUpdateMirrorWorker' => false,
'RepositoryPushAuditEventWorker' => 3,
'RepositoryUpdateRemoteMirrorWorker' => 3,
diff --git a/spec/workers/repository_remove_remote_worker_spec.rb b/spec/workers/repository_remove_remote_worker_spec.rb
deleted file mode 100644
index 11081ec9b37..00000000000
--- a/spec/workers/repository_remove_remote_worker_spec.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe RepositoryRemoveRemoteWorker do
- include ExclusiveLeaseHelpers
- include GitHelpers
-
- describe '#perform' do
- let!(:project) { create(:project, :repository) }
- let(:remote_name) { 'joe'}
- let(:lease_key) { "remove_remote_#{project.id}_#{remote_name}" }
- let(:lease_timeout) { RepositoryRemoveRemoteWorker::LEASE_TIMEOUT }
-
- it 'returns nil when project does not exist' do
- expect(subject.perform(-1, 'remote_name')).to be_nil
- end
-
- context 'when project exists' do
- before do
- allow(Project)
- .to receive(:find_by)
- .with(id: project.id)
- .and_return(project)
- end
-
- it 'does nothing when cannot obtain lease' do
- stub_exclusive_lease_taken(lease_key, timeout: lease_timeout)
-
- expect(project.repository)
- .not_to receive(:remove_remote)
- expect(subject)
- .not_to receive(:log_error)
-
- subject.perform(project.id, remote_name)
- end
-
- it 'does nothing when obtain a lease' do
- stub_exclusive_lease(lease_key, timeout: lease_timeout)
-
- expect(project.repository)
- .not_to receive(:remove_remote)
-
- subject.perform(project.id, remote_name)
- end
- end
- end
-end