Fix relative links in Markdown wiki when displayed in "Project" tab

Refers to #23806.
This commit is contained in:
Adam Niedzielski 2016-11-01 10:18:49 +01:00
parent 266fcfb193
commit f6cff8f7bc
3 changed files with 47 additions and 1 deletions

View file

@ -43,6 +43,7 @@ Please view this file on the master branch, on stable branches it's out of date.
## 8.13.3 ## 8.13.3
- Fix relative links in Markdown wiki when displayed in "Project" tab !7218
- Reduce the overhead to calculate number of open/closed issues and merge requests within the group or project - Reduce the overhead to calculate number of open/closed issues and merge requests within the group or project
## 8.13.2 (2016-10-31) ## 8.13.2 (2016-10-31)

View file

@ -289,7 +289,8 @@ class ProjectsController < Projects::ApplicationController
render 'projects/empty' if @project.empty_repo? render 'projects/empty' if @project.empty_repo?
else else
if @project.wiki_enabled? if @project.wiki_enabled?
@wiki_home = @project.wiki.find_page('home', params[:version_id]) @project_wiki = @project.wiki
@wiki_home = @project_wiki.find_page('home', params[:version_id])
elsif @project.feature_available?(:issues, current_user) elsif @project.feature_available?(:issues, current_user)
@issues = issues_collection @issues = issues_collection
@issues = @issues.page(params[:page]) @issues = @issues.page(params[:page])

View file

@ -0,0 +1,44 @@
require 'spec_helper'
describe 'Projects > Wiki > User views wiki in project page', feature: true do
let(:user) { create(:user) }
let(:project) { create(:empty_project) }
before do
project.team << [user, :master]
login_as(user)
end
context 'when repository is disabled for project' do
before do
project.project_feature.update!(
repository_access_level: ProjectFeature::DISABLED,
merge_requests_access_level: ProjectFeature::DISABLED,
builds_access_level: ProjectFeature::DISABLED
)
end
context 'when wiki homepage contains a link' do
before do
WikiPages::CreateService.new(
project,
user,
title: 'home',
content: '[some link](other-page)'
).execute
end
it 'displays the correct URL for the link' do
visit namespace_project_path(project.namespace, project)
expect(page).to have_link(
'some link',
href: namespace_project_wiki_path(
project.namespace,
project,
'other-page'
)
)
end
end
end
end