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
diff options
context:
space:
mode:
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/access_tokens_helper_spec.rb1
-rw-r--r--spec/helpers/appearances_helper_spec.rb14
-rw-r--r--spec/helpers/application_helper_spec.rb4
-rw-r--r--spec/helpers/application_settings_helper_spec.rb10
-rw-r--r--spec/helpers/auth_helper_spec.rb96
-rw-r--r--spec/helpers/blob_helper_spec.rb55
-rw-r--r--spec/helpers/breadcrumbs_helper_spec.rb8
-rw-r--r--spec/helpers/ci/builds_helper_spec.rb18
-rw-r--r--spec/helpers/ci/jobs_helper_spec.rb11
-rw-r--r--spec/helpers/ci/pipelines_helper_spec.rb7
-rw-r--r--spec/helpers/ci/status_helper_spec.rb46
-rw-r--r--spec/helpers/ci/triggers_helper_spec.rb8
-rw-r--r--spec/helpers/clusters_helper_spec.rb10
-rw-r--r--spec/helpers/diff_helper_spec.rb37
-rw-r--r--spec/helpers/emails_helper_spec.rb6
-rw-r--r--spec/helpers/form_helper_spec.rb5
-rw-r--r--spec/helpers/groups/observability_helper_spec.rb76
-rw-r--r--spec/helpers/groups_helper_spec.rb121
-rw-r--r--spec/helpers/ide_helper_spec.rb33
-rw-r--r--spec/helpers/issuables_description_templates_helper_spec.rb6
-rw-r--r--spec/helpers/issuables_helper_spec.rb57
-rw-r--r--spec/helpers/issues_helper_spec.rb2
-rw-r--r--spec/helpers/nav_helper_spec.rb4
-rw-r--r--spec/helpers/organizations/organization_helper_spec.rb29
-rw-r--r--spec/helpers/page_layout_helper_spec.rb6
-rw-r--r--spec/helpers/profiles_helper_spec.rb6
-rw-r--r--spec/helpers/projects/ml/experiments_helper_spec.rb8
-rw-r--r--spec/helpers/projects_helper_spec.rb145
-rw-r--r--spec/helpers/releases_helper_spec.rb12
-rw-r--r--spec/helpers/sidekiq_helper_spec.rb73
-rw-r--r--spec/helpers/sorting_helper_spec.rb42
-rw-r--r--spec/helpers/todos_helper_spec.rb9
-rw-r--r--spec/helpers/tracking_helper_spec.rb2
-rw-r--r--spec/helpers/users_helper_spec.rb2
-rw-r--r--spec/helpers/wiki_helper_spec.rb42
35 files changed, 340 insertions, 671 deletions
diff --git a/spec/helpers/access_tokens_helper_spec.rb b/spec/helpers/access_tokens_helper_spec.rb
index a466b2a0d3b..9b47f23f514 100644
--- a/spec/helpers/access_tokens_helper_spec.rb
+++ b/spec/helpers/access_tokens_helper_spec.rb
@@ -9,6 +9,7 @@ RSpec.describe AccessTokensHelper do
where(:prefix, :description_location) do
:personal_access_token | [:doorkeeper, :scope_desc]
:project_access_token | [:doorkeeper, :project_access_token_scope_desc]
+ :group_access_token | [:doorkeeper, :group_access_token_scope_desc]
end
with_them do
diff --git a/spec/helpers/appearances_helper_spec.rb b/spec/helpers/appearances_helper_spec.rb
index 4a32c586315..376db6412e8 100644
--- a/spec/helpers/appearances_helper_spec.rb
+++ b/spec/helpers/appearances_helper_spec.rb
@@ -152,7 +152,7 @@ RSpec.describe AppearancesHelper do
let!(:appearance) { create(:appearance, :with_logo) }
it 'returns a path' do
- expect(helper.brand_image).to match(%r(img .* data-src="/uploads/-/system/appearance/.*png))
+ expect(helper.brand_image).to match(%r{img .* data-src="/uploads/-/system/appearance/.*png})
end
context 'when there is no associated upload' do
@@ -163,14 +163,14 @@ RSpec.describe AppearancesHelper do
end
it 'falls back to using the original path' do
- expect(helper.brand_image).to match(%r(img .* data-src="/uploads/-/system/appearance/.*png))
+ expect(helper.brand_image).to match(%r{img .* data-src="/uploads/-/system/appearance/.*png})
end
end
end
context 'when there is no logo' do
it 'returns path of GitLab logo' do
- expect(helper.brand_image).to match(%r(img .* data-src="#{gitlab_logo}))
+ expect(helper.brand_image).to match(%r{img .* data-src="#{gitlab_logo}})
end
end
@@ -178,13 +178,13 @@ RSpec.describe AppearancesHelper do
let!(:appearance) { create(:appearance, title: 'My title') }
it 'returns the title' do
- expect(helper.brand_image).to match(%r(img alt="My title"))
+ expect(helper.brand_image).to match(%r{img alt="My title"})
end
end
context 'when there is no title' do
it 'returns the default title' do
- expect(helper.brand_image).to match(%r(img alt="GitLab))
+ expect(helper.brand_image).to match(%r{img alt="GitLab})
end
end
end
@@ -194,7 +194,7 @@ RSpec.describe AppearancesHelper do
let!(:appearance) { create(:appearance, :with_logo) }
it 'returns path of custom logo' do
- expect(helper.brand_image_path).to match(%r(/uploads/-/system/appearance/.*/dk.png))
+ expect(helper.brand_image_path).to match(%r{/uploads/-/system/appearance/.*/dk.png})
end
end
@@ -240,7 +240,7 @@ RSpec.describe AppearancesHelper do
let!(:appearance) { create(:appearance, :with_header_logo) }
it 'renders image tag' do
- expect(helper).to receive(:image_tag).with(appearance.header_logo_path, class: 'brand-header-logo')
+ expect(helper).to receive(:image_tag).with(appearance.header_logo_path, class: 'brand-header-logo', alt: '')
subject
end
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 757f832faa4..7cf64c6e049 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -922,14 +922,14 @@ RSpec.describe ApplicationHelper do
context 'when resource is an issue' do
let_it_be(:resource) { build(:issue) }
- let(:expected_title) { 'This issue is hidden because its author has been banned' }
+ let(:expected_title) { 'This issue is hidden because its author has been banned.' }
it_behaves_like 'returns icon with tooltip'
end
context 'when resource is a merge request' do
let_it_be(:resource) { build(:merge_request) }
- let(:expected_title) { 'This merge request is hidden because its author has been banned' }
+ let(:expected_title) { 'This merge request is hidden because its author has been banned.' }
it_behaves_like 'returns icon with tooltip'
end
diff --git a/spec/helpers/application_settings_helper_spec.rb b/spec/helpers/application_settings_helper_spec.rb
index 9d591164547..5dc75a60a6e 100644
--- a/spec/helpers/application_settings_helper_spec.rb
+++ b/spec/helpers/application_settings_helper_spec.rb
@@ -47,7 +47,7 @@ RSpec.describe ApplicationSettingsHelper do
describe '.visible_attributes' do
it 'contains tracking parameters' do
- expect(helper.visible_attributes).to include(*%i(snowplow_collector_hostname snowplow_cookie_domain snowplow_enabled snowplow_app_id))
+ expect(helper.visible_attributes).to include(*%i[snowplow_collector_hostname snowplow_cookie_domain snowplow_enabled snowplow_app_id])
end
it 'contains :deactivate_dormant_users' do
@@ -60,16 +60,16 @@ RSpec.describe ApplicationSettingsHelper do
it 'contains rate limit parameters' do
expect(helper.visible_attributes).to include(
- *%i(
+ *%i[
issues_create_limit notes_create_limit project_export_limit
project_download_export_limit project_export_limit project_import_limit
raw_blob_request_limit group_export_limit group_download_export_limit
group_import_limit users_get_by_id_limit search_rate_limit search_rate_limit_unauthenticated
- ))
+ ])
end
it 'contains GitLab for Slack app parameters' do
- params = %i(slack_app_enabled slack_app_id slack_app_secret slack_app_signing_secret slack_app_verification_token)
+ params = %i[slack_app_enabled slack_app_id slack_app_secret slack_app_signing_secret slack_app_verification_token]
expect(helper.visible_attributes).to include(*params)
end
@@ -306,7 +306,7 @@ RSpec.describe ApplicationSettingsHelper do
describe '#sidekiq_job_limiter_modes_for_select' do
subject { helper.sidekiq_job_limiter_modes_for_select }
- it { is_expected.to eq([%w(Track track), %w(Compress compress)]) }
+ it { is_expected.to eq([%w[Track track], %w[Compress compress]]) }
end
describe '#instance_clusters_enabled?', :request_store do
diff --git a/spec/helpers/auth_helper_spec.rb b/spec/helpers/auth_helper_spec.rb
index 4b0b44d1325..40798b4c038 100644
--- a/spec/helpers/auth_helper_spec.rb
+++ b/spec/helpers/auth_helper_spec.rb
@@ -35,12 +35,12 @@ RSpec.describe AuthHelper do
describe "form_based_providers" do
it 'includes LDAP providers' do
allow(helper).to receive(:auth_providers) { [:twitter, :ldapmain] }
- expect(helper.form_based_providers).to eq %i(ldapmain)
+ expect(helper.form_based_providers).to eq %i[ldapmain]
end
it 'includes crowd provider' do
allow(helper).to receive(:auth_providers) { [:twitter, :crowd] }
- expect(helper.form_based_providers).to eq %i(crowd)
+ expect(helper.form_based_providers).to eq %i[crowd]
end
end
@@ -101,15 +101,15 @@ RSpec.describe AuthHelper do
describe 'popular_enabled_button_based_providers' do
it 'returns the intersection set of popular & enabled providers', :aggregate_failures do
- allow(helper).to receive(:enabled_button_based_providers) { %w(twitter github google_oauth2) }
+ allow(helper).to receive(:enabled_button_based_providers) { %w[twitter github google_oauth2] }
- expect(helper.popular_enabled_button_based_providers).to eq(%w(github google_oauth2))
+ expect(helper.popular_enabled_button_based_providers).to eq(%w[github google_oauth2])
- allow(helper).to receive(:enabled_button_based_providers) { %w(google_oauth2 bitbucket) }
+ allow(helper).to receive(:enabled_button_based_providers) { %w[google_oauth2 bitbucket] }
- expect(helper.popular_enabled_button_based_providers).to eq(%w(google_oauth2))
+ expect(helper.popular_enabled_button_based_providers).to eq(%w[google_oauth2])
- allow(helper).to receive(:enabled_button_based_providers) { %w(bitbucket) }
+ allow(helper).to receive(:enabled_button_based_providers) { %w[bitbucket] }
expect(helper.popular_enabled_button_based_providers).to be_empty
end
@@ -129,7 +129,7 @@ RSpec.describe AuthHelper do
context 'all the button based providers are disabled via application_setting' do
it 'returns false' do
stub_application_setting(
- disabled_oauth_sign_in_sources: %w(github twitter)
+ disabled_oauth_sign_in_sources: %w[github twitter]
)
expect(helper.button_based_providers_enabled?).to be false
@@ -277,86 +277,6 @@ RSpec.describe AuthHelper do
end
end
- describe '#google_tag_manager_enabled?' do
- let(:is_gitlab_com) { true }
- let(:user) { nil }
-
- before do
- allow(Gitlab).to receive(:com?).and_return(is_gitlab_com)
- allow(helper).to receive(:current_user).and_return(user)
- end
-
- subject(:google_tag_manager_enabled) { helper.google_tag_manager_enabled? }
-
- context 'when not on gitlab.com' do
- let(:is_gitlab_com) { false }
-
- it { is_expected.to eq(false) }
- end
-
- context 'regular and nonce versions' do
- using RSpec::Parameterized::TableSyntax
-
- where(:gtm_nonce_enabled, :gtm_key) do
- false | 'google_tag_manager_id'
- true | 'google_tag_manager_nonce_id'
- end
-
- with_them do
- before do
- stub_feature_flags(gtm_nonce: gtm_nonce_enabled)
- stub_config(extra: { gtm_key => 'key' })
- end
-
- context 'on gitlab.com and a key set without a current user' do
- it { is_expected.to be_truthy }
- end
-
- context 'when no key is set' do
- before do
- stub_config(extra: {})
- end
-
- it { is_expected.to eq(false) }
- end
- end
- end
- end
-
- describe '#google_tag_manager_id' do
- subject(:google_tag_manager_id) { helper.google_tag_manager_id }
-
- before do
- stub_config(extra: { 'google_tag_manager_nonce_id': 'nonce', 'google_tag_manager_id': 'gtm' })
- end
-
- context 'when google tag manager is disabled' do
- before do
- allow(helper).to receive(:google_tag_manager_enabled?).and_return(false)
- end
-
- it { is_expected.to be_falsey }
- end
-
- context 'when google tag manager is enabled' do
- before do
- allow(helper).to receive(:google_tag_manager_enabled?).and_return(true)
- end
-
- context 'when nonce feature flag is enabled' do
- it { is_expected.to eq('nonce') }
- end
-
- context 'when nonce feature flag is disabled' do
- before do
- stub_feature_flags(gtm_nonce: false)
- end
-
- it { is_expected.to eq('gtm') }
- end
- end
- end
-
describe '#auth_app_owner_text' do
shared_examples 'generates text with the correct info' do
it 'includes the name of the application owner' do
diff --git a/spec/helpers/blob_helper_spec.rb b/spec/helpers/blob_helper_spec.rb
index 6d97afd4c78..e832fa2718a 100644
--- a/spec/helpers/blob_helper_spec.rb
+++ b/spec/helpers/blob_helper_spec.rb
@@ -469,61 +469,6 @@ RSpec.describe BlobHelper do
end
end
- describe '#editing_ci_config?' do
- let(:project) { build(:project) }
-
- subject { helper.editing_ci_config? }
-
- before do
- assign(:project, project)
- assign(:path, path)
- end
-
- context 'when path is nil' do
- let(:path) { nil }
-
- it { is_expected.to be_falsey }
- end
-
- context 'when path is not a ci file' do
- let(:path) { 'some-file.txt' }
-
- it { is_expected.to be_falsey }
- end
-
- context 'when path ends is gitlab-ci.yml' do
- let(:path) { '.gitlab-ci.yml' }
-
- it { is_expected.to be_truthy }
- end
-
- context 'when path ends with gitlab-ci.yml' do
- let(:path) { 'template.gitlab-ci.yml' }
-
- it { is_expected.to be_truthy }
- end
-
- context 'with custom ci paths' do
- let(:path) { 'path/to/ci.yaml' }
-
- before do
- project.ci_config_path = 'path/to/ci.yaml'
- end
-
- it { is_expected.to be_truthy }
- end
-
- context 'with custom ci config and path' do
- let(:path) { 'path/to/template.gitlab-ci.yml' }
-
- before do
- project.ci_config_path = 'ci/path/.gitlab-ci.yml@another-group/another-project'
- end
-
- it { is_expected.to be_truthy }
- end
- end
-
describe '#vue_blob_app_data' do
let(:blob) { fake_blob(path: 'file.md', size: 2.megabytes) }
let(:project) { build_stubbed(:project) }
diff --git a/spec/helpers/breadcrumbs_helper_spec.rb b/spec/helpers/breadcrumbs_helper_spec.rb
index 8e2a684656b..43a30f59e50 100644
--- a/spec/helpers/breadcrumbs_helper_spec.rb
+++ b/spec/helpers/breadcrumbs_helper_spec.rb
@@ -54,8 +54,8 @@ RSpec.describe BreadcrumbsHelper do
describe '#schema_breadcrumb_json' do
let(:elements) do
[
- %w(element1 http://test.host/link1),
- %w(element2 http://test.host/link2)
+ %w[element1 http://test.host/link1],
+ %w[element2 http://test.host/link2]
]
end
@@ -89,8 +89,8 @@ RSpec.describe BreadcrumbsHelper do
context 'when extra breadcrumb element is added' do
let(:extra_elements) do
[
- %w(extra_element1 http://test.host/extra_link1),
- %w(extra_element2 http://test.host/extra_link2)
+ %w[extra_element1 http://test.host/extra_link1],
+ %w[extra_element2 http://test.host/extra_link2]
]
end
diff --git a/spec/helpers/ci/builds_helper_spec.rb b/spec/helpers/ci/builds_helper_spec.rb
index eabd40f3dd4..dcb775fb16d 100644
--- a/spec/helpers/ci/builds_helper_spec.rb
+++ b/spec/helpers/ci/builds_helper_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Ci::BuildsHelper do
+RSpec.describe Ci::BuildsHelper, feature_category: :continuous_integration do
describe '#sidebar_build_class' do
using RSpec::Parameterized::TableSyntax
@@ -25,22 +25,6 @@ RSpec.describe Ci::BuildsHelper do
end
end
- describe '#javascript_build_options' do
- subject { helper.javascript_build_options }
-
- it 'returns build options' do
- project = assign_project
- ci_build = assign_build
-
- expect(subject).to eq({
- page_path: project_job_path(project, ci_build),
- build_status: ci_build.status,
- build_stage: ci_build.stage_name,
- log_state: ''
- })
- end
- end
-
describe '#build_failed_issue_options' do
subject { helper.build_failed_issue_options }
diff --git a/spec/helpers/ci/jobs_helper_spec.rb b/spec/helpers/ci/jobs_helper_spec.rb
index 30cad66af04..884fe7a018e 100644
--- a/spec/helpers/ci/jobs_helper_spec.rb
+++ b/spec/helpers/ci/jobs_helper_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Ci::JobsHelper do
+RSpec.describe Ci::JobsHelper, feature_category: :continuous_integration do
describe 'job helper functions' do
let_it_be(:project) { create(:project, :repository) }
let_it_be(:job) { create(:ci_build, project: project) }
@@ -20,20 +20,13 @@ RSpec.describe Ci::JobsHelper do
it 'returns jobs data' do
expect(helper.jobs_data(project, job)).to include({
"endpoint" => "/#{project.full_path}/-/jobs/#{job.id}.json",
+ "page_path" => "/#{project.full_path}/-/jobs/#{job.id}",
"project_path" => project.full_path,
"artifact_help_url" => "/help/user/gitlab_com/index.md#gitlab-cicd",
"deployment_help_url" => "/help/user/project/clusters/deploy_to_cluster.md#troubleshooting",
"runner_settings_url" => "/#{project.full_path}/-/runners#js-runners-settings",
- "page_path" => "/#{project.full_path}/-/jobs/#{job.id}",
"build_status" => "pending",
"build_stage" => "test",
- "log_state" => "",
- "build_options" => {
- build_stage: "test",
- build_status: "pending",
- log_state: "",
- page_path: "/#{project.full_path}/-/jobs/#{job.id}"
- },
"retry_outdated_job_docs_url" => "/help/ci/pipelines/settings#retry-outdated-jobs"
})
end
diff --git a/spec/helpers/ci/pipelines_helper_spec.rb b/spec/helpers/ci/pipelines_helper_spec.rb
index 00bc38dbd94..477c07bf3e3 100644
--- a/spec/helpers/ci/pipelines_helper_spec.rb
+++ b/spec/helpers/ci/pipelines_helper_spec.rb
@@ -88,10 +88,7 @@ RSpec.describe Ci::PipelinesHelper do
:params,
:artifacts_endpoint,
:artifacts_endpoint_placeholder,
- :pipeline_schedule_url,
- :empty_state_svg_path,
- :error_state_svg_path,
- :no_pipelines_svg_path,
+ :pipeline_schedules_path,
:can_create_pipeline,
:new_pipeline_path,
:ci_lint_path,
@@ -110,7 +107,7 @@ RSpec.describe Ci::PipelinesHelper do
before do
allow(helper).to receive(:current_user).and_return(user)
project.add_developer(user)
- create(:project_setting, project: project, target_platforms: %w(ios))
+ create(:project_setting, project: project, target_platforms: %w[ios])
end
describe 'the `registration_token` attribute' do
diff --git a/spec/helpers/ci/status_helper_spec.rb b/spec/helpers/ci/status_helper_spec.rb
index 66c821df8f1..17fe474b360 100644
--- a/spec/helpers/ci/status_helper_spec.rb
+++ b/spec/helpers/ci/status_helper_spec.rb
@@ -55,10 +55,6 @@ RSpec.describe Ci::StatusHelper do
is_expected.to include("href=\"/commit-path\"")
end
- it "does not contain a span element" do
- is_expected.not_to include("<span")
- end
-
it "has 'Pipeline' as the status type in the title" do
is_expected.to include("title=\"Pipeline: passed\"")
end
@@ -88,7 +84,8 @@ RSpec.describe Ci::StatusHelper do
subject { helper.render_status_with_link("success", cssclass: "extra-class") }
it "has appended extra class to icon classes" do
- is_expected.to include("class=\"ci-status-link ci-status-icon-success d-inline-flex extra-class\"")
+ is_expected.to include('class="ci-status-link ci-status-icon-success d-inline-flex ' \
+ 'gl-line-height-1 extra-class"')
end
end
@@ -107,5 +104,44 @@ RSpec.describe Ci::StatusHelper do
is_expected.to include("<svg class=\"s24\"")
end
end
+
+ context "when status is success-with-warnings" do
+ subject { helper.render_status_with_link("success-with-warnings") }
+
+ it "renders warning variant of gl-badge" do
+ is_expected.to include('gl-badge badge badge-pill badge-warning')
+ end
+ end
+
+ context "when status is manual" do
+ subject { helper.render_status_with_link("manual") }
+
+ it "renders neutral variant of gl-badge" do
+ is_expected.to include('gl-badge badge badge-pill badge-neutral')
+ end
+ end
+ end
+
+ describe '#badge_variant' do
+ using RSpec::Parameterized::TableSyntax
+
+ where(:status, :expected_badge_variant_class) do
+ 'success' | 'badge-success'
+ 'success-with-warnings' | 'badge-warning'
+ 'pending' | 'badge-warning'
+ 'failed' | 'badge-danger'
+ 'running' | 'badge-info'
+ 'canceled' | 'badge-neutral'
+ 'manual' | 'badge-neutral'
+ 'other-status' | 'badge-muted'
+ end
+
+ with_them do
+ subject { helper.render_status_with_link(status) }
+
+ it 'uses the correct badge variant classes for gl-badge' do
+ is_expected.to include("gl-badge badge badge-pill #{expected_badge_variant_class}")
+ end
+ end
end
end
diff --git a/spec/helpers/ci/triggers_helper_spec.rb b/spec/helpers/ci/triggers_helper_spec.rb
index 5e43dbfdd5c..63755257215 100644
--- a/spec/helpers/ci/triggers_helper_spec.rb
+++ b/spec/helpers/ci/triggers_helper_spec.rb
@@ -21,11 +21,11 @@ RSpec.describe Ci::TriggersHelper do
end
end
- describe '.service_trigger_url' do
- subject { helper.service_trigger_url(service) }
+ describe '.integration_trigger_url' do
+ subject { helper.integration_trigger_url(integration) }
- let(:service) { double(project_id: 1, to_param: 'param') }
+ let(:integration) { double(project_id: 1, to_param: 'param') }
- specify { expect(subject).to eq "#{Settings.gitlab.url}/api/v4/projects/1/services/param/trigger" }
+ specify { expect(subject).to eq "#{Settings.gitlab.url}/api/v4/projects/1/integrations/param/trigger" }
end
end
diff --git a/spec/helpers/clusters_helper_spec.rb b/spec/helpers/clusters_helper_spec.rb
index a9fbdfbe3ca..f3d6b5bdda6 100644
--- a/spec/helpers/clusters_helper_spec.rb
+++ b/spec/helpers/clusters_helper_spec.rb
@@ -48,9 +48,9 @@ RSpec.describe ClustersHelper do
end
it 'generates svg image data', :aggregate_failures do
- expect(subject.dig(:img_tags, :aws, :path)).to match(%r(/illustrations/logos/amazon_eks|svg))
- expect(subject.dig(:img_tags, :default, :path)).to match(%r(/illustrations/logos/kubernetes|svg))
- expect(subject.dig(:img_tags, :gcp, :path)).to match(%r(/illustrations/logos/google_gke|svg))
+ expect(subject.dig(:img_tags, :aws, :path)).to match(%r{/illustrations/logos/amazon_eks|svg})
+ expect(subject.dig(:img_tags, :default, :path)).to match(%r{/illustrations/logos/kubernetes|svg})
+ expect(subject.dig(:img_tags, :gcp, :path)).to match(%r{/illustrations/logos/google_gke|svg})
expect(subject.dig(:img_tags, :aws, :text)).to eq('Amazon EKS')
expect(subject.dig(:img_tags, :default, :text)).to eq('Kubernetes Cluster')
@@ -62,8 +62,8 @@ RSpec.describe ClustersHelper do
end
it 'displays empty image path' do
- expect(subject[:clusters_empty_state_image]).to match(%r(/illustrations/empty-state/empty-state-clusters|svg))
- expect(subject[:empty_state_image]).to match(%r(/illustrations/empty-state/empty-state-agents|svg))
+ expect(subject[:clusters_empty_state_image]).to match(%r{/illustrations/empty-state/empty-state-clusters|svg})
+ expect(subject[:empty_state_image]).to match(%r{/illustrations/empty-state/empty-state-agents|svg})
end
it 'displays add cluster using certificate path' do
diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb
index 2318bbf861a..a6db9e77c61 100644
--- a/spec/helpers/diff_helper_spec.rb
+++ b/spec/helpers/diff_helper_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe DiffHelper do
+RSpec.describe DiffHelper, feature_category: :code_review_workflow do
include RepoHelpers
let(:project) { create(:project, :repository) }
@@ -196,26 +196,26 @@ RSpec.describe DiffHelper do
end
describe "#mark_inline_diffs" do
- let(:old_line) { %{abc 'def'} }
- let(:new_line) { %{abc "def"} }
+ let(:old_line) { %(abc 'def') }
+ let(:new_line) { %(abc "def") }
it "returns strings with marked inline diffs" do
marked_old_line, marked_new_line = mark_inline_diffs(old_line, new_line)
- expect(marked_old_line).to eq(%q{abc <span class="idiff left deletion">&#39;</span>def<span class="idiff right deletion">&#39;</span>})
+ expect(marked_old_line).to eq(%q(abc <span class="idiff left deletion">&#39;</span>def<span class="idiff right deletion">&#39;</span>))
expect(marked_old_line).to be_html_safe
- expect(marked_new_line).to eq(%q{abc <span class="idiff left addition">&quot;</span>def<span class="idiff right addition">&quot;</span>})
+ expect(marked_new_line).to eq(%q(abc <span class="idiff left addition">&quot;</span>def<span class="idiff right addition">&quot;</span>))
expect(marked_new_line).to be_html_safe
end
context 'when given HTML' do
it 'sanitizes it' do
- old_line = %{test.txt}
+ old_line = %(test.txt)
new_line = %{<img src=x onerror=alert(document.domain)>}
marked_old_line, marked_new_line = mark_inline_diffs(old_line, new_line)
- expect(marked_old_line).to eq(%q{<span class="idiff left right deletion">test.txt</span>})
+ expect(marked_old_line).to eq(%q(<span class="idiff left right deletion">test.txt</span>))
expect(marked_old_line).to be_html_safe
expect(marked_new_line).to eq(%q{<span class="idiff left right addition">&lt;img src=x onerror=alert(document.domain)&gt;</span>})
expect(marked_new_line).to be_html_safe
@@ -637,4 +637,27 @@ RSpec.describe DiffHelper do
end
end
end
+
+ describe '#submodule_diff_compare_link' do
+ context 'when the diff includes submodule changes' do
+ it 'generates a link to compare a diff for a submodule' do
+ allow(helper).to receive(:submodule_links).and_return(
+ Gitlab::SubmoduleLinks::Urls.new(nil, nil, '/comparison-path')
+ )
+
+ output = helper.submodule_diff_compare_link(diff_file)
+ expect(output).to match(%r{href="/comparison-path"})
+ expect(output).to match(
+ %r{Compare <span class="commit-sha">5b812ff1</span>...<span class="commit-sha">7e3e39eb</span>}
+ )
+ end
+ end
+
+ context 'when the diff does not include submodule changes' do
+ it 'returns an empty string' do
+ output = helper.submodule_diff_compare_link(diff_file)
+ expect(output).to eq('')
+ end
+ end
+ end
end
diff --git a/spec/helpers/emails_helper_spec.rb b/spec/helpers/emails_helper_spec.rb
index dbc6bd2eb28..ee623cea664 100644
--- a/spec/helpers/emails_helper_spec.rb
+++ b/spec/helpers/emails_helper_spec.rb
@@ -237,7 +237,7 @@ RSpec.describe EmailsHelper do
it 'returns the brand header logo' do
expect(header_logo).to eq(
- %{<img style="height: 50px" src="/uploads/-/system/appearance/header_logo/#{appearance.id}/dk.png" />}
+ %(<img style="height: 50px" src="/uploads/-/system/appearance/header_logo/#{appearance.id}/dk.png" />)
)
end
@@ -326,8 +326,8 @@ RSpec.describe EmailsHelper do
create :appearance, header_message: 'Foo', footer_message: 'Bar', email_header_and_footer_enabled: true
aggregate_failures do
- expect(html_header_message).to eq(%{<div class="header-message" style=""><p>Foo</p></div>})
- expect(html_footer_message).to eq(%{<div class="footer-message" style=""><p>Bar</p></div>})
+ expect(html_header_message).to eq(%(<div class="header-message" style=""><p>Foo</p></div>))
+ expect(html_footer_message).to eq(%(<div class="footer-message" style=""><p>Bar</p></div>))
expect(text_header_message).to eq('Foo')
expect(text_footer_message).to eq('Bar')
end
diff --git a/spec/helpers/form_helper_spec.rb b/spec/helpers/form_helper_spec.rb
index 83b08e5fcec..0db48dfc28e 100644
--- a/spec/helpers/form_helper_spec.rb
+++ b/spec/helpers/form_helper_spec.rb
@@ -67,11 +67,10 @@ RSpec.describe FormHelper do
it 'renders an appropriately styled alert div' do
model = double(errors: errors_stub('Error 1'))
+ alert_classes = "gl-alert gl-mb-5 gl-alert-danger gl-alert-not-dismissible gl-alert-has-title"
expect(helper.form_errors(model))
- .to include(
- '<div class="gl-alert gl-mb-5 gl-alert-danger gl-alert-not-dismissible" id="error_explanation" role="alert">'
- )
+ .to include("<div class=\"#{alert_classes}\" id=\"error_explanation\" role=\"alert\">")
end
it 'contains a summary message' do
diff --git a/spec/helpers/groups/observability_helper_spec.rb b/spec/helpers/groups/observability_helper_spec.rb
deleted file mode 100644
index f0e6aa0998a..00000000000
--- a/spec/helpers/groups/observability_helper_spec.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-# frozen_string_literal: true
-
-require "spec_helper"
-
-RSpec.describe Groups::ObservabilityHelper do
- let(:group) { build_stubbed(:group) }
-
- describe '#observability_iframe_src' do
- before do
- allow(Gitlab::Observability).to receive(:build_full_url).and_return('full-url')
- end
-
- it 'returns the iframe src for action: dashboards' do
- allow(helper).to receive(:params).and_return({ action: 'dashboards', observability_path: '/foo?bar=foobar' })
- expect(helper.observability_iframe_src(group)).to eq('full-url')
- expect(Gitlab::Observability).to have_received(:build_full_url).with(group, '/foo?bar=foobar', '/')
- end
-
- it 'returns the iframe src for action: manage' do
- allow(helper).to receive(:params).and_return({ action: 'manage', observability_path: '/foo?bar=foobar' })
- expect(helper.observability_iframe_src(group)).to eq('full-url')
- expect(Gitlab::Observability).to have_received(:build_full_url).with(group, '/foo?bar=foobar', '/dashboards')
- end
-
- it 'returns the iframe src for action: explore' do
- allow(helper).to receive(:params).and_return({ action: 'explore', observability_path: '/foo?bar=foobar' })
- expect(helper.observability_iframe_src(group)).to eq('full-url')
- expect(Gitlab::Observability).to have_received(:build_full_url).with(group, '/foo?bar=foobar', '/explore')
- end
-
- it 'returns the iframe src for action: datasources' do
- allow(helper).to receive(:params).and_return({ action: 'datasources', observability_path: '/foo?bar=foobar' })
- expect(helper.observability_iframe_src(group)).to eq('full-url')
- expect(Gitlab::Observability).to have_received(:build_full_url).with(group, '/foo?bar=foobar', '/datasources')
- end
-
- it 'returns the iframe src when action is not recognised' do
- allow(helper).to receive(:params).and_return({ action: 'unrecognised', observability_path: '/foo?bar=foobar' })
- expect(helper.observability_iframe_src(group)).to eq('full-url')
- expect(Gitlab::Observability).to have_received(:build_full_url).with(group, '/foo?bar=foobar', '/')
- end
-
- it 'returns the iframe src when observability_path is missing' do
- allow(helper).to receive(:params).and_return({ action: 'dashboards' })
- expect(helper.observability_iframe_src(group)).to eq('full-url')
- expect(Gitlab::Observability).to have_received(:build_full_url).with(group, nil, '/')
- end
- end
-
- describe '#observability_page_title' do
- it 'returns the title for action: dashboards' do
- allow(helper).to receive(:params).and_return({ action: 'dashboards' })
- expect(helper.observability_page_title).to eq("Dashboards")
- end
-
- it 'returns the title for action: manage' do
- allow(helper).to receive(:params).and_return({ action: 'manage' })
- expect(helper.observability_page_title).to eq("Manage dashboards")
- end
-
- it 'returns the title for action: explore' do
- allow(helper).to receive(:params).and_return({ action: 'explore' })
- expect(helper.observability_page_title).to eq("Explore telemetry data")
- end
-
- it 'returns the title for action: datasources' do
- allow(helper).to receive(:params).and_return({ action: 'datasources' })
- expect(helper.observability_page_title).to eq("Data sources")
- end
-
- it 'returns the default title for unknown action' do
- allow(helper).to receive(:params).and_return({ action: 'unknown' })
- expect(helper.observability_page_title).to eq("Dashboards")
- end
- end
-end
diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb
index 1b5f23a5e8e..0db15541b99 100644
--- a/spec/helpers/groups_helper_spec.rb
+++ b/spec/helpers/groups_helper_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe GroupsHelper do
+RSpec.describe GroupsHelper, feature_category: :groups_and_projects do
include ApplicationHelper
include AvatarsHelper
@@ -97,23 +97,11 @@ RSpec.describe GroupsHelper do
end
end
- context 'recursive' do
- before do
- stub_feature_flags(use_traversal_ids: false)
- end
-
- include_examples 'correct ancestor order'
+ before do
+ very_deep_nested_group.reload # make sure traversal_ids are reloaded
end
- context 'linear' do
- before do
- stub_feature_flags(use_traversal_ids: true)
-
- very_deep_nested_group.reload # make sure traversal_ids are reloaded
- end
-
- include_examples 'correct ancestor order'
- end
+ include_examples 'correct ancestor order'
end
it 'enqueues the elements in the breadcrumb schema list' do
@@ -269,21 +257,7 @@ RSpec.describe GroupsHelper do
end
end
- context 'recursive' do
- before do
- stub_feature_flags(use_traversal_ids: false)
- end
-
- include_examples 'correct ancestor order'
- end
-
- context 'linear' do
- before do
- stub_feature_flags(use_traversal_ids: true)
- end
-
- include_examples 'correct ancestor order'
- end
+ include_examples 'correct ancestor order'
end
end
@@ -524,23 +498,58 @@ RSpec.describe GroupsHelper do
end
end
+ describe '#show_group_readme?' do
+ let_it_be_with_refind(:group) { create(:group, :public) }
+ let_it_be(:current_user) { nil }
+
+ before do
+ allow(helper).to receive(:current_user).and_return(current_user)
+ end
+
+ context 'when project is public' do
+ let_it_be(:project) { create(:project, :public, :readme, group: group, path: 'gitlab-profile') }
+
+ it { expect(helper.show_group_readme?(group)).to be(true) }
+ end
+
+ context 'when project is private' do
+ let_it_be(:project) { create(:project, :private, :readme, group: group, path: 'gitlab-profile') }
+
+ context 'when user can see the project' do
+ let_it_be(:current_user) { create(:user) }
+
+ before do
+ project.add_developer(current_user)
+ end
+
+ it { expect(helper.show_group_readme?(group)).to be(true) }
+ end
+
+ it 'when user can not see the project' do
+ expect(helper.show_group_readme?(group)).to be(false)
+ end
+ end
+ end
+
describe "#enabled_git_access_protocol_options_for_group" do
- subject { helper.enabled_git_access_protocol_options_for_group }
+ let_it_be(:group) { create(:group) }
+
+ subject { helper.enabled_git_access_protocol_options_for_group(group) }
before do
- expect(::Gitlab::CurrentSettings).to receive(:enabled_git_access_protocol).and_return(instance_setting)
+ allow(::Gitlab::CurrentSettings).to receive(:enabled_git_access_protocol).and_return(instance_setting)
end
context "instance setting is nil" do
let(:instance_setting) { nil }
- it { is_expected.to contain_exactly([_("Both SSH and HTTP(S)"), "all"], [_("Only SSH"), "ssh"], [_("Only HTTP(S)"), "http"]) }
+ it { is_expected.to include([_("Both SSH and HTTP(S)"), "all"], [_("Only SSH"), "ssh"], [_("Only HTTP(S)"), "http"]) }
end
context "instance setting is blank" do
- let(:instance_setting) { nil }
+ let(:instance_setting) { '' }
- it { is_expected.to contain_exactly([_("Both SSH and HTTP(S)"), "all"], [_("Only SSH"), "ssh"], [_("Only HTTP(S)"), "http"]) }
+ it { is_expected.to include([_("Both SSH and HTTP(S)"), "all"], [_("Only SSH"), "ssh"], [_("Only HTTP(S)"), "http"]) }
end
context "instance setting is ssh" do
@@ -555,4 +564,44 @@ RSpec.describe GroupsHelper do
it { is_expected.to contain_exactly([_("Only HTTP(S)"), "http"]) }
end
end
+
+ describe '#new_custom_emoji_path' do
+ subject { helper.new_custom_emoji_path(group) }
+
+ let_it_be(:group) { create(:group) }
+
+ context 'with feature flag disabled' do
+ before do
+ stub_feature_flags(custom_emoji: false)
+ end
+
+ it { is_expected.to eq(nil) }
+ end
+
+ context 'with feature flag enabled' do
+ context 'with nil group' do
+ let(:group) { nil }
+
+ it { is_expected.to eq(nil) }
+ end
+
+ context 'with current_user who has no permissions' do
+ before do
+ allow(helper).to receive(:current_user).and_return(create(:user))
+ end
+
+ it { is_expected.to eq(nil) }
+ end
+
+ context 'with current_user who has permissions' do
+ before do
+ user = create(:user)
+ group.add_owner(user)
+ allow(helper).to receive(:current_user).and_return(user)
+ end
+
+ it { is_expected.to eq(new_group_custom_emoji_path(group)) }
+ end
+ end
+ end
end
diff --git a/spec/helpers/ide_helper_spec.rb b/spec/helpers/ide_helper_spec.rb
index 7f657caa986..47500b8e21e 100644
--- a/spec/helpers/ide_helper_spec.rb
+++ b/spec/helpers/ide_helper_spec.rb
@@ -103,10 +103,7 @@ RSpec.describe IdeHelper, feature_category: :web_ide do
'new-web-ide-help-page-path' =>
help_page_path('user/project/web_ide/index.md', anchor: 'vscode-reimplementation'),
'csp-nonce' => 'test-csp-nonce',
- 'ide-remote-path' => ide_remote_path(remote_host: ':remote_host', remote_path: ':remote_path'),
- 'editor-font-family' => 'GitLab Mono',
- 'editor-font-format' => 'woff2',
- 'editor-font-src-url' => a_string_matching(%r{gitlab-mono/GitLabMono})
+ 'ide-remote-path' => ide_remote_path(remote_host: ':remote_host', remote_path: ':remote_path')
}
end
@@ -119,6 +116,34 @@ RSpec.describe IdeHelper, feature_category: :web_ide do
.to include(base_data)
end
+ it 'includes editor font configuration' do
+ ide_data = helper.ide_data(project: nil, fork_info: fork_info, params: params)
+ editor_font = ::Gitlab::Json.parse(ide_data.fetch('editor-font'), symbolize_names: true)
+
+ expect(editor_font).to include({
+ fallback_font_family: 'monospace',
+ font_faces: [
+ {
+ family: 'GitLab Mono',
+ display: 'block',
+ src: [{
+ url: a_string_matching(%r{gitlab-mono/GitLabMono-[^I]}),
+ format: 'woff2'
+ }]
+ },
+ {
+ family: 'GitLab Mono',
+ display: 'block',
+ style: 'italic',
+ src: [{
+ url: a_string_matching(%r{gitlab-mono/GitLabMono-Italic}),
+ format: 'woff2'
+ }]
+ }
+ ]
+ })
+ end
+
it 'does not use new web ide if feature flag is disabled' do
stub_feature_flags(vscode_web_ide: false)
diff --git a/spec/helpers/issuables_description_templates_helper_spec.rb b/spec/helpers/issuables_description_templates_helper_spec.rb
index b32a99fe989..4634ff83469 100644
--- a/spec/helpers/issuables_description_templates_helper_spec.rb
+++ b/spec/helpers/issuables_description_templates_helper_spec.rb
@@ -85,7 +85,7 @@ RSpec.describe IssuablesDescriptionTemplatesHelper, :clean_gitlab_redis_cache do
end
describe '#selected_template_name' do
- let(:template_names) { %w(another_issue_template custom_issue_template) }
+ let(:template_names) { %w[another_issue_template custom_issue_template] }
context 'when no issuable_template parameter is provided' do
it 'does not select a template' do
@@ -118,7 +118,7 @@ RSpec.describe IssuablesDescriptionTemplatesHelper, :clean_gitlab_redis_cache do
describe '#default_template_name' do
context 'when a default template is available' do
- let(:template_names) { %w(another_issue_template deFault) }
+ let(:template_names) { %w[another_issue_template deFault] }
it 'returns the default template' do
issue = build(:issue)
@@ -140,7 +140,7 @@ RSpec.describe IssuablesDescriptionTemplatesHelper, :clean_gitlab_redis_cache do
end
context 'when there is no default template' do
- let(:template_names) { %w(another_issue_template) }
+ let(:template_names) { %w[another_issue_template] }
it 'returns nil' do
expect(helper.default_template_name(template_names, build(:issue))).to be_nil
diff --git a/spec/helpers/issuables_helper_spec.rb b/spec/helpers/issuables_helper_spec.rb
index 9fe820ccae9..0faea5629e8 100644
--- a/spec/helpers/issuables_helper_spec.rb
+++ b/spec/helpers/issuables_helper_spec.rb
@@ -268,7 +268,6 @@ RSpec.describe IssuablesHelper, feature_category: :team_planning do
markdownPreviewPath: "/#{@project.full_path}/preview_markdown?target_id=#{issue.iid}&target_type=Issue",
markdownDocsPath: '/help/user/markdown',
lockVersion: issue.lock_version,
- state: issue.state,
issuableTemplateNamesPath: template_names_path(@project, issue),
initialTitleHtml: issue.title,
initialTitleText: issue.title,
@@ -284,7 +283,6 @@ RSpec.describe IssuablesHelper, feature_category: :team_planning do
issuableId: issue.id,
issueType: 'issue',
isHidden: false,
- sentryIssueIdentifier: nil,
zoomMeetingUrl: nil
}
@@ -384,26 +382,6 @@ RSpec.describe IssuablesHelper, feature_category: :team_planning do
end
end
- describe '#sentryIssueIdentifier' do
- let(:issue) { create(:issue, author: user) }
-
- before do
- assign(:project, issue.project)
- end
-
- it 'sets sentryIssueIdentifier to nil with no sentry issue' do
- expect(helper.issuable_initial_data(issue)[:sentryIssueIdentifier])
- .to be_nil
- end
-
- it 'sets sentryIssueIdentifier to sentry_issue_identifier' do
- sentry_issue = create(:sentry_issue, issue: issue)
-
- expect(helper.issuable_initial_data(issue)[:sentryIssueIdentifier])
- .to eq(sentry_issue.sentry_issue_identifier)
- end
- end
-
describe '#zoomMeetingUrl in issue' do
let(:issue) { create(:issue, author: user) }
@@ -568,41 +546,6 @@ RSpec.describe IssuablesHelper, feature_category: :team_planning do
end
end
- describe '#state_name_with_icon' do
- let_it_be(:project) { create(:project, :repository) }
-
- context 'for an issue' do
- let_it_be(:issue) { create(:issue, project: project) }
- let_it_be(:issue_closed) { create(:issue, :closed, project: project) }
-
- it 'returns the correct state name and icon when issue is open' do
- expect(helper.state_name_with_icon(issue)).to match_array([_('Open'), 'issues'])
- end
-
- it 'returns the correct state name and icon when issue is closed' do
- expect(helper.state_name_with_icon(issue_closed)).to match_array([_('Closed'), 'issue-closed'])
- end
- end
-
- context 'for a merge request' do
- let_it_be(:merge_request) { create(:merge_request, source_project: project) }
- let_it_be(:merge_request_merged) { create(:merge_request, :merged, source_project: project) }
- let_it_be(:merge_request_closed) { create(:merge_request, :closed, source_project: project) }
-
- it 'returns the correct state name and icon when merge request is open' do
- expect(helper.state_name_with_icon(merge_request)).to match_array([_('Open'), 'merge-request-open'])
- end
-
- it 'returns the correct state name and icon when merge request is merged' do
- expect(helper.state_name_with_icon(merge_request_merged)).to match_array([_('Merged'), 'merge'])
- end
-
- it 'returns the correct state name and icon when merge request is closed' do
- expect(helper.state_name_with_icon(merge_request_closed)).to match_array([_('Closed'), 'merge-request-close'])
- end
- end
- end
-
describe '#issuable_type_selector_data' do
using RSpec::Parameterized::TableSyntax
diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb
index 72fa264698d..62d94b59c2a 100644
--- a/spec/helpers/issues_helper_spec.rb
+++ b/spec/helpers/issues_helper_spec.rb
@@ -78,7 +78,7 @@ RSpec.describe IssuesHelper, feature_category: :team_planning do
describe 'awards_sort' do
it 'sorts a hash so thumbsup and thumbsdown are always on top' do
data = { 'thumbsdown' => 'some value', 'lifter' => 'some value', 'thumbsup' => 'some value' }
- expect(awards_sort(data).keys).to eq(%w(thumbsup thumbsdown lifter))
+ expect(awards_sort(data).keys).to eq(%w[thumbsup thumbsdown lifter])
end
end
diff --git a/spec/helpers/nav_helper_spec.rb b/spec/helpers/nav_helper_spec.rb
index 950d8b77d01..12ab7ca93c0 100644
--- a/spec/helpers/nav_helper_spec.rb
+++ b/spec/helpers/nav_helper_spec.rb
@@ -115,13 +115,13 @@ RSpec.describe NavHelper, feature_category: :navigation do
describe '#page_has_markdown?' do
using RSpec::Parameterized::TableSyntax
- where path: %w(
+ where path: %w[
projects/merge_requests#show
projects/merge_requests/conflicts#show
issues#show
milestones#show
issues#designs
- )
+ ]
with_them do
before do
diff --git a/spec/helpers/organizations/organization_helper_spec.rb b/spec/helpers/organizations/organization_helper_spec.rb
index ec99d928059..cf8ae358e49 100644
--- a/spec/helpers/organizations/organization_helper_spec.rb
+++ b/spec/helpers/organizations/organization_helper_spec.rb
@@ -6,12 +6,19 @@ RSpec.describe Organizations::OrganizationHelper, feature_category: :cell do
let_it_be(:organization) { build_stubbed(:organization) }
let_it_be(:new_group_path) { '/groups/new' }
let_it_be(:new_project_path) { '/projects/new' }
+ let_it_be(:organizations_empty_state_svg_path) { 'illustrations/empty-state/empty-organizations-md.svg' }
+ let_it_be(:organizations_path) { '/-/organizations/' }
+ let_it_be(:root_url) { 'http://127.0.0.1:3000/' }
let_it_be(:groups_empty_state_svg_path) { 'illustrations/empty-state/empty-groups-md.svg' }
let_it_be(:projects_empty_state_svg_path) { 'illustrations/empty-state/empty-projects-md.svg' }
before do
allow(helper).to receive(:new_group_path).and_return(new_group_path)
allow(helper).to receive(:new_project_path).and_return(new_project_path)
+ allow(helper).to receive(:image_path).with(organizations_empty_state_svg_path)
+ .and_return(organizations_empty_state_svg_path)
+ allow(helper).to receive(:organizations_path).and_return(organizations_path)
+ allow(helper).to receive(:root_url).and_return(root_url)
allow(helper).to receive(:image_path).with(groups_empty_state_svg_path).and_return(groups_empty_state_svg_path)
allow(helper).to receive(:image_path).with(projects_empty_state_svg_path).and_return(projects_empty_state_svg_path)
end
@@ -62,4 +69,26 @@ RSpec.describe Organizations::OrganizationHelper, feature_category: :cell do
)
end
end
+
+ describe '#organization_index_app_data' do
+ it 'returns expected data object' do
+ expect(helper.organization_index_app_data).to eq(
+ {
+ new_organization_url: new_organization_path,
+ organizations_empty_state_svg_path: organizations_empty_state_svg_path
+ }
+ )
+ end
+ end
+
+ describe '#organization_new_app_data' do
+ it 'returns expected json' do
+ expect(Gitlab::Json.parse(helper.organization_new_app_data)).to eq(
+ {
+ 'organizations_path' => organizations_path,
+ 'root_url' => root_url
+ }
+ )
+ end
+ end
end
diff --git a/spec/helpers/page_layout_helper_spec.rb b/spec/helpers/page_layout_helper_spec.rb
index 43500d98591..a4f10933be6 100644
--- a/spec/helpers/page_layout_helper_spec.rb
+++ b/spec/helpers/page_layout_helper_spec.rb
@@ -55,7 +55,7 @@ RSpec.describe PageLayoutHelper do
expect(helper.page_image).to match_asset_path 'assets/twitter_card.jpg'
end
- %w(project user group).each do |type|
+ %w[project user group].each do |type|
context "with @#{type} assigned" do
let(:object) { build(type, trait) }
let(:trait) { :with_avatar }
@@ -116,11 +116,11 @@ RSpec.describe PageLayoutHelper do
it 'escapes content' do
allow(helper).to receive(:page_card_attributes)
- .and_return(foo: %q{foo" http-equiv="refresh}.html_safe)
+ .and_return(foo: %q(foo" http-equiv="refresh).html_safe)
tags = helper.page_card_meta_tags
- expect(tags).to include(%q{content="foo&quot; http-equiv=&quot;refresh"})
+ expect(tags).to include(%q(content="foo&quot; http-equiv=&quot;refresh"))
end
end
diff --git a/spec/helpers/profiles_helper_spec.rb b/spec/helpers/profiles_helper_spec.rb
index 15ca5f61b51..ece6574ee38 100644
--- a/spec/helpers/profiles_helper_spec.rb
+++ b/spec/helpers/profiles_helper_spec.rb
@@ -106,9 +106,9 @@ RSpec.describe ProfilesHelper do
using RSpec::Parameterized::TableSyntax
where(:stacking, :breakpoint, :expected) do
- nil | nil | %w(gl-mb-3 gl-display-inline-block middle-dot-divider)
- true | nil | %w(gl-mb-3 middle-dot-divider-sm gl-display-block gl-sm-display-inline-block)
- nil | :sm | %w(gl-mb-3 gl-display-inline-block middle-dot-divider-sm)
+ nil | nil | %w[gl-mb-3 gl-display-inline-block middle-dot-divider]
+ true | nil | %w[gl-mb-3 middle-dot-divider-sm gl-display-block gl-sm-display-inline-block]
+ nil | :sm | %w[gl-mb-3 gl-display-inline-block middle-dot-divider-sm]
end
with_them do
diff --git a/spec/helpers/projects/ml/experiments_helper_spec.rb b/spec/helpers/projects/ml/experiments_helper_spec.rb
index 569fd0f9ec5..9ac518f664d 100644
--- a/spec/helpers/projects/ml/experiments_helper_spec.rb
+++ b/spec/helpers/projects/ml/experiments_helper_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe Projects::Ml::ExperimentsHelper, feature_category: :mlops do
let_it_be(:project) { create(:project, :private) }
let_it_be(:experiment) { create(:ml_experiments, user_id: project.creator, project: project) }
let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
- let_it_be(:build) { create(:ci_build, pipeline: pipeline) }
+ let_it_be(:build) { create(:ci_build, user: project.creator, pipeline: pipeline) }
let_it_be(:candidate0) do
create(:ml_candidates,
:with_artifact,
@@ -46,7 +46,7 @@ RSpec.describe Projects::Ml::ExperimentsHelper, feature_category: :mlops do
'ci_job' => { 'path' => "/#{project.full_path}/-/jobs/#{build.id}", 'name' => 'test' },
'name' => candidate0.name,
'created_at' => candidate0.created_at.strftime('%Y-%m-%dT%H:%M:%S.%LZ'),
- 'user' => { 'username' => candidate0.user.username, 'path' => "/#{candidate0.user.username}" } },
+ 'user' => { 'username' => build.user.username, 'path' => "/#{build.user.username}" } },
{ 'param2' => 'p3', 'param3' => 'p4', 'metric3' => '0.4000',
'artifact' => nil, 'details' => "/#{project.full_path}/-/ml/candidates/#{candidate1.iid}",
'ci_job' => nil,
@@ -66,6 +66,7 @@ RSpec.describe Projects::Ml::ExperimentsHelper, feature_category: :mlops do
before do
allow(candidate0).to receive(:user).and_return(nil)
+ allow(candidate0.ci_build).to receive(:user).and_return(nil)
end
it 'has the user property, but is nil' do
@@ -80,8 +81,9 @@ RSpec.describe Projects::Ml::ExperimentsHelper, feature_category: :mlops do
.and_return(false)
end
- it 'does not include ci info' do
+ it 'does not include ci info and user for candidate created through CI' do
expect(subject[0]['ci_job']).to be_nil
+ expect(subject[0]['user']).to be_nil
end
end
end
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb
index 9f9372f94cc..90d998e17c3 100644
--- a/spec/helpers/projects_helper_spec.rb
+++ b/spec/helpers/projects_helper_spec.rb
@@ -77,14 +77,6 @@ RSpec.describe ProjectsHelper, feature_category: :source_code_management do
end
end
- describe "#project_status_css_class" do
- it "returns appropriate class" do
- expect(project_status_css_class("started")).to eq("table-active")
- expect(project_status_css_class("failed")).to eq("table-danger")
- expect(project_status_css_class("finished")).to eq("table-success")
- end
- end
-
describe "can_change_visibility_level?" do
let_it_be(:user) { create(:project_member, :reporter, user: create(:user), project: project).user }
@@ -126,82 +118,6 @@ RSpec.describe ProjectsHelper, feature_category: :source_code_management do
end
end
- describe "readme_cache_key" do
- let(:project) { project_with_repo }
-
- it "returns a valid cach key" do
- expect(helper.send(:readme_cache_key)).to eq("#{project.full_path}-#{project.commit.id}-readme")
- end
-
- it "returns a valid cache key if HEAD does not exist" do
- allow(project).to receive(:commit) { nil }
-
- expect(helper.send(:readme_cache_key)).to eq("#{project.full_path}-nil-readme")
- end
- end
-
- describe "#project_list_cache_key", :clean_gitlab_redis_cache do
- let(:project) { project_with_repo }
-
- before do
- allow(helper).to receive(:can?).with(user, :read_cross_project) { true }
- allow(user).to receive(:max_member_access_for_project).and_return(40)
- allow(Gitlab::I18n).to receive(:locale).and_return('es')
- end
-
- it "includes the route" do
- expect(helper.project_list_cache_key(project)).to include(project.route.cache_key)
- end
-
- it "includes the project" do
- expect(helper.project_list_cache_key(project)).to include(project.cache_key)
- end
-
- it "includes the last activity date" do
- expect(helper.project_list_cache_key(project)).to include(project.last_activity_date)
- end
-
- it "includes the controller name" do
- expect(helper.controller).to receive(:controller_name).and_return("testcontroller")
-
- expect(helper.project_list_cache_key(project)).to include("testcontroller")
- end
-
- it "includes the controller action" do
- expect(helper.controller).to receive(:action_name).and_return("testaction")
-
- expect(helper.project_list_cache_key(project)).to include("testaction")
- end
-
- it "includes the application settings" do
- settings = Gitlab::CurrentSettings.current_application_settings
-
- expect(helper.project_list_cache_key(project)).to include(settings.cache_key)
- end
-
- it "includes a version" do
- expect(helper.project_list_cache_key(project).last).to start_with('v')
- end
-
- it 'includes whether or not the user can read cross project' do
- expect(helper.project_list_cache_key(project)).to include('cross-project:true')
- end
-
- it "includes the pipeline status when there is a status" do
- create(:ci_pipeline, :success, project: project, sha: project.commit.sha)
-
- expect(helper.project_list_cache_key(project)).to include("pipeline-status/#{project.commit.sha}-success")
- end
-
- it "includes the user locale" do
- expect(helper.project_list_cache_key(project)).to include('es')
- end
-
- it "includes the user max member access" do
- expect(helper.project_list_cache_key(project)).to include('access:40')
- end
- end
-
describe '#load_pipeline_status' do
it 'loads the pipeline status in batch' do
helper.load_pipeline_status([project])
@@ -753,26 +669,21 @@ RSpec.describe ProjectsHelper, feature_category: :source_code_management do
describe '#show_mobile_devops_project_promo?' do
using RSpec::Parameterized::TableSyntax
- where(:hide_cookie, :feature_flag_enabled, :mobile_target_platform, :result) do
- false | true | true | true
- false | false | true | false
- false | false | false | false
- false | true | false | false
- true | false | false | false
- true | true | false | false
- true | true | true | false
- true | false | true | false
+ where(:hide_cookie, :mobile_target_platform, :result) do
+ false | true | true
+ false | false | false
+ true | false | false
+ true | true | false
end
with_them do
before do
allow(Gitlab).to receive(:com?) { gitlab_com }
- Feature.enable(:mobile_devops_projects_promo, feature_flag_enabled)
project.project_setting.target_platforms << 'ios' if mobile_target_platform
helper.request.cookies["hide_mobile_devops_promo_#{project.id}"] = true if hide_cookie
end
- it 'resolves if the user can import members' do
+ it 'resolves if mobile devops promo banner should be displayed' do
expect(helper.show_mobile_devops_project_promo?(project)).to eq result
end
end
@@ -809,42 +720,6 @@ RSpec.describe ProjectsHelper, feature_category: :source_code_management do
end
end
- describe '#grafana_integration_url' do
- subject { helper.grafana_integration_url }
-
- it { is_expected.to eq(nil) }
-
- context 'grafana integration exists' do
- let!(:grafana_integration) { create(:grafana_integration, project: project) }
-
- it { is_expected.to eq(grafana_integration.grafana_url) }
- end
- end
-
- describe '#grafana_integration_token' do
- subject { helper.grafana_integration_masked_token }
-
- it { is_expected.to eq(nil) }
-
- context 'grafana integration exists' do
- let!(:grafana_integration) { create(:grafana_integration, project: project) }
-
- it { is_expected.to eq(grafana_integration.masked_token) }
- end
- end
-
- describe '#grafana_integration_enabled?' do
- subject { helper.grafana_integration_enabled? }
-
- it { is_expected.to eq(nil) }
-
- context 'grafana integration exists' do
- let!(:grafana_integration) { create(:grafana_integration, project: project) }
-
- it { is_expected.to eq(grafana_integration.enabled) }
- end
- end
-
describe '#project_license_name(project)', :request_store do
let_it_be(:repository) { project.repository }
@@ -1200,14 +1075,6 @@ RSpec.describe ProjectsHelper, feature_category: :source_code_management do
it_behaves_like 'configure import method modal'
end
- describe '#import_from_gitlab_message' do
- let(:import_method) { 'GitLab.com' }
-
- subject { helper.import_from_gitlab_message }
-
- it_behaves_like 'configure import method modal'
- end
-
describe '#show_inactive_project_deletion_banner?' do
shared_examples 'does not show the banner' do |pass_project: true|
it { expect(helper.show_inactive_project_deletion_banner?(pass_project ? project : nil)).to be(false) }
diff --git a/spec/helpers/releases_helper_spec.rb b/spec/helpers/releases_helper_spec.rb
index 5a9deb5c63b..daf034edbb1 100644
--- a/spec/helpers/releases_helper_spec.rb
+++ b/spec/helpers/releases_helper_spec.rb
@@ -59,7 +59,7 @@ RSpec.describe ReleasesHelper do
describe '#data_for_edit_release_page' do
it 'has the needed data to display the "edit release" page' do
- keys = %i(project_id
+ keys = %i[project_id
group_id
group_milestones_available
project_path
@@ -72,7 +72,7 @@ RSpec.describe ReleasesHelper do
new_milestone_path
upcoming_release_docs_path
edit_release_docs_path
- delete_release_docs_path)
+ delete_release_docs_path]
expect(helper.data_for_edit_release_page.keys).to match_array(keys)
end
@@ -80,7 +80,7 @@ RSpec.describe ReleasesHelper do
describe '#data_for_new_release_page' do
it 'has the needed data to display the "new release" page' do
- keys = %i(project_id
+ keys = %i[project_id
group_id
group_milestones_available
project_path
@@ -93,7 +93,7 @@ RSpec.describe ReleasesHelper do
new_milestone_path
default_branch
upcoming_release_docs_path
- edit_release_docs_path)
+ edit_release_docs_path]
expect(helper.data_for_new_release_page.keys).to match_array(keys)
end
@@ -101,9 +101,9 @@ RSpec.describe ReleasesHelper do
describe '#data_for_show_page' do
it 'has the needed data to display the individual "release" page' do
- keys = %i(project_id
+ keys = %i[project_id
project_path
- tag_name)
+ tag_name]
expect(helper.data_for_show_page.keys).to match_array(keys)
end
diff --git a/spec/helpers/sidekiq_helper_spec.rb b/spec/helpers/sidekiq_helper_spec.rb
deleted file mode 100644
index 594996bac95..00000000000
--- a/spec/helpers/sidekiq_helper_spec.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe SidekiqHelper, feature_category: :shared do
- describe 'parse_sidekiq_ps' do
- it 'parses line with time' do
- line = '55137 10,0 2,1 S+ 2:30pm sidekiq 4.1.4 gitlab [0 of 25 busy] '
- parts = helper.parse_sidekiq_ps(line)
-
- expect(parts).to eq(['55137', '10,0', '2,1', 'S+', '2:30pm', 'sidekiq 4.1.4 gitlab [0 of 25 busy]'])
- end
-
- it 'parses line with date' do
- line = '55137 10,0 2,1 S+ Aug 4 sidekiq 4.1.4 gitlab [0 of 25 busy] '
- parts = helper.parse_sidekiq_ps(line)
-
- expect(parts).to eq(['55137', '10,0', '2,1', 'S+', 'Aug 4', 'sidekiq 4.1.4 gitlab [0 of 25 busy]'])
- end
-
- it 'parses line with two digit date' do
- line = '55137 10,0 2,1 S+ Aug 04 sidekiq 4.1.4 gitlab [0 of 25 busy] '
- parts = helper.parse_sidekiq_ps(line)
-
- expect(parts).to eq(['55137', '10,0', '2,1', 'S+', 'Aug 04', 'sidekiq 4.1.4 gitlab [0 of 25 busy]'])
- end
-
- it 'parses line with dot as float separator' do
- line = '55137 10.0 2.1 S+ 2:30pm sidekiq 4.1.4 gitlab [0 of 25 busy] '
- parts = helper.parse_sidekiq_ps(line)
-
- expect(parts).to eq(['55137', '10.0', '2.1', 'S+', '2:30pm', 'sidekiq 4.1.4 gitlab [0 of 25 busy]'])
- end
-
- it 'parses OSX output' do
- line = ' 1641 1.5 3.8 S+ 4:04PM sidekiq 4.2.1 gitlab [0 of 25 busy]'
- parts = helper.parse_sidekiq_ps(line)
-
- expect(parts).to eq(['1641', '1.5', '3.8', 'S+', '4:04PM', 'sidekiq 4.2.1 gitlab [0 of 25 busy]'])
- end
-
- it 'parses Ubuntu output' do
- # Ubuntu Linux 16.04 LTS / procps-3.3.10-4ubuntu2
- line = ' 938 1.4 2.5 Sl+ 21:23:21 sidekiq 4.2.1 gitlab [0 of 25 busy] '
- parts = helper.parse_sidekiq_ps(line)
-
- expect(parts).to eq(['938', '1.4', '2.5', 'Sl+', '21:23:21', 'sidekiq 4.2.1 gitlab [0 of 25 busy]'])
- end
-
- it 'parses Debian output' do
- # Debian Linux Wheezy/Jessie
- line = '17725 1.0 12.1 Ssl 19:20:15 sidekiq 4.2.1 gitlab-rails [0 of 25 busy] '
- parts = helper.parse_sidekiq_ps(line)
-
- expect(parts).to eq(['17725', '1.0', '12.1', 'Ssl', '19:20:15', 'sidekiq 4.2.1 gitlab-rails [0 of 25 busy]'])
- end
-
- it 'parses OpenBSD output' do
- # OpenBSD 6.1
- line = '49258 0.5 2.3 R/0 Fri10PM ruby23: sidekiq 4.2.7 gitlab [0 of 25 busy] (ruby23)'
- parts = helper.parse_sidekiq_ps(line)
-
- expect(parts).to eq(['49258', '0.5', '2.3', 'R/0', 'Fri10PM', 'ruby23: sidekiq 4.2.7 gitlab [0 of 25 busy] (ruby23)'])
- end
-
- it 'does fail gracefully on line not matching the format' do
- line = '55137 10.0 2.1 S+ 2:30pm something'
- parts = helper.parse_sidekiq_ps(line)
-
- expect(parts).to eq(['?', '?', '?', '?', '?', '?'])
- end
- end
-end
diff --git a/spec/helpers/sorting_helper_spec.rb b/spec/helpers/sorting_helper_spec.rb
index d625b46e286..0f53cc98415 100644
--- a/spec/helpers/sorting_helper_spec.rb
+++ b/spec/helpers/sorting_helper_spec.rb
@@ -76,20 +76,6 @@ RSpec.describe SortingHelper do
end
end
- describe '#issuable_sort_option_title' do
- it 'returns correct title for issuable_sort_option_overrides key' do
- expect(issuable_sort_option_title('created_asc')).to eq('Created date')
- end
-
- it 'returns correct title for a valid sort value' do
- expect(issuable_sort_option_title('priority')).to eq('Priority')
- end
-
- it 'returns nil for invalid sort value' do
- expect(issuable_sort_option_title('invalid_key')).to eq(nil)
- end
- end
-
describe '#issuable_sort_direction_button' do
before do
set_sorting_url 'test_label'
@@ -156,6 +142,23 @@ RSpec.describe SortingHelper do
end
end
+ describe '#groups_sort_options_hash' do
+ let(:expected_options) do
+ {
+ sort_value_name => sort_title_name,
+ sort_value_name_desc => sort_title_name_desc,
+ sort_value_recently_created => sort_title_recently_created,
+ sort_value_oldest_created => sort_title_oldest_created,
+ sort_value_latest_activity => sort_title_recently_updated,
+ sort_value_oldest_activity => sort_title_oldest_updated
+ }
+ end
+
+ it 'returns a hash of available sorting options for the groups' do
+ expect(groups_sort_options_hash).to eq(expected_options)
+ end
+ end
+
describe 'with `projects` controller' do
before do
stub_controller_path 'projects'
@@ -192,17 +195,6 @@ RSpec.describe SortingHelper do
stub_controller_path 'forks'
end
- describe '#forks_sort_options_hash' do
- it 'returns a hash of available sorting options' do
- expect(forks_sort_options_hash).to include({
- sort_value_recently_created => sort_title_created_date,
- sort_value_oldest_created => sort_title_created_date,
- sort_value_latest_activity => sort_title_latest_activity,
- sort_value_oldest_activity => sort_title_latest_activity
- })
- end
- end
-
describe '#forks_reverse_sort_options_hash' do
context 'for each sort option' do
using RSpec::Parameterized::TableSyntax
diff --git a/spec/helpers/todos_helper_spec.rb b/spec/helpers/todos_helper_spec.rb
index dfb5cb995bc..4680a43058d 100644
--- a/spec/helpers/todos_helper_spec.rb
+++ b/spec/helpers/todos_helper_spec.rb
@@ -401,6 +401,15 @@ RSpec.describe TodosHelper do
end
end
end
+
+ context 'okr checkin reminder' do
+ it 'returns okr checkin reminder message' do
+ alert_todo.action = Todo::OKR_CHECKIN_REQUESTED
+ expect(helper.todo_action_name(alert_todo)).to eq(
+ format(s_("Todos|requested an OKR update for %{what}"), what: alert_todo.target.title)
+ )
+ end
+ end
end
describe '#todo_due_date' do
diff --git a/spec/helpers/tracking_helper_spec.rb b/spec/helpers/tracking_helper_spec.rb
index 81121275c92..9d3f2d07cbe 100644
--- a/spec/helpers/tracking_helper_spec.rb
+++ b/spec/helpers/tracking_helper_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe TrackingHelper do
describe '#tracking_attrs' do
using RSpec::Parameterized::TableSyntax
- let(:input) { %w(a b c) }
+ let(:input) { %w[a b c] }
let(:result) { { data: { track_label: 'a', track_action: 'b', track_property: 'c' } } }
before do
diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb
index ad8aef276bb..20b5452d2d4 100644
--- a/spec/helpers/users_helper_spec.rb
+++ b/spec/helpers/users_helper_spec.rb
@@ -646,7 +646,7 @@ RSpec.describe UsersHelper do
expect(preload_queries).not_to exceed_query_limit(2)
expect(helper_queries).not_to exceed_query_limit(0)
- expect(access_queries).not_to exceed_query_limit(0)
+ expect(access_queries).not_to exceed_query_limit(1)
end
end
end
diff --git a/spec/helpers/wiki_helper_spec.rb b/spec/helpers/wiki_helper_spec.rb
index 497cd5d1e7f..6eaa603a43d 100644
--- a/spec/helpers/wiki_helper_spec.rb
+++ b/spec/helpers/wiki_helper_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe WikiHelper do
+RSpec.describe WikiHelper, feature_category: :wiki do
describe '#wiki_page_title' do
let_it_be(:page) { create(:wiki_page) }
@@ -75,38 +75,42 @@ RSpec.describe WikiHelper do
describe '#wiki_sort_controls' do
let(:wiki) { create(:project_wiki) }
- let(:wiki_link) { helper.wiki_sort_controls(wiki, direction) }
- let(:classes) { "gl-button btn btn-default btn-icon has-tooltip reverse-sort-btn rspec-reverse-sort" }
- def expected_link(direction, icon_class)
+ before do
+ allow(Pajamas::ButtonComponent).to receive(:new).and_call_original
+ end
+
+ def expected_link_args(direction, icon_class)
path = "/#{wiki.project.full_path}/-/wikis/pages?direction=#{direction}"
title = direction == 'desc' ? _('Sort direction: Ascending') : _('Sort direction: Descending')
- helper.link_to(path, type: 'button', class: classes, title: title) do
- helper.sprite_icon("sort-#{icon_class}")
- end
+ {
+ href: path,
+ icon: "sort-#{icon_class}",
+ button_options: hash_including(title: title)
+ }
end
- context 'initial call' do
- let(:direction) { nil }
+ context 'when initially rendering' do
+ it 'uses default values' do
+ helper.wiki_sort_controls(wiki, nil)
- it 'renders with default values' do
- expect(wiki_link).to eq(expected_link('desc', 'lowest'))
+ expect(Pajamas::ButtonComponent).to have_received(:new).with(expected_link_args('desc', 'lowest'))
end
end
- context 'sort by asc order' do
- let(:direction) { 'asc' }
-
+ context 'when the current sort order is ascending' do
it 'renders a link with opposite direction' do
- expect(wiki_link).to eq(expected_link('desc', 'lowest'))
+ helper.wiki_sort_controls(wiki, 'asc')
+
+ expect(Pajamas::ButtonComponent).to have_received(:new).with(expected_link_args('desc', 'lowest'))
end
end
- context 'sort by desc order' do
- let(:direction) { 'desc' }
-
+ context 'when the current sort order is descending' do
it 'renders a link with opposite direction' do
- expect(wiki_link).to eq(expected_link('asc', 'highest'))
+ helper.wiki_sort_controls(wiki, 'desc')
+
+ expect(Pajamas::ButtonComponent).to have_received(:new).with(expected_link_args('asc', 'highest'))
end
end
end