Commit c337a278 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'browse_file' into 'master'

Browse file

Fixes #1335

See merge request !951
parents 70848097 91e01275
......@@ -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
......
......@@ -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)
......
......@@ -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
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment