summaryrefslogtreecommitdiff
path: root/spec/helpers
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
committerRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
commit6438df3a1e0fb944485cebf07976160184697d72 (patch)
tree00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/helpers
parent42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff)
downloadgitlab-ce-6438df3a1e0fb944485cebf07976160184697d72.tar.gz
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/blob_helper_spec.rb11
-rw-r--r--spec/helpers/ci/pipelines_helper_spec.rb19
-rw-r--r--spec/helpers/ci/triggers_helper_spec.rb31
-rw-r--r--spec/helpers/commits_helper_spec.rb33
-rw-r--r--spec/helpers/dashboard_helper_spec.rb6
-rw-r--r--spec/helpers/graph_helper_spec.rb12
-rw-r--r--spec/helpers/groups/group_members_helper_spec.rb12
-rw-r--r--spec/helpers/invite_members_helper_spec.rb65
-rw-r--r--spec/helpers/jira_connect_helper_spec.rb15
-rw-r--r--spec/helpers/merge_requests_helper_spec.rb33
-rw-r--r--spec/helpers/projects/project_members_helper_spec.rb145
-rw-r--r--spec/helpers/projects_helper_spec.rb29
-rw-r--r--spec/helpers/services_helper_spec.rb50
-rw-r--r--spec/helpers/tree_helper_spec.rb3
-rw-r--r--spec/helpers/users_helper_spec.rb6
-rw-r--r--spec/helpers/visibility_level_helper_spec.rb38
16 files changed, 407 insertions, 101 deletions
diff --git a/spec/helpers/blob_helper_spec.rb b/spec/helpers/blob_helper_spec.rb
index 764c582e987..b584a906565 100644
--- a/spec/helpers/blob_helper_spec.rb
+++ b/spec/helpers/blob_helper_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe BlobHelper do
end
end
- describe "#edit_blob_link" do
+ describe "#edit_blob_button" do
let(:namespace) { create(:namespace, name: 'gitlab') }
let(:project) { create(:project, :repository, namespace: namespace) }
@@ -28,12 +28,13 @@ RSpec.describe BlobHelper do
allow(helper).to receive(:can_collaborate_with_project?).and_return(true)
end
- it 'verifies blob is text' do
+ it 'does not render edit button when blob is not text' do
expect(helper).not_to receive(:blob_text_viewable?)
- button = helper.edit_blob_button(project, 'refs/heads/master', 'README.md')
+ # RADME.md is not a valid file.
+ button = helper.edit_blob_button(project, 'refs/heads/master', 'RADME.md')
- expect(button).to start_with('<button')
+ expect(button).to eq(nil)
end
it 'uses the passed blob instead retrieve from repository' do
@@ -94,7 +95,7 @@ RSpec.describe BlobHelper do
context 'viewer related' do
include FakeBlobHelpers
- let(:project) { build(:project, lfs_enabled: true) }
+ let_it_be(:project) { create(:project, lfs_enabled: true) }
before do
allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
diff --git a/spec/helpers/ci/pipelines_helper_spec.rb b/spec/helpers/ci/pipelines_helper_spec.rb
index a96d6e7711f..94b5e707d73 100644
--- a/spec/helpers/ci/pipelines_helper_spec.rb
+++ b/spec/helpers/ci/pipelines_helper_spec.rb
@@ -52,4 +52,23 @@ RSpec.describe Ci::PipelinesHelper do
end
end
end
+
+ describe 'has_gitlab_ci?' do
+ using RSpec::Parameterized::TableSyntax
+
+ subject(:has_gitlab_ci?) { helper.has_gitlab_ci?(project) }
+
+ let(:project) { double(:project, has_ci?: has_ci?, builds_enabled?: builds_enabled?) }
+
+ where(:builds_enabled?, :has_ci?, :result) do
+ true | true | true
+ true | false | false
+ false | true | false
+ false | false | false
+ end
+
+ with_them do
+ it { expect(has_gitlab_ci?).to eq(result) }
+ end
+ end
end
diff --git a/spec/helpers/ci/triggers_helper_spec.rb b/spec/helpers/ci/triggers_helper_spec.rb
new file mode 100644
index 00000000000..5e43dbfdd5c
--- /dev/null
+++ b/spec/helpers/ci/triggers_helper_spec.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Ci::TriggersHelper do
+ let(:project_id) { 1 }
+
+ describe '.builds_trigger_url' do
+ subject { helper.builds_trigger_url(project_id, ref: ref) }
+
+ context 'with no ref' do
+ let(:ref) { nil }
+
+ specify { expect(subject).to eq "#{Settings.gitlab.url}/api/v4/projects/1/trigger/pipeline" }
+ end
+
+ context 'with ref' do
+ let(:ref) { 'master' }
+
+ specify { expect(subject).to eq "#{Settings.gitlab.url}/api/v4/projects/1/ref/master/trigger/pipeline" }
+ end
+ end
+
+ describe '.service_trigger_url' do
+ subject { helper.service_trigger_url(service) }
+
+ let(:service) { double(project_id: 1, to_param: 'param') }
+
+ specify { expect(subject).to eq "#{Settings.gitlab.url}/api/v4/projects/1/services/param/trigger" }
+ end
+end
diff --git a/spec/helpers/commits_helper_spec.rb b/spec/helpers/commits_helper_spec.rb
index cc318a21fc9..8a570bf9a90 100644
--- a/spec/helpers/commits_helper_spec.rb
+++ b/spec/helpers/commits_helper_spec.rb
@@ -3,6 +3,39 @@
require 'spec_helper'
RSpec.describe CommitsHelper do
+ describe '#revert_commit_link' do
+ context 'when current_user exists' do
+ before do
+ allow(helper).to receive(:current_user).and_return(double('User'))
+ allow(helper).to receive(:can_collaborate_with_project?).and_return(true)
+ end
+
+ it 'renders a div for Vue' do
+ result = helper.revert_commit_link('_commit_', '_path_', pajamas: true)
+
+ expect(result).to include('js-revert-commit-trigger')
+ end
+
+ it 'does not render a div for Vue' do
+ result = helper.revert_commit_link('_commit_', '_path_')
+
+ expect(result).not_to include('js-revert-commit-trigger')
+ end
+ end
+
+ context 'when current_user does not exist' do
+ before do
+ allow(helper).to receive(:current_user).and_return(nil)
+ end
+
+ it 'does not render anything' do
+ result = helper.revert_commit_link(double('Commit'), '_path_')
+
+ expect(result).to be_nil
+ end
+ end
+ end
+
describe 'commit_author_link' do
it 'escapes the author email' do
commit = double(
diff --git a/spec/helpers/dashboard_helper_spec.rb b/spec/helpers/dashboard_helper_spec.rb
index 65182dcb729..8a76771be0a 100644
--- a/spec/helpers/dashboard_helper_spec.rb
+++ b/spec/helpers/dashboard_helper_spec.rb
@@ -89,4 +89,10 @@ RSpec.describe DashboardHelper do
it { is_expected.to eq(false) }
end
+
+ describe '#reviewer_mrs_dashboard_path' do
+ subject { helper.reviewer_mrs_dashboard_path }
+
+ it { is_expected.to eq(merge_requests_dashboard_path(reviewer_username: user.username)) }
+ end
end
diff --git a/spec/helpers/graph_helper_spec.rb b/spec/helpers/graph_helper_spec.rb
index 3c7e4f970c3..682f6365481 100644
--- a/spec/helpers/graph_helper_spec.rb
+++ b/spec/helpers/graph_helper_spec.rb
@@ -15,4 +15,16 @@ RSpec.describe GraphHelper do
expect(refs).to match('master')
end
end
+
+ describe '#should_render_deployment_frequency_charts' do
+ let(:project) { create(:project, :private) }
+
+ before do
+ self.instance_variable_set(:@project, project)
+ end
+
+ it 'always returns false' do
+ expect(should_render_deployment_frequency_charts).to be(false)
+ end
+ end
end
diff --git a/spec/helpers/groups/group_members_helper_spec.rb b/spec/helpers/groups/group_members_helper_spec.rb
index 222cca43860..d75124b6da7 100644
--- a/spec/helpers/groups/group_members_helper_spec.rb
+++ b/spec/helpers/groups/group_members_helper_spec.rb
@@ -34,38 +34,38 @@ RSpec.describe Groups::GroupMembersHelper do
end
describe '#members_data_json' do
- shared_examples 'group_members.json' do
+ shared_examples 'members.json' do
it 'matches json schema' do
json = helper.members_data_json(group, present_members([group_member]))
- expect(json).to match_schema('group_members')
+ expect(json).to match_schema('members')
end
end
context 'for a group member' do
let(:group_member) { create(:group_member, group: group, created_by: current_user) }
- it_behaves_like 'group_members.json'
+ it_behaves_like 'members.json'
context 'with user status set' do
let(:user) { create(:user) }
let!(:status) { create(:user_status, user: user) }
let(:group_member) { create(:group_member, group: group, user: user, created_by: current_user) }
- it_behaves_like 'group_members.json'
+ it_behaves_like 'members.json'
end
end
context 'for an invited group member' do
let(:group_member) { create(:group_member, :invited, group: group, created_by: current_user) }
- it_behaves_like 'group_members.json'
+ it_behaves_like 'members.json'
end
context 'for an access request' do
let(:group_member) { create(:group_member, :access_request, group: group, created_by: current_user) }
- it_behaves_like 'group_members.json'
+ it_behaves_like 'members.json'
end
end
diff --git a/spec/helpers/invite_members_helper_spec.rb b/spec/helpers/invite_members_helper_spec.rb
index d75b3c9f2e3..914d0931476 100644
--- a/spec/helpers/invite_members_helper_spec.rb
+++ b/spec/helpers/invite_members_helper_spec.rb
@@ -114,4 +114,69 @@ RSpec.describe InviteMembersHelper do
end
end
end
+
+ describe '#dropdown_invite_members_link' do
+ shared_examples_for 'dropdown invite members link' do
+ let(:link_regex) do
+ /data-track-event="click_link".*data-track-property="_track_property_".*Invite members/
+ end
+
+ before do
+ allow(helper).to receive(:experiment_tracking_category_and_group) { '_track_property_' }
+ allow(helper).to receive(:tracking_label).with(owner)
+ allow(helper).to receive(:current_user) { owner }
+ end
+
+ it 'records the experiment' do
+ allow(helper).to receive(:experiment_enabled?)
+
+ helper.dropdown_invite_members_link(form_model)
+
+ expect(helper).to have_received(:experiment_tracking_category_and_group)
+ .with(:invite_members_new_dropdown, subject: owner)
+ end
+
+ context 'with experiment enabled' do
+ before do
+ allow(helper).to receive(:experiment_enabled?).with(:invite_members_new_dropdown) { true }
+ end
+
+ it 'returns link' do
+ link = helper.dropdown_invite_members_link(form_model)
+
+ expect(link).to match(link_regex)
+ expect(link).to include(link_href)
+ expect(link).to include('gl-emoji')
+ end
+ end
+
+ context 'with no experiment enabled' do
+ before do
+ allow(helper).to receive(:experiment_enabled?).with(:invite_members_new_dropdown) { false }
+ end
+
+ it 'returns link' do
+ link = helper.dropdown_invite_members_link(form_model)
+
+ expect(link).to match(link_regex)
+ expect(link).to include(link_href)
+ expect(link).not_to include('gl-emoji')
+ end
+ end
+ end
+
+ context 'with a project' do
+ let_it_be(:form_model) { project }
+ let(:link_href) { "href=\"#{project_project_members_path(form_model)}\"" }
+
+ it_behaves_like 'dropdown invite members link'
+ end
+
+ context 'with a group' do
+ let_it_be(:form_model) { create(:group) }
+ let(:link_href) { "href=\"#{group_group_members_path(form_model)}\"" }
+
+ it_behaves_like 'dropdown invite members link'
+ end
+ end
end
diff --git a/spec/helpers/jira_connect_helper_spec.rb b/spec/helpers/jira_connect_helper_spec.rb
new file mode 100644
index 00000000000..a99072527c8
--- /dev/null
+++ b/spec/helpers/jira_connect_helper_spec.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe JiraConnectHelper do
+ describe '#jira_connect_app_data' do
+ subject { helper.jira_connect_app_data }
+
+ it 'includes Jira Connect app attributes' do
+ is_expected.to include(
+ :groups_path
+ )
+ end
+ end
+end
diff --git a/spec/helpers/merge_requests_helper_spec.rb b/spec/helpers/merge_requests_helper_spec.rb
index 377e2c43a72..821faaab194 100644
--- a/spec/helpers/merge_requests_helper_spec.rb
+++ b/spec/helpers/merge_requests_helper_spec.rb
@@ -67,4 +67,37 @@ RSpec.describe MergeRequestsHelper do
end
end
end
+
+ describe '#user_merge_requests_counts' do
+ let(:user) do
+ double(
+ assigned_open_merge_requests_count: 1,
+ review_requested_open_merge_requests_count: 2
+ )
+ end
+
+ subject { helper.user_merge_requests_counts }
+
+ before do
+ allow(helper).to receive(:current_user).and_return(user)
+ end
+
+ it "returns assigned, review requested and total merge request counts" do
+ expect(subject).to eq(
+ assigned: user.assigned_open_merge_requests_count,
+ review_requested: user.review_requested_open_merge_requests_count,
+ total: user.assigned_open_merge_requests_count + user.review_requested_open_merge_requests_count
+ )
+ end
+
+ context 'when merge_request_reviewers is disabled' do
+ before do
+ stub_feature_flags(merge_request_reviewers: false)
+ end
+
+ it 'returns review_requested as 0' do
+ expect(subject[:review_requested]).to eq(0)
+ end
+ end
+ end
end
diff --git a/spec/helpers/projects/project_members_helper_spec.rb b/spec/helpers/projects/project_members_helper_spec.rb
new file mode 100644
index 00000000000..cc290367e34
--- /dev/null
+++ b/spec/helpers/projects/project_members_helper_spec.rb
@@ -0,0 +1,145 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Projects::ProjectMembersHelper do
+ let_it_be(:current_user) { create(:user) }
+ let_it_be(:project) { create(:project) }
+
+ let(:allow_admin_project) { nil }
+
+ before do
+ allow(helper).to receive(:current_user).and_return(current_user)
+ allow(helper).to receive(:can?).with(current_user, :admin_project_member, project).and_return(allow_admin_project)
+ end
+
+ shared_examples 'when `current_user` does not have `admin_project_member` permissions' do
+ let(:allow_admin_project) { false }
+
+ it { is_expected.to be(false) }
+ end
+
+ describe '#can_manage_project_members?' do
+ subject { helper.can_manage_project_members?(project) }
+
+ context 'when `current_user` has `admin_project_member` permissions' do
+ let(:allow_admin_project) { true }
+
+ it { is_expected.to be(true) }
+ end
+
+ include_examples 'when `current_user` does not have `admin_project_member` permissions'
+ end
+
+ describe '#show_groups?' do
+ subject { helper.show_groups?(project.project_group_links) }
+
+ context 'when group links exist' do
+ let!(:project_group_link) { create(:project_group_link, project: project) }
+
+ it { is_expected.to be(true) }
+ end
+
+ context 'when `search_groups` param is set' do
+ before do
+ allow(helper).to receive(:params).and_return({ search_groups: 'foo' })
+ end
+
+ it { is_expected.to be(true) }
+ end
+
+ context 'when `search_groups` param is not set and group links do not exist' do
+ it { is_expected.to be(false) }
+ end
+ end
+
+ describe '#show_invited_members?' do
+ subject { helper.show_invited_members?(project, project.project_members.invite) }
+
+ context 'when `current_user` has `admin_project_member` permissions' do
+ let(:allow_admin_project) { true }
+
+ context 'when invited members exist' do
+ let!(:invite) { create(:project_member, :invited, project: project) }
+
+ it { is_expected.to be(true) }
+ end
+
+ context 'when invited members do not exist' do
+ it { is_expected.to be(false) }
+ end
+ end
+
+ include_examples 'when `current_user` does not have `admin_project_member` permissions'
+ end
+
+ describe '#show_access_requests?' do
+ subject { helper.show_access_requests?(project, project.requesters) }
+
+ context 'when `current_user` has `admin_project_member` permissions' do
+ let(:allow_admin_project) { true }
+
+ context 'when access requests exist' do
+ let!(:access_request) { create(:project_member, :access_request, project: project) }
+
+ it { is_expected.to be(true) }
+ end
+
+ context 'when access requests do not exist' do
+ it { is_expected.to be(false) }
+ end
+ end
+
+ include_examples 'when `current_user` does not have `admin_project_member` permissions'
+ end
+
+ describe '#groups_tab_active?' do
+ subject { helper.groups_tab_active? }
+
+ context 'when `search_groups` param is set' do
+ before do
+ allow(helper).to receive(:params).and_return({ search_groups: 'foo' })
+ end
+
+ it { is_expected.to be(true) }
+ end
+
+ context 'when `search_groups` param is not set' do
+ it { is_expected.to be(false) }
+ end
+ end
+
+ describe '#current_user_is_group_owner?' do
+ let(:group) { create(:group) }
+
+ subject { helper.current_user_is_group_owner?(project2) }
+
+ describe "when current user is the owner of the project's parent group" do
+ let(:project2) { create(:project, namespace: group) }
+
+ before do
+ group.add_owner(current_user)
+ end
+
+ it { is_expected.to be(true) }
+ end
+
+ describe "when current user is not the owner of the project's parent group" do
+ let_it_be(:user) { create(:user) }
+ let(:project2) { create(:project, namespace: group) }
+
+ before do
+ group.add_owner(user)
+ end
+
+ it { is_expected.to be(false) }
+ end
+
+ describe "when project does not have a parent group" do
+ let(:user) { create(:user) }
+ let(:project2) { create(:project, namespace: user.namespace) }
+
+ it { is_expected.to be(false) }
+ end
+ end
+end
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb
index d28d5ecda1b..b920e2e5600 100644
--- a/spec/helpers/projects_helper_spec.rb
+++ b/spec/helpers/projects_helper_spec.rb
@@ -92,37 +92,11 @@ RSpec.describe ProjectsHelper do
expect(helper.can_change_visibility_level?(project, user)).to be_falsey
end
- it "returns true if there are permissions and it is not fork" do
+ it "returns true if there are permissions" do
allow(helper).to receive(:can?) { true }
expect(helper.can_change_visibility_level?(project, user)).to be_truthy
end
-
- it 'allows visibility level to be changed if the project is forked' do
- allow(helper).to receive(:can?).with(user, :change_visibility_level, project) { true }
- project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
- fork_project(project)
-
- expect(helper.can_change_visibility_level?(project, user)).to be_truthy
- end
-
- context "forks" do
- it "returns false if there are permissions and origin project is PRIVATE" do
- allow(helper).to receive(:can?) { true }
-
- project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
-
- expect(helper.can_change_visibility_level?(forked_project, user)).to be_falsey
- end
-
- it "returns true if there are permissions and origin project is INTERNAL" do
- allow(helper).to receive(:can?) { true }
-
- project.update!(visibility_level: Gitlab::VisibilityLevel::INTERNAL)
-
- expect(helper.can_change_visibility_level?(forked_project, user)).to be_truthy
- end
- end
end
describe '#can_disable_emails?' do
@@ -459,6 +433,7 @@ RSpec.describe ProjectsHelper do
context 'when project has external wiki' do
it 'includes external wiki tab' do
project.create_external_wiki_service(active: true, properties: { 'external_wiki_url' => 'https://gitlab.com' })
+ project.reload
is_expected.to include(:external_wiki)
end
diff --git a/spec/helpers/services_helper_spec.rb b/spec/helpers/services_helper_spec.rb
index 650642f8982..534f33d9b5a 100644
--- a/spec/helpers/services_helper_spec.rb
+++ b/spec/helpers/services_helper_spec.rb
@@ -25,6 +25,10 @@ RSpec.describe ServicesHelper do
:integration_level
)
end
+
+ specify do
+ expect(subject[:reset_path]).to eq(helper.scoped_reset_integration_path(integration))
+ end
end
end
@@ -47,52 +51,12 @@ RSpec.describe ServicesHelper do
is_expected.to eq(reset_group_settings_integration_path(group, integration))
end
end
- end
-
- describe '#reset_integration?' do
- let(:group) { nil }
-
- subject { helper.reset_integration?(integration, group: group) }
-
- context 'when integration is existing record' do
- let_it_be(:integration) { create(:jira_service) }
-
- context 'when `reset_integrations` is not enabled' do
- it 'returns false' do
- stub_feature_flags(reset_integrations: false)
-
- is_expected.to eq(false)
- end
- end
- context 'when `reset_integrations` is enabled' do
- it 'returns true' do
- stub_feature_flags(reset_integrations: true)
-
- is_expected.to eq(true)
- end
- end
-
- context 'when `reset_integrations` is enabled for a group' do
- let(:group) { build_stubbed(:group) }
-
- it 'returns true' do
- stub_feature_flags(reset_integrations: group)
-
- is_expected.to eq(true)
- end
- end
- end
-
- context 'when integration is a new record' do
+ context 'when a new integration is not persisted' do
let_it_be(:integration) { build(:jira_service) }
- context 'when `reset_integrations` is enabled' do
- it 'returns false' do
- stub_feature_flags(reset_integrations: true)
-
- is_expected.to eq(false)
- end
+ it 'returns an empty string' do
+ is_expected.to eq('')
end
end
end
diff --git a/spec/helpers/tree_helper_spec.rb b/spec/helpers/tree_helper_spec.rb
index 136ec07e73d..6cb9894e306 100644
--- a/spec/helpers/tree_helper_spec.rb
+++ b/spec/helpers/tree_helper_spec.rb
@@ -330,9 +330,8 @@ RSpec.describe TreeHelper do
end
end
- context 'gitpod feature is enabled' do
+ context 'gitpod settings is enabled' do
before do
- stub_feature_flags(gitpod: true)
allow(Gitlab::CurrentSettings)
.to receive(:gitpod_enabled)
.and_return(true)
diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb
index c92c6e6e78e..f0f09408249 100644
--- a/spec/helpers/users_helper_spec.rb
+++ b/spec/helpers/users_helper_spec.rb
@@ -337,10 +337,14 @@ RSpec.describe UsersHelper do
describe '#admin_users_data_attributes' do
subject(:data) { helper.admin_users_data_attributes([user]) }
+ before do
+ allow(helper).to receive(:current_user).and_return(user)
+ end
+
it 'users matches the serialized json' do
entity = double
expect_next_instance_of(Admin::UserSerializer) do |instance|
- expect(instance).to receive(:represent).with([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\"}"
diff --git a/spec/helpers/visibility_level_helper_spec.rb b/spec/helpers/visibility_level_helper_spec.rb
index 86b0693af92..10e0815918f 100644
--- a/spec/helpers/visibility_level_helper_spec.rb
+++ b/spec/helpers/visibility_level_helper_spec.rb
@@ -35,29 +35,33 @@ RSpec.describe VisibilityLevelHelper do
describe 'visibility_level_description' do
context 'used with a Project' do
- it 'delegates projects to #project_visibility_level_description' do
- expect(visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, project))
- .to match /project/i
+ let(:descriptions) do
+ [
+ visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, project),
+ visibility_level_description(Gitlab::VisibilityLevel::INTERNAL, project),
+ visibility_level_description(Gitlab::VisibilityLevel::PUBLIC, project)
+ ]
end
- end
- context 'used with a Group' do
- it 'delegates groups to #group_visibility_level_description' do
- expect(visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, group))
- .to match /group/i
+ it 'returns different project related descriptions depending on visibility level' do
+ expect(descriptions.uniq.size).to eq(descriptions.size)
+ expect(descriptions).to all match /project/i
end
end
- end
- describe "#project_visibility_level_description" do
- it "describes private projects" do
- expect(project_visibility_level_description(Gitlab::VisibilityLevel::PRIVATE))
- .to eq _('Project access must be granted explicitly to each user. If this project is part of a group, access will be granted to members of the group.')
- end
+ context 'used with a Group' do
+ let(:descriptions) do
+ [
+ visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, group),
+ visibility_level_description(Gitlab::VisibilityLevel::INTERNAL, group),
+ visibility_level_description(Gitlab::VisibilityLevel::PUBLIC, group)
+ ]
+ end
- it "describes public projects" do
- expect(project_visibility_level_description(Gitlab::VisibilityLevel::PUBLIC))
- .to eq _('The project can be accessed without any authentication.')
+ it 'returns different group related descriptions depending on visibility level' do
+ expect(descriptions.uniq.size).to eq(descriptions.size)
+ expect(descriptions).to all match /group/i
+ end
end
end