summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-10-14 18:31:57 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-10-14 18:31:57 +0000
commitd1a054c513e27ac960a9cf7e147e9a22b48b17df (patch)
tree3a7477d257436ebe4927d9d84acb95c036b14e19
parent18a6f31b6a3e50e7e3b9ef0e22a2996e7d1803ee (diff)
parente649ea2fc5e765f11579ad9aa8e90e69764bd590 (diff)
downloadgitlab-ce-d1a054c513e27ac960a9cf7e147e9a22b48b17df.tar.gz
Merge branch 'fix/relative_links_in_readme' of /home/git/repositories/gitlab/gitlabhq
-rw-r--r--app/helpers/gitlab_markdown_helper.rb13
-rw-r--r--features/project/source/markdown_render.feature7
-rw-r--r--features/steps/project/project_markdown_render.rb16
3 files changed, 31 insertions, 5 deletions
diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb
index 0210bea2f40..b34f7033536 100644
--- a/app/helpers/gitlab_markdown_helper.rb
+++ b/app/helpers/gitlab_markdown_helper.rb
@@ -129,11 +129,18 @@ module GitlabMarkdownHelper
# Covering a special case, when the link is referencing file in the same directory eg:
# If we are at doc/api/README.md and the README.md contains relative links like [Users](users.md)
# 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
+ # If we are at doc/api and the README.md shown in below the tree view
+ # this takes the rquest path(doc/api) and adds users.md so the path looks like doc/api/users.md
def build_nested_path(path, request_path)
return path unless request_path
- base = request_path.split("/")
- base.pop
- (base + [path]).join("/")
+ if local_path(request_path) == "tree"
+ base = request_path.split("/").push(path)
+ base.join("/")
+ else
+ base = request_path.split("/")
+ base.pop
+ base.push(path).join("/")
+ end
end
def file_exists?(path)
diff --git a/features/project/source/markdown_render.feature b/features/project/source/markdown_render.feature
index a7a9cee7b0d..8b4b89e85af 100644
--- a/features/project/source/markdown_render.feature
+++ b/features/project/source/markdown_render.feature
@@ -72,4 +72,9 @@ Feature: Project markdown render
Scenario: I visit the help page with markdown
Given I visit to the help page
And I select a page with markdown
- Then I should see a help page with markdown \ No newline at end of file
+ Then I should see a help page with markdown
+
+ Scenario: Tree view should have correct links in README
+ Given I go directory which contains README file
+ And I click on a relative link in README
+ Then I should see the correct markdown
diff --git a/features/steps/project/project_markdown_render.rb b/features/steps/project/project_markdown_render.rb
index 951c831838d..95d73c93621 100644
--- a/features/steps/project/project_markdown_render.rb
+++ b/features/steps/project/project_markdown_render.rb
@@ -162,4 +162,18 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps
Then 'I should see a help page with markdown' do
page.should have_content "GitLab provides some specific rake tasks to enable special features or perform maintenance tasks"
end
-end \ No newline at end of file
+
+ Given 'I go directory which contains README file' do
+ visit project_tree_path(@project, "master/doc/api")
+ current_path.should == project_tree_path(@project, "master/doc/api")
+ end
+
+ And 'I click on a relative link in README' do
+ click_link "Users"
+ end
+
+ Then 'I should see the correct markdown' do
+ current_path.should == project_blob_path(@project, "master/doc/api/users.md")
+ page.should have_content "List users"
+ end
+end