summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-03 06:07:23 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-03 06:07:23 +0000
commit3d6bfb323c80f30034921103df18cbc2a266fc19 (patch)
treea48b58a79685114848879011dd89be0b33124081 /spec
parentcd6db2c5b462479bf7d798acaf1f360def701c15 (diff)
downloadgitlab-ce-3d6bfb323c80f30034921103df18cbc2a266fc19.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/projects/environments_controller_spec.rb64
-rw-r--r--spec/frontend/ci/pipeline_editor/components/editor/text_editor_spec.js29
-rw-r--r--spec/frontend/ide/components/repo_editor_spec.js27
-rw-r--r--spec/services/ide/schemas_config_service_spec.rb34
4 files changed, 90 insertions, 64 deletions
diff --git a/spec/controllers/projects/environments_controller_spec.rb b/spec/controllers/projects/environments_controller_spec.rb
index 2334521b8a8..62e8c600e9f 100644
--- a/spec/controllers/projects/environments_controller_spec.rb
+++ b/spec/controllers/projects/environments_controller_spec.rb
@@ -998,6 +998,70 @@ RSpec.describe Projects::EnvironmentsController do
end
end
+ describe '#append_info_to_payload' do
+ let(:search_param) { 'my search param' }
+
+ context 'when search_environment_logging feature is disabled' do
+ before do
+ stub_feature_flags(environments_search_logging: false)
+ end
+
+ it 'does not log search params in meta.environment.search' do
+ expect(controller).to receive(:append_info_to_payload).and_wrap_original do |method, payload|
+ method.call(payload)
+
+ expect(payload[:metadata]['meta.environment.search']).to be_nil
+ expect(payload[:action]).to eq("search")
+ expect(payload[:controller]).to eq("Projects::EnvironmentsController")
+ end
+
+ get :search, params: environment_params(format: :json, search: search_param)
+ end
+
+ it 'logs params correctly when search params are missing' do
+ expect(controller).to receive(:append_info_to_payload).and_wrap_original do |method, payload|
+ method.call(payload)
+
+ expect(payload[:metadata]['meta.environment.search']).to be_nil
+ expect(payload[:action]).to eq("search")
+ expect(payload[:controller]).to eq("Projects::EnvironmentsController")
+ end
+
+ get :search, params: environment_params(format: :json)
+ end
+ end
+
+ context 'when search_environment_logging feature is enabled' do
+ before do
+ stub_feature_flags(environments_search_logging: true)
+ end
+
+ it 'logs search params in meta.environment.search' do
+ expect(controller).to receive(:append_info_to_payload).and_wrap_original do |method, payload|
+ method.call(payload)
+
+ expect(payload[:metadata]['meta.environment.search']).to eq(search_param)
+ expect(payload[:action]).to eq("search")
+ expect(payload[:controller]).to eq("Projects::EnvironmentsController")
+ end
+
+ get :search, params: environment_params(format: :json, search: search_param)
+ end
+
+ it 'logs params correctly when search params are missing' do
+ expect(controller).to receive(:append_info_to_payload).and_wrap_original do |method, payload|
+ method.call(payload)
+
+ expect(payload[:metadata]['meta.environment.search']).to be_nil
+ expect(payload[:action]).to eq("search")
+ expect(payload[:controller]).to eq("Projects::EnvironmentsController")
+ end
+
+ get :search, params: environment_params(format: :json)
+ end
+ end
+ end
+
def environment_params(opts = {})
opts.reverse_merge(namespace_id: project.namespace,
project_id: project,
diff --git a/spec/frontend/ci/pipeline_editor/components/editor/text_editor_spec.js b/spec/frontend/ci/pipeline_editor/components/editor/text_editor_spec.js
index 63e23c41263..ec987be8cb8 100644
--- a/spec/frontend/ci/pipeline_editor/components/editor/text_editor_spec.js
+++ b/spec/frontend/ci/pipeline_editor/components/editor/text_editor_spec.js
@@ -26,14 +26,13 @@ describe('Pipeline Editor | Text editor component', () => {
props: ['value', 'fileName', 'editorOptions', 'debounceValue'],
};
- const createComponent = (glFeatures = {}, mountFn = shallowMount) => {
+ const createComponent = (mountFn = shallowMount) => {
wrapper = mountFn(TextEditor, {
provide: {
projectPath: mockProjectPath,
projectNamespace: mockProjectNamespace,
ciConfigPath: mockCiConfigPath,
defaultBranch: mockDefaultBranch,
- glFeatures,
},
propsData: {
commitSha: mockCommitSha,
@@ -107,28 +106,14 @@ describe('Pipeline Editor | Text editor component', () => {
});
describe('CI schema', () => {
- describe('when `schema_linting` feature flag is on', () => {
- beforeEach(() => {
- createComponent({ schemaLinting: true });
- findEditor().vm.$emit(EDITOR_READY_EVENT, editorInstanceDetail);
- });
-
- it('configures editor with syntax highlight', () => {
- expect(mockUse).toHaveBeenCalledTimes(1);
- expect(mockRegisterCiSchema).toHaveBeenCalledTimes(1);
- });
+ beforeEach(() => {
+ createComponent();
+ findEditor().vm.$emit(EDITOR_READY_EVENT, editorInstanceDetail);
});
- describe('when `schema_linting` feature flag is off', () => {
- beforeEach(() => {
- createComponent();
- findEditor().vm.$emit(EDITOR_READY_EVENT, editorInstanceDetail);
- });
-
- it('does not call the register CI schema function', () => {
- expect(mockUse).not.toHaveBeenCalled();
- expect(mockRegisterCiSchema).not.toHaveBeenCalled();
- });
+ it('configures editor with syntax highlight', () => {
+ expect(mockUse).toHaveBeenCalledTimes(1);
+ expect(mockRegisterCiSchema).toHaveBeenCalledTimes(1);
});
});
});
diff --git a/spec/frontend/ide/components/repo_editor_spec.js b/spec/frontend/ide/components/repo_editor_spec.js
index 211fee31a9c..9092d73571b 100644
--- a/spec/frontend/ide/components/repo_editor_spec.js
+++ b/spec/frontend/ide/components/repo_editor_spec.js
@@ -122,7 +122,7 @@ describe('RepoEditor', () => {
vm.$once('editorSetup', resolve);
});
- const createComponent = async ({ state = {}, activeFile = dummyFile.text, flags = {} } = {}) => {
+ const createComponent = async ({ state = {}, activeFile = dummyFile.text } = {}) => {
const store = prepareStore(state, activeFile);
wrapper = shallowMount(RepoEditor, {
store,
@@ -132,9 +132,6 @@ describe('RepoEditor', () => {
mocks: {
ContentViewer,
},
- provide: {
- glFeatures: flags,
- },
});
await waitForPromises();
vm = wrapper.vm;
@@ -196,12 +193,8 @@ describe('RepoEditor', () => {
});
describe('schema registration for .gitlab-ci.yml', () => {
- const setup = async (activeFile, flagIsOn = true) => {
- await createComponent({
- flags: {
- schemaLinting: flagIsOn,
- },
- });
+ const setup = async (activeFile) => {
+ await createComponent();
vm.editor.registerCiSchema = jest.fn();
if (activeFile) {
wrapper.setProps({ file: activeFile });
@@ -210,15 +203,13 @@ describe('RepoEditor', () => {
await nextTick();
};
it.each`
- flagIsOn | activeFile | shouldUseExtension | desc
- ${false} | ${dummyFile.markdown} | ${false} | ${`file is not CI config; should NOT`}
- ${true} | ${dummyFile.markdown} | ${false} | ${`file is not CI config; should NOT`}
- ${false} | ${dummyFile.ciConfig} | ${false} | ${`file is CI config; should NOT`}
- ${true} | ${dummyFile.ciConfig} | ${true} | ${`file is CI config; should`}
+ activeFile | shouldUseExtension | desc
+ ${dummyFile.markdown} | ${false} | ${`file is not CI config; should NOT`}
+ ${dummyFile.ciConfig} | ${true} | ${`file is CI config; should`}
`(
- 'when the flag is "$flagIsOn", $desc use extension',
- async ({ flagIsOn, activeFile, shouldUseExtension }) => {
- await setup(activeFile, flagIsOn);
+ 'when the activeFile is "$activeFile", $desc use extension',
+ async ({ activeFile, shouldUseExtension }) => {
+ await setup(activeFile);
if (shouldUseExtension) {
expect(applyExtensionSpy).toHaveBeenCalledWith({
diff --git a/spec/services/ide/schemas_config_service_spec.rb b/spec/services/ide/schemas_config_service_spec.rb
index 69ad9b5cbea..f277b8e9954 100644
--- a/spec/services/ide/schemas_config_service_spec.rb
+++ b/spec/services/ide/schemas_config_service_spec.rb
@@ -20,35 +20,21 @@ RSpec.describe Ide::SchemasConfigService do
subject { described_class.new(project, user, filename: filename).execute }
- context 'feature flag schema_linting is enabled', unless: Gitlab.ee? do
- before do
- stub_feature_flags(schema_linting: true)
- end
-
- context 'when no predefined schema exists for the given filename' do
- it 'returns an empty object' do
- is_expected.to include(
- status: :success,
- schema: {})
- end
- end
-
- context 'when a predefined schema exists for the given filename' do
- let(:filename) { '.gitlab-ci.yml' }
-
- it 'uses predefined schema matches' do
- expect(Gitlab::HTTP).to receive(:get).with('https://json.schemastore.org/gitlab-ci')
- expect(subject[:schema]['title']).to eq "Sample schema"
- end
- end
- end
-
- context 'feature flag schema_linting is disabled', unless: Gitlab.ee? do
+ context 'when no predefined schema exists for the given filename', unless: Gitlab.ee? do
it 'returns an empty object' do
is_expected.to include(
status: :success,
schema: {})
end
end
+
+ context 'when a predefined schema exists for the given filename' do
+ let(:filename) { '.gitlab-ci.yml' }
+
+ it 'uses predefined schema matches' do
+ expect(Gitlab::HTTP).to receive(:get).with('https://json.schemastore.org/gitlab-ci')
+ expect(subject[:schema]['title']).to eq "Sample schema"
+ end
+ end
end
end