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-07-20 15:26:25 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-07-20 15:26:25 +0300
commita09983ae35713f5a2bbb100981116d31ce99826e (patch)
tree2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/helpers/wiki_helper_spec.rb
parent18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff)
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/helpers/wiki_helper_spec.rb')
-rw-r--r--spec/helpers/wiki_helper_spec.rb54
1 files changed, 53 insertions, 1 deletions
diff --git a/spec/helpers/wiki_helper_spec.rb b/spec/helpers/wiki_helper_spec.rb
index 4b53823aaed..040368b5ebd 100644
--- a/spec/helpers/wiki_helper_spec.rb
+++ b/spec/helpers/wiki_helper_spec.rb
@@ -2,7 +2,39 @@
require 'spec_helper'
-describe WikiHelper do
+RSpec.describe WikiHelper do
+ describe '#wiki_page_title' do
+ let_it_be(:page) { create(:wiki_page) }
+
+ it 'sets the title for the show action' do
+ expect(helper).to receive(:breadcrumb_title).with(page.human_title)
+ expect(helper).to receive(:wiki_breadcrumb_dropdown_links).with(page.slug)
+ expect(helper).to receive(:page_title).with(page.human_title, 'Wiki')
+ expect(helper).to receive(:add_to_breadcrumbs).with('Wiki', helper.wiki_path(page.wiki))
+
+ helper.wiki_page_title(page)
+ end
+
+ it 'sets the title for a custom action' do
+ expect(helper).to receive(:breadcrumb_title).with(page.human_title)
+ expect(helper).to receive(:wiki_breadcrumb_dropdown_links).with(page.slug)
+ expect(helper).to receive(:page_title).with('Edit', page.human_title, 'Wiki')
+ expect(helper).to receive(:add_to_breadcrumbs).with('Wiki', helper.wiki_path(page.wiki))
+
+ helper.wiki_page_title(page, 'Edit')
+ end
+
+ it 'sets the title for an unsaved page' do
+ expect(page).to receive(:persisted?).and_return(false)
+ expect(helper).not_to receive(:breadcrumb_title)
+ expect(helper).not_to receive(:wiki_breadcrumb_dropdown_links)
+ expect(helper).to receive(:page_title).with('Wiki')
+ expect(helper).to receive(:add_to_breadcrumbs).with('Wiki', helper.wiki_path(page.wiki))
+
+ helper.wiki_page_title(page)
+ end
+ end
+
describe '#breadcrumb' do
context 'when the page is at the root level' do
it 'returns the capitalized page name' do
@@ -72,4 +104,24 @@ describe WikiHelper do
expect(helper.wiki_sort_title('unknown')).to eq('Title')
end
end
+
+ describe '#wiki_page_tracking_context' do
+ let_it_be(:page) { create(:wiki_page, title: 'path/to/page 💩', content: '💩', format: :markdown) }
+
+ subject { helper.wiki_page_tracking_context(page) }
+
+ it 'returns the tracking context' do
+ expect(subject).to eq(
+ 'wiki-format' => :markdown,
+ 'wiki-title-size' => 9,
+ 'wiki-content-size' => 4,
+ 'wiki-directory-nest-level' => 2
+ )
+ end
+
+ it 'returns a nest level of zero for toplevel files' do
+ expect(page).to receive(:path).and_return('page')
+ expect(subject).to include('wiki-directory-nest-level' => 0)
+ end
+ end
end