diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /spec/helpers/groups_helper_spec.rb | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'spec/helpers/groups_helper_spec.rb')
-rw-r--r-- | spec/helpers/groups_helper_spec.rb | 134 |
1 files changed, 6 insertions, 128 deletions
diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb index 42da1cb71f1..825d5236b5d 100644 --- a/spec/helpers/groups_helper_spec.rb +++ b/spec/helpers/groups_helper_spec.rb @@ -19,18 +19,6 @@ RSpec.describe GroupsHelper do end end - describe '#group_dependency_proxy_image_prefix' do - let_it_be(:group) { build_stubbed(:group, path: 'GroupWithUPPERcaseLetters') } - - it 'converts uppercase letters to lowercase' do - expect(group_dependency_proxy_image_prefix(group)).to end_with("/groupwithuppercaseletters#{DependencyProxy::URL_SUFFIX}") - end - - it 'removes the protocol' do - expect(group_dependency_proxy_image_prefix(group)).not_to include('http') - end - end - describe '#group_lfs_status' do let_it_be_with_reload(:group) { create(:group) } let_it_be_with_reload(:project) { create(:project, namespace_id: group.id) } @@ -267,61 +255,6 @@ RSpec.describe GroupsHelper do end end - describe '#group_sidebar_links' do - let_it_be(:group) { create(:group, :public) } - let_it_be(:user) { create(:user) } - - before do - group.add_owner(user) - allow(helper).to receive(:current_user) { user } - allow(helper).to receive(:can?) { |*args| Ability.allowed?(*args) } - helper.instance_variable_set(:@group, group) - end - - it 'returns all the expected links' do - links = [ - :overview, :activity, :issues, :labels, :milestones, :merge_requests, - :runners, :group_members, :settings - ] - - expect(helper.group_sidebar_links).to include(*links) - end - - it 'excludes runners when the user cannot admin the group' do - expect(helper).to receive(:current_user) { user } - # TODO Proper policies, such as `read_group_runners, should be implemented per - # See https://gitlab.com/gitlab-org/gitlab/-/issues/334802 - expect(helper).to receive(:can?).twice.with(user, :admin_group, group) { false } - - expect(helper.group_sidebar_links).not_to include(:runners) - end - - it 'excludes runners when the feature "runner_list_group_view_vue_ui" is disabled' do - stub_feature_flags(runner_list_group_view_vue_ui: false) - - expect(helper.group_sidebar_links).not_to include(:runners) - end - - it 'excludes settings when the user can admin the group' do - expect(helper).to receive(:current_user) { user } - expect(helper).to receive(:can?).twice.with(user, :admin_group, group) { false } - - expect(helper.group_sidebar_links).not_to include(:settings) - end - - it 'excludes cross project features when the user cannot read cross project' do - cross_project_features = [:activity, :issues, :labels, :milestones, - :merge_requests] - - allow(Ability).to receive(:allowed?).and_call_original - cross_project_features.each do |feature| - expect(Ability).to receive(:allowed?).with(user, "read_group_#{feature}".to_sym, group) { false } - end - - expect(helper.group_sidebar_links).not_to include(*cross_project_features) - end - end - describe '#parent_group_options' do let_it_be(:current_user) { create(:user) } let_it_be(:group) { create(:group, name: 'group') } @@ -442,67 +375,6 @@ RSpec.describe GroupsHelper do end end - describe '#show_invite_banner?' do - let_it_be(:current_user) { create(:user) } - let_it_be_with_refind(:group) { create(:group) } - let_it_be(:subgroup) { create(:group, parent: group) } - let_it_be(:users) { [current_user, create(:user)] } - - before do - allow(helper).to receive(:current_user) { current_user } - allow(helper).to receive(:can?).with(current_user, :admin_group, group).and_return(can_admin_group) - allow(helper).to receive(:can?).with(current_user, :admin_group, subgroup).and_return(can_admin_group) - users.take(group_members_count).each { |user| group.add_guest(user) } - end - - using RSpec::Parameterized::TableSyntax - - where(:can_admin_group, :group_members_count, :expected_result) do - true | 1 | true - false | 1 | false - true | 2 | false - false | 2 | false - end - - with_them do - context 'for a parent group' do - subject { helper.show_invite_banner?(group) } - - context 'when the group was just created' do - before do - flash[:notice] = "Group #{group.name} was successfully created" - end - - it { is_expected.to be_falsey } - end - - context 'when no flash message' do - it 'returns the expected result' do - expect(subject).to eq(expected_result) - end - end - end - - context 'for a subgroup' do - subject { helper.show_invite_banner?(subgroup) } - - context 'when the subgroup was just created' do - before do - flash[:notice] = "Group #{subgroup.name} was successfully created" - end - - it { is_expected.to be_falsey } - end - - context 'when no flash message' do - it 'returns the expected result' do - expect(subject).to eq(expected_result) - end - end - end - end - end - describe '#render_setting_to_allow_project_access_token_creation?' do let_it_be(:current_user) { create(:user) } let_it_be(:parent) { create(:group) } @@ -541,4 +413,10 @@ RSpec.describe GroupsHelper do expect(helper.can_admin_group_member?(group)).to be(false) end end + + describe '#localized_jobs_to_be_done_choices' do + it 'has a translation for all `jobs_to_be_done` values' do + expect(localized_jobs_to_be_done_choices.keys).to match_array(NamespaceSetting.jobs_to_be_dones.keys) + end + end end |