Fix wiki tests

This commit is contained in:
Sebastian Klier 2016-04-15 12:47:09 +08:00
parent ca3e1d9e3f
commit edd07e2363
4 changed files with 26 additions and 1 deletions

View file

@ -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

View 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

View 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

View file

@ -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