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>2023-04-12 18:15:44 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-04-12 18:15:44 +0300
commitc1a7bcdf1bfef9455bc58b1737f52530bf681a90 (patch)
treefb683b37e3ef58bb7bd7698629796ed9c5bfbeae /spec
parente0d7577e29dcab90623e1f38cf11b351c665ee23 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/factories/clusters/applications/helm.rb97
-rw-r--r--spec/factories/clusters/clusters.rb8
-rw-r--r--spec/features/nav/pinned_nav_items_spec.rb8
-rw-r--r--spec/features/projects/compare_spec.rb17
-rw-r--r--spec/features/projects/navbar_spec.rb2
-rw-r--r--spec/fixtures/markdown.md.erb26
-rw-r--r--spec/frontend/packages_and_registries/infrastructure_registry/components/list/components/infrastructure_title_spec.js2
-rw-r--r--spec/frontend/vue_shared/issuable/show/components/issuable_header_spec.js19
-rw-r--r--spec/graphql/graphql_triggers_spec.rb40
-rw-r--r--spec/helpers/sidebars_helper_spec.rb4
-rw-r--r--spec/lib/banzai/filter/math_filter_spec.rb1
-rw-r--r--spec/lib/gitlab/database/migration_helpers/convert_to_bigint_spec.rb4
-rw-r--r--spec/lib/gitlab/email/reply_parser_spec.rb77
-rw-r--r--spec/lib/gitlab/kubernetes/helm/api_spec.rb269
-rw-r--r--spec/lib/gitlab/kubernetes/helm/v2/base_command_spec.rb50
-rw-r--r--spec/lib/gitlab/kubernetes/helm/v2/certificate_spec.rb28
-rw-r--r--spec/lib/gitlab/kubernetes/helm/v2/delete_command_spec.rb38
-rw-r--r--spec/lib/gitlab/kubernetes/helm/v2/init_command_spec.rb35
-rw-r--r--spec/lib/gitlab/kubernetes/helm/v2/install_command_spec.rb183
-rw-r--r--spec/lib/gitlab/kubernetes/helm/v2/patch_command_spec.rb87
-rw-r--r--spec/lib/gitlab/kubernetes/helm/v2/reset_command_spec.rb32
-rw-r--r--spec/lib/gitlab/kubernetes/helm/v3/base_command_spec.rb44
-rw-r--r--spec/lib/gitlab/kubernetes/helm/v3/delete_command_spec.rb35
-rw-r--r--spec/lib/gitlab/kubernetes/helm/v3/install_command_spec.rb168
-rw-r--r--spec/lib/gitlab/kubernetes/helm/v3/patch_command_spec.rb81
-rw-r--r--spec/lib/gitlab/regex_spec.rb19
-rw-r--r--spec/lib/gitlab/untrusted_regexp_spec.rb35
-rw-r--r--spec/lib/sidebars/projects/menus/issues_menu_spec.rb11
-rw-r--r--spec/lib/sidebars/projects/menus/merge_requests_menu_spec.rb13
-rw-r--r--spec/lib/sidebars/search/panel_spec.rb29
-rw-r--r--spec/models/clusters/applications/helm_spec.rb116
-rw-r--r--spec/models/clusters/cluster_spec.rb127
-rw-r--r--spec/models/clusters/integrations/prometheus_spec.rb4
-rw-r--r--spec/support/helpers/fake_webauthn_device.rb2
-rw-r--r--spec/support/helpers/navbar_structure_helper.rb2
-rw-r--r--spec/support/matchers/markdown_matchers.rb2
-rw-r--r--spec/support/shared_examples/features/2fa_shared_examples.rb4
-rw-r--r--spec/support/shared_examples/services/base_helm_service_shared_examples.rb22
-rw-r--r--spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb8
-rw-r--r--spec/workers/clusters/cleanup/project_namespace_worker_spec.rb1
40 files changed, 219 insertions, 1531 deletions
diff --git a/spec/factories/clusters/applications/helm.rb b/spec/factories/clusters/applications/helm.rb
deleted file mode 100644
index 4cf7023b5aa..00000000000
--- a/spec/factories/clusters/applications/helm.rb
+++ /dev/null
@@ -1,97 +0,0 @@
-# frozen_string_literal: true
-
-FactoryBot.define do
- factory :clusters_applications_helm, class: 'Clusters::Applications::Helm' do
- cluster factory: %i(cluster provided_by_gcp)
-
- transient do
- helm_installed { true }
- end
-
- before(:create) do |_record, evaluator|
- if evaluator.helm_installed
- stub_method(Gitlab::Kubernetes::Helm::V2::Certificate, :generate_root) do
- OpenStruct.new( # rubocop: disable Style/OpenStructUse
- key_string: File.read(Rails.root.join('spec/fixtures/clusters/sample_key.key')),
- cert_string: File.read(Rails.root.join('spec/fixtures/clusters/sample_cert.pem'))
- )
- end
- end
- end
-
- after(:create) do |_record, evaluator|
- if evaluator.helm_installed
- restore_original_methods(Gitlab::Kubernetes::Helm::V2::Certificate)
- end
- end
-
- trait :not_installable do
- status { -2 }
- end
-
- trait :errored do
- status { -1 }
- status_reason { 'something went wrong' }
- end
-
- trait :installable do
- status { 0 }
- end
-
- trait :scheduled do
- status { 1 }
- end
-
- trait :installing do
- status { 2 }
- end
-
- trait :installed do
- status { 3 }
- end
-
- trait :updating do
- status { 4 }
- end
-
- trait :updated do
- status { 5 }
- end
-
- trait :update_errored do
- status { 6 }
- status_reason { 'something went wrong' }
- end
-
- trait :uninstalling do
- status { 7 }
- end
-
- trait :uninstall_errored do
- status { 8 }
- status_reason { 'something went wrong' }
- end
-
- trait :uninstalled do
- status { 10 }
- end
-
- trait :externally_installed do
- status { 11 }
- end
-
- trait :timed_out do
- installing
- updated_at { ClusterWaitForAppInstallationWorker::TIMEOUT.ago }
- end
-
- # Common trait used by the apps below
- trait :no_helm_installed do
- cluster factory: %i(cluster provided_by_gcp)
-
- transient do
- helm_installed { false }
- end
- end
- end
-end
diff --git a/spec/factories/clusters/clusters.rb b/spec/factories/clusters/clusters.rb
index e50240aee7e..2785a8c9946 100644
--- a/spec/factories/clusters/clusters.rb
+++ b/spec/factories/clusters/clusters.rb
@@ -82,18 +82,10 @@ FactoryBot.define do
sequence(:environment_scope) { |n| "production#{n}/*" }
end
- trait :with_installed_helm do
- application_helm factory: %i(clusters_applications_helm installed)
- end
-
trait :with_installed_prometheus do
integration_prometheus factory: %i(clusters_integrations_prometheus)
end
- trait :with_all_applications do
- application_helm factory: %i(clusters_applications_helm installed)
- end
-
trait :with_domain do
domain { 'example.com' }
end
diff --git a/spec/features/nav/pinned_nav_items_spec.rb b/spec/features/nav/pinned_nav_items_spec.rb
index d05e3042401..b4eea931857 100644
--- a/spec/features/nav/pinned_nav_items_spec.rb
+++ b/spec/features/nav/pinned_nav_items_spec.rb
@@ -59,7 +59,7 @@ RSpec.describe 'Navigation menu item pinning', :js, feature_category: :navigatio
within '#super-sidebar' do
click_on 'Operate'
add_pin('Package Registry')
- add_pin('Infrastructure Registry')
+ add_pin('Terraform modules')
wait_for_requests
end
end
@@ -75,11 +75,11 @@ RSpec.describe 'Navigation menu item pinning', :js, feature_category: :navigatio
section = find("[data-testid=\"nav-item-link\"]", text: 'Operate')
within(section.sibling('ul')) do
- remove_pin('Infrastructure Registry')
+ remove_pin('Terraform modules')
end
within '[data-testid="pinned-nav-items"]' do
- expect(page).not_to have_content 'Infrastructure Registry'
+ expect(page).not_to have_content 'Terraform modules'
end
end
@@ -87,7 +87,7 @@ RSpec.describe 'Navigation menu item pinning', :js, feature_category: :navigatio
within '[data-testid="pinned-nav-items"]' do
pinned_items = page.find_all('a').map(&:text)
item1 = page.find('a', text: 'Package Registry')
- item2 = page.find('a', text: 'Infrastructure Registry')
+ item2 = page.find('a', text: 'Terraform modules')
expect(pinned_items).to eq [item1.text, item2.text]
drag_item(item2, to: item1)
diff --git a/spec/features/projects/compare_spec.rb b/spec/features/projects/compare_spec.rb
index d7baecedfe6..4c13d23559b 100644
--- a/spec/features/projects/compare_spec.rb
+++ b/spec/features/projects/compare_spec.rb
@@ -11,7 +11,7 @@ RSpec.describe "Compare", :js, feature_category: :projects do
sign_in user
end
- describe "branches" do
+ shared_examples "compare view of branches" do
shared_examples 'compares branches' do
it 'compares branches' do
visit project_compare_index_path(project, from: 'master', to: 'master')
@@ -148,7 +148,7 @@ RSpec.describe "Compare", :js, feature_category: :projects do
end
end
- describe "tags" do
+ shared_examples "compare view of tags" do
it "compares tags" do
visit project_compare_index_path(project, from: "master", to: "master")
@@ -182,4 +182,17 @@ RSpec.describe "Compare", :js, feature_category: :projects do
dropdown.all(".js-compare-#{dropdown_type}-dropdown .dropdown-item", text: selection).first.click
end
end
+
+ it_behaves_like "compare view of branches"
+ it_behaves_like "compare view of tags"
+
+ context "when super sidebar is enabled" do
+ before do
+ user.update!(use_new_navigation: true)
+ stub_feature_flags(super_sidebar_nav: true)
+ end
+
+ it_behaves_like "compare view of branches"
+ it_behaves_like "compare view of tags"
+ end
end
diff --git a/spec/features/projects/navbar_spec.rb b/spec/features/projects/navbar_spec.rb
index 03ad5f9a292..521f633e0e7 100644
--- a/spec/features/projects/navbar_spec.rb
+++ b/spec/features/projects/navbar_spec.rb
@@ -91,7 +91,7 @@ RSpec.describe 'Project navbar', :with_license, feature_category: :projects do
before do
stub_feature_flags(harbor_registry_integration: true)
- insert_harbor_registry_nav(_('Infrastructure Registry'))
+ insert_harbor_registry_nav(_('Terraform modules'))
visit project_path(project)
end
diff --git a/spec/fixtures/markdown.md.erb b/spec/fixtures/markdown.md.erb
index 979e96e6e8e..26e5f110687 100644
--- a/spec/fixtures/markdown.md.erb
+++ b/spec/fixtures/markdown.md.erb
@@ -299,6 +299,32 @@ References should be parseable even inside _<%= merge_request.to_reference %>_ e
v^2 + w^2 = x^2
```
+Parsed correctly when between code blocks
+
+```ruby
+x = 1
+```
+
+$$
+a^2+b^2=c^2
+$$
+
+```
+plaintext
+```
+
+Parsed correctly with a mixture of HTML comments and HTML blocks
+
+<!-- sdf -->
+
+$$
+a^2+b^2=c^2
+$$
+
+<h1>
+html
+</h1>
+
### Gollum Tags
- [[linked-resource]]
diff --git a/spec/frontend/packages_and_registries/infrastructure_registry/components/list/components/infrastructure_title_spec.js b/spec/frontend/packages_and_registries/infrastructure_registry/components/list/components/infrastructure_title_spec.js
index 7c7faa8a3b0..12859b1d77c 100644
--- a/spec/frontend/packages_and_registries/infrastructure_registry/components/list/components/infrastructure_title_spec.js
+++ b/spec/frontend/packages_and_registries/infrastructure_registry/components/list/components/infrastructure_title_spec.js
@@ -32,7 +32,7 @@ describe('Infrastructure Title', () => {
});
it('has the correct title', () => {
- expect(findTitleArea().props('title')).toBe('Infrastructure Registry');
+ expect(findTitleArea().props('title')).toBe('Terraform Module Registry');
});
describe('with no modules', () => {
diff --git a/spec/frontend/vue_shared/issuable/show/components/issuable_header_spec.js b/spec/frontend/vue_shared/issuable/show/components/issuable_header_spec.js
index d9f1b6c15a8..5902ea34d53 100644
--- a/spec/frontend/vue_shared/issuable/show/components/issuable_header_spec.js
+++ b/spec/frontend/vue_shared/issuable/show/components/issuable_header_spec.js
@@ -1,4 +1,4 @@
-import { GlBadge, GlIcon, GlAvatarLabeled } from '@gitlab/ui';
+import { GlButton, GlBadge, GlIcon, GlAvatarLabeled, GlAvatarLink } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
import IssuableHeader from '~/vue_shared/issuable/show/components/issuable_header.vue';
@@ -13,7 +13,10 @@ const issuableHeaderProps = {
describe('IssuableHeader', () => {
let wrapper;
+ const findAvatar = () => wrapper.findByTestId('avatar');
const findTaskStatusEl = () => wrapper.findByTestId('task-status');
+ const findButton = () => wrapper.findComponent(GlButton);
+ const findGlAvatarLink = () => wrapper.findComponent(GlAvatarLink);
const createComponent = (props = {}, { stubs } = {}) => {
wrapper = shallowMountExtended(IssuableHeader, {
@@ -40,7 +43,7 @@ describe('IssuableHeader', () => {
describe('authorId', () => {
it('returns numeric ID from GraphQL ID of `author` prop', () => {
createComponent();
- expect(wrapper.vm.authorId).toBe(1);
+ expect(findGlAvatarLink().attributes('data-user-id')).toBe('1');
});
});
});
@@ -52,12 +55,14 @@ describe('IssuableHeader', () => {
it('dispatches `click` event on sidebar toggle button', () => {
createComponent();
- wrapper.vm.toggleSidebarButtonEl = document.querySelector('.js-toggle-right-sidebar-button');
- jest.spyOn(wrapper.vm.toggleSidebarButtonEl, 'dispatchEvent').mockImplementation(jest.fn);
+ const toggleSidebarButtonEl = document.querySelector('.js-toggle-right-sidebar-button');
+ const dispatchEvent = jest
+ .spyOn(toggleSidebarButtonEl, 'dispatchEvent')
+ .mockImplementation(jest.fn);
- wrapper.vm.handleRightSidebarToggleClick();
+ findButton().vm.$emit('click');
- expect(wrapper.vm.toggleSidebarButtonEl.dispatchEvent).toHaveBeenCalledWith(
+ expect(dispatchEvent).toHaveBeenCalledWith(
expect.objectContaining({
type: 'click',
}),
@@ -109,7 +114,7 @@ describe('IssuableHeader', () => {
href: webUrl,
target: '_blank',
};
- const avatarEl = wrapper.findByTestId('avatar');
+ const avatarEl = findAvatar();
expect(avatarEl.exists()).toBe(true);
expect(avatarEl.attributes()).toMatchObject(avatarElAttrs);
expect(avatarEl.findComponent(GlAvatarLabeled).attributes()).toMatchObject({
diff --git a/spec/graphql/graphql_triggers_spec.rb b/spec/graphql/graphql_triggers_spec.rb
index 08b8f67c4bc..a8a37289ddd 100644
--- a/spec/graphql/graphql_triggers_spec.rb
+++ b/spec/graphql/graphql_triggers_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe GraphqlTriggers do
+RSpec.describe GraphqlTriggers, feature_category: :shared do
let_it_be(:issuable, refind: true) { create(:work_item) }
describe '.issuable_assignees_updated' do
@@ -12,9 +12,9 @@ RSpec.describe GraphqlTriggers do
issuable.update!(assignees: assignees)
end
- it 'triggers the issuableAssigneesUpdated subscription' do
+ it 'triggers the issuable_assignees_updated subscription' do
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
- 'issuableAssigneesUpdated',
+ :issuable_assignees_updated,
{ issuable_id: issuable.to_gid },
issuable
)
@@ -24,9 +24,9 @@ RSpec.describe GraphqlTriggers do
end
describe '.issuable_title_updated' do
- it 'triggers the issuableTitleUpdated subscription' do
+ it 'triggers the issuable_title_updated subscription' do
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
- 'issuableTitleUpdated',
+ :issuable_title_updated,
{ issuable_id: issuable.to_gid },
issuable
).and_call_original
@@ -36,9 +36,9 @@ RSpec.describe GraphqlTriggers do
end
describe '.issuable_description_updated' do
- it 'triggers the issuableDescriptionUpdated subscription' do
+ it 'triggers the issuable_description_updated subscription' do
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
- 'issuableDescriptionUpdated',
+ :issuable_description_updated,
{ issuable_id: issuable.to_gid },
issuable
).and_call_original
@@ -54,9 +54,9 @@ RSpec.describe GraphqlTriggers do
issuable.update!(labels: labels)
end
- it 'triggers the issuableLabelsUpdated subscription' do
+ it 'triggers the issuable_labels_updated subscription' do
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
- 'issuableLabelsUpdated',
+ :issuable_labels_updated,
{ issuable_id: issuable.to_gid },
issuable
)
@@ -66,9 +66,9 @@ RSpec.describe GraphqlTriggers do
end
describe '.issuable_dates_updated' do
- it 'triggers the issuableDatesUpdated subscription' do
+ it 'triggers the issuable_dates_updated subscription' do
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
- 'issuableDatesUpdated',
+ :issuable_dates_updated,
{ issuable_id: issuable.to_gid },
issuable
).and_call_original
@@ -78,9 +78,9 @@ RSpec.describe GraphqlTriggers do
end
describe '.issuable_milestone_updated' do
- it 'triggers the issuableMilestoneUpdated subscription' do
+ it 'triggers the issuable_milestone_updated subscription' do
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
- 'issuableMilestoneUpdated',
+ :issuable_milestone_updated,
{ issuable_id: issuable.to_gid },
issuable
).and_call_original
@@ -90,11 +90,11 @@ RSpec.describe GraphqlTriggers do
end
describe '.merge_request_reviewers_updated' do
- it 'triggers the mergeRequestReviewersUpdated subscription' do
+ it 'triggers the merge_request_reviewers_updated subscription' do
merge_request = build_stubbed(:merge_request)
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
- 'mergeRequestReviewersUpdated',
+ :merge_request_reviewers_updated,
{ issuable_id: merge_request.to_gid },
merge_request
).and_call_original
@@ -104,11 +104,11 @@ RSpec.describe GraphqlTriggers do
end
describe '.merge_request_merge_status_updated' do
- it 'triggers the mergeRequestMergeStatusUpdated subscription' do
+ it 'triggers the merge_request_merge_status_updated subscription' do
merge_request = build_stubbed(:merge_request)
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
- 'mergeRequestMergeStatusUpdated',
+ :merge_request_merge_status_updated,
{ issuable_id: merge_request.to_gid },
merge_request
).and_call_original
@@ -121,7 +121,7 @@ RSpec.describe GraphqlTriggers do
stub_feature_flags(realtime_mr_status_change: false)
end
- it 'does not trigger mergeRequestMergeStatusUpdated subscription' do
+ it 'does not trigger realtime_mr_status_change subscription' do
merge_request = build_stubbed(:merge_request)
expect(GitlabSchema.subscriptions).not_to receive(:trigger)
@@ -132,11 +132,11 @@ RSpec.describe GraphqlTriggers do
end
describe '.merge_request_approval_state_updated' do
- it 'triggers the mergeRequestApprovalStateUpdated subscription' do
+ it 'triggers the merge_request_approval_state_updated subscription' do
merge_request = build_stubbed(:merge_request)
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
- 'mergeRequestApprovalStateUpdated',
+ :merge_request_approval_state_updated,
{ issuable_id: merge_request.to_gid },
merge_request
).and_call_original
diff --git a/spec/helpers/sidebars_helper_spec.rb b/spec/helpers/sidebars_helper_spec.rb
index 968c56bb62d..c7d5c0cfc4f 100644
--- a/spec/helpers/sidebars_helper_spec.rb
+++ b/spec/helpers/sidebars_helper_spec.rb
@@ -405,6 +405,10 @@ RSpec.describe SidebarsHelper, feature_category: :navigation do
expect(helper.super_sidebar_nav_panel(nav: 'your_work', user: user)).to be_a(Sidebars::YourWork::Panel)
end
+ it 'returns Search Panel for search nav' do
+ expect(helper.super_sidebar_nav_panel(nav: 'search', user: user)).to be_a(Sidebars::Search::Panel)
+ end
+
it 'returns "Your Work" Panel as a fallback', :use_clean_rails_memory_store_caching do
expect(helper.super_sidebar_nav_panel(user: user)).to be_a(Sidebars::YourWork::Panel)
end
diff --git a/spec/lib/banzai/filter/math_filter_spec.rb b/spec/lib/banzai/filter/math_filter_spec.rb
index 374983e40a1..50784d3e423 100644
--- a/spec/lib/banzai/filter/math_filter_spec.rb
+++ b/spec/lib/banzai/filter/math_filter_spec.rb
@@ -101,6 +101,7 @@ RSpec.describe Banzai::Filter::MathFilter, feature_category: :team_planning do
context 'with valid syntax' do
where(:text, :result_template) do
"$$\n2+2\n$$" | "<math>2+2\n</math>"
+ "$$ \n2+2\n$$" | "<math>2+2\n</math>"
"$$\n2+2\n3+4\n$$" | "<math>2+2\n3+4\n</math>"
end
diff --git a/spec/lib/gitlab/database/migration_helpers/convert_to_bigint_spec.rb b/spec/lib/gitlab/database/migration_helpers/convert_to_bigint_spec.rb
index b1971977e7c..cee5f54bd6a 100644
--- a/spec/lib/gitlab/database/migration_helpers/convert_to_bigint_spec.rb
+++ b/spec/lib/gitlab/database/migration_helpers/convert_to_bigint_spec.rb
@@ -7,9 +7,9 @@ RSpec.describe Gitlab::Database::MigrationHelpers::ConvertToBigint, feature_cate
using RSpec::Parameterized::TableSyntax
where(:dot_com, :dev_or_test, :jh, :expectation) do
- true | true | true | false
+ true | true | true | true
true | false | true | false
- false | true | true | false
+ false | true | true | true
false | false | true | false
true | true | false | true
true | false | false | true
diff --git a/spec/lib/gitlab/email/reply_parser_spec.rb b/spec/lib/gitlab/email/reply_parser_spec.rb
index e4c68dbba92..35065b74eff 100644
--- a/spec/lib/gitlab/email/reply_parser_spec.rb
+++ b/spec/lib/gitlab/email/reply_parser_spec.rb
@@ -3,7 +3,7 @@
require "spec_helper"
# Inspired in great part by Discourse's Email::Receiver
-RSpec.describe Gitlab::Email::ReplyParser do
+RSpec.describe Gitlab::Email::ReplyParser, feature_category: :team_planning do
describe '#execute' do
def test_parse_body(mail_string, params = {})
described_class.new(Mail::Message.new(mail_string), **params).execute
@@ -188,67 +188,36 @@ RSpec.describe Gitlab::Email::ReplyParser do
)
end
- context 'properly renders email reply from gmail web client' do
- context 'when feature flag is enabled' do
- it do
- expect(test_parse_body(fixture_file("emails/html_only.eml")))
- .to eq(
- <<-BODY.strip_heredoc.chomp
- ### This is a reply from standard GMail in Google Chrome.
-
- The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
-
- Here's some **bold** text, **strong** text and *italic* in Markdown.
-
- Here's a link http://example.com
-
- Here's an img ![Miro](http://img.png)<details>
- <summary>
- One</summary>
- Some details</details>
-
- <details>
- <summary>
- Two</summary>
- Some details</details>
-
- Test reply.
-
- First paragraph.
-
- Second paragraph.
- BODY
- )
- end
- end
-
- context 'when feature flag is disabled' do
- before do
- stub_feature_flags(service_desk_html_to_text_email_handler: false)
- end
+ context 'properly renders email reply from gmail web client', feature_category: :service_desk do
+ it do
+ expect(test_parse_body(fixture_file("emails/html_only.eml")))
+ .to eq(
+ <<-BODY.strip_heredoc.chomp
+ ### This is a reply from standard GMail in Google Chrome.
- it do
- expect(test_parse_body(fixture_file("emails/html_only.eml")))
- .to eq(
- <<-BODY.strip_heredoc.chomp
- ### This is a reply from standard GMail in Google Chrome.
+ The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
- The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
+ Here's some **bold** text, **strong** text and *italic* in Markdown.
- Here's some **bold** text, strong text and italic in Markdown.
+ Here's a link http://example.com
- Here's a link http://example.com
+ Here's an img ![Miro](http://img.png)<details>
+ <summary>
+ One</summary>
+ Some details</details>
- Here's an img [Miro]One Some details Two Some details
+ <details>
+ <summary>
+ Two</summary>
+ Some details</details>
- Test reply.
+ Test reply.
- First paragraph.
+ First paragraph.
- Second paragraph.
- BODY
- )
- end
+ Second paragraph.
+ BODY
+ )
end
end
diff --git a/spec/lib/gitlab/kubernetes/helm/api_spec.rb b/spec/lib/gitlab/kubernetes/helm/api_spec.rb
deleted file mode 100644
index e022f5bd912..00000000000
--- a/spec/lib/gitlab/kubernetes/helm/api_spec.rb
+++ /dev/null
@@ -1,269 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Gitlab::Kubernetes::Helm::API do
- let(:client) { double('kubernetes client') }
- let(:helm) { described_class.new(client) }
- let(:gitlab_namespace) { Gitlab::Kubernetes::Helm::NAMESPACE }
- let(:gitlab_namespace_labels) { Gitlab::Kubernetes::Helm::NAMESPACE_LABELS }
- let(:namespace) { Gitlab::Kubernetes::Namespace.new(gitlab_namespace, client, labels: gitlab_namespace_labels) }
- let(:application_name) { 'app-name' }
- let(:rbac) { false }
- let(:files) { {} }
-
- let(:command) do
- Gitlab::Kubernetes::Helm::V2::InstallCommand.new(
- name: application_name,
- chart: 'chart-name',
- rbac: rbac,
- files: files
- )
- end
-
- subject { helm }
-
- before do
- allow(Gitlab::Kubernetes::Namespace).to(
- receive(:new).with(gitlab_namespace, client, labels: gitlab_namespace_labels).and_return(namespace)
- )
- allow(client).to receive(:create_config_map)
- end
-
- describe '#initialize' do
- it 'creates a namespace object' do
- expect(Gitlab::Kubernetes::Namespace).to(
- receive(:new).with(gitlab_namespace, client, labels: gitlab_namespace_labels)
- )
-
- subject
- end
- end
-
- describe '#uninstall' do
- before do
- allow(client).to receive(:create_pod).and_return(nil)
- allow(client).to receive(:get_config_map).and_return(nil)
- allow(client).to receive(:create_config_map).and_return(nil)
- allow(client).to receive(:delete_pod).and_return(nil)
- allow(namespace).to receive(:ensure_exists!).once
- end
-
- it 'ensures the namespace exists before creating the POD' do
- expect(namespace).to receive(:ensure_exists!).once.ordered
- expect(client).to receive(:create_pod).once.ordered
-
- subject.uninstall(command)
- end
-
- it 'removes an existing pod before installing' do
- expect(client).to receive(:delete_pod).with('install-app-name', 'gitlab-managed-apps').once.ordered
- expect(client).to receive(:create_pod).once.ordered
-
- subject.uninstall(command)
- end
-
- context 'with a ConfigMap' do
- let(:resource) { Gitlab::Kubernetes::ConfigMap.new(application_name, files).generate }
-
- it 'creates a ConfigMap on kubeclient' do
- expect(client).to receive(:create_config_map).with(resource).once
-
- subject.install(command)
- end
-
- context 'config map already exists' do
- before do
- expect(client).to receive(:get_config_map).with("values-content-configuration-#{application_name}", gitlab_namespace).and_return(resource)
- end
-
- it 'updates the config map' do
- expect(client).to receive(:update_config_map).with(resource).once
-
- subject.install(command)
- end
- end
- end
- end
-
- describe '#install' do
- before do
- allow(client).to receive(:create_pod).and_return(nil)
- allow(client).to receive(:get_config_map).and_return(nil)
- allow(client).to receive(:create_config_map).and_return(nil)
- allow(client).to receive(:create_service_account).and_return(nil)
- allow(client).to receive(:delete_pod).and_return(nil)
- allow(namespace).to receive(:ensure_exists!).once
- end
-
- it 'ensures the namespace exists before creating the POD' do
- expect(namespace).to receive(:ensure_exists!).once.ordered
- expect(client).to receive(:create_pod).once.ordered
-
- subject.install(command)
- end
-
- it 'removes an existing pod before installing' do
- expect(client).to receive(:delete_pod).with('install-app-name', 'gitlab-managed-apps').once.ordered
- expect(client).to receive(:create_pod).once.ordered
-
- subject.install(command)
- end
-
- context 'with a ConfigMap' do
- let(:resource) { Gitlab::Kubernetes::ConfigMap.new(application_name, files).generate }
-
- it 'creates a ConfigMap on kubeclient' do
- expect(client).to receive(:create_config_map).with(resource).once
-
- subject.install(command)
- end
-
- context 'config map already exists' do
- before do
- expect(client).to receive(:get_config_map).with("values-content-configuration-#{application_name}", gitlab_namespace).and_return(resource)
- end
-
- it 'updates the config map' do
- expect(client).to receive(:update_config_map).with(resource).once
-
- subject.install(command)
- end
- end
- end
-
- context 'without a service account' do
- it 'does not create a service account on kubeclient' do
- expect(client).not_to receive(:create_service_account)
- expect(client).not_to receive(:update_cluster_role_binding)
-
- subject.install(command)
- end
- end
-
- context 'with a service account' do
- let(:command) { Gitlab::Kubernetes::Helm::V2::InitCommand.new(name: application_name, files: files, rbac: rbac) }
-
- context 'rbac-enabled cluster' do
- let(:rbac) { true }
-
- let(:service_account_resource) do
- Kubeclient::Resource.new(metadata: { name: 'tiller', namespace: 'gitlab-managed-apps' })
- end
-
- let(:cluster_role_binding_resource) do
- Kubeclient::Resource.new(
- metadata: { name: 'tiller-admin' },
- roleRef: { apiGroup: 'rbac.authorization.k8s.io', kind: 'ClusterRole', name: 'cluster-admin' },
- subjects: [{ kind: 'ServiceAccount', name: 'tiller', namespace: 'gitlab-managed-apps' }]
- )
- end
-
- context 'service account does not exist' do
- before do
- expect(client).to receive(:get_service_account).with('tiller', 'gitlab-managed-apps').and_raise(Kubeclient::ResourceNotFoundError.new(404, 'Not found', nil))
- end
-
- it 'creates a service account, followed the cluster role binding on kubeclient' do
- expect(client).to receive(:create_service_account).with(service_account_resource).once.ordered
- expect(client).to receive(:update_cluster_role_binding).with(cluster_role_binding_resource).once.ordered
-
- subject.install(command)
- end
- end
-
- context 'service account already exists' do
- before do
- expect(client).to receive(:get_service_account).with('tiller', 'gitlab-managed-apps').and_return(service_account_resource)
- end
-
- it 'updates the service account, followed by creating the cluster role binding' do
- expect(client).to receive(:update_service_account).with(service_account_resource).once.ordered
- expect(client).to receive(:update_cluster_role_binding).with(cluster_role_binding_resource).once.ordered
-
- subject.install(command)
- end
- end
-
- context 'a non-404 error is thrown' do
- before do
- expect(client).to receive(:get_service_account).with('tiller', 'gitlab-managed-apps').and_raise(Kubeclient::HttpError.new(401, 'Unauthorized', nil))
- end
-
- it 'raises an error' do
- expect { subject.install(command) }.to raise_error(Kubeclient::HttpError)
- end
- end
- end
-
- context 'legacy abac cluster' do
- it 'does not create a service account on kubeclient' do
- expect(client).not_to receive(:create_service_account)
- expect(client).not_to receive(:update_cluster_role_binding)
-
- subject.install(command)
- end
- end
- end
- end
-
- describe '#status' do
- let(:phase) { Gitlab::Kubernetes::Pod::RUNNING }
- let(:pod) { Kubeclient::Resource.new(status: { phase: phase }) } # partial representation
-
- it 'fetches POD phase from kubernetes cluster' do
- expect(client).to receive(:get_pod).with(command.pod_name, gitlab_namespace).once.and_return(pod)
-
- expect(subject.status(command.pod_name)).to eq(phase)
- end
- end
-
- describe '#log' do
- let(:log) { 'some output' }
- let(:response) { RestClient::Response.new(log) }
-
- it 'fetches POD phase from kubernetes cluster' do
- expect(client).to receive(:get_pod_log).with(command.pod_name, gitlab_namespace).once.and_return(response)
-
- expect(subject.log(command.pod_name)).to eq(log)
- end
- end
-
- describe '#delete_pod!' do
- it 'deletes the POD from kubernetes cluster' do
- expect(client).to receive(:delete_pod).with('install-app-name', 'gitlab-managed-apps').once
-
- subject.delete_pod!('install-app-name')
- end
-
- context 'when the resource being deleted does not exist' do
- it 'catches the error' do
- expect(client).to receive(:delete_pod).with('install-app-name', 'gitlab-managed-apps')
- .and_raise(Kubeclient::ResourceNotFoundError.new(404, 'Not found', nil))
-
- subject.delete_pod!('install-app-name')
- end
- end
- end
-
- describe '#get_config_map' do
- before do
- allow(namespace).to receive(:ensure_exists!).once
- allow(client).to receive(:get_config_map).and_return(nil)
- end
-
- it 'ensures the namespace exists before retrieving the config map' do
- expect(namespace).to receive(:ensure_exists!).once
-
- subject.get_config_map('example-config-map-name')
- end
-
- it 'gets the config map on kubeclient' do
- expect(client).to receive(:get_config_map)
- .with('example-config-map-name', namespace.name)
- .once
-
- subject.get_config_map('example-config-map-name')
- end
- end
-end
diff --git a/spec/lib/gitlab/kubernetes/helm/v2/base_command_spec.rb b/spec/lib/gitlab/kubernetes/helm/v2/base_command_spec.rb
deleted file mode 100644
index 3d2b36b9094..00000000000
--- a/spec/lib/gitlab/kubernetes/helm/v2/base_command_spec.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Gitlab::Kubernetes::Helm::V2::BaseCommand do
- subject(:base_command) do
- test_class.new(rbac)
- end
-
- let(:application) { create(:clusters_applications_helm) }
- let(:rbac) { false }
-
- let(:test_class) do
- Class.new(described_class) do
- def initialize(rbac)
- super(
- name: 'test-class-name',
- rbac: rbac,
- files: { some: 'value' }
- )
- end
- end
- end
-
- describe 'HELM_VERSION' do
- subject { described_class::HELM_VERSION }
-
- it { is_expected.to match /^2\.\d+\.\d+$/ }
- end
-
- describe '#env' do
- subject { base_command.env }
-
- it { is_expected.to include(TILLER_NAMESPACE: 'gitlab-managed-apps') }
- end
-
- it_behaves_like 'helm command generator' do
- let(:commands) { '' }
- end
-
- describe '#pod_name' do
- subject { base_command.pod_name }
-
- it { is_expected.to eq('install-test-class-name') }
- end
-
- it_behaves_like 'helm command' do
- let(:command) { base_command }
- end
-end
diff --git a/spec/lib/gitlab/kubernetes/helm/v2/certificate_spec.rb b/spec/lib/gitlab/kubernetes/helm/v2/certificate_spec.rb
deleted file mode 100644
index 698b88c9fa1..00000000000
--- a/spec/lib/gitlab/kubernetes/helm/v2/certificate_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-# frozen_string_literal: true
-require 'fast_spec_helper'
-
-RSpec.describe Gitlab::Kubernetes::Helm::V2::Certificate do
- describe '.generate_root' do
- subject { described_class.generate_root }
-
- it 'generates a root CA that expires a long way in the future' do
- expect(subject.cert.not_after).to be > 999.years.from_now
- end
- end
-
- describe '#issue' do
- subject { described_class.generate_root.issue }
-
- it 'generates a cert that expires soon' do
- expect(subject.cert.not_after).to be < 60.minutes.from_now
- end
-
- context 'passing in INFINITE_EXPIRY' do
- subject { described_class.generate_root.issue(expires_in: described_class::INFINITE_EXPIRY) }
-
- it 'generates a cert that expires a long way in the future' do
- expect(subject.cert.not_after).to be > 999.years.from_now
- end
- end
- end
-end
diff --git a/spec/lib/gitlab/kubernetes/helm/v2/delete_command_spec.rb b/spec/lib/gitlab/kubernetes/helm/v2/delete_command_spec.rb
deleted file mode 100644
index 4a3a41dba4a..00000000000
--- a/spec/lib/gitlab/kubernetes/helm/v2/delete_command_spec.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Gitlab::Kubernetes::Helm::V2::DeleteCommand do
- subject(:delete_command) { described_class.new(name: app_name, rbac: rbac, files: files) }
-
- let(:app_name) { 'app-name' }
- let(:rbac) { true }
- let(:files) { {} }
-
- it_behaves_like 'helm command generator' do
- let(:commands) do
- <<~EOS
- export HELM_HOST="localhost:44134"
- tiller -listen ${HELM_HOST} -alsologtostderr &
- helm init --client-only
- helm delete --purge app-name
- EOS
- end
- end
-
- describe '#pod_name' do
- subject { delete_command.pod_name }
-
- it { is_expected.to eq('uninstall-app-name') }
- end
-
- it_behaves_like 'helm command' do
- let(:command) { delete_command }
- end
-
- describe '#delete_command' do
- it 'deletes the release' do
- expect(subject.delete_command).to eq('helm delete --purge app-name')
- end
- end
-end
diff --git a/spec/lib/gitlab/kubernetes/helm/v2/init_command_spec.rb b/spec/lib/gitlab/kubernetes/helm/v2/init_command_spec.rb
deleted file mode 100644
index 8ae78ada15c..00000000000
--- a/spec/lib/gitlab/kubernetes/helm/v2/init_command_spec.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Gitlab::Kubernetes::Helm::V2::InitCommand do
- subject(:init_command) { described_class.new(name: application.name, files: files, rbac: rbac) }
-
- let(:application) { create(:clusters_applications_helm) }
- let(:rbac) { false }
- let(:files) { {} }
-
- it_behaves_like 'helm command generator' do
- let(:commands) do
- <<~EOS
- helm init --tiller-tls --tiller-tls-verify --tls-ca-cert /data/helm/helm/config/ca.pem --tiller-tls-cert /data/helm/helm/config/cert.pem --tiller-tls-key /data/helm/helm/config/key.pem
- EOS
- end
- end
-
- context 'on a rbac-enabled cluster' do
- let(:rbac) { true }
-
- it_behaves_like 'helm command generator' do
- let(:commands) do
- <<~EOS
- helm init --tiller-tls --tiller-tls-verify --tls-ca-cert /data/helm/helm/config/ca.pem --tiller-tls-cert /data/helm/helm/config/cert.pem --tiller-tls-key /data/helm/helm/config/key.pem --service-account tiller
- EOS
- end
- end
- end
-
- it_behaves_like 'helm command' do
- let(:command) { init_command }
- end
-end
diff --git a/spec/lib/gitlab/kubernetes/helm/v2/install_command_spec.rb b/spec/lib/gitlab/kubernetes/helm/v2/install_command_spec.rb
deleted file mode 100644
index 250d1a82e7a..00000000000
--- a/spec/lib/gitlab/kubernetes/helm/v2/install_command_spec.rb
+++ /dev/null
@@ -1,183 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Gitlab::Kubernetes::Helm::V2::InstallCommand do
- subject(:install_command) do
- described_class.new(
- name: 'app-name',
- chart: 'chart-name',
- rbac: rbac,
- files: files,
- version: version,
- repository: repository,
- preinstall: preinstall,
- postinstall: postinstall
- )
- end
-
- let(:files) { { 'ca.pem': 'some file content' } }
- let(:repository) { 'https://repository.example.com' }
- let(:rbac) { false }
- let(:version) { '1.2.3' }
- let(:preinstall) { nil }
- let(:postinstall) { nil }
-
- it_behaves_like 'helm command generator' do
- let(:commands) do
- <<~EOS
- export HELM_HOST="localhost:44134"
- tiller -listen ${HELM_HOST} -alsologtostderr &
- helm init --client-only
- helm repo add app-name https://repository.example.com
- helm repo update
- #{helm_install_comand}
- EOS
- end
-
- let(:helm_install_comand) do
- <<~EOS.squish
- helm upgrade app-name chart-name
- --install
- --atomic
- --cleanup-on-fail
- --reset-values
- --version 1.2.3
- --set rbac.create\\=false,rbac.enabled\\=false
- --namespace gitlab-managed-apps
- -f /data/helm/app-name/config/values.yaml
- EOS
- end
- end
-
- context 'when rbac is true' do
- let(:rbac) { true }
-
- it_behaves_like 'helm command generator' do
- let(:commands) do
- <<~EOS
- export HELM_HOST="localhost:44134"
- tiller -listen ${HELM_HOST} -alsologtostderr &
- helm init --client-only
- helm repo add app-name https://repository.example.com
- helm repo update
- #{helm_install_command}
- EOS
- end
-
- let(:helm_install_command) do
- <<~EOS.squish
- helm upgrade app-name chart-name
- --install
- --atomic
- --cleanup-on-fail
- --reset-values
- --version 1.2.3
- --set rbac.create\\=true,rbac.enabled\\=true
- --namespace gitlab-managed-apps
- -f /data/helm/app-name/config/values.yaml
- EOS
- end
- end
- end
-
- context 'when there is a pre-install script' do
- let(:preinstall) { ['/bin/date', '/bin/true'] }
-
- it_behaves_like 'helm command generator' do
- let(:commands) do
- <<~EOS
- export HELM_HOST="localhost:44134"
- tiller -listen ${HELM_HOST} -alsologtostderr &
- helm init --client-only
- helm repo add app-name https://repository.example.com
- helm repo update
- /bin/date
- /bin/true
- #{helm_install_command}
- EOS
- end
-
- let(:helm_install_command) do
- <<~EOS.squish
- helm upgrade app-name chart-name
- --install
- --atomic
- --cleanup-on-fail
- --reset-values
- --version 1.2.3
- --set rbac.create\\=false,rbac.enabled\\=false
- --namespace gitlab-managed-apps
- -f /data/helm/app-name/config/values.yaml
- EOS
- end
- end
- end
-
- context 'when there is a post-install script' do
- let(:postinstall) { ['/bin/date', "/bin/false\n"] }
-
- it_behaves_like 'helm command generator' do
- let(:commands) do
- <<~EOS
- export HELM_HOST="localhost:44134"
- tiller -listen ${HELM_HOST} -alsologtostderr &
- helm init --client-only
- helm repo add app-name https://repository.example.com
- helm repo update
- #{helm_install_command}
- /bin/date
- /bin/false
- EOS
- end
-
- let(:helm_install_command) do
- <<~EOS.squish
- helm upgrade app-name chart-name
- --install
- --atomic
- --cleanup-on-fail
- --reset-values
- --version 1.2.3
- --set rbac.create\\=false,rbac.enabled\\=false
- --namespace gitlab-managed-apps
- -f /data/helm/app-name/config/values.yaml
- EOS
- end
- end
- end
-
- context 'when there is no version' do
- let(:version) { nil }
-
- it_behaves_like 'helm command generator' do
- let(:commands) do
- <<~EOS
- export HELM_HOST="localhost:44134"
- tiller -listen ${HELM_HOST} -alsologtostderr &
- helm init --client-only
- helm repo add app-name https://repository.example.com
- helm repo update
- #{helm_install_command}
- EOS
- end
-
- let(:helm_install_command) do
- <<~EOS.squish
- helm upgrade app-name chart-name
- --install
- --atomic
- --cleanup-on-fail
- --reset-values
- --set rbac.create\\=false,rbac.enabled\\=false
- --namespace gitlab-managed-apps
- -f /data/helm/app-name/config/values.yaml
- EOS
- end
- end
- end
-
- it_behaves_like 'helm command' do
- let(:command) { install_command }
- end
-end
diff --git a/spec/lib/gitlab/kubernetes/helm/v2/patch_command_spec.rb b/spec/lib/gitlab/kubernetes/helm/v2/patch_command_spec.rb
deleted file mode 100644
index 98eb77d397c..00000000000
--- a/spec/lib/gitlab/kubernetes/helm/v2/patch_command_spec.rb
+++ /dev/null
@@ -1,87 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Gitlab::Kubernetes::Helm::V2::PatchCommand do
- let(:files) { { 'ca.pem': 'some file content' } }
- let(:repository) { 'https://repository.example.com' }
- let(:rbac) { false }
- let(:version) { '1.2.3' }
-
- subject(:patch_command) do
- described_class.new(
- name: 'app-name',
- chart: 'chart-name',
- rbac: rbac,
- files: files,
- version: version,
- repository: repository
- )
- end
-
- it_behaves_like 'helm command generator' do
- let(:commands) do
- <<~EOS
- export HELM_HOST="localhost:44134"
- tiller -listen ${HELM_HOST} -alsologtostderr &
- helm init --client-only
- helm repo add app-name https://repository.example.com
- helm repo update
- #{helm_upgrade_comand}
- EOS
- end
-
- let(:helm_upgrade_comand) do
- <<~EOS.squish
- helm upgrade app-name chart-name
- --reuse-values
- --version 1.2.3
- --namespace gitlab-managed-apps
- -f /data/helm/app-name/config/values.yaml
- EOS
- end
- end
-
- context 'when rbac is true' do
- let(:rbac) { true }
-
- it_behaves_like 'helm command generator' do
- let(:commands) do
- <<~EOS
- export HELM_HOST="localhost:44134"
- tiller -listen ${HELM_HOST} -alsologtostderr &
- helm init --client-only
- helm repo add app-name https://repository.example.com
- helm repo update
- #{helm_upgrade_command}
- EOS
- end
-
- let(:helm_upgrade_command) do
- <<~EOS.squish
- helm upgrade app-name chart-name
- --reuse-values
- --version 1.2.3
- --namespace gitlab-managed-apps
- -f /data/helm/app-name/config/values.yaml
- EOS
- end
- end
- end
-
- context 'when there is no version' do
- let(:version) { nil }
-
- it { expect { patch_command }.to raise_error(ArgumentError, 'version is required') }
- end
-
- describe '#pod_name' do
- subject { patch_command.pod_name }
-
- it { is_expected.to eq 'install-app-name' }
- end
-
- it_behaves_like 'helm command' do
- let(:command) { patch_command }
- end
-end
diff --git a/spec/lib/gitlab/kubernetes/helm/v2/reset_command_spec.rb b/spec/lib/gitlab/kubernetes/helm/v2/reset_command_spec.rb
deleted file mode 100644
index 2a3a4cec2b0..00000000000
--- a/spec/lib/gitlab/kubernetes/helm/v2/reset_command_spec.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Gitlab::Kubernetes::Helm::V2::ResetCommand do
- subject(:reset_command) { described_class.new(name: name, rbac: rbac, files: files) }
-
- let(:rbac) { true }
- let(:name) { 'helm' }
- let(:files) { {} }
-
- it_behaves_like 'helm command generator' do
- let(:commands) do
- <<~EOS
- export HELM_HOST="localhost:44134"
- tiller -listen ${HELM_HOST} -alsologtostderr &
- helm init --client-only
- helm reset --force
- EOS
- end
- end
-
- describe '#pod_name' do
- subject { reset_command.pod_name }
-
- it { is_expected.to eq('uninstall-helm') }
- end
-
- it_behaves_like 'helm command' do
- let(:command) { reset_command }
- end
-end
diff --git a/spec/lib/gitlab/kubernetes/helm/v3/base_command_spec.rb b/spec/lib/gitlab/kubernetes/helm/v3/base_command_spec.rb
deleted file mode 100644
index ad5ff13b4c9..00000000000
--- a/spec/lib/gitlab/kubernetes/helm/v3/base_command_spec.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Gitlab::Kubernetes::Helm::V3::BaseCommand do
- subject(:base_command) do
- test_class.new(rbac)
- end
-
- let(:application) { create(:clusters_applications_helm) }
- let(:rbac) { false }
-
- let(:test_class) do
- Class.new(described_class) do
- def initialize(rbac)
- super(
- name: 'test-class-name',
- rbac: rbac,
- files: { some: 'value' }
- )
- end
- end
- end
-
- describe 'HELM_VERSION' do
- subject { described_class::HELM_VERSION }
-
- it { is_expected.to match /^3\.\d+\.\d+$/ }
- end
-
- it_behaves_like 'helm command generator' do
- let(:commands) { '' }
- end
-
- describe '#pod_name' do
- subject { base_command.pod_name }
-
- it { is_expected.to eq('install-test-class-name') }
- end
-
- it_behaves_like 'helm command' do
- let(:command) { base_command }
- end
-end
diff --git a/spec/lib/gitlab/kubernetes/helm/v3/delete_command_spec.rb b/spec/lib/gitlab/kubernetes/helm/v3/delete_command_spec.rb
deleted file mode 100644
index 63e7a8d2f25..00000000000
--- a/spec/lib/gitlab/kubernetes/helm/v3/delete_command_spec.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Gitlab::Kubernetes::Helm::V3::DeleteCommand do
- subject(:delete_command) { described_class.new(name: app_name, rbac: rbac, files: files) }
-
- let(:app_name) { 'app-name' }
- let(:rbac) { true }
- let(:files) { {} }
-
- it_behaves_like 'helm command generator' do
- let(:commands) do
- <<~EOS
- helm uninstall app-name --namespace gitlab-managed-apps
- EOS
- end
- end
-
- describe '#pod_name' do
- subject { delete_command.pod_name }
-
- it { is_expected.to eq('uninstall-app-name') }
- end
-
- it_behaves_like 'helm command' do
- let(:command) { delete_command }
- end
-
- describe '#delete_command' do
- it 'deletes the release' do
- expect(subject.delete_command).to eq('helm uninstall app-name --namespace gitlab-managed-apps')
- end
- end
-end
diff --git a/spec/lib/gitlab/kubernetes/helm/v3/install_command_spec.rb b/spec/lib/gitlab/kubernetes/helm/v3/install_command_spec.rb
deleted file mode 100644
index 2bf1f713b3f..00000000000
--- a/spec/lib/gitlab/kubernetes/helm/v3/install_command_spec.rb
+++ /dev/null
@@ -1,168 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Gitlab::Kubernetes::Helm::V3::InstallCommand do
- subject(:install_command) do
- described_class.new(
- name: 'app-name',
- chart: 'chart-name',
- rbac: rbac,
- files: files,
- version: version,
- repository: repository,
- preinstall: preinstall,
- postinstall: postinstall
- )
- end
-
- let(:files) { { 'ca.pem': 'some file content' } }
- let(:repository) { 'https://repository.example.com' }
- let(:rbac) { false }
- let(:version) { '1.2.3' }
- let(:preinstall) { nil }
- let(:postinstall) { nil }
-
- it_behaves_like 'helm command generator' do
- let(:commands) do
- <<~EOS
- helm repo add app-name https://repository.example.com
- helm repo update
- #{helm_install_comand}
- EOS
- end
-
- let(:helm_install_comand) do
- <<~EOS.squish
- helm upgrade app-name chart-name
- --install
- --atomic
- --cleanup-on-fail
- --reset-values
- --version 1.2.3
- --set rbac.create\\=false,rbac.enabled\\=false
- --namespace gitlab-managed-apps
- -f /data/helm/app-name/config/values.yaml
- EOS
- end
- end
-
- context 'when rbac is true' do
- let(:rbac) { true }
-
- it_behaves_like 'helm command generator' do
- let(:commands) do
- <<~EOS
- helm repo add app-name https://repository.example.com
- helm repo update
- #{helm_install_command}
- EOS
- end
-
- let(:helm_install_command) do
- <<~EOS.squish
- helm upgrade app-name chart-name
- --install
- --atomic
- --cleanup-on-fail
- --reset-values
- --version 1.2.3
- --set rbac.create\\=true,rbac.enabled\\=true
- --namespace gitlab-managed-apps
- -f /data/helm/app-name/config/values.yaml
- EOS
- end
- end
- end
-
- context 'when there is a pre-install script' do
- let(:preinstall) { ['/bin/date', '/bin/true'] }
-
- it_behaves_like 'helm command generator' do
- let(:commands) do
- <<~EOS
- helm repo add app-name https://repository.example.com
- helm repo update
- /bin/date
- /bin/true
- #{helm_install_command}
- EOS
- end
-
- let(:helm_install_command) do
- <<~EOS.squish
- helm upgrade app-name chart-name
- --install
- --atomic
- --cleanup-on-fail
- --reset-values
- --version 1.2.3
- --set rbac.create\\=false,rbac.enabled\\=false
- --namespace gitlab-managed-apps
- -f /data/helm/app-name/config/values.yaml
- EOS
- end
- end
- end
-
- context 'when there is a post-install script' do
- let(:postinstall) { ['/bin/date', "/bin/false\n"] }
-
- it_behaves_like 'helm command generator' do
- let(:commands) do
- <<~EOS
- helm repo add app-name https://repository.example.com
- helm repo update
- #{helm_install_command}
- /bin/date
- /bin/false
- EOS
- end
-
- let(:helm_install_command) do
- <<~EOS.squish
- helm upgrade app-name chart-name
- --install
- --atomic
- --cleanup-on-fail
- --reset-values
- --version 1.2.3
- --set rbac.create\\=false,rbac.enabled\\=false
- --namespace gitlab-managed-apps
- -f /data/helm/app-name/config/values.yaml
- EOS
- end
- end
- end
-
- context 'when there is no version' do
- let(:version) { nil }
-
- it_behaves_like 'helm command generator' do
- let(:commands) do
- <<~EOS
- helm repo add app-name https://repository.example.com
- helm repo update
- #{helm_install_command}
- EOS
- end
-
- let(:helm_install_command) do
- <<~EOS.squish
- helm upgrade app-name chart-name
- --install
- --atomic
- --cleanup-on-fail
- --reset-values
- --set rbac.create\\=false,rbac.enabled\\=false
- --namespace gitlab-managed-apps
- -f /data/helm/app-name/config/values.yaml
- EOS
- end
- end
- end
-
- it_behaves_like 'helm command' do
- let(:command) { install_command }
- end
-end
diff --git a/spec/lib/gitlab/kubernetes/helm/v3/patch_command_spec.rb b/spec/lib/gitlab/kubernetes/helm/v3/patch_command_spec.rb
deleted file mode 100644
index 2f22e0f2e77..00000000000
--- a/spec/lib/gitlab/kubernetes/helm/v3/patch_command_spec.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Gitlab::Kubernetes::Helm::V3::PatchCommand do
- let(:files) { { 'ca.pem': 'some file content' } }
- let(:repository) { 'https://repository.example.com' }
- let(:rbac) { false }
- let(:version) { '1.2.3' }
-
- subject(:patch_command) do
- described_class.new(
- name: 'app-name',
- chart: 'chart-name',
- rbac: rbac,
- files: files,
- version: version,
- repository: repository
- )
- end
-
- it_behaves_like 'helm command generator' do
- let(:commands) do
- <<~EOS
- helm repo add app-name https://repository.example.com
- helm repo update
- #{helm_upgrade_comand}
- EOS
- end
-
- let(:helm_upgrade_comand) do
- <<~EOS.squish
- helm upgrade app-name chart-name
- --reuse-values
- --version 1.2.3
- --namespace gitlab-managed-apps
- -f /data/helm/app-name/config/values.yaml
- EOS
- end
- end
-
- context 'when rbac is true' do
- let(:rbac) { true }
-
- it_behaves_like 'helm command generator' do
- let(:commands) do
- <<~EOS
- helm repo add app-name https://repository.example.com
- helm repo update
- #{helm_upgrade_command}
- EOS
- end
-
- let(:helm_upgrade_command) do
- <<~EOS.squish
- helm upgrade app-name chart-name
- --reuse-values
- --version 1.2.3
- --namespace gitlab-managed-apps
- -f /data/helm/app-name/config/values.yaml
- EOS
- end
- end
- end
-
- context 'when there is no version' do
- let(:version) { nil }
-
- it { expect { patch_command }.to raise_error(ArgumentError, 'version is required') }
- end
-
- describe '#pod_name' do
- subject { patch_command.pod_name }
-
- it { is_expected.to eq 'install-app-name' }
- end
-
- it_behaves_like 'helm command' do
- let(:command) { patch_command }
- end
-end
diff --git a/spec/lib/gitlab/regex_spec.rb b/spec/lib/gitlab/regex_spec.rb
index e01b9fedba4..5e58282ff92 100644
--- a/spec/lib/gitlab/regex_spec.rb
+++ b/spec/lib/gitlab/regex_spec.rb
@@ -1189,10 +1189,21 @@ RSpec.describe Gitlab::Regex, feature_category: :tooling do
MARKDOWN
end
- it { is_expected.to match(%(<section>\nsomething\n</section>)) }
- it { is_expected.not_to match(%(must start in first column <section>\nsomething\n</section>)) }
- it { is_expected.not_to match(%(<section>must be multi-line</section>)) }
- it { expect(subject.match(markdown)[:html]).to eq expected }
+ describe 'normal regular expression' do
+ it { is_expected.to match(%(<section>\nsomething\n</section>)) }
+ it { is_expected.not_to match(%(must start in first column <section>\nsomething\n</section>)) }
+ it { is_expected.not_to match(%(<section>must be multi-line</section>)) }
+ it { expect(subject.match(markdown)[:html]).to eq expected }
+ end
+
+ describe 'untrusted regular expression' do
+ subject { Gitlab::UntrustedRegexp.new(described_class::MARKDOWN_HTML_BLOCK_REGEX_UNTRUSTED, multiline: true) }
+
+ it { is_expected.to match(%(<section>\nsomething\n</section>)) }
+ it { is_expected.not_to match(%(must start in first column <section>\nsomething\n</section>)) }
+ it { is_expected.not_to match(%(<section>must be multi-line</section>)) }
+ it { expect(subject.match(markdown)[:html]).to eq expected }
+ end
end
context 'HTML comment lines' do
diff --git a/spec/lib/gitlab/untrusted_regexp_spec.rb b/spec/lib/gitlab/untrusted_regexp_spec.rb
index 66675b20107..232329a5a1b 100644
--- a/spec/lib/gitlab/untrusted_regexp_spec.rb
+++ b/spec/lib/gitlab/untrusted_regexp_spec.rb
@@ -3,7 +3,7 @@
require 'fast_spec_helper'
require 'support/shared_examples/lib/gitlab/malicious_regexp_shared_examples'
-RSpec.describe Gitlab::UntrustedRegexp do
+RSpec.describe Gitlab::UntrustedRegexp, feature_category: :shared do
describe '#initialize' do
subject { described_class.new(pattern) }
@@ -22,6 +22,39 @@ RSpec.describe Gitlab::UntrustedRegexp do
end
end
+ describe '#replace_gsub' do
+ let(:regex_str) { '(?P<scheme>(ftp))' }
+ let(:regex) { described_class.new(regex_str, multiline: true) }
+
+ def result(regex, text)
+ regex.replace_gsub(text) do |match|
+ if match[:scheme]
+ "http|#{match[:scheme]}|rss"
+ else
+ match.to_s
+ end
+ end
+ end
+
+ it 'replaces all instances of the match in a string' do
+ text = 'Use only https instead of ftp'
+
+ expect(result(regex, text)).to eq('Use only https instead of http|ftp|rss')
+ end
+
+ it 'replaces nothing when no match' do
+ text = 'Use only https instead of gopher'
+
+ expect(result(regex, text)).to eq(text)
+ end
+
+ it 'handles empty text' do
+ text = ''
+
+ expect(result(regex, text)).to eq('')
+ end
+ end
+
describe '#replace' do
it 'replaces the first instance of the match in a string' do
result = described_class.new('foo').replace('foo bar foo', 'oof')
diff --git a/spec/lib/sidebars/projects/menus/issues_menu_spec.rb b/spec/lib/sidebars/projects/menus/issues_menu_spec.rb
index c7ff846bc95..f783e7fcff2 100644
--- a/spec/lib/sidebars/projects/menus/issues_menu_spec.rb
+++ b/spec/lib/sidebars/projects/menus/issues_menu_spec.rb
@@ -56,7 +56,7 @@ RSpec.describe Sidebars::Projects::Menus::IssuesMenu, feature_category: :navigat
describe '#pill_count' do
it 'returns zero when there are no open issues' do
- expect(subject.pill_count).to eq 0
+ expect(subject.pill_count).to eq '0'
end
it 'memoizes the query' do
@@ -74,7 +74,14 @@ RSpec.describe Sidebars::Projects::Menus::IssuesMenu, feature_category: :navigat
create_list(:issue, 2, :opened, project: project)
create(:issue, :closed, project: project)
- expect(subject.pill_count).to eq 2
+ expect(subject.pill_count).to eq '2'
+ end
+ end
+
+ describe 'formatting' do
+ it 'returns truncated digits for count value over 1000' do
+ allow(project).to receive(:open_issues_count).and_return 1001
+ expect(subject.pill_count).to eq('1k')
end
end
end
diff --git a/spec/lib/sidebars/projects/menus/merge_requests_menu_spec.rb b/spec/lib/sidebars/projects/menus/merge_requests_menu_spec.rb
index a19df559b58..697f8a6d7c7 100644
--- a/spec/lib/sidebars/projects/menus/merge_requests_menu_spec.rb
+++ b/spec/lib/sidebars/projects/menus/merge_requests_menu_spec.rb
@@ -51,7 +51,7 @@ RSpec.describe Sidebars::Projects::Menus::MergeRequestsMenu, feature_category: :
describe '#pill_count' do
it 'returns zero when there are no open merge requests' do
- expect(subject.pill_count).to eq 0
+ expect(subject.pill_count).to eq '0'
end
it 'memoizes the query' do
@@ -69,7 +69,16 @@ RSpec.describe Sidebars::Projects::Menus::MergeRequestsMenu, feature_category: :
create_list(:merge_request, 2, :unique_branches, source_project: project, author: user, state: :opened)
create(:merge_request, source_project: project, state: :merged)
- expect(subject.pill_count).to eq 2
+ expect(subject.pill_count).to eq '2'
+ end
+ end
+
+ describe 'formatting' do
+ it 'returns truncated digits for count value over 1000' do
+ create_list(:merge_request, 1001, :unique_branches, source_project: project, author: user, state: :opened)
+ create(:merge_request, source_project: project, state: :merged)
+
+ expect(subject.pill_count).to eq('1k')
end
end
end
diff --git a/spec/lib/sidebars/search/panel_spec.rb b/spec/lib/sidebars/search/panel_spec.rb
new file mode 100644
index 00000000000..8561dc0b875
--- /dev/null
+++ b/spec/lib/sidebars/search/panel_spec.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Sidebars::Search::Panel, feature_category: :navigation do
+ let_it_be(:current_user) { create(:user) }
+ let_it_be(:user) { create(:user) }
+
+ let(:context) { Sidebars::Context.new(current_user: current_user, container: user) }
+ let(:panel) { described_class.new(context) }
+
+ subject { described_class.new(context) }
+
+ describe '#aria_label' do
+ it 'returns the correct aria label' do
+ expect(panel.aria_label).to eq(_('Search'))
+ end
+ end
+
+ describe '#super_sidebar_context_header' do
+ it 'returns a hash with the correct title and icon' do
+ expected_header = {
+ title: 'Search',
+ icon: 'search'
+ }
+ expect(panel.super_sidebar_context_header).to eq(expected_header)
+ end
+ end
+end
diff --git a/spec/models/clusters/applications/helm_spec.rb b/spec/models/clusters/applications/helm_spec.rb
deleted file mode 100644
index 1b8be92475a..00000000000
--- a/spec/models/clusters/applications/helm_spec.rb
+++ /dev/null
@@ -1,116 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Clusters::Applications::Helm do
- include_examples 'cluster application core specs', :clusters_applications_helm
-
- describe 'default values' do
- it { expect(subject.version).to eq(Gitlab::Kubernetes::Helm::V2::BaseCommand::HELM_VERSION) }
- end
-
- describe '.available' do
- subject { described_class.available }
-
- let!(:installed_cluster) { create(:clusters_applications_helm, :installed) }
- let!(:updated_cluster) { create(:clusters_applications_helm, :updated) }
-
- before do
- create(:clusters_applications_helm, :errored)
- end
-
- it { is_expected.to contain_exactly(installed_cluster, updated_cluster) }
- end
-
- describe '#can_uninstall?' do
- subject(:application) { build(:clusters_applications_helm).can_uninstall? }
-
- it { is_expected.to eq true }
- end
-
- describe '#issue_client_cert' do
- let(:application) { create(:clusters_applications_helm) }
-
- subject { application.issue_client_cert }
-
- it 'returns a new cert' do
- is_expected.to be_kind_of(Gitlab::Kubernetes::Helm::V2::Certificate)
- expect(subject.cert_string).not_to eq(application.ca_cert)
- expect(subject.key_string).not_to eq(application.ca_key)
- end
- end
-
- describe '#install_command' do
- let(:helm) { create(:clusters_applications_helm) }
-
- subject { helm.install_command }
-
- it { is_expected.to be_an_instance_of(Gitlab::Kubernetes::Helm::V2::InitCommand) }
-
- it 'is initialized with 1 arguments' do
- expect(subject.name).to eq('helm')
- end
-
- it 'has cert files' do
- expect(subject.files[:'ca.pem']).to be_present
- expect(subject.files[:'ca.pem']).to eq(helm.ca_cert)
-
- expect(subject.files[:'cert.pem']).to be_present
- expect(subject.files[:'key.pem']).to be_present
-
- cert = OpenSSL::X509::Certificate.new(subject.files[:'cert.pem'])
- expect(cert.not_after).to be > 999.years.from_now
- end
-
- describe 'rbac' do
- context 'rbac cluster' do
- it { expect(subject).to be_rbac }
- end
-
- context 'non rbac cluster' do
- before do
- helm.cluster.platform_kubernetes.abac!
- end
-
- it { expect(subject).not_to be_rbac }
- end
- end
- end
-
- describe '#uninstall_command' do
- let(:helm) { create(:clusters_applications_helm) }
-
- subject { helm.uninstall_command }
-
- it { is_expected.to be_an_instance_of(Gitlab::Kubernetes::Helm::V2::ResetCommand) }
-
- it 'has name' do
- expect(subject.name).to eq('helm')
- end
-
- it 'has cert files' do
- expect(subject.files[:'ca.pem']).to be_present
- expect(subject.files[:'ca.pem']).to eq(helm.ca_cert)
-
- expect(subject.files[:'cert.pem']).to be_present
- expect(subject.files[:'key.pem']).to be_present
-
- cert = OpenSSL::X509::Certificate.new(subject.files[:'cert.pem'])
- expect(cert.not_after).to be > 999.years.from_now
- end
-
- describe 'rbac' do
- context 'rbac cluster' do
- it { expect(subject).to be_rbac }
- end
-
- context 'non rbac cluster' do
- before do
- helm.cluster.platform_kubernetes.abac!
- end
-
- it { expect(subject).not_to be_rbac }
- end
- end
- end
-end
diff --git a/spec/models/clusters/cluster_spec.rb b/spec/models/clusters/cluster_spec.rb
index f1d4a91f289..b038eb7c03e 100644
--- a/spec/models/clusters/cluster_spec.rb
+++ b/spec/models/clusters/cluster_spec.rb
@@ -23,7 +23,6 @@ feature_category: :kubernetes_management do
it { is_expected.to have_one(:provider_aws) }
it { is_expected.to have_one(:platform_kubernetes) }
it { is_expected.to have_one(:integration_prometheus) }
- it { is_expected.to have_one(:application_helm) }
it { is_expected.to have_many(:kubernetes_namespaces) }
it { is_expected.to have_one(:cluster_project) }
it { is_expected.to have_many(:deployment_clusters) }
@@ -45,15 +44,6 @@ feature_category: :kubernetes_management do
let(:factory_name) { :cluster }
end
- describe 'applications have inverse_of: :cluster option' do
- let(:cluster) { create(:cluster) }
- let!(:helm) { create(:clusters_applications_helm, cluster: cluster) }
-
- it 'does not do a third query when referencing cluster again' do
- expect { cluster.application_helm.cluster }.not_to exceed_query_limit(2)
- end
- end
-
describe '.enabled' do
subject { described_class.enabled }
@@ -688,89 +678,6 @@ feature_category: :kubernetes_management do
end
end
- describe '.with_persisted_applications' do
- let(:cluster) { create(:cluster) }
- let!(:helm) { create(:clusters_applications_helm, :installed, cluster: cluster) }
-
- it 'preloads persisted applications' do
- query_rec = ActiveRecord::QueryRecorder.new do
- described_class.with_persisted_applications.find_by_id(cluster.id).application_helm
- end
-
- expect(query_rec.count).to eq(1)
- end
- end
-
- describe '#persisted_applications' do
- let(:cluster) { create(:cluster) }
-
- subject { cluster.persisted_applications }
-
- context 'when applications are created' do
- let!(:helm) { create(:clusters_applications_helm, cluster: cluster) }
-
- it 'returns a list of created applications' do
- is_expected.to contain_exactly(helm)
- end
- end
- end
-
- describe '#applications' do
- let_it_be(:cluster, reload: true) { create(:cluster) }
-
- subject { cluster.applications }
-
- context 'when none of applications are created' do
- it 'returns a list of a new objects' do
- is_expected.not_to be_empty
- end
- end
-
- context 'when applications are created' do
- let(:cluster) { create(:cluster, :with_all_applications) }
-
- it 'returns a list of created applications', :aggregate_failures do
- is_expected.to have_attributes(size: described_class::APPLICATIONS.size)
- is_expected.to all(be_kind_of(::Clusters::Concerns::ApplicationCore))
- is_expected.to all(be_persisted)
- end
- end
- end
-
- describe '#find_or_build_application' do
- let_it_be(:cluster, reload: true) { create(:cluster) }
-
- it 'rejects classes that are not applications' do
- expect do
- cluster.find_or_build_application(Project)
- end.to raise_error(ArgumentError)
- end
-
- context 'when none of applications are created' do
- it 'returns the new application', :aggregate_failures do
- described_class::APPLICATIONS.values.each do |application_class|
- application = cluster.find_or_build_application(application_class)
-
- expect(application).to be_a(application_class)
- expect(application).not_to be_persisted
- end
- end
- end
-
- context 'when application is persisted' do
- let(:cluster) { create(:cluster, :with_all_applications) }
-
- it 'returns the persisted application', :aggregate_failures do
- described_class::APPLICATIONS.each_value do |application_class|
- application = cluster.find_or_build_application(application_class)
-
- expect(application).to be_kind_of(::Clusters::Concerns::ApplicationCore)
- expect(application).to be_persisted
- end
- end
- end
- end
-
describe '#allow_user_defined_namespace?' do
subject { cluster.allow_user_defined_namespace? }
@@ -820,7 +727,7 @@ feature_category: :kubernetes_management do
describe '#all_projects' do
context 'cluster_type is project_type' do
let(:project) { create(:project) }
- let(:cluster) { create(:cluster, :with_installed_helm, projects: [project]) }
+ let(:cluster) { create(:cluster, projects: [project]) }
it 'returns projects' do
expect(cluster.all_projects).to match_array [project]
@@ -830,7 +737,7 @@ feature_category: :kubernetes_management do
context 'cluster_type is group_type' do
let(:group) { create(:group) }
let!(:project) { create(:project, group: group) }
- let(:cluster) { create(:cluster_for_group, :with_installed_helm, groups: [group]) }
+ let(:cluster) { create(:cluster_for_group, groups: [group]) }
it 'returns group projects' do
expect(cluster.all_projects.ids).to match_array [project.id]
@@ -1468,34 +1375,4 @@ feature_category: :kubernetes_management do
end
end
end
-
- describe '#application_helm_available?' do
- subject(:application_helm_available?) { cluster.application_helm_available? }
-
- before do
- allow(cluster).to receive(:application_helm).and_return(application_helm)
- end
-
- context 'without application_helm' do
- let(:application_helm) {}
-
- it { is_expected.to eq(false) }
- end
-
- context 'with application_helm' do
- let(:application_helm) { instance_double(Clusters::Applications::Helm, available?: available?) }
-
- context 'with available? set to true' do
- let(:available?) { true }
-
- it { is_expected.to eq(true) }
- end
-
- context 'with available? set to false' do
- let(:available?) { false }
-
- it { is_expected.to eq(false) }
- end
- end
- end
end
diff --git a/spec/models/clusters/integrations/prometheus_spec.rb b/spec/models/clusters/integrations/prometheus_spec.rb
index d6d1105cdb1..f7ab0ae067c 100644
--- a/spec/models/clusters/integrations/prometheus_spec.rb
+++ b/spec/models/clusters/integrations/prometheus_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe Clusters::Integrations::Prometheus do
describe 'after_destroy' do
subject(:integration) { create(:clusters_integrations_prometheus, cluster: cluster, enabled: true) }
- let(:cluster) { create(:cluster, :with_installed_helm) }
+ let(:cluster) { create(:cluster) }
it 'deactivates prometheus_integration' do
expect(Clusters::Applications::DeactivateIntegrationWorker)
@@ -41,7 +41,7 @@ RSpec.describe Clusters::Integrations::Prometheus do
describe 'after_save' do
subject(:integration) { create(:clusters_integrations_prometheus, cluster: cluster, enabled: enabled) }
- let(:cluster) { create(:cluster, :with_installed_helm) }
+ let(:cluster) { create(:cluster) }
let(:enabled) { true }
context 'when no change to enabled status' do
diff --git a/spec/support/helpers/fake_webauthn_device.rb b/spec/support/helpers/fake_webauthn_device.rb
index d2c2f7d6bf3..5a535735817 100644
--- a/spec/support/helpers/fake_webauthn_device.rb
+++ b/spec/support/helpers/fake_webauthn_device.rb
@@ -45,7 +45,7 @@ class FakeWebauthnDevice
return Promise.resolve(result);
};
JS
- @page.click_link('Try again?', href: false)
+ @page.click_button(_('Try again?'))
end
def fake_webauthn_authentication
diff --git a/spec/support/helpers/navbar_structure_helper.rb b/spec/support/helpers/navbar_structure_helper.rb
index 8248ea0bb84..15c4b679786 100644
--- a/spec/support/helpers/navbar_structure_helper.rb
+++ b/spec/support/helpers/navbar_structure_helper.rb
@@ -73,7 +73,7 @@ module NavbarStructureHelper
insert_after_sub_nav_item(
_('Package Registry'),
within: _('Packages and registries'),
- new_sub_nav_item_name: _('Infrastructure Registry')
+ new_sub_nav_item_name: _('Terraform modules')
)
end
diff --git a/spec/support/matchers/markdown_matchers.rb b/spec/support/matchers/markdown_matchers.rb
index a80c269f915..575ae572f25 100644
--- a/spec/support/matchers/markdown_matchers.rb
+++ b/spec/support/matchers/markdown_matchers.rb
@@ -202,7 +202,7 @@ module MarkdownMatchers
match do |actual|
expect(actual).to have_selector('[data-math-style="inline"]', count: 4)
- expect(actual).to have_selector('[data-math-style="display"]', count: 4)
+ expect(actual).to have_selector('[data-math-style="display"]', count: 6)
end
end
diff --git a/spec/support/shared_examples/features/2fa_shared_examples.rb b/spec/support/shared_examples/features/2fa_shared_examples.rb
index 13d87ea12a2..6c4e98c9989 100644
--- a/spec/support/shared_examples/features/2fa_shared_examples.rb
+++ b/spec/support/shared_examples/features/2fa_shared_examples.rb
@@ -96,9 +96,7 @@ RSpec.shared_examples 'hardware device for 2fa' do |device_type|
end
it 'provides a button that shows the fallback otp code UI' do
- expect(page).to have_link('Sign in via 2FA code')
-
- click_link('Sign in via 2FA code')
+ click_button(_('Sign in via 2FA code'))
assert_fallback_ui(page)
end
diff --git a/spec/support/shared_examples/services/base_helm_service_shared_examples.rb b/spec/support/shared_examples/services/base_helm_service_shared_examples.rb
deleted file mode 100644
index c2252c83140..00000000000
--- a/spec/support/shared_examples/services/base_helm_service_shared_examples.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.shared_examples 'logs kubernetes errors' do
- let(:error_hash) do
- {
- service: service.class.name,
- app_id: application.id,
- project_ids: application.cluster.project_ids,
- group_ids: [],
- error_code: error_code
- }
- end
-
- it 'logs into kubernetes.log and Sentry' do
- expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
- error,
- hash_including(error_hash)
- )
-
- service.execute
- end
-end
diff --git a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
index 502f103af00..c85534b73ee 100644
--- a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
+++ b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
@@ -567,11 +567,11 @@ RSpec.describe 'layouts/nav/sidebar/_project', feature_category: :navigation do
end
end
- describe 'Infrastructure Registry' do
- it 'shows link to infrastructure registry page' do
+ describe 'Terraform modules' do
+ it 'shows link to terraform modules page' do
render
- expect(rendered).to have_link('Infrastructure Registry', href: project_infrastructure_registry_index_path(project))
+ expect(rendered).to have_link('Terraform modules', href: project_infrastructure_registry_index_path(project))
end
context 'when package registry config is disabled' do
@@ -580,7 +580,7 @@ RSpec.describe 'layouts/nav/sidebar/_project', feature_category: :navigation do
render
- expect(rendered).not_to have_link('Infrastructure Registry', href: project_infrastructure_registry_index_path(project))
+ expect(rendered).not_to have_link('Terraform modules', href: project_infrastructure_registry_index_path(project))
end
end
end
diff --git a/spec/workers/clusters/cleanup/project_namespace_worker_spec.rb b/spec/workers/clusters/cleanup/project_namespace_worker_spec.rb
index 15fc9e8678e..008ac5249da 100644
--- a/spec/workers/clusters/cleanup/project_namespace_worker_spec.rb
+++ b/spec/workers/clusters/cleanup/project_namespace_worker_spec.rb
@@ -27,7 +27,6 @@ RSpec.describe Clusters::Cleanup::ProjectNamespaceWorker, feature_category: :kub
exception: 'ClusterCleanupMethods::ExceededExecutionLimitError',
cluster_id: kind_of(Integer),
class_name: described_class.name,
- applications: "",
cleanup_status: cluster.cleanup_status_name,
event: :failed_to_remove_cluster_and_resources,
message: "exceeded execution limit of 10 tries"