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>2020-08-20 21:42:06 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 21:42:06 +0300
commit6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch)
tree78be5963ec075d80116a932011d695dd33910b4e /spec/helpers
parent1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff)
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/appearances_helper_spec.rb2
-rw-r--r--spec/helpers/application_helper_spec.rb36
-rw-r--r--spec/helpers/auto_devops_helper_spec.rb2
-rw-r--r--spec/helpers/award_emoji_helper_spec.rb4
-rw-r--r--spec/helpers/blame_helper_spec.rb2
-rw-r--r--spec/helpers/blob_helper_spec.rb110
-rw-r--r--spec/helpers/branches_helper_spec.rb32
-rw-r--r--spec/helpers/ci/pipelines_helper_spec.rb35
-rw-r--r--spec/helpers/ci/status_helper_spec.rb2
-rw-r--r--spec/helpers/environments_helper_spec.rb7
-rw-r--r--spec/helpers/events_helper_spec.rb2
-rw-r--r--spec/helpers/gitlab_routing_helper_spec.rb84
-rw-r--r--spec/helpers/groups_helper_spec.rb2
-rw-r--r--spec/helpers/icons_helper_spec.rb13
-rw-r--r--spec/helpers/issuables_helper_spec.rb2
-rw-r--r--spec/helpers/issues_helper_spec.rb8
-rw-r--r--spec/helpers/members_helper_spec.rb2
-rw-r--r--spec/helpers/namespace_storage_limit_alert_helper_spec.rb11
-rw-r--r--spec/helpers/namespaces_helper_spec.rb4
-rw-r--r--spec/helpers/notes_helper_spec.rb14
-rw-r--r--spec/helpers/notifications_helper_spec.rb1
-rw-r--r--spec/helpers/operations_helper_spec.rb2
-rw-r--r--spec/helpers/packages_helper_spec.rb88
-rw-r--r--spec/helpers/profiles_helper_spec.rb2
-rw-r--r--spec/helpers/projects/alert_management_helper_spec.rb5
-rw-r--r--spec/helpers/projects/incidents_helper_spec.rb27
-rw-r--r--spec/helpers/projects/issues/service_desk_helper_spec.rb53
-rw-r--r--spec/helpers/projects_helper_spec.rb8
-rw-r--r--spec/helpers/releases_helper_spec.rb1
-rw-r--r--spec/helpers/services_helper_spec.rb5
-rw-r--r--spec/helpers/snippets_helper_spec.rb57
-rw-r--r--spec/helpers/user_callouts_helper_spec.rb46
-rw-r--r--spec/helpers/visibility_level_helper_spec.rb7
-rw-r--r--spec/helpers/wiki_helper_spec.rb2
34 files changed, 577 insertions, 101 deletions
diff --git a/spec/helpers/appearances_helper_spec.rb b/spec/helpers/appearances_helper_spec.rb
index 179c69b2a67..d972ac27119 100644
--- a/spec/helpers/appearances_helper_spec.rb
+++ b/spec/helpers/appearances_helper_spec.rb
@@ -70,7 +70,7 @@ RSpec.describe AppearancesHelper do
context 'when there is a logo but no associated upload' do
before do
# Legacy attachments were not tracked in the uploads table
- appearance.logo.upload.destroy
+ appearance.logo.upload.destroy!
appearance.reload
end
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 08107b841d7..ce4e73bdc55 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -168,6 +168,42 @@ RSpec.describe ApplicationHelper do
it { expect(helper.active_when(false)).to eq(nil) }
end
+ describe '#promo_host' do
+ subject { helper.promo_host }
+
+ it 'returns the url' do
+ is_expected.to eq('about.gitlab.com')
+ end
+ end
+
+ describe '#promo_url' do
+ subject { helper.promo_url }
+
+ it 'returns the url' do
+ is_expected.to eq('https://about.gitlab.com')
+ end
+
+ it 'changes if promo_host changes' do
+ allow(helper).to receive(:promo_host).and_return('foobar.baz')
+
+ is_expected.to eq('https://foobar.baz')
+ end
+ end
+
+ describe '#contact_sales_url' do
+ subject { helper.contact_sales_url }
+
+ it 'returns the url' do
+ is_expected.to eq('https://about.gitlab.com/sales')
+ end
+
+ it 'changes if promo_url changes' do
+ allow(helper).to receive(:promo_url).and_return('https://somewhere.else')
+
+ is_expected.to eq('https://somewhere.else/sales')
+ end
+ end
+
describe '#support_url' do
context 'when alternate support url is specified' do
let(:alternate_url) { 'http://company.example.com/getting-help' }
diff --git a/spec/helpers/auto_devops_helper_spec.rb b/spec/helpers/auto_devops_helper_spec.rb
index ad705dc5a7b..4f060a0ae3b 100644
--- a/spec/helpers/auto_devops_helper_spec.rb
+++ b/spec/helpers/auto_devops_helper_spec.rb
@@ -128,7 +128,7 @@ RSpec.describe AutoDevopsHelper do
context 'with groups' do
before do
- receiver.update(parent: parent)
+ receiver.update!(parent: parent)
end
context 'when auto devops is enabled on parent' do
diff --git a/spec/helpers/award_emoji_helper_spec.rb b/spec/helpers/award_emoji_helper_spec.rb
index 51e0a1b9721..74ebdad3e8f 100644
--- a/spec/helpers/award_emoji_helper_spec.rb
+++ b/spec/helpers/award_emoji_helper_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe AwardEmojiHelper do
subject { helper.toggle_award_url(note) }
it 'returns correct url' do
- expected_url = "/snippets/#{note.noteable.id}/notes/#{note.id}/toggle_award_emoji"
+ expected_url = "/-/snippets/#{note.noteable.id}/notes/#{note.id}/toggle_award_emoji"
expect(subject).to eq(expected_url)
end
@@ -38,7 +38,7 @@ RSpec.describe AwardEmojiHelper do
let(:awardable) { snippet }
it 'returns correct url' do
- expected_url = "/snippets/#{snippet.id}/toggle_award_emoji"
+ expected_url = "/-/snippets/#{snippet.id}/toggle_award_emoji"
expect(subject).to eq(expected_url)
end
diff --git a/spec/helpers/blame_helper_spec.rb b/spec/helpers/blame_helper_spec.rb
index 6371c2b63ce..d305c4c595e 100644
--- a/spec/helpers/blame_helper_spec.rb
+++ b/spec/helpers/blame_helper_spec.rb
@@ -11,6 +11,7 @@ RSpec.describe BlameHelper do
Time.zone.local(2013, 2, 24, 0, 0, 0),
Time.zone.local(2010, 9, 22, 0, 0, 0)]
end
+
let(:blame_groups) do
[
{ commit: double(committed_date: dates[0]) },
@@ -57,6 +58,7 @@ RSpec.describe BlameHelper do
project = double(created_at: now)
helper.age_map_duration(today_blame_groups, project)
end
+
let(:today_blame_groups) { [{ commit: double(committed_date: now) }] }
let(:now) { Time.zone.now }
diff --git a/spec/helpers/blob_helper_spec.rb b/spec/helpers/blob_helper_spec.rb
index fe975aa7723..3ba9f39d21a 100644
--- a/spec/helpers/blob_helper_spec.rb
+++ b/spec/helpers/blob_helper_spec.rb
@@ -30,6 +30,8 @@ RSpec.describe BlobHelper do
let(:namespace) { create(:namespace, name: 'gitlab') }
let(:project) { create(:project, :repository, namespace: namespace) }
+ subject(:link) { helper.edit_blob_button(project, 'master', 'README.md') }
+
before do
allow(helper).to receive(:current_user).and_return(nil)
allow(helper).to receive(:can?).and_return(true)
@@ -53,15 +55,49 @@ RSpec.describe BlobHelper do
end
it 'returns a link with the proper route' do
- link = helper.edit_blob_button(project, 'master', 'README.md')
-
expect(Capybara.string(link).find_link('Edit')[:href]).to eq("/#{project.full_path}/-/edit/master/README.md")
end
it 'returns a link with the passed link_opts on the expected route' do
- link = helper.edit_blob_button(project, 'master', 'README.md', link_opts: { mr_id: 10 })
+ link_with_mr = helper.edit_blob_button(project, 'master', 'README.md', link_opts: { mr_id: 10 })
- expect(Capybara.string(link).find_link('Edit')[:href]).to eq("/#{project.full_path}/-/edit/master/README.md?mr_id=10")
+ expect(Capybara.string(link_with_mr).find_link('Edit')[:href]).to eq("/#{project.full_path}/-/edit/master/README.md?mr_id=10")
+ end
+
+ context 'when edit is the primary button' do
+ before do
+ stub_feature_flags(web_ide_primary_edit: false)
+ end
+
+ it 'is rendered as primary' do
+ expect(link).not_to match(/btn-inverted/)
+ end
+
+ it 'passes on primary tracking attributes' do
+ parsed_link = Capybara.string(link).find_link('Edit')
+
+ expect(parsed_link[:'data-track-event']).to eq("click_edit")
+ expect(parsed_link[:'data-track-label']).to eq("Edit")
+ expect(parsed_link[:'data-track-property']).to eq(nil)
+ end
+ end
+
+ context 'when Web IDE is the primary button' do
+ before do
+ stub_feature_flags(web_ide_primary_edit: true)
+ end
+
+ it 'is rendered as inverted' do
+ expect(link).to match(/btn-inverted/)
+ end
+
+ it 'passes on secondary tracking attributes' do
+ parsed_link = Capybara.string(link).find_link('Edit')
+
+ expect(parsed_link[:'data-track-event']).to eq("click_edit")
+ expect(parsed_link[:'data-track-label']).to eq("Edit")
+ expect(parsed_link[:'data-track-property']).to eq("secondary")
+ end
end
end
@@ -246,6 +282,16 @@ RSpec.describe BlobHelper do
expect(helper.show_suggest_pipeline_creation_celebration?).to be_falsey
end
end
+
+ context 'blob does not have auxiliary view' do
+ before do
+ allow(blob).to receive(:auxiliary_viewer).and_return(nil)
+ end
+
+ it 'is false' do
+ expect(helper.show_suggest_pipeline_creation_celebration?).to be_falsey
+ end
+ end
end
context 'experiment disabled' do
@@ -285,6 +331,62 @@ RSpec.describe BlobHelper do
end
end
+ describe `#ide_edit_button` do
+ let_it_be(:namespace) { create(:namespace, name: 'gitlab') }
+ let_it_be(:project) { create(:project, :repository, namespace: namespace) }
+ let_it_be(:current_user) { create(:user) }
+ let(:can_push_code) { true }
+ let(:blob) { project.repository.blob_at('refs/heads/master', 'README.md') }
+
+ subject(:link) { helper.ide_edit_button(project, 'master', 'README.md', blob: blob) }
+
+ before do
+ allow(helper).to receive(:current_user).and_return(current_user)
+ allow(helper).to receive(:can?).with(current_user, :push_code, project).and_return(can_push_code)
+ allow(helper).to receive(:can_collaborate_with_project?).and_return(true)
+ end
+
+ it 'returns a link with a Web IDE route' do
+ expect(Capybara.string(link).find_link('Web IDE')[:href]).to eq("/-/ide/project/#{project.full_path}/edit/master/-/README.md")
+ end
+
+ context 'when edit is the primary button' do
+ before do
+ stub_feature_flags(web_ide_primary_edit: false)
+ end
+
+ it 'is rendered as inverted' do
+ expect(link).to match(/btn-inverted/)
+ end
+
+ it 'passes on secondary tracking attributes' do
+ parsed_link = Capybara.string(link).find_link('Web IDE')
+
+ expect(parsed_link[:'data-track-event']).to eq("click_edit_ide")
+ expect(parsed_link[:'data-track-label']).to eq("Web IDE")
+ expect(parsed_link[:'data-track-property']).to eq("secondary")
+ end
+ end
+
+ context 'when Web IDE is the primary button' do
+ before do
+ stub_feature_flags(web_ide_primary_edit: true)
+ end
+
+ it 'is rendered as primary' do
+ expect(link).not_to match(/btn-inverted/)
+ end
+
+ it 'passes on primary tracking attributes' do
+ parsed_link = Capybara.string(link).find_link('Web IDE')
+
+ expect(parsed_link[:'data-track-event']).to eq("click_edit_ide")
+ expect(parsed_link[:'data-track-label']).to eq("Web IDE")
+ expect(parsed_link[:'data-track-property']).to eq(nil)
+ end
+ end
+ end
+
describe '#ide_edit_path' do
let(:project) { create(:project) }
let(:current_user) { create(:user) }
diff --git a/spec/helpers/branches_helper_spec.rb b/spec/helpers/branches_helper_spec.rb
new file mode 100644
index 00000000000..1f7bf25afcd
--- /dev/null
+++ b/spec/helpers/branches_helper_spec.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe BranchesHelper do
+ describe '#access_levels_data' do
+ subject { helper.access_levels_data(access_levels) }
+
+ context 'when access_levels is nil' do
+ let(:access_levels) { nil }
+
+ it { is_expected.to be_empty }
+ end
+
+ context 'when access levels are provided' do
+ let(:protected_branch) { create(:protected_branch, :developers_can_merge, :maintainers_can_push) }
+
+ let(:merge_level) { protected_branch.merge_access_levels.first }
+ let(:push_level) { protected_branch.push_access_levels.first }
+ let(:access_levels) { [merge_level, push_level] }
+
+ it 'returns the correct array' do
+ expected_array = [
+ { id: merge_level.id, type: :role, access_level: Gitlab::Access::DEVELOPER },
+ { id: push_level.id, type: :role, access_level: Gitlab::Access::MAINTAINER }
+ ]
+
+ expect(subject).to eq(expected_array)
+ end
+ end
+ end
+end
diff --git a/spec/helpers/ci/pipelines_helper_spec.rb b/spec/helpers/ci/pipelines_helper_spec.rb
new file mode 100644
index 00000000000..89b9907d0c2
--- /dev/null
+++ b/spec/helpers/ci/pipelines_helper_spec.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Ci::PipelinesHelper do
+ include Devise::Test::ControllerHelpers
+
+ describe 'pipeline_warnings' do
+ let(:pipeline) { double(:pipeline, warning_messages: warning_messages) }
+
+ subject { helper.pipeline_warnings(pipeline) }
+
+ context 'when pipeline has no warnings' do
+ let(:warning_messages) { [] }
+
+ it 'is empty' do
+ expect(subject).to be_nil
+ end
+ end
+
+ context 'when pipeline has warnings' do
+ let(:warning_messages) { [double(content: 'Warning 1'), double(content: 'Warning 2')] }
+
+ it 'returns a warning callout box' do
+ expect(subject).to have_css 'div.alert-warning'
+ expect(subject).to include 'Warning:'
+ end
+
+ it 'lists the the warnings' do
+ expect(subject).to include 'Warning 1'
+ expect(subject).to include 'Warning 2'
+ end
+ end
+ end
+end
diff --git a/spec/helpers/ci/status_helper_spec.rb b/spec/helpers/ci/status_helper_spec.rb
index 12a6acb1ecc..0af396149ef 100644
--- a/spec/helpers/ci/status_helper_spec.rb
+++ b/spec/helpers/ci/status_helper_spec.rb
@@ -127,7 +127,7 @@ RSpec.describe Ci::StatusHelper do
subject { helper.render_status_with_link("success", icon_size: 24) }
it "has the svg class to change size" do
- is_expected.to include("<svg class=\"s24\">")
+ is_expected.to include("<svg class=\"s24\"")
end
end
end
diff --git a/spec/helpers/environments_helper_spec.rb b/spec/helpers/environments_helper_spec.rb
index 90d6096654e..cb7d12b331a 100644
--- a/spec/helpers/environments_helper_spec.rb
+++ b/spec/helpers/environments_helper_spec.rb
@@ -23,7 +23,7 @@ RSpec.describe EnvironmentsHelper do
'metrics-dashboard-base-path' => environment_metrics_path(environment),
'current-environment-name' => environment.name,
'documentation-path' => help_page_path('administration/monitoring/prometheus/index.md'),
- 'add-dashboard-documentation-path' => help_page_path('user/project/integrations/prometheus.md', anchor: 'adding-a-new-dashboard-to-your-project'),
+ 'add-dashboard-documentation-path' => help_page_path('operations/metrics/dashboards/index.md', anchor: 'add-a-new-dashboard-to-your-project'),
'empty-getting-started-svg-path' => match_asset_path('/assets/illustrations/monitoring/getting_started.svg'),
'empty-loading-svg-path' => match_asset_path('/assets/illustrations/monitoring/loading.svg'),
'empty-no-data-svg-path' => match_asset_path('/assets/illustrations/monitoring/no_data.svg'),
@@ -42,9 +42,10 @@ RSpec.describe EnvironmentsHelper do
'custom-metrics-available' => 'true',
'alerts-endpoint' => project_prometheus_alerts_path(project, environment_id: environment.id, format: :json),
'prometheus-alerts-available' => 'true',
- 'custom-dashboard-base-path' => Metrics::Dashboard::CustomDashboardService::DASHBOARD_ROOT,
+ 'custom-dashboard-base-path' => Gitlab::Metrics::Dashboard::RepoDashboardFinder::DASHBOARD_ROOT,
'operations-settings-path' => project_settings_operations_path(project),
- 'can-access-operations-settings' => 'true'
+ 'can-access-operations-settings' => 'true',
+ 'panel-preview-endpoint' => project_metrics_dashboards_builder_path(project, format: :json)
)
end
diff --git a/spec/helpers/events_helper_spec.rb b/spec/helpers/events_helper_spec.rb
index 4ca31405c1e..c629643e248 100644
--- a/spec/helpers/events_helper_spec.rb
+++ b/spec/helpers/events_helper_spec.rb
@@ -200,7 +200,7 @@ RSpec.describe EventsHelper do
it 'returns a project snippet note url' do
event.target = create(:note_on_project_snippet, note: 'keep going')
- expect(subject).to eq("#{project_base_url}/snippets/#{event.note_target.id}#note_#{event.target.id}")
+ expect(subject).to eq("#{project_base_url}/-/snippets/#{event.note_target.id}#note_#{event.target.id}")
end
it 'returns a project issue url' do
diff --git a/spec/helpers/gitlab_routing_helper_spec.rb b/spec/helpers/gitlab_routing_helper_spec.rb
index bd48fc7cee2..1ad7c7bb9ff 100644
--- a/spec/helpers/gitlab_routing_helper_spec.rb
+++ b/spec/helpers/gitlab_routing_helper_spec.rb
@@ -88,7 +88,7 @@ RSpec.describe GitlabRoutingHelper do
it 'returns snippet preview markdown path for a personal snippet' do
@snippet = create(:personal_snippet)
- expect(preview_markdown_path(nil)).to eq("/snippets/preview_markdown")
+ expect(preview_markdown_path(nil)).to eq("/-/snippets/preview_markdown")
end
it 'returns project preview markdown path for a project snippet' do
@@ -153,132 +153,152 @@ RSpec.describe GitlabRoutingHelper do
describe '#gitlab_snippet_path' do
it 'returns the personal snippet path' do
- expect(gitlab_snippet_path(personal_snippet)).to eq("/snippets/#{personal_snippet.id}")
+ expect(gitlab_snippet_path(personal_snippet)).to eq("/-/snippets/#{personal_snippet.id}")
end
it 'returns the project snippet path' do
- expect(gitlab_snippet_path(project_snippet)).to eq("/#{project_snippet.project.full_path}/snippets/#{project_snippet.id}")
+ expect(gitlab_snippet_path(project_snippet)).to eq("/#{project_snippet.project.full_path}/-/snippets/#{project_snippet.id}")
end
end
describe '#gitlab_snippet_url' do
it 'returns the personal snippet url' do
- expect(gitlab_snippet_url(personal_snippet)).to eq("http://test.host/snippets/#{personal_snippet.id}")
+ expect(gitlab_snippet_url(personal_snippet)).to eq("http://test.host/-/snippets/#{personal_snippet.id}")
end
it 'returns the project snippet url' do
- expect(gitlab_snippet_url(project_snippet)).to eq("http://test.host/#{project_snippet.project.full_path}/snippets/#{project_snippet.id}")
+ expect(gitlab_snippet_url(project_snippet)).to eq("http://test.host/#{project_snippet.project.full_path}/-/snippets/#{project_snippet.id}")
end
end
describe '#gitlab_raw_snippet_path' do
it 'returns the raw personal snippet path' do
- expect(gitlab_raw_snippet_path(personal_snippet)).to eq("/snippets/#{personal_snippet.id}/raw")
+ expect(gitlab_raw_snippet_path(personal_snippet)).to eq("/-/snippets/#{personal_snippet.id}/raw")
end
it 'returns the raw project snippet path' do
- expect(gitlab_raw_snippet_path(project_snippet)).to eq("/#{project_snippet.project.full_path}/snippets/#{project_snippet.id}/raw")
+ expect(gitlab_raw_snippet_path(project_snippet)).to eq("/#{project_snippet.project.full_path}/-/snippets/#{project_snippet.id}/raw")
end
end
describe '#gitlab_raw_snippet_blob_path' do
+ let(:snippet) { personal_snippet }
+ let(:blob) { snippet.blobs.first }
let(:ref) { 'test-ref' }
+ let(:args) { {} }
+
+ subject { gitlab_raw_snippet_blob_path(snippet, blob.path, ref, args) }
+
+ it_behaves_like 'snippet blob raw path'
+
+ context 'when an argument is set' do
+ let(:args) { { inline: true } }
- it_behaves_like 'snippet blob raw path' do
- subject { gitlab_raw_snippet_blob_path(blob, ref) }
+ it { expect(subject).to eq("/-/snippets/#{personal_snippet.id}/raw/#{ref}/#{blob.path}?inline=true") }
end
context 'without a ref' do
- let(:blob) { personal_snippet.blobs.first }
- let(:ref) { blob.repository.root_ref }
+ let(:ref) { nil }
+ let(:expected_ref) { blob.repository.root_ref }
it 'uses the root ref' do
- expect(gitlab_raw_snippet_blob_path(blob)).to eq("/-/snippets/#{personal_snippet.id}/raw/#{ref}/#{blob.path}")
+ expect(subject).to eq("/-/snippets/#{personal_snippet.id}/raw/#{expected_ref}/#{blob.path}")
end
end
end
describe '#gitlab_raw_snippet_url' do
it 'returns the raw personal snippet url' do
- expect(gitlab_raw_snippet_url(personal_snippet)).to eq("http://test.host/snippets/#{personal_snippet.id}/raw")
+ expect(gitlab_raw_snippet_url(personal_snippet)).to eq("http://test.host/-/snippets/#{personal_snippet.id}/raw")
end
it 'returns the raw project snippet url' do
- expect(gitlab_raw_snippet_url(project_snippet)).to eq("http://test.host/#{project_snippet.project.full_path}/snippets/#{project_snippet.id}/raw")
+ expect(gitlab_raw_snippet_url(project_snippet)).to eq("http://test.host/#{project_snippet.project.full_path}/-/snippets/#{project_snippet.id}/raw")
end
end
describe '#gitlab_raw_snippet_blob_url' do
let(:blob) { snippet.blobs.first }
let(:ref) { 'snippet-test-ref' }
+ let(:args) { {} }
- context 'for a PersonalSnippet' do
- let(:snippet) { personal_snippet }
+ subject { gitlab_raw_snippet_blob_url(snippet, blob.path, ref, args) }
- it { expect(gitlab_raw_snippet_blob_url(snippet, blob.path, ref)).to eq("http://test.host/-/snippets/#{snippet.id}/raw/#{ref}/#{blob.path}") }
- end
+ it_behaves_like 'snippet blob raw url'
- context 'for a ProjectSnippet' do
- let(:snippet) { project_snippet }
+ context 'when an argument is set' do
+ let(:args) { { inline: true } }
+ let(:snippet) { personal_snippet }
- it { expect(gitlab_raw_snippet_blob_url(snippet, blob.path, ref)).to eq("http://test.host/#{snippet.project.full_path}/-/snippets/#{snippet.id}/raw/#{ref}/#{blob.path}") }
+ it { expect(subject).to eq("http://test.host/-/snippets/#{snippet.id}/raw/#{ref}/#{blob.path}?inline=true") }
end
context 'without a ref' do
let(:snippet) { personal_snippet }
- let(:ref) { snippet.repository.root_ref }
+ let(:ref) { nil }
+ let(:expected_ref) { snippet.repository.root_ref }
it 'uses the root ref' do
- expect(gitlab_raw_snippet_blob_url(snippet, blob.path)).to eq("http://test.host/-/snippets/#{snippet.id}/raw/#{ref}/#{blob.path}")
+ expect(subject).to eq("http://test.host/-/snippets/#{snippet.id}/raw/#{expected_ref}/#{blob.path}")
end
end
end
+ describe '#gitlab_raw_snippet_url' do
+ it 'returns the raw personal snippet url' do
+ expect(gitlab_raw_snippet_url(personal_snippet)).to eq("http://test.host/-/snippets/#{personal_snippet.id}/raw")
+ end
+
+ it 'returns the raw project snippet url' do
+ expect(gitlab_raw_snippet_url(project_snippet)).to eq("http://test.host/#{project_snippet.project.full_path}/-/snippets/#{project_snippet.id}/raw")
+ end
+ end
+
describe '#gitlab_snippet_notes_path' do
it 'returns the notes path for the personal snippet' do
- expect(gitlab_snippet_notes_path(personal_snippet)).to eq("/snippets/#{personal_snippet.id}/notes")
+ expect(gitlab_snippet_notes_path(personal_snippet)).to eq("/-/snippets/#{personal_snippet.id}/notes")
end
end
describe '#gitlab_snippet_notes_url' do
it 'returns the notes url for the personal snippet' do
- expect(gitlab_snippet_notes_url(personal_snippet)).to eq("http://test.host/snippets/#{personal_snippet.id}/notes")
+ expect(gitlab_snippet_notes_url(personal_snippet)).to eq("http://test.host/-/snippets/#{personal_snippet.id}/notes")
end
end
describe '#gitlab_snippet_note_path' do
it 'returns the note path for the personal snippet' do
- expect(gitlab_snippet_note_path(personal_snippet, note)).to eq("/snippets/#{personal_snippet.id}/notes/#{note.id}")
+ expect(gitlab_snippet_note_path(personal_snippet, note)).to eq("/-/snippets/#{personal_snippet.id}/notes/#{note.id}")
end
end
describe '#gitlab_snippet_note_url' do
it 'returns the note url for the personal snippet' do
- expect(gitlab_snippet_note_url(personal_snippet, note)).to eq("http://test.host/snippets/#{personal_snippet.id}/notes/#{note.id}")
+ expect(gitlab_snippet_note_url(personal_snippet, note)).to eq("http://test.host/-/snippets/#{personal_snippet.id}/notes/#{note.id}")
end
end
describe '#gitlab_toggle_award_emoji_snippet_note_path' do
it 'returns the note award emoji path for the personal snippet' do
- expect(gitlab_toggle_award_emoji_snippet_note_path(personal_snippet, note)).to eq("/snippets/#{personal_snippet.id}/notes/#{note.id}/toggle_award_emoji")
+ expect(gitlab_toggle_award_emoji_snippet_note_path(personal_snippet, note)).to eq("/-/snippets/#{personal_snippet.id}/notes/#{note.id}/toggle_award_emoji")
end
end
describe '#gitlab_toggle_award_emoji_snippet_note_url' do
it 'returns the note award emoji url for the personal snippet' do
- expect(gitlab_toggle_award_emoji_snippet_note_url(personal_snippet, note)).to eq("http://test.host/snippets/#{personal_snippet.id}/notes/#{note.id}/toggle_award_emoji")
+ expect(gitlab_toggle_award_emoji_snippet_note_url(personal_snippet, note)).to eq("http://test.host/-/snippets/#{personal_snippet.id}/notes/#{note.id}/toggle_award_emoji")
end
end
describe '#gitlab_toggle_award_emoji_snippet_path' do
it 'returns the award emoji path for the personal snippet' do
- expect(gitlab_toggle_award_emoji_snippet_path(personal_snippet)).to eq("/snippets/#{personal_snippet.id}/toggle_award_emoji")
+ expect(gitlab_toggle_award_emoji_snippet_path(personal_snippet)).to eq("/-/snippets/#{personal_snippet.id}/toggle_award_emoji")
end
end
describe '#gitlab_toggle_award_emoji_snippet_url' do
it 'returns the award url for the personal snippet' do
- expect(gitlab_toggle_award_emoji_snippet_url(personal_snippet)).to eq("http://test.host/snippets/#{personal_snippet.id}/toggle_award_emoji")
+ expect(gitlab_toggle_award_emoji_snippet_url(personal_snippet)).to eq("http://test.host/-/snippets/#{personal_snippet.id}/toggle_award_emoji")
end
end
@@ -288,7 +308,7 @@ RSpec.describe GitlabRoutingHelper do
end
it 'returns the project snippets dashboard path' do
- expect(gitlab_dashboard_snippets_path(project_snippet)).to eq("/#{project_snippet.project.full_path}/snippets")
+ expect(gitlab_dashboard_snippets_path(project_snippet)).to eq("/#{project_snippet.project.full_path}/-/snippets")
end
end
end
diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb
index a739c16f3b1..0790dc1b674 100644
--- a/spec/helpers/groups_helper_spec.rb
+++ b/spec/helpers/groups_helper_spec.rb
@@ -114,12 +114,14 @@ RSpec.describe GroupsHelper do
ancestor_locked_and_has_been_overridden: /This setting is applied on .+ and has been overridden on this subgroup/
}
end
+
let(:possible_linked_ancestors) do
{
root_group: root_group,
subgroup: subgroup
}
end
+
let(:users) do
{
root_owner: root_owner,
diff --git a/spec/helpers/icons_helper_spec.rb b/spec/helpers/icons_helper_spec.rb
index c47bba42ae2..872aa821560 100644
--- a/spec/helpers/icons_helper_spec.rb
+++ b/spec/helpers/icons_helper_spec.rb
@@ -48,19 +48,24 @@ RSpec.describe IconsHelper do
describe 'sprite_icon' do
icon_name = 'clock'
- it 'returns svg icon html' do
+ it 'returns svg icon html with DEFAULT_ICON_SIZE' do
expect(sprite_icon(icon_name).to_s)
- .to eq "<svg><use xlink:href=\"#{icons_path}##{icon_name}\"></use></svg>"
+ .to eq "<svg class=\"s#{IconsHelper::DEFAULT_ICON_SIZE}\" data-testid=\"#{icon_name}-icon\"><use xlink:href=\"#{icons_path}##{icon_name}\"></use></svg>"
+ end
+
+ it 'returns svg icon html without size class' do
+ expect(sprite_icon(icon_name, size: nil).to_s)
+ .to eq "<svg data-testid=\"#{icon_name}-icon\"><use xlink:href=\"#{icons_path}##{icon_name}\"></use></svg>"
end
it 'returns svg icon html + size classes' do
expect(sprite_icon(icon_name, size: 72).to_s)
- .to eq "<svg class=\"s72\"><use xlink:href=\"#{icons_path}##{icon_name}\"></use></svg>"
+ .to eq "<svg class=\"s72\" data-testid=\"#{icon_name}-icon\"><use xlink:href=\"#{icons_path}##{icon_name}\"></use></svg>"
end
it 'returns svg icon html + size classes + additional class' do
expect(sprite_icon(icon_name, size: 72, css_class: 'icon-danger').to_s)
- .to eq "<svg class=\"s72 icon-danger\"><use xlink:href=\"#{icons_path}##{icon_name}\"></use></svg>"
+ .to eq "<svg class=\"s72 icon-danger\" data-testid=\"#{icon_name}-icon\"><use xlink:href=\"#{icons_path}##{icon_name}\"></use></svg>"
end
describe 'non existing icon' do
diff --git a/spec/helpers/issuables_helper_spec.rb b/spec/helpers/issuables_helper_spec.rb
index a3945b5bd8a..9b32758c053 100644
--- a/spec/helpers/issuables_helper_spec.rb
+++ b/spec/helpers/issuables_helper_spec.rb
@@ -160,7 +160,7 @@ RSpec.describe IssuablesHelper do
end
before do
- user.destroy
+ user.destroy!
end
it 'returns "Ghost user" as edited_by' do
diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb
index f2757f0e3ed..3f84eeb12c2 100644
--- a/spec/helpers/issues_helper_spec.rb
+++ b/spec/helpers/issues_helper_spec.rb
@@ -162,7 +162,7 @@ RSpec.describe IssuesHelper do
context 'with linked issue' do
context 'with moved issue' do
before do
- issue.update(moved_to: new_issue)
+ issue.update!(moved_to: new_issue)
end
context 'when user has permission to see new issue' do
@@ -181,7 +181,7 @@ RSpec.describe IssuesHelper do
context 'with duplicated issue' do
before do
- issue.update(duplicated_to: new_issue)
+ issue.update!(duplicated_to: new_issue)
end
context 'when user has permission to see new issue' do
@@ -203,7 +203,7 @@ RSpec.describe IssuesHelper do
let(:user) { project.owner }
before do
- issue.update(moved_to: nil, duplicated_to: nil)
+ issue.update!(moved_to: nil, duplicated_to: nil)
end
it_behaves_like 'does not display link'
@@ -220,7 +220,7 @@ RSpec.describe IssuesHelper do
allow(Gitlab::IncomingEmail).to receive(:enabled?) { true }
allow(Gitlab::IncomingEmail).to receive(:supports_wildcard?) { true }
- old_issue.update(moved_to: new_issue)
+ old_issue.update!(moved_to: new_issue)
end
it 'is true when moved issue project has service desk disabled' do
diff --git a/spec/helpers/members_helper_spec.rb b/spec/helpers/members_helper_spec.rb
index 99e8696e960..84b3f99b89a 100644
--- a/spec/helpers/members_helper_spec.rb
+++ b/spec/helpers/members_helper_spec.rb
@@ -25,7 +25,7 @@ RSpec.describe MembersHelper do
context 'an accepted user invitation with no user associated' do
before do
- group_member_invite.update(invite_email: "#{SecureRandom.hex}@example.com", invite_token: nil, user_id: nil)
+ group_member_invite.update_columns(invite_email: "#{SecureRandom.hex}@example.com", invite_token: nil, user_id: nil)
end
it 'logs an exception and shows orphaned status' do
diff --git a/spec/helpers/namespace_storage_limit_alert_helper_spec.rb b/spec/helpers/namespace_storage_limit_alert_helper_spec.rb
new file mode 100644
index 00000000000..ab3cf96edef
--- /dev/null
+++ b/spec/helpers/namespace_storage_limit_alert_helper_spec.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe NamespaceStorageLimitAlertHelper do
+ describe '#display_namespace_storage_limit_alert!' do
+ it 'is defined in CE' do
+ expect { helper.display_namespace_storage_limit_alert! }.not_to raise_error
+ end
+ end
+end
diff --git a/spec/helpers/namespaces_helper_spec.rb b/spec/helpers/namespaces_helper_spec.rb
index 1313a5c9352..1636ba6ef42 100644
--- a/spec/helpers/namespaces_helper_spec.rb
+++ b/spec/helpers/namespaces_helper_spec.rb
@@ -10,6 +10,7 @@ RSpec.describe NamespacesHelper do
:private,
project_creation_level: admin_project_creation_level)
end
+
let!(:user) { create(:user) }
let!(:user_project_creation_level) { nil }
let!(:user_group) do
@@ -17,18 +18,21 @@ RSpec.describe NamespacesHelper do
:private,
project_creation_level: user_project_creation_level)
end
+
let!(:subgroup1) do
create(:group,
:private,
parent: admin_group,
project_creation_level: nil)
end
+
let!(:subgroup2) do
create(:group,
:private,
parent: admin_group,
project_creation_level: ::Gitlab::Access::DEVELOPER_MAINTAINER_PROJECT_ACCESS)
end
+
let!(:subgroup3) do
create(:group,
:private,
diff --git a/spec/helpers/notes_helper_spec.rb b/spec/helpers/notes_helper_spec.rb
index f29f947ba46..41511b65cc4 100644
--- a/spec/helpers/notes_helper_spec.rb
+++ b/spec/helpers/notes_helper_spec.rb
@@ -77,9 +77,9 @@ RSpec.describe NotesHelper do
context 'for a merge request discusion' do
let(:merge_request) { create(:merge_request, source_project: project, target_project: project, importing: true) }
- let!(:merge_request_diff1) { merge_request.merge_request_diffs.create(head_commit_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
- let!(:merge_request_diff2) { merge_request.merge_request_diffs.create(head_commit_sha: nil) }
- let!(:merge_request_diff3) { merge_request.merge_request_diffs.create(head_commit_sha: '5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
+ let!(:merge_request_diff1) { merge_request.merge_request_diffs.create!(head_commit_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
+ let!(:merge_request_diff2) { merge_request.merge_request_diffs.create!(head_commit_sha: nil) }
+ let!(:merge_request_diff3) { merge_request.merge_request_diffs.create!(head_commit_sha: '5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
context 'for a diff discussion' do
context 'when the discussion is active' do
@@ -225,7 +225,7 @@ RSpec.describe NotesHelper do
it 'return snippet notes path for personal snippet' do
@snippet = create(:personal_snippet)
- expect(helper.notes_url).to eq("/snippets/#{@snippet.id}/notes")
+ expect(helper.notes_url).to eq("/-/snippets/#{@snippet.id}/notes")
end
it 'return project notes path for project snippet' do
@@ -250,7 +250,7 @@ RSpec.describe NotesHelper do
it 'return snippet notes path for personal snippet' do
note = create(:note_on_personal_snippet)
- expect(helper.note_url(note)).to eq("/snippets/#{note.noteable.id}/notes/#{note.id}")
+ expect(helper.note_url(note)).to eq("/-/snippets/#{note.noteable.id}/notes/#{note.id}")
end
it 'return project notes path for project snippet' do
@@ -284,7 +284,7 @@ RSpec.describe NotesHelper do
@snippet = create(:project_snippet, project: @project)
@note = create(:note_on_personal_snippet)
- expect(helper.form_resources).to eq([@project.namespace, @project, @note])
+ expect(helper.form_resources).to eq([@project, @note])
end
it 'returns namespace, project and note path for other noteables' do
@@ -292,7 +292,7 @@ RSpec.describe NotesHelper do
@project = create(:project, path: 'test', namespace: namespace)
@note = create(:note_on_issue, project: @project)
- expect(helper.form_resources).to eq([@project.namespace, @project, @note])
+ expect(helper.form_resources).to eq([@project, @note])
end
end
diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb
index 319c85c19f9..8d2806cbef6 100644
--- a/spec/helpers/notifications_helper_spec.rb
+++ b/spec/helpers/notifications_helper_spec.rb
@@ -22,6 +22,7 @@ RSpec.describe NotificationsHelper do
it { expect(notification_event_name(:success_pipeline)).to match('Successful pipeline') }
it { expect(notification_event_name(:failed_pipeline)).to match('Failed pipeline') }
it { expect(notification_event_name(:fixed_pipeline)).to match('Fixed pipeline') }
+ it { expect(notification_event_name(:moved_project)).to match('Moved project') }
end
describe '#notification_icon_level' do
diff --git a/spec/helpers/operations_helper_spec.rb b/spec/helpers/operations_helper_spec.rb
index 73deb2249bc..8e3b1db5272 100644
--- a/spec/helpers/operations_helper_spec.rb
+++ b/spec/helpers/operations_helper_spec.rb
@@ -152,7 +152,7 @@ RSpec.describe OperationsHelper do
send_email: 'false',
pagerduty_active: 'true',
pagerduty_token: operations_settings.pagerduty_token,
- pagerduty_webhook_url: project_incidents_pagerduty_url(project, token: operations_settings.pagerduty_token),
+ pagerduty_webhook_url: project_incidents_integrations_pagerduty_url(project, token: operations_settings.pagerduty_token),
pagerduty_reset_key_path: reset_pagerduty_token_project_settings_operations_path(project)
)
end
diff --git a/spec/helpers/packages_helper_spec.rb b/spec/helpers/packages_helper_spec.rb
new file mode 100644
index 00000000000..1917c851547
--- /dev/null
+++ b/spec/helpers/packages_helper_spec.rb
@@ -0,0 +1,88 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe PackagesHelper do
+ let_it_be(:base_url) { "#{Gitlab.config.gitlab.url}/api/v4/" }
+ let_it_be(:project) { create(:project) }
+
+ describe 'package_registry_instance_url' do
+ it 'returns conant instance url when registry_type is conant' do
+ url = helper.package_registry_instance_url(:conan)
+
+ expect(url).to eq("#{base_url}packages/conan")
+ end
+
+ it 'returns npm instance url when registry_type is npm' do
+ url = helper.package_registry_instance_url(:npm)
+
+ expect(url).to eq("#{base_url}packages/npm")
+ end
+ end
+
+ describe 'package_registry_project_url' do
+ it 'returns maven registry url when registry_type is not provided' do
+ url = helper.package_registry_project_url(1)
+
+ expect(url).to eq("#{base_url}projects/1/packages/maven")
+ end
+
+ it 'returns specified registry url when registry_type is provided' do
+ url = helper.package_registry_project_url(1, :npm)
+
+ expect(url).to eq("#{base_url}projects/1/packages/npm")
+ end
+ end
+
+ describe 'pypi_registry_url' do
+ let_it_be(:base_url_with_token) { base_url.sub('://', '://__token__:<your_personal_token>@') }
+
+ it 'returns the pypi registry url' do
+ url = helper.pypi_registry_url(1)
+
+ expect(url).to eq("#{base_url_with_token}projects/1/packages/pypi/simple")
+ end
+ end
+
+ describe 'composer_registry_url' do
+ it 'return the composer registry url' do
+ url = helper.composer_registry_url(1)
+
+ expect(url).to eq("#{base_url}group/1/-/packages/composer/packages.json")
+ end
+ end
+
+ describe 'packages_coming_soon_enabled?' do
+ it 'returns false when the feature flag is disabled' do
+ stub_feature_flags(packages_coming_soon: false)
+
+ expect(helper.packages_coming_soon_enabled?(project)).to eq(false)
+ end
+
+ it 'returns false when not on dev or gitlab.com' do
+ expect(helper.packages_coming_soon_enabled?(project)).to eq(false)
+ end
+ end
+
+ describe 'packages_coming_soon_data' do
+ let_it_be(:group) { create(:group) }
+
+ before do
+ allow(Gitlab).to receive(:dev_env_or_com?) { true }
+ end
+
+ it 'returns the gitlab project on gitlab.com' do
+ allow(Gitlab).to receive(:com?) { true }
+
+ expect(helper.packages_coming_soon_data(project)).to include({ project_path: 'gitlab-org/gitlab' })
+ end
+
+ it 'returns the test project when not on gitlab.com' do
+ expect(helper.packages_coming_soon_data(project)).to include({ project_path: 'gitlab-org/gitlab-test' })
+ end
+
+ it 'works correctly with a group' do
+ expect(helper.packages_coming_soon_data(group)).to include({ project_path: 'gitlab-org/gitlab-test' })
+ end
+ end
+end
diff --git a/spec/helpers/profiles_helper_spec.rb b/spec/helpers/profiles_helper_spec.rb
index 4a8ba2b7113..61b7ff94edb 100644
--- a/spec/helpers/profiles_helper_spec.rb
+++ b/spec/helpers/profiles_helper_spec.rb
@@ -31,7 +31,7 @@ RSpec.describe ProfilesHelper do
end
it 'returns DB stored commit_email' do
- user.update(commit_email: Gitlab::PrivateCommitEmail::TOKEN)
+ user.update!(commit_email: Gitlab::PrivateCommitEmail::TOKEN)
expect(helper.selected_commit_email(user)).to eq(Gitlab::PrivateCommitEmail::TOKEN)
end
diff --git a/spec/helpers/projects/alert_management_helper_spec.rb b/spec/helpers/projects/alert_management_helper_spec.rb
index 859c08b194a..183f0438c35 100644
--- a/spec/helpers/projects/alert_management_helper_spec.rb
+++ b/spec/helpers/projects/alert_management_helper_spec.rb
@@ -28,7 +28,8 @@ RSpec.describe Projects::AlertManagementHelper do
expect(helper.alert_management_data(current_user, project)).to match(
'project-path' => project_path,
'enable-alert-management-path' => setting_path,
- 'populating-alerts-help-url' => 'http://test.host/help/user/project/operations/alert_management.html#enable-alert-management',
+ 'alerts-help-url' => 'http://test.host/help/operations/incident_management/index.md',
+ 'populating-alerts-help-url' => 'http://test.host/help/operations/incident_management/index.md#enable-alert-management',
'empty-alert-svg-path' => match_asset_path('/assets/illustrations/alert-management-empty-state.svg'),
'user-can-enable-alert-management' => 'true',
'alert-management-enabled' => 'false'
@@ -49,7 +50,7 @@ RSpec.describe Projects::AlertManagementHelper do
context 'when alerts service is inactive' do
it 'disables alert management' do
- alerts_service.update(active: false)
+ alerts_service.update!(active: false)
expect(data).to include(
'alert-management-enabled' => 'false'
diff --git a/spec/helpers/projects/incidents_helper_spec.rb b/spec/helpers/projects/incidents_helper_spec.rb
new file mode 100644
index 00000000000..0affa67a902
--- /dev/null
+++ b/spec/helpers/projects/incidents_helper_spec.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Projects::IncidentsHelper do
+ include Gitlab::Routing.url_helpers
+
+ let(:project) { create(:project) }
+ let(:project_path) { project.full_path }
+ let(:new_issue_path) { new_project_issue_path(project) }
+ let(:issue_path) { project_issues_path(project) }
+
+ describe '#incidents_data' do
+ subject(:data) { helper.incidents_data(project) }
+
+ it 'returns frontend configuration' do
+ expect(data).to match(
+ 'project-path' => project_path,
+ 'new-issue-path' => new_issue_path,
+ 'incident-template-name' => 'incident',
+ 'incident-type' => 'incident',
+ 'issue-path' => issue_path,
+ 'empty-list-svg-path' => match_asset_path('/assets/illustrations/incident-empty-state.svg')
+ )
+ end
+ end
+end
diff --git a/spec/helpers/projects/issues/service_desk_helper_spec.rb b/spec/helpers/projects/issues/service_desk_helper_spec.rb
new file mode 100644
index 00000000000..3f488fe692d
--- /dev/null
+++ b/spec/helpers/projects/issues/service_desk_helper_spec.rb
@@ -0,0 +1,53 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Projects::Issues::ServiceDeskHelper do
+ let_it_be(:project) { create(:project, :public, service_desk_enabled: true) }
+ let(:user) { build_stubbed(:user) }
+ let(:current_user) { user }
+
+ describe '#service_desk_meta' do
+ subject { helper.service_desk_meta(project) }
+
+ context "when service desk is supported and user can edit project settings" do
+ before do
+ allow(Gitlab::IncomingEmail).to receive(:enabled?).and_return(true)
+ allow(Gitlab::IncomingEmail).to receive(:supports_wildcard?).and_return(true)
+ allow(helper).to receive(:current_user).and_return(user)
+ allow(helper).to receive(:can?).with(current_user, :admin_project, project).and_return(true)
+ end
+
+ it {
+ is_expected.to eq({
+ is_service_desk_supported: true,
+ is_service_desk_enabled: true,
+ can_edit_project_settings: true,
+ service_desk_address: project.service_desk_address,
+ service_desk_help_page: help_page_path('user/project/service_desk'),
+ edit_project_page: edit_project_path(project),
+ svg_path: ActionController::Base.helpers.image_path('illustrations/service_desk_empty.svg')
+ })
+ }
+ end
+
+ context "when service desk is not supported and user cannot edit project settings" do
+ before do
+ allow(Gitlab::IncomingEmail).to receive(:enabled?).and_return(false)
+ allow(Gitlab::IncomingEmail).to receive(:supports_wildcard?).and_return(false)
+ allow(helper).to receive(:current_user).and_return(user)
+ allow(helper).to receive(:can?).with(current_user, :admin_project, project).and_return(false)
+ end
+
+ it {
+ is_expected.to eq({
+ is_service_desk_supported: false,
+ is_service_desk_enabled: false,
+ can_edit_project_settings: false,
+ incoming_email_help_page: help_page_path('administration/incoming_email', anchor: 'set-it-up'),
+ svg_path: ActionController::Base.helpers.image_path('illustrations/service-desk-setup.svg')
+ })
+ }
+ end
+ end
+end
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb
index a3d0673f1b3..2b345ff3ae6 100644
--- a/spec/helpers/projects_helper_spec.rb
+++ b/spec/helpers/projects_helper_spec.rb
@@ -126,7 +126,7 @@ RSpec.describe ProjectsHelper 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)
+ project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
expect(helper.can_change_visibility_level?(forked_project, user)).to be_falsey
end
@@ -134,7 +134,7 @@ RSpec.describe ProjectsHelper do
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)
+ project.update!(visibility_level: Gitlab::VisibilityLevel::INTERNAL)
expect(helper.can_change_visibility_level?(forked_project, user)).to be_truthy
end
@@ -647,7 +647,7 @@ RSpec.describe ProjectsHelper do
context 'user has a configured commit email' do
before do
confirmed_email = create(:email, :confirmed, user: user)
- user.update(commit_email: confirmed_email)
+ user.update!(commit_email: confirmed_email)
end
it 'returns the commit email' do
@@ -866,7 +866,7 @@ RSpec.describe ProjectsHelper do
when :developer, :maintainer
project.add_user(user, access)
when :owner
- project.namespace.update(owner: user)
+ project.namespace.update!(owner: user)
end
end
diff --git a/spec/helpers/releases_helper_spec.rb b/spec/helpers/releases_helper_spec.rb
index 82fc799f9b0..6ae99648ff3 100644
--- a/spec/helpers/releases_helper_spec.rb
+++ b/spec/helpers/releases_helper_spec.rb
@@ -80,6 +80,7 @@ RSpec.describe ReleasesHelper do
describe '#data_for_new_release_page' do
it 'has the needed data to display the "new release" page' do
keys = %i(project_id
+ releases_page_path
markdown_preview_path
markdown_docs_path
update_release_api_docs_path
diff --git a/spec/helpers/services_helper_spec.rb b/spec/helpers/services_helper_spec.rb
index 10d6ec7b6a7..481bc41bcf3 100644
--- a/spec/helpers/services_helper_spec.rb
+++ b/spec/helpers/services_helper_spec.rb
@@ -3,11 +3,6 @@
require 'spec_helper'
RSpec.describe ServicesHelper do
- describe 'event_action_title' do
- it { expect(event_action_title('comment')).to eq 'Comment' }
- it { expect(event_action_title('something')).to eq 'Something' }
- end
-
describe '#integration_form_data' do
subject { helper.integration_form_data(integration) }
diff --git a/spec/helpers/snippets_helper_spec.rb b/spec/helpers/snippets_helper_spec.rb
index 8fc54f17e71..302122c3990 100644
--- a/spec/helpers/snippets_helper_spec.rb
+++ b/spec/helpers/snippets_helper_spec.rb
@@ -6,21 +6,29 @@ RSpec.describe SnippetsHelper do
include Gitlab::Routing
include IconsHelper
- let_it_be(:public_personal_snippet) { create(:personal_snippet, :public) }
- let_it_be(:public_project_snippet) { create(:project_snippet, :public) }
+ let_it_be(:public_personal_snippet) { create(:personal_snippet, :public, :repository) }
+ let_it_be(:public_project_snippet) { create(:project_snippet, :public, :repository) }
describe '#embedded_raw_snippet_button' do
- subject { embedded_raw_snippet_button.to_s }
+ let(:blob) { snippet.blobs.first }
+ let(:ref) { blob.repository.root_ref }
- it 'returns view raw button of embedded snippets for personal snippets' do
- @snippet = create(:personal_snippet, :public)
- expect(subject).to eq(download_link("http://test.host/snippets/#{@snippet.id}/raw"))
+ subject { embedded_raw_snippet_button(snippet, blob) }
+
+ context 'for Personal Snippets' do
+ let(:snippet) { public_personal_snippet }
+
+ it 'returns view raw button of embedded snippets' do
+ expect(subject).to eq(download_link("http://test.host/-/snippets/#{snippet.id}/raw/#{ref}/#{blob.path}"))
+ end
end
- it 'returns view raw button of embedded snippets for project snippets' do
- @snippet = create(:project_snippet, :public)
+ context 'for Project Snippets' do
+ let(:snippet) { public_project_snippet }
- expect(subject).to eq(download_link("http://test.host/#{@snippet.project.path_with_namespace}/snippets/#{@snippet.id}/raw"))
+ it 'returns view raw button of embedded snippets' do
+ expect(subject).to eq(download_link("http://test.host/#{snippet.project.path_with_namespace}/-/snippets/#{snippet.id}/raw/#{ref}/#{blob.path}"))
+ end
end
def download_link(url)
@@ -29,18 +37,25 @@ RSpec.describe SnippetsHelper do
end
describe '#embedded_snippet_download_button' do
- subject { embedded_snippet_download_button }
+ let(:blob) { snippet.blobs.first }
+ let(:ref) { blob.repository.root_ref }
- it 'returns download button of embedded snippets for personal snippets' do
- @snippet = create(:personal_snippet, :public)
+ subject { embedded_snippet_download_button(snippet, blob) }
- expect(subject).to eq(download_link("http://test.host/snippets/#{@snippet.id}/raw"))
+ context 'for Personal Snippets' do
+ let(:snippet) { public_personal_snippet }
+
+ it 'returns download button of embedded snippets' do
+ expect(subject).to eq(download_link("http://test.host/-/snippets/#{snippet.id}/raw/#{ref}/#{blob.path}"))
+ end
end
- it 'returns download button of embedded snippets for project snippets' do
- @snippet = create(:project_snippet, :public)
+ context 'for Project Snippets' do
+ let(:snippet) { public_project_snippet }
- expect(subject).to eq(download_link("http://test.host/#{@snippet.project.path_with_namespace}/snippets/#{@snippet.id}/raw"))
+ it 'returns download button of embedded snippets' do
+ expect(subject).to eq(download_link("http://test.host/#{snippet.project.path_with_namespace}/-/snippets/#{snippet.id}/raw/#{ref}/#{blob.path}"))
+ end
end
def download_link(url)
@@ -56,7 +71,7 @@ RSpec.describe SnippetsHelper do
context 'public' do
it 'returns a script tag with the snippet full url' do
- expect(subject).to eq(script_embed("http://test.host/snippets/#{snippet.id}"))
+ expect(subject).to eq(script_embed("http://test.host/-/snippets/#{snippet.id}"))
end
end
end
@@ -65,7 +80,7 @@ RSpec.describe SnippetsHelper do
let(:snippet) { public_project_snippet }
it 'returns a script tag with the snippet full url' do
- expect(subject).to eq(script_embed("http://test.host/#{snippet.project.path_with_namespace}/snippets/#{snippet.id}"))
+ expect(subject).to eq(script_embed("http://test.host/#{snippet.project.path_with_namespace}/-/snippets/#{snippet.id}"))
end
end
@@ -81,7 +96,7 @@ RSpec.describe SnippetsHelper do
let(:snippet) { public_personal_snippet }
it 'returns the download button' do
- expect(subject).to eq(download_link("/snippets/#{snippet.id}/raw"))
+ expect(subject).to eq(download_link("/-/snippets/#{snippet.id}/raw"))
end
end
@@ -89,7 +104,7 @@ RSpec.describe SnippetsHelper do
let(:snippet) { public_project_snippet }
it 'returns the download button' do
- expect(subject).to eq(download_link("/#{snippet.project.path_with_namespace}/snippets/#{snippet.id}/raw"))
+ expect(subject).to eq(download_link("/#{snippet.project.path_with_namespace}/-/snippets/#{snippet.id}/raw"))
end
end
@@ -107,7 +122,7 @@ RSpec.describe SnippetsHelper do
let(:visibility) { :private }
it 'returns the snippet badge' do
- expect(subject).to eq "<span class=\"badge badge-gray\"><i class=\"fa fa-lock\"></i> private</span>"
+ expect(subject).to eq "<span class=\"badge badge-gray\">#{sprite_icon('lock', size: 14, css_class: 'gl-vertical-align-middle')} private</span>"
end
end
diff --git a/spec/helpers/user_callouts_helper_spec.rb b/spec/helpers/user_callouts_helper_spec.rb
index 60238053aa2..6f1f358af83 100644
--- a/spec/helpers/user_callouts_helper_spec.rb
+++ b/spec/helpers/user_callouts_helper_spec.rb
@@ -25,7 +25,21 @@ RSpec.describe UserCalloutsHelper do
allow(helper).to receive(:user_dismissed?).and_return(false)
end
- it { is_expected.to be true }
+ context 'when active_nav_link is in the operations section' do
+ before do
+ allow(helper).to receive(:active_nav_link?).and_return(true)
+ end
+
+ it { is_expected.to be true }
+ end
+
+ context 'when active_nav_link is not in the operations section' do
+ before do
+ allow(helper).to receive(:active_nav_link?).and_return(false)
+ end
+
+ it { is_expected.to be false }
+ end
end
context 'when user dismissed' do
@@ -67,6 +81,36 @@ RSpec.describe UserCalloutsHelper do
end
end
+ describe '.show_customize_homepage_banner?' do
+ let(:customize_homepage) { true }
+
+ subject { helper.show_customize_homepage_banner?(customize_homepage) }
+
+ context 'when user has not dismissed' do
+ before do
+ allow(helper).to receive(:user_dismissed?).with(described_class::CUSTOMIZE_HOMEPAGE) { false }
+ end
+
+ context 'when customize_homepage is set' do
+ it { is_expected.to be true }
+ end
+
+ context 'when customize_homepage is false' do
+ let(:customize_homepage) { false }
+
+ it { is_expected.to be false }
+ end
+ end
+
+ context 'when user dismissed' do
+ before do
+ allow(helper).to receive(:user_dismissed?).with(described_class::CUSTOMIZE_HOMEPAGE) { true }
+ end
+
+ it { is_expected.to be false }
+ end
+ end
+
describe '.render_flash_user_callout' do
it 'renders the flash_user_callout partial' do
expect(helper).to receive(:render)
diff --git a/spec/helpers/visibility_level_helper_spec.rb b/spec/helpers/visibility_level_helper_spec.rb
index 9cbace3cfd0..7ef911131ba 100644
--- a/spec/helpers/visibility_level_helper_spec.rb
+++ b/spec/helpers/visibility_level_helper_spec.rb
@@ -171,13 +171,14 @@ RSpec.describe VisibilityLevelHelper do
with_them do
it "provides correct visibility level for forked project" do
- project.update(visibility_level: max_allowed)
+ project.update!(visibility_level: max_allowed)
expect(selected_visibility_level(forked_project, requested_level)).to eq(expected)
end
- it "provides correct visibiility level for project in group" do
- project.group.update(visibility_level: max_allowed)
+ it "provides correct visibility level for project in group" do
+ project.update!(visibility_level: max_allowed)
+ project.group.update!(visibility_level: max_allowed)
expect(selected_visibility_level(project, requested_level)).to eq(expected)
end
diff --git a/spec/helpers/wiki_helper_spec.rb b/spec/helpers/wiki_helper_spec.rb
index 040368b5ebd..6c7172e6232 100644
--- a/spec/helpers/wiki_helper_spec.rb
+++ b/spec/helpers/wiki_helper_spec.rb
@@ -62,7 +62,7 @@ RSpec.describe WikiHelper do
path = "/#{wiki.project.full_path}/-/wikis/pages?direction=#{direction}&sort=#{sort}"
helper.link_to(path, type: 'button', class: classes, title: 'Sort direction') do
- helper.sprite_icon("sort-#{icon_class}", size: 16)
+ helper.sprite_icon("sort-#{icon_class}")
end
end