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:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-05-19 10:33:21 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-05-19 10:33:21 +0300
commit36a59d088eca61b834191dacea009677a96c052f (patch)
treee4f33972dab5d8ef79e3944a9f403035fceea43f /spec/helpers
parenta1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff)
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/appearances_helper_spec.rb44
-rw-r--r--spec/helpers/application_settings_helper_spec.rb2
-rw-r--r--spec/helpers/auth_helper_spec.rb10
-rw-r--r--spec/helpers/badges_helper_spec.rb6
-rw-r--r--spec/helpers/ci/builds_helper_spec.rb14
-rw-r--r--spec/helpers/ci/pipeline_editor_helper_spec.rb2
-rw-r--r--spec/helpers/ci/pipelines_helper_spec.rb52
-rw-r--r--spec/helpers/ci/runners_helper_spec.rb14
-rw-r--r--spec/helpers/ci/secure_files_helper_spec.rb76
-rw-r--r--spec/helpers/clusters_helper_spec.rb16
-rw-r--r--spec/helpers/container_registry_helper_spec.rb14
-rw-r--r--spec/helpers/cookies_helper_spec.rb6
-rw-r--r--spec/helpers/emails_helper_spec.rb4
-rw-r--r--spec/helpers/instance_configuration_helper_spec.rb10
-rw-r--r--spec/helpers/integrations_helper_spec.rb1
-rw-r--r--spec/helpers/invite_members_helper_spec.rb46
-rw-r--r--spec/helpers/issuables_helper_spec.rb36
-rw-r--r--spec/helpers/issues_helper_spec.rb1
-rw-r--r--spec/helpers/jira_connect_helper_spec.rb1
-rw-r--r--spec/helpers/lazy_image_tag_helper_spec.rb109
-rw-r--r--spec/helpers/merge_requests_helper_spec.rb31
-rw-r--r--spec/helpers/namespaces_helper_spec.rb5
-rw-r--r--spec/helpers/page_layout_helper_spec.rb6
-rw-r--r--spec/helpers/profiles_helper_spec.rb9
-rw-r--r--spec/helpers/projects/pipeline_helper_spec.rb1
-rw-r--r--spec/helpers/projects_helper_spec.rb4
-rw-r--r--spec/helpers/releases_helper_spec.rb10
-rw-r--r--spec/helpers/search_helper_spec.rb3
-rw-r--r--spec/helpers/sidebars_helper_spec.rb2
-rw-r--r--spec/helpers/storage_helper_spec.rb28
-rw-r--r--spec/helpers/tracking_helper_spec.rb31
-rw-r--r--spec/helpers/users_helper_spec.rb2
32 files changed, 448 insertions, 148 deletions
diff --git a/spec/helpers/appearances_helper_spec.rb b/spec/helpers/appearances_helper_spec.rb
index d972ac27119..edd704ce739 100644
--- a/spec/helpers/appearances_helper_spec.rb
+++ b/spec/helpers/appearances_helper_spec.rb
@@ -80,6 +80,50 @@ RSpec.describe AppearancesHelper do
end
end
+ describe '#brand_header_logo' do
+ let(:options) { {} }
+
+ subject do
+ helper.brand_header_logo(options)
+ end
+
+ context 'with header logo' 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')
+
+ subject
+ end
+ end
+
+ context 'with add_gitlab_white_text option' do
+ let(:options) { { add_gitlab_white_text: true } }
+
+ it 'renders shared/logo_with_white_text partial' do
+ expect(helper).to receive(:render).with(partial: 'shared/logo_with_white_text', formats: :svg)
+
+ subject
+ end
+ end
+
+ context 'with add_gitlab_black_text option' do
+ let(:options) { { add_gitlab_black_text: true } }
+
+ it 'renders shared/logo_with_black_text partial' do
+ expect(helper).to receive(:render).with(partial: 'shared/logo_with_black_text', formats: :svg)
+
+ subject
+ end
+ end
+
+ it 'renders shared/logo by default' do
+ expect(helper).to receive(:render).with(partial: 'shared/logo', formats: :svg)
+
+ subject
+ end
+ end
+
describe '#brand_title' do
it 'returns the default title when no appearance is present' do
allow(helper).to receive(:current_appearance).and_return(nil)
diff --git a/spec/helpers/application_settings_helper_spec.rb b/spec/helpers/application_settings_helper_spec.rb
index c93762416f5..0304aac18ae 100644
--- a/spec/helpers/application_settings_helper_spec.rb
+++ b/spec/helpers/application_settings_helper_spec.rb
@@ -295,7 +295,7 @@ RSpec.describe ApplicationSettingsHelper do
it { is_expected.to eq([%w(Track track), %w(Compress compress)]) }
end
- describe '#instance_clusters_enabled?' do
+ describe '#instance_clusters_enabled?', :request_store do
let_it_be(:user) { create(:user) }
subject { helper.instance_clusters_enabled? }
diff --git a/spec/helpers/auth_helper_spec.rb b/spec/helpers/auth_helper_spec.rb
index 4bb09699db4..4b0b44d1325 100644
--- a/spec/helpers/auth_helper_spec.rb
+++ b/spec/helpers/auth_helper_spec.rb
@@ -500,6 +500,16 @@ RSpec.describe AuthHelper do
)
end
+ context 'when SAML is enabled without specifying a strategy class' do
+ before do
+ allow(Gitlab::Auth::OAuth::Provider).to receive(:providers).and_return([:saml])
+ end
+
+ it 'returns the saml provider' do
+ expect(saml_providers).to match_array([:saml])
+ end
+ end
+
context 'when configuration specifies no provider' do
before do
allow(Devise).to receive(:omniauth_providers).and_return([])
diff --git a/spec/helpers/badges_helper_spec.rb b/spec/helpers/badges_helper_spec.rb
index 5be3b4a737b..8e1f92305da 100644
--- a/spec/helpers/badges_helper_spec.rb
+++ b/spec/helpers/badges_helper_spec.rb
@@ -89,16 +89,16 @@ RSpec.describe BadgesHelper do
end
describe 'icons' do
- let(:spacing_class_regex) { %r{<svg .*class=".*gl-mr-2.*".*>.*</svg>} }
+ let(:spacing_class_regex) { %r{<svg .*class=".*my-icon-class gl-mr-2".*>.*</svg>} }
describe 'with text' do
- subject { helper.gl_badge_tag(label, icon: "question-o") }
+ subject { helper.gl_badge_tag(label, icon: "question-o", icon_classes: 'my-icon-class') }
it 'renders an icon' do
expect(subject).to match(%r{<svg .*#question-o".*>.*</svg>})
end
- it 'adds a spacing class to the icon' do
+ it 'adds a spacing class and any custom classes to the icon' do
expect(subject).to match(spacing_class_regex)
end
end
diff --git a/spec/helpers/ci/builds_helper_spec.rb b/spec/helpers/ci/builds_helper_spec.rb
index 143d96cf632..ea3b5aac4ea 100644
--- a/spec/helpers/ci/builds_helper_spec.rb
+++ b/spec/helpers/ci/builds_helper_spec.rb
@@ -97,6 +97,20 @@ RSpec.describe Ci::BuildsHelper do
end
end
+ describe '#prepare_failed_jobs_summary_data' do
+ let(:failed_build) { create(:ci_build, :failed, :trace_live) }
+
+ subject { helper.prepare_failed_jobs_summary_data([failed_build]) }
+
+ it 'returns array of failed jobs with id, failure and failure summary' do
+ expect(subject).to eq([{
+ id: failed_build.id,
+ failure: failed_build.present.callout_failure_message,
+ failure_summary: helper.build_summary(failed_build)
+ }].to_json)
+ end
+ end
+
def assign_project
build(:project).tap do |project|
assign(:project, project)
diff --git a/spec/helpers/ci/pipeline_editor_helper_spec.rb b/spec/helpers/ci/pipeline_editor_helper_spec.rb
index 12456deb538..429d4c7941a 100644
--- a/spec/helpers/ci/pipeline_editor_helper_spec.rb
+++ b/spec/helpers/ci/pipeline_editor_helper_spec.rb
@@ -45,6 +45,7 @@ RSpec.describe Ci::PipelineEditorHelper do
"default-branch" => project.default_branch_or_main,
"empty-state-illustration-path" => 'foo',
"initial-branch-name" => nil,
+ "includes-help-page-path" => help_page_path('ci/yaml/includes'),
"lint-help-page-path" => help_page_path('ci/lint', anchor: 'check-cicd-syntax'),
"lint-unavailable-help-page-path" => help_page_path('ci/pipeline_editor/index', anchor: 'configuration-validation-currently-not-available-message'),
"needs-help-page-path" => help_page_path('ci/yaml/index', anchor: 'needs'),
@@ -72,6 +73,7 @@ RSpec.describe Ci::PipelineEditorHelper do
"default-branch" => project.default_branch_or_main,
"empty-state-illustration-path" => 'foo',
"initial-branch-name" => nil,
+ "includes-help-page-path" => help_page_path('ci/yaml/includes'),
"lint-help-page-path" => help_page_path('ci/lint', anchor: 'check-cicd-syntax'),
"lint-unavailable-help-page-path" => help_page_path('ci/pipeline_editor/index', anchor: 'configuration-validation-currently-not-available-message'),
"needs-help-page-path" => help_page_path('ci/yaml/index', anchor: 'needs'),
diff --git a/spec/helpers/ci/pipelines_helper_spec.rb b/spec/helpers/ci/pipelines_helper_spec.rb
index c473e1e4ab6..19946afb1a4 100644
--- a/spec/helpers/ci/pipelines_helper_spec.rb
+++ b/spec/helpers/ci/pipelines_helper_spec.rb
@@ -152,18 +152,18 @@ RSpec.describe Ci::PipelinesHelper do
end
end
- describe 'the `registration_token` attribute' do
- subject { data[:registration_token] }
+ describe 'when the project is eligible for the `ios_specific_templates` experiment' do
+ let_it_be(:project) { create(:project, :auto_devops_disabled, shared_runners_enabled: false) }
+ let_it_be(:user) { create(:user) }
- describe 'when the project is eligible for the `ios_specific_templates` experiment' do
- let_it_be(:project) { create(:project, :auto_devops_disabled) }
- let_it_be(:user) { create(:user) }
+ before do
+ allow(helper).to receive(:current_user).and_return(user)
+ project.add_developer(user)
+ create(:project_setting, project: project, target_platforms: %w(ios))
+ end
- before do
- allow(helper).to receive(:current_user).and_return(user)
- project.add_developer(user)
- create(:project_setting, project: project, target_platforms: %w(ios))
- end
+ describe 'the `registration_token` attribute' do
+ subject { data[:registration_token] }
context 'when the `ios_specific_templates` experiment variant is control' do
before do
@@ -191,6 +191,38 @@ RSpec.describe Ci::PipelinesHelper do
end
end
end
+
+ describe 'the `ios_runners_available` attribute' do
+ before do
+ allow(Gitlab).to receive(:com?).and_return(true)
+ end
+
+ subject { data[:ios_runners_available] }
+
+ context 'when the `ios_specific_templates` experiment variant is control' do
+ before do
+ stub_experiments(ios_specific_templates: :control)
+ end
+
+ it { is_expected.to be_nil }
+ end
+
+ context 'when the `ios_specific_templates` experiment variant is candidate' do
+ before do
+ stub_experiments(ios_specific_templates: :candidate)
+ end
+
+ context 'when shared runners are not enabled' do
+ it { is_expected.to eq('false') }
+ end
+
+ context 'when shared runners are enabled' do
+ let_it_be(:project) { create(:project, :auto_devops_disabled, shared_runners_enabled: true) }
+
+ it { is_expected.to eq('true') }
+ end
+ end
+ end
end
end
end
diff --git a/spec/helpers/ci/runners_helper_spec.rb b/spec/helpers/ci/runners_helper_spec.rb
index 0046d481282..cf62579338f 100644
--- a/spec/helpers/ci/runners_helper_spec.rb
+++ b/spec/helpers/ci/runners_helper_spec.rb
@@ -99,17 +99,17 @@ RSpec.describe Ci::RunnersHelper do
let(:runner_constants) do
{
- runner_enabled: Namespace::SR_ENABLED,
- runner_disabled: Namespace::SR_DISABLED_AND_UNOVERRIDABLE,
- runner_allow_override: Namespace::SR_DISABLED_WITH_OVERRIDE
+ runner_enabled_value: Namespace::SR_ENABLED,
+ runner_disabled_value: Namespace::SR_DISABLED_AND_UNOVERRIDABLE,
+ runner_allow_override_value: Namespace::SR_DISABLED_WITH_OVERRIDE
}
end
it 'returns group data for top level group' do
result = {
update_path: "/api/v4/groups/#{parent.id}",
- shared_runners_availability: Namespace::SR_ENABLED,
- parent_shared_runners_availability: nil
+ shared_runners_setting: Namespace::SR_ENABLED,
+ parent_shared_runners_setting: nil
}.merge(runner_constants)
expect(helper.group_shared_runners_settings_data(parent)).to eq result
@@ -118,8 +118,8 @@ RSpec.describe Ci::RunnersHelper do
it 'returns group data for child group' do
result = {
update_path: "/api/v4/groups/#{group.id}",
- shared_runners_availability: Namespace::SR_DISABLED_AND_UNOVERRIDABLE,
- parent_shared_runners_availability: Namespace::SR_ENABLED
+ shared_runners_setting: Namespace::SR_DISABLED_AND_UNOVERRIDABLE,
+ parent_shared_runners_setting: Namespace::SR_ENABLED
}.merge(runner_constants)
expect(helper.group_shared_runners_settings_data(group)).to eq result
diff --git a/spec/helpers/ci/secure_files_helper_spec.rb b/spec/helpers/ci/secure_files_helper_spec.rb
new file mode 100644
index 00000000000..02da44f56b2
--- /dev/null
+++ b/spec/helpers/ci/secure_files_helper_spec.rb
@@ -0,0 +1,76 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Ci::SecureFilesHelper do
+ let_it_be(:maintainer) { create(:user) }
+ let_it_be(:developer) { create(:user) }
+ let_it_be(:guest) { create(:user) }
+ let_it_be(:anonymous) { create(:user) }
+ let_it_be(:unconfirmed) { create(:user, :unconfirmed) }
+ let_it_be(:project) { create(:project, creator_id: maintainer.id) }
+
+ before_all do
+ project.add_maintainer(maintainer)
+ project.add_developer(developer)
+ project.add_guest(guest)
+ end
+
+ subject { helper.show_secure_files_setting(project, user) }
+
+ describe '#show_secure_files_setting' do
+ context 'when the :ci_secure_files feature flag is enabled' do
+ before do
+ stub_feature_flags(ci_secure_files: true)
+ end
+
+ context 'authenticated user with admin permissions' do
+ let(:user) { maintainer }
+
+ it { is_expected.to be true }
+ end
+
+ context 'authenticated user with read permissions' do
+ let(:user) { developer }
+
+ it { is_expected.to be true }
+ end
+
+ context 'authenticated user with guest permissions' do
+ let(:user) { guest }
+
+ it { is_expected.to be false }
+ end
+
+ context 'authenticated user with no permissions' do
+ let(:user) { anonymous }
+
+ it { is_expected.to be false }
+ end
+
+ context 'unconfirmed user' do
+ let(:user) { unconfirmed }
+
+ it { is_expected.to be false }
+ end
+
+ context 'unauthenticated user' do
+ let(:user) { nil }
+
+ it { is_expected.to be false }
+ end
+ end
+
+ context 'when the :ci_secure_files feature flag is disabled' do
+ before do
+ stub_feature_flags(ci_secure_files: false)
+ end
+
+ context 'authenticated user with admin permissions' do
+ let(:user) { maintainer }
+
+ it { is_expected.to be false }
+ end
+ end
+ end
+end
diff --git a/spec/helpers/clusters_helper_spec.rb b/spec/helpers/clusters_helper_spec.rb
index 4feb9d1a2cd..9a3cd5fd18d 100644
--- a/spec/helpers/clusters_helper_spec.rb
+++ b/spec/helpers/clusters_helper_spec.rb
@@ -66,10 +66,6 @@ RSpec.describe ClustersHelper do
expect(subject[:empty_state_image]).to match(%r(/illustrations/empty-state/empty-state-agents|svg))
end
- it 'displays create cluster using certificate path' do
- expect(subject[:new_cluster_path]).to eq("#{project_path(project)}/-/clusters/new")
- end
-
it 'displays add cluster using certificate path' do
expect(subject[:add_cluster_path]).to eq("#{project_path(project)}/-/clusters/connect")
end
@@ -94,6 +90,10 @@ RSpec.describe ClustersHelper do
expect(subject[:gitlab_version]).to eq(Gitlab.version_info)
end
+ it 'displays KAS version' do
+ expect(subject[:kas_version]).to eq(Gitlab::Kas.version_info)
+ end
+
context 'user has no permissions to create a cluster' do
it 'displays that user can\'t add cluster' do
expect(subject[:can_add_cluster]).to eq("false")
@@ -166,14 +166,6 @@ RSpec.describe ClustersHelper do
end
end
- describe '#js_cluster_new' do
- subject { helper.js_cluster_new }
-
- it 'displays a cluster_connect_help_path' do
- expect(subject[:cluster_connect_help_path]).to eq(help_page_path('user/project/clusters/add_remove_clusters', anchor: 'add-existing-cluster'))
- end
- end
-
describe '#cluster_type_label' do
subject { helper.cluster_type_label(cluster_type) }
diff --git a/spec/helpers/container_registry_helper_spec.rb b/spec/helpers/container_registry_helper_spec.rb
index 57641d4b5df..250f26172a8 100644
--- a/spec/helpers/container_registry_helper_spec.rb
+++ b/spec/helpers/container_registry_helper_spec.rb
@@ -3,17 +3,9 @@
require 'spec_helper'
RSpec.describe ContainerRegistryHelper do
- describe '#container_registry_expiration_policies_throttling?' do
- subject { helper.container_registry_expiration_policies_throttling? }
+ describe '#container_repository_gid_prefix' do
+ subject { helper.container_repository_gid_prefix }
- it { is_expected.to eq(true) }
-
- context 'with container_registry_expiration_policies_throttling disabled' do
- before do
- stub_feature_flags(container_registry_expiration_policies_throttling: false)
- end
-
- it { is_expected.to eq(false) }
- end
+ it { is_expected.to eq('gid://gitlab/ContainerRepository/') }
end
end
diff --git a/spec/helpers/cookies_helper_spec.rb b/spec/helpers/cookies_helper_spec.rb
index c73e7d64987..95970c24086 100644
--- a/spec/helpers/cookies_helper_spec.rb
+++ b/spec/helpers/cookies_helper_spec.rb
@@ -11,7 +11,7 @@ RSpec.describe CookiesHelper do
value = 'secure value'
expect_next_instance_of(ActionDispatch::Cookies::EncryptedKeyRotatingCookieJar) do |instance|
- expect(instance).to receive(:[]=).with(key, httponly: true, secure: true, expires: expiration, value: value)
+ expect(instance).to receive(:[]=).with(key, { httponly: true, secure: true, expires: expiration, value: value })
end
helper.set_secure_cookie(key, value, httponly: true, expires: expiration, type: CookiesHelper::COOKIE_TYPE_ENCRYPTED)
@@ -22,7 +22,7 @@ RSpec.describe CookiesHelper do
value = 'permanent value'
expect_next_instance_of(ActionDispatch::Cookies::PermanentCookieJar) do |instance|
- expect(instance).to receive(:[]=).with(key, httponly: false, secure: false, expires: nil, value: value)
+ expect(instance).to receive(:[]=).with(key, { httponly: false, secure: false, expires: nil, value: value })
end
helper.set_secure_cookie(key, value, type: CookiesHelper::COOKIE_TYPE_PERMANENT)
@@ -33,7 +33,7 @@ RSpec.describe CookiesHelper do
value = 'regular value'
expect_next_instance_of(ActionDispatch::Cookies::CookieJar) do |instance|
- expect(instance).to receive(:[]=).with(key, httponly: false, secure: false, expires: nil, value: value)
+ expect(instance).to receive(:[]=).with(key, { httponly: false, secure: false, expires: nil, value: value })
end
helper.set_secure_cookie(key, value)
diff --git a/spec/helpers/emails_helper_spec.rb b/spec/helpers/emails_helper_spec.rb
index 956c19f54d1..39b919fa925 100644
--- a/spec/helpers/emails_helper_spec.rb
+++ b/spec/helpers/emails_helper_spec.rb
@@ -239,7 +239,7 @@ RSpec.describe EmailsHelper do
create :appearance, header_logo: nil
expect(header_logo).to match(
- %r{<img alt="GitLab" src="/images/mailers/gitlab_header_logo\.(?:gif|png)" width="\d+" height="\d+" />}
+ %r{<img alt="GitLab" src="/images/mailers/gitlab_logo\.(?:gif|png)" width="\d+" height="\d+" />}
)
end
end
@@ -247,7 +247,7 @@ RSpec.describe EmailsHelper do
context 'there is no brand item' do
it 'returns the default header logo' do
expect(header_logo).to match(
- %r{<img alt="GitLab" src="/images/mailers/gitlab_header_logo\.(?:gif|png)" width="\d+" height="\d+" />}
+ %r{<img alt="GitLab" src="/images/mailers/gitlab_logo\.(?:gif|png)" width="\d+" height="\d+" />}
)
end
end
diff --git a/spec/helpers/instance_configuration_helper_spec.rb b/spec/helpers/instance_configuration_helper_spec.rb
index 1ba06b97088..921ec7ee588 100644
--- a/spec/helpers/instance_configuration_helper_spec.rb
+++ b/spec/helpers/instance_configuration_helper_spec.rb
@@ -50,4 +50,14 @@ RSpec.describe InstanceConfigurationHelper do
expect(helper.instance_configuration_human_size_cell(1048576)).to eq('1 MB')
end
end
+
+ describe '#instance_configuration_disabled_cell_html' do
+ it 'returns "-" if parameter is 0' do
+ expect(helper.instance_configuration_disabled_cell_html(0)).to eq('-')
+ end
+
+ it 'return parameter if not 0' do
+ expect(helper.instance_configuration_disabled_cell_html(1)).to eq(1)
+ end
+ end
end
diff --git a/spec/helpers/integrations_helper_spec.rb b/spec/helpers/integrations_helper_spec.rb
index 3bedc1d8aec..dccbc110be6 100644
--- a/spec/helpers/integrations_helper_spec.rb
+++ b/spec/helpers/integrations_helper_spec.rb
@@ -62,6 +62,7 @@ RSpec.describe IntegrationsHelper do
:enable_comments,
:comment_detail,
:learn_more_path,
+ :about_pricing_url,
:trigger_events,
:fields,
:inherit_from_id,
diff --git a/spec/helpers/invite_members_helper_spec.rb b/spec/helpers/invite_members_helper_spec.rb
index 859d145eb53..4d47732e008 100644
--- a/spec/helpers/invite_members_helper_spec.rb
+++ b/spec/helpers/invite_members_helper_spec.rb
@@ -30,6 +30,28 @@ RSpec.describe InviteMembersHelper do
expect(helper.common_invite_group_modal_data(project, ProjectMember, 'true')).to include(attributes)
end
+
+ context 'when sharing with groups outside the hierarchy is disabled' do
+ let_it_be(:group) { create(:group) }
+
+ before do
+ group.update!(prevent_sharing_groups_outside_hierarchy: true)
+ end
+
+ it 'provides the correct attributes' do
+ expect(helper.common_invite_group_modal_data(group, GroupMember, 'false')).to include({ groups_filter: 'descendant_groups', parent_id: group.id })
+ end
+ end
+
+ context 'when sharing with groups outside the hierarchy is enabled' do
+ before do
+ group.update!(prevent_sharing_groups_outside_hierarchy: false)
+ end
+
+ it 'does not return filter attributes' do
+ expect(helper.common_invite_group_modal_data(project.group, ProjectMember, 'true').keys).not_to include(:groups_filter, :parent_id)
+ end
+ end
end
describe '#common_invite_modal_dataset' do
@@ -162,28 +184,4 @@ RSpec.describe InviteMembersHelper do
end
end
end
-
- describe '#group_select_data' do
- let_it_be(:group) { create(:group) }
-
- context 'when sharing with groups outside the hierarchy is disabled' do
- before do
- group.namespace_settings.update!(prevent_sharing_groups_outside_hierarchy: true)
- end
-
- it 'provides the correct attributes' do
- expect(helper.group_select_data(group)).to eq({ groups_filter: 'descendant_groups', parent_id: group.id })
- end
- end
-
- context 'when sharing with groups outside the hierarchy is enabled' do
- before do
- group.namespace_settings.update!(prevent_sharing_groups_outside_hierarchy: false)
- end
-
- it 'returns an empty hash' do
- expect(helper.group_select_data(project.group)).to eq({})
- end
- end
- end
end
diff --git a/spec/helpers/issuables_helper_spec.rb b/spec/helpers/issuables_helper_spec.rb
index ee5b0145d13..73527bea14e 100644
--- a/spec/helpers/issuables_helper_spec.rb
+++ b/spec/helpers/issuables_helper_spec.rb
@@ -294,6 +294,7 @@ RSpec.describe IssuablesHelper do
projectPath: @project.path,
projectId: @project.id,
projectNamespace: @project.namespace.path,
+ state: issue.state,
initialTitleHtml: issue.title,
initialTitleText: issue.title,
initialDescriptionHtml: '<p dir="auto">issue text</p>',
@@ -464,6 +465,41 @@ RSpec.describe IssuablesHelper 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_display_type' do
using RSpec::Parameterized::TableSyntax
diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb
index 0f653fdd282..0421c7b7458 100644
--- a/spec/helpers/issues_helper_spec.rb
+++ b/spec/helpers/issues_helper_spec.rb
@@ -302,6 +302,7 @@ RSpec.describe IssuesHelper do
is_anonymous_search_disabled: 'true',
is_issue_repositioning_disabled: 'true',
is_project: 'true',
+ is_public_visibility_restricted: 'false',
is_signed_in: current_user.present?.to_s,
jira_integration_path: help_page_url('integration/jira/issues', anchor: 'view-jira-issues'),
markdown_help_path: help_page_path('user/markdown'),
diff --git a/spec/helpers/jira_connect_helper_spec.rb b/spec/helpers/jira_connect_helper_spec.rb
index 1c1b2a22b7c..169a5c0076a 100644
--- a/spec/helpers/jira_connect_helper_spec.rb
+++ b/spec/helpers/jira_connect_helper_spec.rb
@@ -23,6 +23,7 @@ RSpec.describe JiraConnectHelper do
it 'includes Jira Connect app attributes' do
is_expected.to include(
:groups_path,
+ :add_subscriptions_path,
:subscriptions_path,
:users_path,
:subscriptions,
diff --git a/spec/helpers/lazy_image_tag_helper_spec.rb b/spec/helpers/lazy_image_tag_helper_spec.rb
new file mode 100644
index 00000000000..2d9445bb6cb
--- /dev/null
+++ b/spec/helpers/lazy_image_tag_helper_spec.rb
@@ -0,0 +1,109 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe LazyImageTagHelper do
+ describe '#image_tag' do
+ let(:image_src) { '/path/to/image.jpg' }
+ let(:dark_image_src) { '/path/to/image_dark.jpg' }
+
+ context 'when only source passed' do
+ let(:current_user) { create(:user) }
+ let(:result) { image_tag(image_src) }
+
+ it 'returns a lazy image tag by default' do
+ expect(result).to eq(
+ "<img data-src=\"#{image_src}\" class=\"lazy\" src=\"#{placeholder_image}\" />"
+ )
+ end
+ end
+
+ context 'when lazy mode is disabled' do
+ let(:current_user) { create(:user) }
+ let(:result) { image_tag(image_src, lazy: false) }
+
+ it 'returns a normal image tag' do
+ expect(result).to eq(
+ "<img src=\"#{image_src}\" />"
+ )
+ end
+ end
+
+ context 'when Dark Mode is enabled' do
+ let(:current_user) { create(:user, theme_id: 11) }
+
+ context 'when auto dark enabled' do
+ let(:result) { image_tag(image_src, auto_dark: true) }
+
+ it 'adds an auto dark mode class from gitlab-ui' do
+ expect(result).to eq(
+ "<img class=\"gl-dark-invert-keep-hue lazy\" data-src=\"#{image_src}\" src=\"#{placeholder_image}\" />"
+ )
+ end
+ end
+
+ context 'when auto dark disabled' do
+ let(:result) { image_tag(image_src, auto_dark: false) }
+
+ it 'does nothing' do
+ expect(result).to eq(
+ "<img data-src=\"#{image_src}\" class=\"lazy\" src=\"#{placeholder_image}\" />"
+ )
+ end
+ end
+
+ context 'when dark variant is present' do
+ let(:result) { image_tag(image_src, dark_variant: dark_image_src) }
+
+ it 'uses dark variant as a source' do
+ expect(result).to eq(
+ "<img data-src=\"#{dark_image_src}\" class=\"lazy\" src=\"#{placeholder_image}\" />"
+ )
+ end
+ end
+ end
+
+ context 'when Dark Mode is disabled' do
+ let(:current_user) { create(:user, theme_id: 1) }
+
+ context 'when auto dark enabled' do
+ let(:result) { image_tag(image_src, auto_dark: true) }
+
+ it 'does not add a dark mode class from gitlab-ui' do
+ expect(result).to eq(
+ "<img data-src=\"#{image_src}\" class=\"lazy\" src=\"#{placeholder_image}\" />"
+ )
+ end
+ end
+
+ context 'when auto dark disabled' do
+ let(:result) { image_tag(image_src, auto_dark: true) }
+
+ it 'does nothing' do
+ expect(result).to eq(
+ "<img data-src=\"#{image_src}\" class=\"lazy\" src=\"#{placeholder_image}\" />"
+ )
+ end
+ end
+
+ context 'when dark variant is present' do
+ let(:result) { image_tag(image_src, dark_variant: dark_image_src) }
+
+ it 'uses original image as a source' do
+ expect(result).to eq(
+ "<img data-src=\"#{image_src}\" class=\"lazy\" src=\"#{placeholder_image}\" />"
+ )
+ end
+ end
+ end
+
+ context 'when auto_dark and dark_variant are both passed' do
+ let(:current_user) { create(:user) }
+
+ it 'does not add a dark mode class from gitlab-ui' do
+ expect { image_tag('image.jpg', dark_variant: 'image_dark.jpg', auto_dark: true) }
+ .to raise_error(ArgumentError, 'dark_variant and auto_dark are mutually exclusive')
+ end
+ end
+ end
+end
diff --git a/spec/helpers/merge_requests_helper_spec.rb b/spec/helpers/merge_requests_helper_spec.rb
index 38f2efd75a8..97ad55d9df9 100644
--- a/spec/helpers/merge_requests_helper_spec.rb
+++ b/spec/helpers/merge_requests_helper_spec.rb
@@ -5,31 +5,6 @@ require 'spec_helper'
RSpec.describe MergeRequestsHelper do
include ProjectForksHelper
- describe '#state_name_with_icon' do
- using RSpec::Parameterized::TableSyntax
-
- let(:merge_request) { MergeRequest.new }
-
- where(:state, :expected_name, :expected_icon) do
- :merged? | 'Merged' | 'git-merge'
- :closed? | 'Closed' | 'close'
- :opened? | 'Open' | 'issue-open-m'
- end
-
- with_them do
- before do
- allow(merge_request).to receive(state).and_return(true)
- end
-
- it 'returns name and icon' do
- name, icon = helper.state_name_with_icon(merge_request)
-
- expect(name).to eq(expected_name)
- expect(icon).to eq(expected_icon)
- end
- end
- end
-
describe '#format_mr_branch_names' do
describe 'within the same project' do
let(:merge_request) { create(:merge_request) }
@@ -84,7 +59,7 @@ RSpec.describe MergeRequestsHelper do
describe 'mr_attention_requests disabled' do
before do
- stub_feature_flags(mr_attention_requests: false)
+ allow(user).to receive(:mr_attention_requests_enabled?).and_return(false)
end
it "returns assigned, review requested and total merge request counts" do
@@ -97,6 +72,10 @@ RSpec.describe MergeRequestsHelper do
end
describe 'mr_attention_requests enabled' do
+ before do
+ allow(user).to receive(:mr_attention_requests_enabled?).and_return(true)
+ end
+
it "returns assigned, review requested, attention requests and total merge request counts" do
expect(subject).to eq(
assigned: user.assigned_open_merge_requests_count,
diff --git a/spec/helpers/namespaces_helper_spec.rb b/spec/helpers/namespaces_helper_spec.rb
index 52c1130e818..39f0e1c15f5 100644
--- a/spec/helpers/namespaces_helper_spec.rb
+++ b/spec/helpers/namespaces_helper_spec.rb
@@ -269,12 +269,13 @@ RSpec.describe NamespacesHelper do
end
end
- describe '#pipeline_usage_quota_app_data' do
+ describe '#pipeline_usage_app_data' do
it 'returns a hash with necessary data for the frontend' do
- expect(helper.pipeline_usage_quota_app_data(user_group)).to eql({
+ expect(helper.pipeline_usage_app_data(user_group)).to eql({
namespace_actual_plan_name: user_group.actual_plan_name,
namespace_path: user_group.full_path,
namespace_id: user_group.id,
+ user_namespace: user_group.user_namespace?.to_s,
page_size: Kaminari.config.default_per_page
})
end
diff --git a/spec/helpers/page_layout_helper_spec.rb b/spec/helpers/page_layout_helper_spec.rb
index d261fb43bb6..d0d399ad10f 100644
--- a/spec/helpers/page_layout_helper_spec.rb
+++ b/spec/helpers/page_layout_helper_spec.rb
@@ -52,7 +52,7 @@ RSpec.describe PageLayoutHelper do
describe 'page_image' do
it 'defaults to the GitLab logo' do
- expect(helper.page_image).to match_asset_path 'assets/gitlab_logo.png'
+ expect(helper.page_image).to match_asset_path 'assets/twitter_card.jpg'
end
%w(project user group).each do |type|
@@ -72,14 +72,14 @@ RSpec.describe PageLayoutHelper do
let(:trait) { nil }
it 'falls back to the default when avatar_url is nil' do
- expect(helper.page_image).to match_asset_path 'assets/gitlab_logo.png'
+ expect(helper.page_image).to match_asset_path 'assets/twitter_card.jpg'
end
end
end
context "with no assignments" do
it 'falls back to the default' do
- expect(helper.page_image).to match_asset_path 'assets/gitlab_logo.png'
+ expect(helper.page_image).to match_asset_path 'assets/twitter_card.jpg'
end
end
end
diff --git a/spec/helpers/profiles_helper_spec.rb b/spec/helpers/profiles_helper_spec.rb
index c3a3c2a0178..399726263db 100644
--- a/spec/helpers/profiles_helper_spec.rb
+++ b/spec/helpers/profiles_helper_spec.rb
@@ -111,7 +111,6 @@ RSpec.describe ProfilesHelper do
where(:error, :expired, :result) do
false | false | nil
true | false | error_message
- false | true | 'Key usable beyond expiration date.'
true | true | error_message
end
@@ -130,13 +129,9 @@ RSpec.describe ProfilesHelper do
end
describe "#ssh_key_expires_field_description" do
- before do
- allow(Key).to receive(:enforce_ssh_key_expiration_feature_available?).and_return(false)
- end
+ subject { helper.ssh_key_expires_field_description }
- it 'returns the description' do
- expect(helper.ssh_key_expires_field_description).to eq('Key can still be used after expiration.')
- end
+ it { is_expected.to eq('Key becomes invalid on this date.') }
end
describe '#middle_dot_divider_classes' do
diff --git a/spec/helpers/projects/pipeline_helper_spec.rb b/spec/helpers/projects/pipeline_helper_spec.rb
index 67405ee3b21..90cf3cb03f8 100644
--- a/spec/helpers/projects/pipeline_helper_spec.rb
+++ b/spec/helpers/projects/pipeline_helper_spec.rb
@@ -16,6 +16,7 @@ RSpec.describe Projects::PipelineHelper do
can_generate_codequality_reports: pipeline.can_generate_codequality_reports?.to_json,
graphql_resource_etag: graphql_etag_pipeline_path(pipeline),
metrics_path: namespace_project_ci_prometheus_metrics_histograms_path(namespace_id: project.namespace, project_id: project, format: :json),
+ pipeline_iid: pipeline.iid,
pipeline_project_path: project.full_path
})
end
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb
index 1cf36fd69cf..d13c5dfcc9e 100644
--- a/spec/helpers/projects_helper_spec.rb
+++ b/spec/helpers/projects_helper_spec.rb
@@ -279,7 +279,7 @@ RSpec.describe ProjectsHelper do
it 'returns message prompting user to set password or set up a PAT' do
stub_application_setting(password_authentication_enabled_for_git?: true)
- expect(helper.no_password_message).to eq('Your account is authenticated with SSO or SAML. To <a href="/help/gitlab-basics/start-using-git#pull-and-push" target="_blank" rel="noopener noreferrer">push and pull</a> over HTTP with Git using this account, you must <a href="/-/profile/password/edit">set a password</a> or <a href="/-/profile/personal_access_tokens">set up a Personal Access Token</a> to use instead of a password. For more information, see <a href="/help/gitlab-basics/start-using-git#clone-with-https" target="_blank" rel="noopener noreferrer">Clone with HTTPS</a>.')
+ expect(helper.no_password_message).to eq('Your account is authenticated with SSO or SAML. To <a href="/help/topics/git/terminology#pull-and-push" target="_blank" rel="noopener noreferrer">push and pull</a> over HTTP with Git using this account, you must <a href="/-/profile/password/edit">set a password</a> or <a href="/-/profile/personal_access_tokens">set up a Personal Access Token</a> to use instead of a password. For more information, see <a href="/help/gitlab-basics/start-using-git#clone-with-https" target="_blank" rel="noopener noreferrer">Clone with HTTPS</a>.')
end
end
@@ -287,7 +287,7 @@ RSpec.describe ProjectsHelper do
it 'returns message prompting user to set up a PAT' do
stub_application_setting(password_authentication_enabled_for_git?: false)
- expect(helper.no_password_message).to eq('Your account is authenticated with SSO or SAML. To <a href="/help/gitlab-basics/start-using-git#pull-and-push" target="_blank" rel="noopener noreferrer">push and pull</a> over HTTP with Git using this account, you must <a href="/-/profile/personal_access_tokens">set up a Personal Access Token</a> to use instead of a password. For more information, see <a href="/help/gitlab-basics/start-using-git#clone-with-https" target="_blank" rel="noopener noreferrer">Clone with HTTPS</a>.')
+ expect(helper.no_password_message).to eq('Your account is authenticated with SSO or SAML. To <a href="/help/topics/git/terminology#pull-and-push" target="_blank" rel="noopener noreferrer">push and pull</a> over HTTP with Git using this account, you must <a href="/-/profile/personal_access_tokens">set up a Personal Access Token</a> to use instead of a password. For more information, see <a href="/help/gitlab-basics/start-using-git#clone-with-https" target="_blank" rel="noopener noreferrer">Clone with HTTPS</a>.')
end
end
end
diff --git a/spec/helpers/releases_helper_spec.rb b/spec/helpers/releases_helper_spec.rb
index 69f66dc6488..b7493e84c6a 100644
--- a/spec/helpers/releases_helper_spec.rb
+++ b/spec/helpers/releases_helper_spec.rb
@@ -9,9 +9,9 @@ RSpec.describe ReleasesHelper do
end
end
- describe '#help_page' do
+ describe '#releases_help_page_path' do
it 'returns the correct link to the help page' do
- expect(helper.help_page).to include('user/project/releases/index')
+ expect(helper.releases_help_page_path).to include('user/project/releases/index')
end
end
@@ -63,7 +63,8 @@ RSpec.describe ReleasesHelper do
releases_page_path
release_assets_docs_path
manage_milestones_path
- new_milestone_path)
+ new_milestone_path
+ edit_release_docs_path)
expect(helper.data_for_edit_release_page.keys).to match_array(keys)
end
@@ -81,7 +82,8 @@ RSpec.describe ReleasesHelper do
release_assets_docs_path
manage_milestones_path
new_milestone_path
- default_branch)
+ default_branch
+ edit_release_docs_path)
expect(helper.data_for_new_release_page.keys).to match_array(keys)
end
diff --git a/spec/helpers/search_helper_spec.rb b/spec/helpers/search_helper_spec.rb
index d1be451a759..8e2ec014383 100644
--- a/spec/helpers/search_helper_spec.rb
+++ b/spec/helpers/search_helper_spec.rb
@@ -328,7 +328,6 @@ RSpec.describe SearchHelper do
end
it 'includes project endpoints' do
- expect(search_filter_input_options('')[:data]['runner-tags-endpoint']).to eq(tag_list_admin_runners_path)
expect(search_filter_input_options('')[:data]['labels-endpoint']).to eq(project_labels_path(@project))
expect(search_filter_input_options('')[:data]['milestones-endpoint']).to eq(project_milestones_path(@project))
expect(search_filter_input_options('')[:data]['releases-endpoint']).to eq(project_releases_path(@project))
@@ -349,7 +348,6 @@ RSpec.describe SearchHelper do
end
it 'includes group endpoints' do
- expect(search_filter_input_options('')[:data]['runner-tags-endpoint']).to eq(tag_list_admin_runners_path)
expect(search_filter_input_options('')[:data]['labels-endpoint']).to eq(group_labels_path(@group))
expect(search_filter_input_options('')[:data]['milestones-endpoint']).to eq(group_milestones_path(@group))
end
@@ -362,7 +360,6 @@ RSpec.describe SearchHelper do
end
it 'includes dashboard endpoints' do
- expect(search_filter_input_options('')[:data]['runner-tags-endpoint']).to eq(tag_list_admin_runners_path)
expect(search_filter_input_options('')[:data]['labels-endpoint']).to eq(dashboard_labels_path)
expect(search_filter_input_options('')[:data]['milestones-endpoint']).to eq(dashboard_milestones_path)
end
diff --git a/spec/helpers/sidebars_helper_spec.rb b/spec/helpers/sidebars_helper_spec.rb
index e329968e6c0..6db955f3637 100644
--- a/spec/helpers/sidebars_helper_spec.rb
+++ b/spec/helpers/sidebars_helper_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe SidebarsHelper do
subject { helper.sidebar_tracking_attributes_by_object(object) }
before do
- allow(helper).to receive(:tracking_enabled?).and_return(true)
+ stub_application_setting(snowplow_enabled: true)
end
context 'when object is a project' do
diff --git a/spec/helpers/storage_helper_spec.rb b/spec/helpers/storage_helper_spec.rb
index 6b743422b04..5bc4024ae24 100644
--- a/spec/helpers/storage_helper_spec.rb
+++ b/spec/helpers/storage_helper_spec.rb
@@ -88,14 +88,26 @@ RSpec.describe StorageHelper do
expect(helper.storage_enforcement_banner_info(free_group)).to be(nil)
end
- it 'returns a hash when current_user can access usage quotas page' do
- expect(helper.storage_enforcement_banner_info(free_group)).to eql({
- text: "From #{storage_enforcement_date} storage limits will apply to this namespace. View and manage your usage in <strong>Group settings &gt; Usage quotas</strong>.",
- variant: 'warning',
- callouts_feature_name: 'storage_enforcement_banner_second_enforcement_threshold',
- callouts_path: '/-/users/group_callouts',
- learn_more_link: '<a rel="noopener noreferrer" target="_blank" href="/help//">Learn more.</a>'
- })
+ context 'when current_user can access the usage quotas page' do
+ it 'returns a hash' do
+ expect(helper.storage_enforcement_banner_info(free_group)).to eql({
+ text: "From #{storage_enforcement_date} storage limits will apply to this namespace. You are currently using 0 Bytes of namespace storage. View and manage your usage from <strong>Group settings &gt; Usage quotas</strong>.",
+ variant: 'warning',
+ callouts_feature_name: 'storage_enforcement_banner_second_enforcement_threshold',
+ callouts_path: '/-/users/group_callouts',
+ learn_more_link: '<a rel="noopener noreferrer" target="_blank" href="/help//">Learn more.</a>'
+ })
+ end
+
+ context 'when namespace has used storage' do
+ before do
+ create(:namespace_root_storage_statistics, namespace: free_group, storage_size: 102400)
+ end
+
+ it 'returns a hash with the correct storage size text' do
+ expect(helper.storage_enforcement_banner_info(free_group)[:text]).to eql("From #{storage_enforcement_date} storage limits will apply to this namespace. You are currently using 100 KB of namespace storage. View and manage your usage from <strong>Group settings &gt; Usage quotas</strong>.")
+ end
+ end
end
end
diff --git a/spec/helpers/tracking_helper_spec.rb b/spec/helpers/tracking_helper_spec.rb
index cd2f8f9b7d1..81121275c92 100644
--- a/spec/helpers/tracking_helper_spec.rb
+++ b/spec/helpers/tracking_helper_spec.rb
@@ -7,29 +7,24 @@ RSpec.describe TrackingHelper do
using RSpec::Parameterized::TableSyntax
let(:input) { %w(a b c) }
- let(:results) do
- {
- no_data: {},
- with_data: { data: { track_label: 'a', track_action: 'b', track_property: 'c' } }
- }
+ let(:result) { { data: { track_label: 'a', track_action: 'b', track_property: 'c' } } }
+
+ before do
+ stub_application_setting(snowplow_enabled: true)
end
- where(:snowplow_enabled, :environment, :result) do
- true | 'production' | :with_data
- false | 'production' | :no_data
- true | 'development' | :no_data
- false | 'development' | :no_data
- true | 'test' | :no_data
- false | 'test' | :no_data
+ it 'returns no data if snowplow is disabled' do
+ stub_application_setting(snowplow_enabled: false)
+
+ expect(helper.tracking_attrs(*input)).to eq({})
end
- with_them do
- it 'returns a hash' do
- stub_application_setting(snowplow_enabled: snowplow_enabled)
- allow(Rails).to receive(:env).and_return(environment.inquiry)
+ it 'returns data hash' do
+ expect(helper.tracking_attrs(*input)).to eq(result)
+ end
- expect(helper.tracking_attrs(*input)).to eq(results[result])
- end
+ it 'can return data directly' do
+ expect(helper.tracking_attrs_data(*input)).to eq(result[:data])
end
end
end
diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb
index 82f4ae596e1..88030299574 100644
--- a/spec/helpers/users_helper_spec.rb
+++ b/spec/helpers/users_helper_spec.rb
@@ -378,7 +378,7 @@ RSpec.describe UsersHelper do
it 'users matches the serialized json' do
entity = double
expect_next_instance_of(Admin::UserSerializer) do |instance|
- expect(instance).to receive(:represent).with([user], current_user: user).and_return(entity)
+ expect(instance).to receive(:represent).with([user], { current_user: user }).and_return(entity)
end
expect(entity).to receive(:to_json).and_return("{\"username\":\"admin\"}")
expect(data[:users]).to eq "{\"username\":\"admin\"}"