summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-09 15:13:00 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-09 15:13:00 +0000
commitc337a2782463cdaed6cd0cae36b904b9ccda78b7 (patch)
tree6d26b06907f4aaec500ccf72deef986ef55b7760
parent70848097a49580aa9c64de3d45ab730eb4243ac1 (diff)
parent91e01275cb7c63e8f101c016d83f725d0e7e6cb9 (diff)
downloadgitlab-ce-c337a2782463cdaed6cd0cae36b904b9ccda78b7.tar.gz
Merge branch 'browse_file' into 'master'
Browse file Fixes #1335 See merge request !951
-rw-r--r--app/helpers/commits_helper.rb11
-rw-r--r--app/views/projects/commits/_commit.html.haml3
-rw-r--r--features/project/source/browse_files.feature14
-rw-r--r--features/steps/project/browse_files.rb28
4 files changed, 54 insertions, 2 deletions
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb
index 4d27cf2851e..7100d679358 100644
--- a/app/helpers/commits_helper.rb
+++ b/app/helpers/commits_helper.rb
@@ -180,6 +180,17 @@ module CommitsHelper
return old_lines, new_lines
end
+ def link_to_browse_code(project, commit)
+ if current_controller?(:projects, :commits)
+ if @repo.blob_at(commit.id, @path)
+ return link_to "Browse File »", project_blob_path(project, tree_join(commit.id, @path)), class: "pull-right"
+ elsif @path.present?
+ return link_to "Browse Dir »", project_tree_path(project, tree_join(commit.id, @path)), class: "pull-right"
+ end
+ end
+ link_to "Browse Code »", project_tree_path(project, commit), class: "pull-right"
+ end
+
protected
# Private: Returns a link to a person. If the person has a matching user and
diff --git a/app/views/projects/commits/_commit.html.haml b/app/views/projects/commits/_commit.html.haml
index 74146b5f196..5adb6b9e3b1 100644
--- a/app/views/projects/commits/_commit.html.haml
+++ b/app/views/projects/commits/_commit.html.haml
@@ -7,7 +7,8 @@
- if commit.description?
%a.text-expander.js-toggle-button ...
- = link_to "Browse Code »", project_tree_path(project, commit), class: "pull-right"
+ = link_to_browse_code(project, commit)
+
.notes_count
- if @note_counts
- note_count = @note_counts.fetch(commit.id, 0)
diff --git a/features/project/source/browse_files.feature b/features/project/source/browse_files.feature
index a204c3e10c7..4af2cc83581 100644
--- a/features/project/source/browse_files.feature
+++ b/features/project/source/browse_files.feature
@@ -38,4 +38,16 @@ Feature: Project Browse files
And I click link "Diff"
Then I see diff
-
+ Scenario: I can browse directory with Browse Dir
+ Given I click on app directory
+ And I click on history link
+ Then I see Browse dir link
+
+ Scenario: I can browse file with Browse File
+ Given I click on readme file
+ And I click on history link
+ Then I see Browse file link
+
+ Scenario: I can browse code with Browse Code
+ Given I click on history link
+ Then I see Browse code link
diff --git a/features/steps/project/browse_files.rb b/features/steps/project/browse_files.rb
index 7cdd1101ac5..7134050da69 100644
--- a/features/steps/project/browse_files.rb
+++ b/features/steps/project/browse_files.rb
@@ -62,4 +62,32 @@ class ProjectBrowseFiles < Spinach::FeatureSteps
page.should have_content "File name"
page.should have_content "Commit message"
end
+
+ step 'I click on app directory' do
+ click_link 'app'
+ end
+
+ step 'I click on history link' do
+ click_link 'history'
+ end
+
+ step 'I see Browse dir link' do
+ page.should have_link 'Browse Dir »'
+ page.should_not have_link 'Browse Code »'
+ end
+
+ step 'I click on readme file' do
+ click_link 'README.md'
+ end
+
+ step 'I see Browse file link' do
+ page.should have_link 'Browse File »'
+ page.should_not have_link 'Browse Code »'
+ end
+
+ step 'I see Browse code link' do
+ page.should have_link 'Browse Code »'
+ page.should_not have_link 'Browse File »'
+ page.should_not have_link 'Browse Dir »'
+ end
end