Commit e649ea2fc5e765f11579ad9aa8e90e69764bd590
1 parent
ace9ff4a
Exists in
master
and in
4 other branches
Links in Readme in tree view.
Showing
3 changed files
with
31 additions
and
5 deletions
Show diff stats
app/helpers/gitlab_markdown_helper.rb
| ... | ... | @@ -129,11 +129,18 @@ module GitlabMarkdownHelper |
| 129 | 129 | # Covering a special case, when the link is referencing file in the same directory eg: |
| 130 | 130 | # If we are at doc/api/README.md and the README.md contains relative links like [Users](users.md) |
| 131 | 131 | # this takes the request path(doc/api/README.md), and replaces the README.md with users.md so the path looks like doc/api/users.md |
| 132 | + # If we are at doc/api and the README.md shown in below the tree view | |
| 133 | + # this takes the rquest path(doc/api) and adds users.md so the path looks like doc/api/users.md | |
| 132 | 134 | def build_nested_path(path, request_path) |
| 133 | 135 | return path unless request_path |
| 134 | - base = request_path.split("/") | |
| 135 | - base.pop | |
| 136 | - (base + [path]).join("/") | |
| 136 | + if local_path(request_path) == "tree" | |
| 137 | + base = request_path.split("/").push(path) | |
| 138 | + base.join("/") | |
| 139 | + else | |
| 140 | + base = request_path.split("/") | |
| 141 | + base.pop | |
| 142 | + base.push(path).join("/") | |
| 143 | + end | |
| 137 | 144 | end |
| 138 | 145 | |
| 139 | 146 | def file_exists?(path) | ... | ... |
features/project/source/markdown_render.feature
| ... | ... | @@ -72,4 +72,9 @@ Feature: Project markdown render |
| 72 | 72 | Scenario: I visit the help page with markdown |
| 73 | 73 | Given I visit to the help page |
| 74 | 74 | And I select a page with markdown |
| 75 | - Then I should see a help page with markdown | |
| 76 | 75 | \ No newline at end of file |
| 76 | + Then I should see a help page with markdown | |
| 77 | + | |
| 78 | + Scenario: Tree view should have correct links in README | |
| 79 | + Given I go directory which contains README file | |
| 80 | + And I click on a relative link in README | |
| 81 | + Then I should see the correct markdown | ... | ... |
features/steps/project/project_markdown_render.rb
| ... | ... | @@ -162,4 +162,18 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps |
| 162 | 162 | Then 'I should see a help page with markdown' do |
| 163 | 163 | page.should have_content "GitLab provides some specific rake tasks to enable special features or perform maintenance tasks" |
| 164 | 164 | end |
| 165 | -end | |
| 166 | 165 | \ No newline at end of file |
| 166 | + | |
| 167 | + Given 'I go directory which contains README file' do | |
| 168 | + visit project_tree_path(@project, "master/doc/api") | |
| 169 | + current_path.should == project_tree_path(@project, "master/doc/api") | |
| 170 | + end | |
| 171 | + | |
| 172 | + And 'I click on a relative link in README' do | |
| 173 | + click_link "Users" | |
| 174 | + end | |
| 175 | + | |
| 176 | + Then 'I should see the correct markdown' do | |
| 177 | + current_path.should == project_blob_path(@project, "master/doc/api/users.md") | |
| 178 | + page.should have_content "List users" | |
| 179 | + end | |
| 180 | +end | ... | ... |