diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-09 21:08:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-09 21:08:33 +0300 |
commit | e440e09fe47e84c45f9ed9acc3ec1213846e8be4 (patch) | |
tree | 5ad7c327c3a6edb620ed49f0762ea958db40fdfb /spec | |
parent | 9c39a0a9b81f06f6345a6b6e071b8e8cd249c064 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
7 files changed, 35 insertions, 535 deletions
diff --git a/spec/controllers/admin/clusters/applications_controller_spec.rb b/spec/controllers/admin/clusters/applications_controller_spec.rb deleted file mode 100644 index d1ca64d6bd2..00000000000 --- a/spec/controllers/admin/clusters/applications_controller_spec.rb +++ /dev/null @@ -1,139 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Admin::Clusters::ApplicationsController do - include AccessMatchersForController - - def current_application - Clusters::Cluster::APPLICATIONS[application] - end - - shared_examples 'a secure endpoint' do - it { expect { subject }.to be_allowed_for(:admin) } - it { expect { subject }.to be_denied_for(:user) } - it { expect { subject }.to be_denied_for(:external) } - end - - let(:cluster) { create(:cluster, :instance, :provided_by_gcp) } - - describe 'POST create' do - subject do - post :create, params: params - end - - let(:application) { 'ingress' } - let(:params) { { application: application, id: cluster.id } } - - describe 'functionality' do - let(:admin) { create(:admin) } - - before do - sign_in(admin) - end - - it 'schedule an application installation' do - expect(ClusterInstallAppWorker).to receive(:perform_async).with(application, anything).once - - expect { subject }.to change { current_application.count } - expect(response).to have_gitlab_http_status(:no_content) - expect(cluster.application_ingress).to be_scheduled - end - - context 'when cluster do not exists' do - before do - cluster.destroy! - end - - it 'return 404' do - expect { subject }.not_to change { current_application.count } - expect(response).to have_gitlab_http_status(:not_found) - end - end - - context 'when application is unknown' do - let(:application) { 'unkwnown-app' } - - it 'return 404' do - is_expected.to have_gitlab_http_status(:not_found) - end - end - - context 'when application is already installing' do - before do - create(:clusters_applications_ingress, :installing, cluster: cluster) - end - - it 'returns 400' do - is_expected.to have_gitlab_http_status(:bad_request) - end - end - end - - describe 'security' do - before do - allow(ClusterInstallAppWorker).to receive(:perform_async) - end - - it_behaves_like 'a secure endpoint' - end - end - - describe 'PATCH update' do - subject do - patch :update, params: params - end - - let!(:application) { create(:clusters_applications_cert_manager, :installed, cluster: cluster) } - let(:application_name) { application.name } - let(:params) { { application: application_name, id: cluster.id, email: "new-email@example.com" } } - - describe 'functionality' do - let(:admin) { create(:admin) } - - before do - sign_in(admin) - end - - context "when cluster and app exists" do - it "schedules an application update" do - expect(ClusterPatchAppWorker).to receive(:perform_async).with(application.name, anything).once - - is_expected.to have_gitlab_http_status(:no_content) - - expect(cluster.application_cert_manager).to be_scheduled - end - end - - context 'when cluster do not exists' do - before do - cluster.destroy! - end - - it { is_expected.to have_gitlab_http_status(:not_found) } - end - - context 'when application is unknown' do - let(:application_name) { 'unkwnown-app' } - - it { is_expected.to have_gitlab_http_status(:not_found) } - end - - context 'when application is already scheduled' do - before do - application.make_scheduled! - end - - it { is_expected.to have_gitlab_http_status(:bad_request) } - end - end - - describe 'security' do - before do - allow(ClusterPatchAppWorker).to receive(:perform_async) - end - - it_behaves_like 'a secure endpoint' - end - end -end diff --git a/spec/controllers/groups/clusters/applications_controller_spec.rb b/spec/controllers/groups/clusters/applications_controller_spec.rb deleted file mode 100644 index 5629e86c928..00000000000 --- a/spec/controllers/groups/clusters/applications_controller_spec.rb +++ /dev/null @@ -1,148 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Groups::Clusters::ApplicationsController do - include AccessMatchersForController - - def current_application - Clusters::Cluster::APPLICATIONS[application] - end - - shared_examples 'a secure endpoint' do - it('is allowed for admin when admin mode is enabled', :enable_admin_mode) { expect { subject }.to be_allowed_for(:admin) } - it('is denied for admin when admin mode is disabled') { expect { subject }.to be_denied_for(:admin) } - it { expect { subject }.to be_allowed_for(:owner).of(group) } - it { expect { subject }.to be_allowed_for(:maintainer).of(group) } - it { expect { subject }.to be_denied_for(:developer).of(group) } - it { expect { subject }.to be_denied_for(:reporter).of(group) } - it { expect { subject }.to be_denied_for(:guest).of(group) } - it { expect { subject }.to be_denied_for(:user) } - it { expect { subject }.to be_denied_for(:external) } - end - - let(:cluster) { create(:cluster, :group, :provided_by_gcp) } - let(:group) { cluster.group } - - describe 'POST create' do - subject do - post :create, params: params.merge(group_id: group) - end - - let(:application) { 'ingress' } - let(:params) { { application: application, id: cluster.id } } - - describe 'functionality' do - let(:user) { create(:user) } - - before do - group.add_maintainer(user) - sign_in(user) - end - - it 'schedule an application installation' do - expect(ClusterInstallAppWorker).to receive(:perform_async).with(application, anything).once - - expect { subject }.to change { current_application.count } - expect(response).to have_gitlab_http_status(:no_content) - expect(cluster.application_ingress).to be_scheduled - end - - context 'when cluster do not exists' do - before do - cluster.destroy! - end - - it 'return 404' do - expect { subject }.not_to change { current_application.count } - expect(response).to have_gitlab_http_status(:not_found) - end - end - - context 'when application is unknown' do - let(:application) { 'unkwnown-app' } - - it 'return 404' do - is_expected.to have_gitlab_http_status(:not_found) - end - end - - context 'when application is already installing' do - before do - create(:clusters_applications_ingress, :installing, cluster: cluster) - end - - it 'returns 400' do - is_expected.to have_gitlab_http_status(:bad_request) - end - end - end - - describe 'security' do - before do - allow(ClusterInstallAppWorker).to receive(:perform_async) - end - - it_behaves_like 'a secure endpoint' - end - end - - describe 'PATCH update' do - subject do - patch :update, params: params.merge(group_id: group) - end - - let!(:application) { create(:clusters_applications_cert_manager, :installed, cluster: cluster) } - let(:application_name) { application.name } - let(:params) { { application: application_name, id: cluster.id, email: "new-email@example.com" } } - - describe 'functionality' do - let(:user) { create(:user) } - - before do - group.add_maintainer(user) - sign_in(user) - end - - context "when cluster and app exists" do - it "schedules an application update" do - expect(ClusterPatchAppWorker).to receive(:perform_async).with(application.name, anything).once - - is_expected.to have_gitlab_http_status(:no_content) - - expect(cluster.application_cert_manager).to be_scheduled - end - end - - context 'when cluster do not exists' do - before do - cluster.destroy! - end - - it { is_expected.to have_gitlab_http_status(:not_found) } - end - - context 'when application is unknown' do - let(:application_name) { 'unkwnown-app' } - - it { is_expected.to have_gitlab_http_status(:not_found) } - end - - context 'when application is already scheduled' do - before do - application.make_scheduled! - end - - it { is_expected.to have_gitlab_http_status(:bad_request) } - end - end - - describe 'security' do - before do - allow(ClusterPatchAppWorker).to receive(:perform_async) - end - - it_behaves_like 'a secure endpoint' - end - end -end diff --git a/spec/controllers/projects/clusters/applications_controller_spec.rb b/spec/controllers/projects/clusters/applications_controller_spec.rb deleted file mode 100644 index cc6170252c1..00000000000 --- a/spec/controllers/projects/clusters/applications_controller_spec.rb +++ /dev/null @@ -1,215 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Projects::Clusters::ApplicationsController do - include AccessMatchersForController - - def current_application - Clusters::Cluster::APPLICATIONS[application] - end - - shared_examples 'a secure endpoint' do - it 'is allowed for admin when admin mode enabled', :enable_admin_mode do - expect { subject }.to be_allowed_for(:admin) - end - it 'is denied for admin when admin mode disabled' do - expect { subject }.to be_denied_for(:admin) - end - it { expect { subject }.to be_allowed_for(:owner).of(project) } - it { expect { subject }.to be_allowed_for(:maintainer).of(project) } - it { expect { subject }.to be_denied_for(:developer).of(project) } - it { expect { subject }.to be_denied_for(:reporter).of(project) } - it { expect { subject }.to be_denied_for(:guest).of(project) } - it { expect { subject }.to be_denied_for(:user) } - it { expect { subject }.to be_denied_for(:external) } - end - - describe 'POST create' do - subject do - post :create, params: params.merge(namespace_id: project.namespace, project_id: project) - end - - let(:cluster) { create(:cluster, :project, :provided_by_gcp) } - let(:project) { cluster.project } - let(:application) { 'ingress' } - let(:params) { { application: application, id: cluster.id } } - - describe 'functionality' do - let(:user) { create(:user) } - - before do - project.add_maintainer(user) - sign_in(user) - end - - it 'schedule an application installation' do - expect(ClusterInstallAppWorker).to receive(:perform_async).with(application, anything).once - - expect { subject }.to change { current_application.count } - expect(response).to have_gitlab_http_status(:no_content) - expect(cluster.application_ingress).to be_scheduled - end - - context 'when cluster do not exists' do - before do - cluster.destroy! - end - - it 'return 404' do - expect { subject }.not_to change { current_application.count } - expect(response).to have_gitlab_http_status(:not_found) - end - end - - context 'when application is unknown' do - let(:application) { 'unkwnown-app' } - - it 'return 404' do - is_expected.to have_gitlab_http_status(:not_found) - end - end - - context 'when application is already installing' do - before do - create(:clusters_applications_ingress, :installing, cluster: cluster) - end - - it 'returns 400' do - is_expected.to have_gitlab_http_status(:bad_request) - end - end - end - - describe 'security' do - before do - allow(ClusterInstallAppWorker).to receive(:perform_async) - end - - it_behaves_like 'a secure endpoint' - end - end - - describe 'PATCH update' do - subject do - patch :update, params: params.merge(namespace_id: project.namespace, project_id: project) - end - - let(:cluster) { create(:cluster, :project, :provided_by_gcp) } - let(:project) { cluster.project } - let!(:application) { create(:clusters_applications_knative, :installed, cluster: cluster) } - let(:application_name) { application.name } - let(:params) { { application: application_name, id: cluster.id, hostname: "new.example.com" } } - - describe 'functionality' do - let(:user) { create(:user) } - - before do - project.add_maintainer(user) - sign_in(user) - end - - context "when cluster and app exists" do - it "schedules an application update" do - expect(ClusterPatchAppWorker).to receive(:perform_async).with(application.name, anything).once - - is_expected.to have_gitlab_http_status(:no_content) - - expect(cluster.application_knative).to be_scheduled - end - end - - context 'when cluster do not exists' do - before do - cluster.destroy! - end - - it { is_expected.to have_gitlab_http_status(:not_found) } - end - - context 'when application is unknown' do - let(:application_name) { 'unkwnown-app' } - - it { is_expected.to have_gitlab_http_status(:not_found) } - end - - context 'when application is already scheduled' do - before do - application.make_scheduled! - end - - it { is_expected.to have_gitlab_http_status(:bad_request) } - end - end - - describe 'security' do - before do - allow(ClusterPatchAppWorker).to receive(:perform_async) - end - - it_behaves_like 'a secure endpoint' - end - end - - describe 'DELETE destroy' do - subject do - delete :destroy, params: params.merge(namespace_id: project.namespace, project_id: project) - end - - let(:cluster) { create(:cluster, :project, :provided_by_gcp) } - let(:project) { cluster.project } - let!(:application) { create(:clusters_applications_prometheus, :installed, cluster: cluster) } - let(:application_name) { application.name } - let(:params) { { application: application_name, id: cluster.id } } - let(:worker_class) { Clusters::Applications::UninstallWorker } - - describe 'functionality' do - let(:user) { create(:user) } - - before do - project.add_maintainer(user) - sign_in(user) - end - - context "when cluster and app exists" do - it "schedules an application update" do - expect(worker_class).to receive(:perform_async).with(application.name, application.id).once - - is_expected.to have_gitlab_http_status(:no_content) - - expect(cluster.application_prometheus).to be_scheduled - end - end - - context 'when cluster do not exists' do - before do - cluster.destroy! - end - - it { is_expected.to have_gitlab_http_status(:not_found) } - end - - context 'when application is unknown' do - let(:application_name) { 'unkwnown-app' } - - it { is_expected.to have_gitlab_http_status(:not_found) } - end - - context 'when application is already scheduled' do - before do - application.make_scheduled! - end - - it { is_expected.to have_gitlab_http_status(:bad_request) } - end - end - - describe 'security' do - before do - allow(worker_class).to receive(:perform_async) - end - - it_behaves_like 'a secure endpoint' - end - end -end diff --git a/spec/frontend/vue_shared/components/markdown/toolbar_button_spec.js b/spec/frontend/vue_shared/components/markdown/toolbar_button_spec.js index 786dfabb990..19e4f2d8c92 100644 --- a/spec/frontend/vue_shared/components/markdown/toolbar_button_spec.js +++ b/spec/frontend/vue_shared/components/markdown/toolbar_button_spec.js @@ -1,3 +1,4 @@ +import { GlButton } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import ToolbarButton from '~/vue_shared/components/markdown/toolbar_button.vue'; @@ -25,7 +26,7 @@ describe('toolbar_button', () => { }); const getButtonShortcutsAttr = () => { - return wrapper.find('button').attributes('data-md-shortcuts'); + return wrapper.find(GlButton).attributes('data-md-shortcuts'); }; describe('keyboard shortcuts', () => { diff --git a/spec/lib/gitlab/usage_data_metrics_spec.rb b/spec/lib/gitlab/usage_data_metrics_spec.rb index 476a6e99cfd..5bc72845222 100644 --- a/spec/lib/gitlab/usage_data_metrics_spec.rb +++ b/spec/lib/gitlab/usage_data_metrics_spec.rb @@ -87,6 +87,39 @@ RSpec.describe Gitlab::UsageDataMetrics do ]) end + it 'includes issues_edit monthly and weekly keys' do + expect(subject[:redis_hll_counters][:issues_edit].keys).to include( + :g_project_management_issue_title_changed_monthly, :g_project_management_issue_title_changed_weekly, + :g_project_management_issue_description_changed_monthly, :g_project_management_issue_description_changed_weekly, + :g_project_management_issue_assignee_changed_monthly, :g_project_management_issue_assignee_changed_weekly, + :g_project_management_issue_made_confidential_monthly, :g_project_management_issue_made_confidential_weekly, + :g_project_management_issue_made_visible_monthly, :g_project_management_issue_made_visible_weekly, + :g_project_management_issue_created_monthly, :g_project_management_issue_created_weekly, + :g_project_management_issue_closed_monthly, :g_project_management_issue_closed_weekly, + :g_project_management_issue_reopened_monthly, :g_project_management_issue_reopened_weekly, + :g_project_management_issue_label_changed_monthly, :g_project_management_issue_label_changed_weekly, + :g_project_management_issue_milestone_changed_monthly, :g_project_management_issue_milestone_changed_weekly, + :g_project_management_issue_cross_referenced_monthly, :g_project_management_issue_cross_referenced_weekly, + :g_project_management_issue_moved_monthly, :g_project_management_issue_moved_weekly, + :g_project_management_issue_related_monthly, :g_project_management_issue_related_weekly, + :g_project_management_issue_unrelated_monthly, :g_project_management_issue_unrelated_weekly, + :g_project_management_issue_marked_as_duplicate_monthly, :g_project_management_issue_marked_as_duplicate_weekly, + :g_project_management_issue_locked_monthly, :g_project_management_issue_locked_weekly, + :g_project_management_issue_unlocked_monthly, :g_project_management_issue_unlocked_weekly, + :g_project_management_issue_designs_added_monthly, :g_project_management_issue_designs_added_weekly, + :g_project_management_issue_designs_modified_monthly, :g_project_management_issue_designs_modified_weekly, + :g_project_management_issue_designs_removed_monthly, :g_project_management_issue_designs_removed_weekly, + :g_project_management_issue_due_date_changed_monthly, :g_project_management_issue_due_date_changed_weekly, + :g_project_management_issue_time_estimate_changed_monthly, :g_project_management_issue_time_estimate_changed_weekly, + :g_project_management_issue_time_spent_changed_monthly, :g_project_management_issue_time_spent_changed_weekly, + :g_project_management_issue_comment_added_monthly, :g_project_management_issue_comment_added_weekly, + :g_project_management_issue_comment_edited_monthly, :g_project_management_issue_comment_edited_weekly, + :g_project_management_issue_comment_removed_monthly, :g_project_management_issue_comment_removed_weekly, + :g_project_management_issue_cloned_monthly, :g_project_management_issue_cloned_weekly, + :issues_edit_total_unique_counts_monthly, :issues_edit_total_unique_counts_weekly + ) + end + it 'includes counts keys' do expect(subject[:counts]).to include(:issues) end diff --git a/spec/presenters/group_clusterable_presenter_spec.rb b/spec/presenters/group_clusterable_presenter_spec.rb index 27360201e81..84b97ba0bb7 100644 --- a/spec/presenters/group_clusterable_presenter_spec.rb +++ b/spec/presenters/group_clusterable_presenter_spec.rb @@ -67,22 +67,6 @@ RSpec.describe GroupClusterablePresenter do it { is_expected.to eq(cluster_status_group_cluster_path(group, cluster)) } end - describe '#install_applications_cluster_path' do - let(:application) { :helm } - - subject { presenter.install_applications_cluster_path(cluster, application) } - - it { is_expected.to eq(install_applications_group_cluster_path(group, cluster, application)) } - end - - describe '#update_applications_cluster_path' do - let(:application) { :helm } - - subject { presenter.update_applications_cluster_path(cluster, application) } - - it { is_expected.to eq(update_applications_group_cluster_path(group, cluster, application)) } - end - describe '#clear_cluster_cache_path' do subject { presenter.clear_cluster_cache_path(cluster) } diff --git a/spec/presenters/project_clusterable_presenter_spec.rb b/spec/presenters/project_clusterable_presenter_spec.rb index b518c63f0ca..9057b518647 100644 --- a/spec/presenters/project_clusterable_presenter_spec.rb +++ b/spec/presenters/project_clusterable_presenter_spec.rb @@ -67,22 +67,6 @@ RSpec.describe ProjectClusterablePresenter do it { is_expected.to eq(cluster_status_project_cluster_path(project, cluster)) } end - describe '#install_applications_cluster_path' do - let(:application) { :helm } - - subject { presenter.install_applications_cluster_path(cluster, application) } - - it { is_expected.to eq(install_applications_project_cluster_path(project, cluster, application)) } - end - - describe '#update_applications_cluster_path' do - let(:application) { :helm } - - subject { presenter.update_applications_cluster_path(cluster, application) } - - it { is_expected.to eq(update_applications_project_cluster_path(project, cluster, application)) } - end - describe '#clear_cluster_cache_path' do subject { presenter.clear_cluster_cache_path(cluster) } |