diff options
author | Nick Thomas <nick@gitlab.com> | 2018-10-15 18:34:55 +0100 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-10-16 12:53:30 +0100 |
commit | c5bff77ea4a6170a3dc1966254feac0ca1836eaa (patch) | |
tree | 8f54c14718b7911f5524a4b569f206bfc73a5a49 /spec | |
parent | 0621ee38b501b2f2a1f7717aff249ebf1bcebbf8 (diff) | |
download | gitlab-ce-c5bff77ea4a6170a3dc1966254feac0ca1836eaa.tar.gz |
Remove a dependency on gitlab-gollum-libnick.thomas/gitlab-ce-44361-remove-gitlab-grit
Inlining this code allows us to remove a dependency on gitlab_grit in
gitlab-ce. We can't stop maintaining gitlab_grit yet, since gitaly-ruby
still depends on this gem, but it moves us a step closer.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/git/wiki_spec.rb | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/spec/lib/gitlab/git/wiki_spec.rb b/spec/lib/gitlab/git/wiki_spec.rb index c5666e4ec61..ded5d7576df 100644 --- a/spec/lib/gitlab/git/wiki_spec.rb +++ b/spec/lib/gitlab/git/wiki_spec.rb @@ -1,10 +1,13 @@ require 'spec_helper' describe Gitlab::Git::Wiki do + using RSpec::Parameterized::TableSyntax + let(:project) { create(:project) } let(:user) { project.owner } let(:project_wiki) { ProjectWiki.new(project, user) } - subject { project_wiki.wiki } + + subject(:wiki) { project_wiki.wiki } describe '#pages' do before do @@ -64,8 +67,44 @@ describe Gitlab::Git::Wiki do end end - def create_page(name, content) - subject.write_page(name, :markdown, content, commit_details(name)) + describe '#preview_slug' do + where(:title, :format, :expected_slug) do + 'The Best Thing' | :markdown | 'The-Best-Thing' + 'The Best Thing' | :md | 'The-Best-Thing' + 'The Best Thing' | :txt | 'The-Best-Thing' + 'A Subject/Title Here' | :txt | 'A-Subject/Title-Here' + 'A subject' | :txt | 'A-subject' + 'A 1/B 2/C 3' | :txt | 'A-1/B-2/C-3' + 'subject/title' | :txt | 'subject/title' + 'subject/title.md' | :txt | 'subject/title.md' + 'foo<bar>+baz' | :txt | 'foo-bar--baz' + 'foo%2Fbar' | :txt | 'foo%2Fbar' + '' | :markdown | '.md' + '' | :md | '.md' + '' | :txt | '.txt' + end + + with_them do + subject { wiki.preview_slug(title, format) } + + let(:gitaly_slug) { wiki.pages.first } + + it { is_expected.to eq(expected_slug) } + + it 'matches the slug generated by gitaly' do + skip('Gitaly cannot generate a slug for an empty title') unless title.present? + + create_page(title, 'content', format: format) + + gitaly_slug = wiki.pages.first.url_path + + is_expected.to eq(gitaly_slug) + end + end + end + + def create_page(name, content, format: :markdown) + wiki.write_page(name, format, content, commit_details(name)) end def commit_details(name) @@ -73,7 +112,7 @@ describe Gitlab::Git::Wiki do end def destroy_page(title, dir = '') - page = subject.page(title: title, dir: dir) + page = wiki.page(title: title, dir: dir) project_wiki.delete_page(page, "test commit") end end |