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:
Diffstat (limited to 'spec/models/wiki_page_spec.rb')
-rw-r--r--spec/models/wiki_page_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb
index 2e1cb9d3d9b..f3cf8966b9a 100644
--- a/spec/models/wiki_page_spec.rb
+++ b/spec/models/wiki_page_spec.rb
@@ -58,6 +58,7 @@ RSpec.describe WikiPage, feature_category: :wiki do
let(:front_matter) { { title: 'Foo', slugs: %w[slug_a slug_b] } }
it { expect(wiki_page.front_matter).to eq(front_matter) }
+ it { expect(wiki_page.front_matter_title).to eq(front_matter[:title]) }
end
context 'the wiki page has front matter' do
@@ -1054,4 +1055,28 @@ RSpec.describe WikiPage, feature_category: :wiki do
)
end
end
+
+ describe "#human_title" do
+ context "with front matter title" do
+ let(:front_matter_title) { "abc" }
+ let(:content_with_front_matter_title) { "---\ntitle: #{front_matter_title}\n---\nHome Page" }
+ let(:wiki_page) { create(:wiki_page, container: container, content: content_with_front_matter_title) }
+
+ context "when wiki_front_matter_title enabled" do
+ it 'returns the front matter title' do
+ expect(wiki_page.human_title).to eq front_matter_title
+ end
+ end
+
+ context "when wiki_front_matter_title disabled" do
+ before do
+ stub_feature_flags(wiki_front_matter_title: false)
+ end
+
+ it 'returns the page title' do
+ expect(wiki_page.human_title).to eq wiki_page.title
+ end
+ end
+ end
+ end
end