Add tests to check for correct browse link name.

This commit is contained in:
Marin Jankovski 2014-07-09 10:12:02 +02:00
parent 6b121aa5a7
commit 91e01275cb
3 changed files with 44 additions and 5 deletions

View file

@ -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

View file

@ -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

View file

@ -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