From 6438df3a1e0fb944485cebf07976160184697d72 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 20 Jan 2021 13:34:23 -0600 Subject: Add latest changes from gitlab-org/gitlab@13-8-stable-ee --- spec/helpers/blob_helper_spec.rb | 11 +- spec/helpers/ci/pipelines_helper_spec.rb | 19 +++ spec/helpers/ci/triggers_helper_spec.rb | 31 +++++ spec/helpers/commits_helper_spec.rb | 33 +++++ spec/helpers/dashboard_helper_spec.rb | 6 + spec/helpers/graph_helper_spec.rb | 12 ++ spec/helpers/groups/group_members_helper_spec.rb | 12 +- spec/helpers/invite_members_helper_spec.rb | 65 +++++++++ spec/helpers/jira_connect_helper_spec.rb | 15 +++ spec/helpers/merge_requests_helper_spec.rb | 33 +++++ .../projects/project_members_helper_spec.rb | 145 +++++++++++++++++++++ spec/helpers/projects_helper_spec.rb | 29 +---- spec/helpers/services_helper_spec.rb | 50 +------ spec/helpers/tree_helper_spec.rb | 3 +- spec/helpers/users_helper_spec.rb | 6 +- spec/helpers/visibility_level_helper_spec.rb | 38 +++--- 16 files changed, 407 insertions(+), 101 deletions(-) create mode 100644 spec/helpers/ci/triggers_helper_spec.rb create mode 100644 spec/helpers/jira_connect_helper_spec.rb create mode 100644 spec/helpers/projects/project_members_helper_spec.rb (limited to 'spec/helpers') 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(' '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 -- cgit v1.2.3