Fix wiki tests
This commit is contained in:
parent
ca3e1d9e3f
commit
edd07e2363
4 changed files with 26 additions and 1 deletions
|
@ -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
|
||||
|
|
7
spec/factories/project_wikis.rb
Normal file
7
spec/factories/project_wikis.rb
Normal file
|
@ -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
|
9
spec/factories/wiki_pages.rb
Normal file
9
spec/factories/wiki_pages.rb
Normal file
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue