diff options
-rw-r--r-- | app/services/wiki_pages/base_service.rb | 2 | ||||
-rw-r--r-- | spec/factories/project_wikis.rb | 7 | ||||
-rw-r--r-- | spec/factories/wiki_pages.rb | 9 | ||||
-rw-r--r-- | spec/lib/gitlab/url_builder_spec.rb | 9 |
4 files changed, 26 insertions, 1 deletions
diff --git a/app/services/wiki_pages/base_service.rb b/app/services/wiki_pages/base_service.rb index 9ab9d187413..9162f128602 100644 --- a/app/services/wiki_pages/base_service.rb +++ b/app/services/wiki_pages/base_service.rb @@ -11,7 +11,7 @@ module WikiPages repository: @project.hook_attrs.slice(:name, :url, :description, :homepage) } - page_url = Gitlab::UrlBuilder.new(:wiki_page).build(page) + page_url = Gitlab::UrlBuilder.build(page) hook_data[:object_attributes].merge!(url: page_url, action: action) hook_data end diff --git a/spec/factories/project_wikis.rb b/spec/factories/project_wikis.rb new file mode 100644 index 00000000000..a3403fd76ae --- /dev/null +++ b/spec/factories/project_wikis.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :project_wiki do + project factory: :empty_project + user factory: :user + initialize_with { new(project, user) } + end +end diff --git a/spec/factories/wiki_pages.rb b/spec/factories/wiki_pages.rb new file mode 100644 index 00000000000..938ccf2306b --- /dev/null +++ b/spec/factories/wiki_pages.rb @@ -0,0 +1,9 @@ +require 'ostruct' + +FactoryGirl.define do + factory :wiki_page do + page = OpenStruct.new(url_path: 'some-name') + association :wiki, factory: :project_wiki, strategy: :build + initialize_with { new(wiki, page, true) } + end +end diff --git a/spec/lib/gitlab/url_builder_spec.rb b/spec/lib/gitlab/url_builder_spec.rb index 6ffc0d6e658..bf11472407a 100644 --- a/spec/lib/gitlab/url_builder_spec.rb +++ b/spec/lib/gitlab/url_builder_spec.rb @@ -106,5 +106,14 @@ describe Gitlab::UrlBuilder, lib: true do end end end + + context 'when passing a WikiPage' do + it 'returns a proper URL' do + wiki_page = build(:wiki_page) + url = described_class.build(wiki_page) + + expect(url).to eq "#{Gitlab.config.gitlab.url}#{wiki_page.wiki.wiki_base_path}/#{wiki_page.slug}" + end + end end end |