diff options
Diffstat (limited to 'spec/helpers')
63 files changed, 336 insertions, 33 deletions
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 2f481e237a7..e8c438e459b 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe ApplicationHelper do diff --git a/spec/helpers/auto_devops_helper_spec.rb b/spec/helpers/auto_devops_helper_spec.rb index e80388f9ea7..5d42a80aae3 100644 --- a/spec/helpers/auto_devops_helper_spec.rb +++ b/spec/helpers/auto_devops_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe AutoDevopsHelper do diff --git a/spec/helpers/avatars_helper_spec.rb b/spec/helpers/avatars_helper_spec.rb index 9330e75af11..77182a59c1c 100644 --- a/spec/helpers/avatars_helper_spec.rb +++ b/spec/helpers/avatars_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe AvatarsHelper do diff --git a/spec/helpers/award_emoji_helper_spec.rb b/spec/helpers/award_emoji_helper_spec.rb index 035960ed96e..2ee27bc5427 100644 --- a/spec/helpers/award_emoji_helper_spec.rb +++ b/spec/helpers/award_emoji_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe AwardEmojiHelper do diff --git a/spec/helpers/blame_helper_spec.rb b/spec/helpers/blame_helper_spec.rb index 722d21c566f..8b5de040508 100644 --- a/spec/helpers/blame_helper_spec.rb +++ b/spec/helpers/blame_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe BlameHelper do diff --git a/spec/helpers/blob_helper_spec.rb b/spec/helpers/blob_helper_spec.rb index 1f236429347..4996e27c2e6 100644 --- a/spec/helpers/blob_helper_spec.rb +++ b/spec/helpers/blob_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe BlobHelper do @@ -268,4 +270,32 @@ describe BlobHelper do end end end + + describe '#ide_fork_and_edit_path' do + let(:project) { create(:project) } + let(:current_user) { create(:user) } + let(:can_push_code) { true } + + before do + allow(helper).to receive(:current_user).and_return(current_user) + allow(helper).to receive(:can?).and_return(can_push_code) + end + + it 'returns path to fork the repo with a redirect param to the full IDE path' do + uri = URI(helper.ide_fork_and_edit_path(project, "master", "")) + params = CGI.unescape(uri.query) + + expect(uri.path).to eq("/#{project.namespace.path}/#{project.path}/-/forks") + expect(params).to include("continue[to]=/-/ide/project/#{project.namespace.path}/#{project.path}/edit/master") + expect(params).to include("namespace_key=#{current_user.namespace.id}") + end + + context 'when user is not logged in' do + let(:current_user) { nil } + + it 'returns nil' do + expect(helper.ide_fork_and_edit_path(project, "master", "")).to be_nil + end + end + end end diff --git a/spec/helpers/boards_helper_spec.rb b/spec/helpers/boards_helper_spec.rb index ad088398ce9..8a4446b7f59 100644 --- a/spec/helpers/boards_helper_spec.rb +++ b/spec/helpers/boards_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe BoardsHelper do diff --git a/spec/helpers/broadcast_messages_helper_spec.rb b/spec/helpers/broadcast_messages_helper_spec.rb index 9bec0f9f432..d0f0e6f1dd5 100644 --- a/spec/helpers/broadcast_messages_helper_spec.rb +++ b/spec/helpers/broadcast_messages_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe BroadcastMessagesHelper do diff --git a/spec/helpers/button_helper_spec.rb b/spec/helpers/button_helper_spec.rb index eebae1d7290..e918c34ffef 100644 --- a/spec/helpers/button_helper_spec.rb +++ b/spec/helpers/button_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe ButtonHelper do @@ -164,7 +166,7 @@ describe ButtonHelper do it 'shows copy to clipboard button with default configuration and no text set to copy' do expect(element.attr('class')).to eq('btn btn-clipboard btn-transparent') expect(element.attr('type')).to eq('button') - expect(element.attr('aria-label')).to eq('Copy to clipboard') + expect(element.attr('aria-label')).to eq('Copy') expect(element.attr('data-toggle')).to eq('tooltip') expect(element.attr('data-placement')).to eq('bottom') expect(element.attr('data-container')).to eq('body') diff --git a/spec/helpers/calendar_helper_spec.rb b/spec/helpers/calendar_helper_spec.rb index 828a9d9fea0..8dba6815e8d 100644 --- a/spec/helpers/calendar_helper_spec.rb +++ b/spec/helpers/calendar_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe CalendarHelper do diff --git a/spec/helpers/ci_status_helper_spec.rb b/spec/helpers/ci_status_helper_spec.rb index 4f665dc0514..80be119b069 100644 --- a/spec/helpers/ci_status_helper_spec.rb +++ b/spec/helpers/ci_status_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe CiStatusHelper do diff --git a/spec/helpers/commits_helper_spec.rb b/spec/helpers/commits_helper_spec.rb index 9e53bc05a48..cbc5566979b 100644 --- a/spec/helpers/commits_helper_spec.rb +++ b/spec/helpers/commits_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe CommitsHelper do diff --git a/spec/helpers/components_helper_spec.rb b/spec/helpers/components_helper_spec.rb index 94a59193be8..703bee0ca92 100644 --- a/spec/helpers/components_helper_spec.rb +++ b/spec/helpers/components_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe ComponentsHelper do diff --git a/spec/helpers/dashboard_helper_spec.rb b/spec/helpers/dashboard_helper_spec.rb index 059ae128d93..c899c2d9853 100644 --- a/spec/helpers/dashboard_helper_spec.rb +++ b/spec/helpers/dashboard_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe DashboardHelper do diff --git a/spec/helpers/defer_script_tag_helper_spec.rb b/spec/helpers/defer_script_tag_helper_spec.rb index 9ada3ae75ba..440904188ca 100644 --- a/spec/helpers/defer_script_tag_helper_spec.rb +++ b/spec/helpers/defer_script_tag_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe DeferScriptTagHelper do diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb index 5396243f44d..47c076e3322 100644 --- a/spec/helpers/diff_helper_spec.rb +++ b/spec/helpers/diff_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe DiffHelper do diff --git a/spec/helpers/emails_helper_spec.rb b/spec/helpers/emails_helper_spec.rb index a14ae2cde4b..931b7008173 100644 --- a/spec/helpers/emails_helper_spec.rb +++ b/spec/helpers/emails_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe EmailsHelper do diff --git a/spec/helpers/environment_helper_spec.rb b/spec/helpers/environment_helper_spec.rb new file mode 100644 index 00000000000..53953d72b06 --- /dev/null +++ b/spec/helpers/environment_helper_spec.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe EnvironmentHelper do + describe '#render_deployment_status' do + context 'when using a manual deployment' do + it 'renders a span tag' do + deploy = build(:deployment, deployable: nil, status: :success) + html = helper.render_deployment_status(deploy) + + expect(html).to have_css('span.ci-status.ci-success') + end + end + + context 'when using a deployment from a build' do + it 'renders a link tag' do + deploy = build(:deployment, status: :success) + html = helper.render_deployment_status(deploy) + + expect(html).to have_css('a.ci-status.ci-success') + end + end + end +end diff --git a/spec/helpers/events_helper_spec.rb b/spec/helpers/events_helper_spec.rb index e062c841717..7853617c3ed 100644 --- a/spec/helpers/events_helper_spec.rb +++ b/spec/helpers/events_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe EventsHelper do diff --git a/spec/helpers/explore_helper_spec.rb b/spec/helpers/explore_helper_spec.rb index 12651d80e36..5208d3bd656 100644 --- a/spec/helpers/explore_helper_spec.rb +++ b/spec/helpers/explore_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe ExploreHelper do diff --git a/spec/helpers/form_helper_spec.rb b/spec/helpers/form_helper_spec.rb index a70d8333f30..68aa0137cd5 100644 --- a/spec/helpers/form_helper_spec.rb +++ b/spec/helpers/form_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe FormHelper do diff --git a/spec/helpers/git_helper_spec.rb b/spec/helpers/git_helper_spec.rb index 9b1ef1e05a2..505d6ed15ac 100644 --- a/spec/helpers/git_helper_spec.rb +++ b/spec/helpers/git_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe GitHelper do diff --git a/spec/helpers/gitlab_routing_helper_spec.rb b/spec/helpers/gitlab_routing_helper_spec.rb index 027480143bd..bf043f3f013 100644 --- a/spec/helpers/gitlab_routing_helper_spec.rb +++ b/spec/helpers/gitlab_routing_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe GitlabRoutingHelper do diff --git a/spec/helpers/graph_helper_spec.rb b/spec/helpers/graph_helper_spec.rb index 1f8a38dc697..dc389c09e60 100644 --- a/spec/helpers/graph_helper_spec.rb +++ b/spec/helpers/graph_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe GraphHelper do diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb index 98719697cea..8b33277ea18 100644 --- a/spec/helpers/groups_helper_spec.rb +++ b/spec/helpers/groups_helper_spec.rb @@ -191,6 +191,41 @@ describe GroupsHelper do end end + describe '#group_container_registry_nav' do + let(:group) { create(:group, :public) } + let(:user) { create(:user) } + before do + stub_container_registry_config(enabled: true) + allow(helper).to receive(:current_user) { user } + allow(helper).to receive(:can?).with(user, :read_container_image, group) { true } + helper.instance_variable_set(:@group, group) + end + + subject { helper.group_container_registry_nav? } + + context 'when container registry is enabled' do + it { is_expected.to be_truthy } + + it 'is disabled for guest' do + allow(helper).to receive(:can?).with(user, :read_container_image, group) { false } + expect(subject).to be false + end + end + + context 'when container registry is not enabled' do + before do + stub_container_registry_config(enabled: false) + end + + it { is_expected.to be_falsy } + + it 'is disabled for guests' do + allow(helper).to receive(:can?).with(user, :read_container_image, group) { false } + expect(subject).to be false + end + end + end + describe '#group_sidebar_links' do let(:group) { create(:group, :public) } let(:user) { create(:user) } diff --git a/spec/helpers/hooks_helper_spec.rb b/spec/helpers/hooks_helper_spec.rb index 2e21f1134b1..4352089c1c0 100644 --- a/spec/helpers/hooks_helper_spec.rb +++ b/spec/helpers/hooks_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe HooksHelper do diff --git a/spec/helpers/icons_helper_spec.rb b/spec/helpers/icons_helper_spec.rb index 950f951e22e..f1b1d411e05 100644 --- a/spec/helpers/icons_helper_spec.rb +++ b/spec/helpers/icons_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe IconsHelper do diff --git a/spec/helpers/import_helper_spec.rb b/spec/helpers/import_helper_spec.rb index 8a1b1e859b1..a6b283e49dc 100644 --- a/spec/helpers/import_helper_spec.rb +++ b/spec/helpers/import_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe ImportHelper do diff --git a/spec/helpers/instance_configuration_helper_spec.rb b/spec/helpers/instance_configuration_helper_spec.rb index 5d716b9191d..31a6c7bc839 100644 --- a/spec/helpers/instance_configuration_helper_spec.rb +++ b/spec/helpers/instance_configuration_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe InstanceConfigurationHelper do diff --git a/spec/helpers/issuables_helper_spec.rb b/spec/helpers/issuables_helper_spec.rb index 3c8179460ac..2f67ea457a0 100644 --- a/spec/helpers/issuables_helper_spec.rb +++ b/spec/helpers/issuables_helper_spec.rb @@ -190,7 +190,6 @@ describe IssuablesHelper do issuableRef: "##{issue.iid}", markdownPreviewPath: "/#{@project.full_path}/preview_markdown", markdownDocsPath: '/help/user/markdown', - issuableTemplates: [], lockVersion: issue.lock_version, projectPath: @project.path, projectNamespace: @project.namespace.path, @@ -244,4 +243,32 @@ describe IssuablesHelper do end end end + + describe '#assignee_sidebar_data' do + let(:user) { create(:user) } + let(:merge_request) { nil } + subject { helper.assignee_sidebar_data(user, merge_request: merge_request) } + + it 'returns hash of assignee data' do + is_expected.to eql({ + avatar_url: user.avatar_url, + name: user.name, + username: user.username + }) + end + + context 'with merge_request' do + let(:merge_request) { build_stubbed(:merge_request) } + + where(can_merge: [true, false]) + + with_them do + before do + allow(merge_request).to receive(:can_be_merged_by?).and_return(can_merge) + end + + it { is_expected.to include({ can_merge: can_merge })} + end + end + end end diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb index d15b5a4ab58..a394812f8f0 100644 --- a/spec/helpers/issues_helper_spec.rb +++ b/spec/helpers/issues_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe IssuesHelper do diff --git a/spec/helpers/labels_helper_spec.rb b/spec/helpers/labels_helper_spec.rb index 1d57aaa0da5..a715390ecae 100644 --- a/spec/helpers/labels_helper_spec.rb +++ b/spec/helpers/labels_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe LabelsHelper do diff --git a/spec/helpers/markup_helper_spec.rb b/spec/helpers/markup_helper_spec.rb index f6e1720e113..364f215420a 100644 --- a/spec/helpers/markup_helper_spec.rb +++ b/spec/helpers/markup_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe MarkupHelper do @@ -408,12 +410,12 @@ describe MarkupHelper do it 'preserves a link href when link text is truncated' do text = 'The quick brown fox jumped over the lazy dog' # 44 chars - input = "#{text}#{text}#{text} " # 133 chars link_url = 'http://example.com/foo/bar/baz' # 30 chars - input << link_url - object = create_object(input) + input = "#{text}#{text}#{text} #{link_url}" # 163 chars expected_link_text = 'http://example...</a>' + object = create_object(input) + expect(first_line_in_markdown(object, attribute, 150, project: project)).to match(link_url) expect(first_line_in_markdown(object, attribute, 150, project: project)).to match(expected_link_text) end diff --git a/spec/helpers/members_helper_spec.rb b/spec/helpers/members_helper_spec.rb index 908e8960f37..169c8707bf4 100644 --- a/spec/helpers/members_helper_spec.rb +++ b/spec/helpers/members_helper_spec.rb @@ -1,13 +1,15 @@ +# frozen_string_literal: true + require 'spec_helper' describe MembersHelper do describe '#remove_member_message' do let(:requester) { create(:user) } - let(:project) { create(:project, :public, :access_requestable) } + let(:project) { create(:project, :public) } let(:project_member) { build(:project_member, project: project) } let(:project_member_invite) { build(:project_member, project: project).tap { |m| m.generate_invite_token! } } let(:project_member_request) { project.request_access(requester) } - let(:group) { create(:group, :access_requestable) } + let(:group) { create(:group) } let(:group_member) { build(:group_member, group: group) } let(:group_member_invite) { build(:group_member, group: group).tap { |m| m.generate_invite_token! } } let(:group_member_request) { group.request_access(requester) } @@ -24,10 +26,10 @@ describe MembersHelper do describe '#remove_member_title' do let(:requester) { create(:user) } - let(:project) { create(:project, :public, :access_requestable) } + let(:project) { create(:project, :public) } let(:project_member) { build(:project_member, project: project) } let(:project_member_request) { project.request_access(requester) } - let(:group) { create(:group, :access_requestable) } + let(:group) { create(:group) } let(:group_member) { build(:group_member, group: group) } let(:group_member_request) { group.request_access(requester) } diff --git a/spec/helpers/merge_requests_helper_spec.rb b/spec/helpers/merge_requests_helper_spec.rb index 193390d2f2c..695d1520897 100644 --- a/spec/helpers/merge_requests_helper_spec.rb +++ b/spec/helpers/merge_requests_helper_spec.rb @@ -39,6 +39,7 @@ describe MergeRequestsHelper do let(:forked_project) { fork_project(project) } let(:merge_request) { create(:merge_request, source_project: forked_project, target_project: project) } subject { format_mr_branch_names(merge_request) } + let(:source_title) { "#{forked_project.full_path}:#{merge_request.source_branch}" } let(:target_title) { "#{project.full_path}:#{merge_request.target_branch}" } diff --git a/spec/helpers/milestones_helper_spec.rb b/spec/helpers/milestones_helper_spec.rb index f5185cb2857..3574066e03e 100644 --- a/spec/helpers/milestones_helper_spec.rb +++ b/spec/helpers/milestones_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe MilestonesHelper do diff --git a/spec/helpers/milestones_routing_helper_spec.rb b/spec/helpers/milestones_routing_helper_spec.rb index dc13a43c2ab..4da589a5007 100644 --- a/spec/helpers/milestones_routing_helper_spec.rb +++ b/spec/helpers/milestones_routing_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe MilestonesRoutingHelper do diff --git a/spec/helpers/namespaces_helper_spec.rb b/spec/helpers/namespaces_helper_spec.rb index e38513f6d94..36465069311 100644 --- a/spec/helpers/namespaces_helper_spec.rb +++ b/spec/helpers/namespaces_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe NamespacesHelper do diff --git a/spec/helpers/nav_helper_spec.rb b/spec/helpers/nav_helper_spec.rb index 979d89812f5..882a125a0da 100644 --- a/spec/helpers/nav_helper_spec.rb +++ b/spec/helpers/nav_helper_spec.rb @@ -1,16 +1,22 @@ +# frozen_string_literal: true + require 'spec_helper' -describe NavHelper do +describe NavHelper, :do_not_mock_admin_mode do describe '#header_links' do + include_context 'custom session' + before do - allow(helper).to receive(:session) { {} } + allow(helper).to receive(:session).and_return(session) end context 'when the user is logged in' do - let(:user) { build(:user) } + let(:user) { create(:user) } + let(:current_user_mode) { Gitlab::Auth::CurrentUserMode.new(user) } before do allow(helper).to receive(:current_user).and_return(user) + allow(helper).to receive(:current_user_mode).and_return(current_user_mode) allow(helper).to receive(:can?) { true } end @@ -26,6 +32,46 @@ describe NavHelper do expect(helper.header_links).to include(:admin_impersonation) end + context 'as admin' do + let(:user) { create(:user, :admin) } + + context 'feature flag :user_mode_in_session is enabled' do + it 'does not contain the admin mode link by default' do + expect(helper.header_links).not_to include(:admin_mode) + end + + context 'with admin mode enabled' do + before do + current_user_mode.enable_admin_mode!(password: user.password) + end + + it 'contains the admin mode link' do + expect(helper.header_links).to include(:admin_mode) + end + end + end + + context 'feature flag :user_mode_in_session is disabled' do + before do + stub_feature_flags(user_mode_in_session: false) + end + + it 'does not contain the admin mode link' do + expect(helper.header_links).not_to include(:admin_mode) + end + + context 'with admin mode enabled' do + before do + current_user_mode.enable_admin_mode!(password: user.password) + end + + it 'has no effect on header links' do + expect(helper.header_links).not_to include(:admin_mode) + end + end + end + end + context 'when the user cannot read cross project' do before do allow(helper).to receive(:can?).with(user, :read_cross_project) { false } diff --git a/spec/helpers/notes_helper_spec.rb b/spec/helpers/notes_helper_spec.rb index 0715f34dafe..2da7717ebfc 100644 --- a/spec/helpers/notes_helper_spec.rb +++ b/spec/helpers/notes_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe NotesHelper do diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index 5717b15d656..2384c87b377 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe NotificationsHelper do diff --git a/spec/helpers/page_layout_helper_spec.rb b/spec/helpers/page_layout_helper_spec.rb index 3b08fc511a3..7e851a1af01 100644 --- a/spec/helpers/page_layout_helper_spec.rb +++ b/spec/helpers/page_layout_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe PageLayoutHelper do diff --git a/spec/helpers/pagination_helper_spec.rb b/spec/helpers/pagination_helper_spec.rb index e235475fb47..9fb51249edc 100644 --- a/spec/helpers/pagination_helper_spec.rb +++ b/spec/helpers/pagination_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe PaginationHelper do diff --git a/spec/helpers/preferences_helper_spec.rb b/spec/helpers/preferences_helper_spec.rb index 554c08add2d..c4ed99e56a0 100644 --- a/spec/helpers/preferences_helper_spec.rb +++ b/spec/helpers/preferences_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe PreferencesHelper do diff --git a/spec/helpers/profiles_helper_spec.rb b/spec/helpers/profiles_helper_spec.rb index da2dc229c35..fc282eee26d 100644 --- a/spec/helpers/profiles_helper_spec.rb +++ b/spec/helpers/profiles_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe ProfilesHelper do diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index d2a4ce6540d..1fa3c639603 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -902,4 +902,40 @@ describe ProjectsHelper do end end end + + describe '#grafana_integration_url' do + let(:project) { create(:project) } + + before do + helper.instance_variable_set(:@project, project) + end + + 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 + let(:project) { create(:project) } + + before do + helper.instance_variable_set(:@project, project) + end + + subject { helper.grafana_integration_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.token) } + end + end end diff --git a/spec/helpers/releases_helper_spec.rb b/spec/helpers/releases_helper_spec.rb index ff820b3cc95..3b4973677ef 100644 --- a/spec/helpers/releases_helper_spec.rb +++ b/spec/helpers/releases_helper_spec.rb @@ -22,23 +22,9 @@ describe ReleasesHelper do helper.instance_variable_set(:@project, project) end - describe '#url_for_merge_requests' do - it 'returns the the correct link with the correct parameters' do - path = "#{project.group.path}/#{project.path}/merge_requests?scope=all&state=opened" - expect(helper.url_for_merge_requests).to include(path) - end - end - - describe '#url_for_issues' do - it 'returns the the correct link with the correct parameters' do - path = "#{project.group.path}/#{project.path}/issues?scope=all&state=opened" - expect(helper.url_for_issues).to include(path) - end - end - describe '#data_for_releases_page' do it 'has the needed data to display release blocks' do - keys = %i(project_id illustration_path documentation_path merge_requests_url issues_url) + keys = %i(project_id illustration_path documentation_path) expect(helper.data_for_releases_page.keys).to eq(keys) end end diff --git a/spec/helpers/rss_helper_spec.rb b/spec/helpers/rss_helper_spec.rb index a7f9bdf07e4..657f5fb42bc 100644 --- a/spec/helpers/rss_helper_spec.rb +++ b/spec/helpers/rss_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe RssHelper do diff --git a/spec/helpers/runners_helper_spec.rb b/spec/helpers/runners_helper_spec.rb index bf00841fcb6..042714d002e 100644 --- a/spec/helpers/runners_helper_spec.rb +++ b/spec/helpers/runners_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe RunnersHelper do diff --git a/spec/helpers/search_helper_spec.rb b/spec/helpers/search_helper_spec.rb index e1dc589236b..9e9f87b3407 100644 --- a/spec/helpers/search_helper_spec.rb +++ b/spec/helpers/search_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe SearchHelper do @@ -103,19 +105,17 @@ describe SearchHelper do using RSpec::Parameterized::TableSyntax where(:scope, :label) do + 'blobs' | 'code result' 'commits' | 'commit' 'issues' | 'issue' 'merge_requests' | 'merge request' 'milestones' | 'milestone' + 'notes' | 'comment' 'projects' | 'project' + 'snippet_blobs' | 'snippet result' 'snippet_titles' | 'snippet' 'users' | 'user' - - 'blobs' | 'result' - 'snippet_blobs' | 'result' - 'wiki_blobs' | 'result' - - 'notes' | 'comment' + 'wiki_blobs' | 'wiki result' end with_them do @@ -140,6 +140,15 @@ describe SearchHelper do end end + describe 'search_entries_empty_message' do + it 'returns the formatted entry message' do + message = search_entries_empty_message('projects', '<h1>foo</h1>') + + expect(message).to eq("We couldn't find any projects matching <code><h1>foo</h1></code>") + expect(message).to be_html_safe + end + end + describe 'search_filter_input_options' do context 'project' do before do diff --git a/spec/helpers/sidekiq_helper_spec.rb b/spec/helpers/sidekiq_helper_spec.rb index 117abc9c556..86e52419f9c 100644 --- a/spec/helpers/sidekiq_helper_spec.rb +++ b/spec/helpers/sidekiq_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe SidekiqHelper do diff --git a/spec/helpers/snippets_helper_spec.rb b/spec/helpers/snippets_helper_spec.rb index ce5e037f88d..66c8d576a4c 100644 --- a/spec/helpers/snippets_helper_spec.rb +++ b/spec/helpers/snippets_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe SnippetsHelper do diff --git a/spec/helpers/storage_helper_spec.rb b/spec/helpers/storage_helper_spec.rb index 4bd0fbb76ca..577e6e5caf0 100644 --- a/spec/helpers/storage_helper_spec.rb +++ b/spec/helpers/storage_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe StorageHelper do diff --git a/spec/helpers/submodule_helper_spec.rb b/spec/helpers/submodule_helper_spec.rb index 465c76e5e6b..fcfce0eaf31 100644 --- a/spec/helpers/submodule_helper_spec.rb +++ b/spec/helpers/submodule_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe SubmoduleHelper do diff --git a/spec/helpers/tab_helper_spec.rb b/spec/helpers/tab_helper_spec.rb index 9abf63d4bd4..3a3935a2130 100644 --- a/spec/helpers/tab_helper_spec.rb +++ b/spec/helpers/tab_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe TabHelper do diff --git a/spec/helpers/time_helper_spec.rb b/spec/helpers/time_helper_spec.rb index 8bf378549fe..858d6d341f4 100644 --- a/spec/helpers/time_helper_spec.rb +++ b/spec/helpers/time_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe TimeHelper do diff --git a/spec/helpers/todos_helper_spec.rb b/spec/helpers/todos_helper_spec.rb index 63806ef91f3..7c73b990338 100644 --- a/spec/helpers/todos_helper_spec.rb +++ b/spec/helpers/todos_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe TodosHelper do diff --git a/spec/helpers/tree_helper_spec.rb b/spec/helpers/tree_helper_spec.rb index 4a62e696cd9..c7cdb4ae45c 100644 --- a/spec/helpers/tree_helper_spec.rb +++ b/spec/helpers/tree_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe TreeHelper do diff --git a/spec/helpers/user_callouts_helper_spec.rb b/spec/helpers/user_callouts_helper_spec.rb index 8fa479a4474..547bf693e94 100644 --- a/spec/helpers/user_callouts_helper_spec.rb +++ b/spec/helpers/user_callouts_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe UserCalloutsHelper do diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb index 9165e91ddcd..59abe8c09e1 100644 --- a/spec/helpers/users_helper_spec.rb +++ b/spec/helpers/users_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe UsersHelper do diff --git a/spec/helpers/version_check_helper_spec.rb b/spec/helpers/version_check_helper_spec.rb index edc0d64d031..421ff21bfdb 100644 --- a/spec/helpers/version_check_helper_spec.rb +++ b/spec/helpers/version_check_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe VersionCheckHelper do diff --git a/spec/helpers/visibility_level_helper_spec.rb b/spec/helpers/visibility_level_helper_spec.rb index 2d276696208..1a176cfe965 100644 --- a/spec/helpers/visibility_level_helper_spec.rb +++ b/spec/helpers/visibility_level_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe VisibilityLevelHelper do diff --git a/spec/helpers/wiki_helper_spec.rb b/spec/helpers/wiki_helper_spec.rb index ee977e37ec1..bcc2bd71da1 100644 --- a/spec/helpers/wiki_helper_spec.rb +++ b/spec/helpers/wiki_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe WikiHelper do |