diff options
author | Marin Jankovski <marin@gitlab.com> | 2014-07-09 10:12:02 +0200 |
---|---|---|
committer | Marin Jankovski <marin@gitlab.com> | 2014-07-09 10:12:09 +0200 |
commit | 91e01275cb7c63e8f101c016d83f725d0e7e6cb9 (patch) | |
tree | 48efe0aec7b09ea58de11fed86aa08b647de60e6 | |
parent | 6b121aa5a7d2a02bf758c13cb9b5ef9845700b08 (diff) | |
download | gitlab-ce-91e01275cb7c63e8f101c016d83f725d0e7e6cb9.tar.gz |
Add tests to check for correct browse link name.
-rw-r--r-- | app/helpers/commits_helper.rb | 9 | ||||
-rw-r--r-- | features/project/source/browse_files.feature | 14 | ||||
-rw-r--r-- | features/steps/project/browse_files.rb | 28 |
3 files changed, 45 insertions, 6 deletions
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index 9643a0a965c..7100d679358 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -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 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 |