Commit 91e01275 authored by Marin Jankovski's avatar Marin Jankovski

Add tests to check for correct browse link name.

parent 6b121aa5
......@@ -183,13 +183,12 @@ module CommitsHelper
def link_to_browse_code(project, commit)
if current_controller?(:projects, :commits)
if @repo.blob_at(commit.id, @path)
link_to "Browse File »", project_blob_path(project, tree_join(commit.id, @path)), class: "pull-right"
else
link_to "Browse Dir »", project_tree_path(project, tree_join(commit.id, @path)), class: "pull-right"
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
else
link_to "Browse Code »", project_tree_path(project, commit), class: "pull-right"
end
link_to "Browse Code »", project_tree_path(project, commit), class: "pull-right"
end
protected
......
......@@ -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