From 551145bc98e257280b615e305d531a44d7aa4131 Mon Sep 17 00:00:00 2001 From: Robert Schilling Date: Sun, 27 Jul 2014 16:40:00 +0200 Subject: Validate branch-names and references in WebUI, API Add specs for GitRefValidator --- features/project/commits/branches.feature | 18 ++++++++++++++++ features/steps/project/browse_branches.rb | 34 ++++++++++++++++++++++++++++--- 2 files changed, 49 insertions(+), 3 deletions(-) (limited to 'features') diff --git a/features/project/commits/branches.feature b/features/project/commits/branches.feature index d657bd4951f..6725a697c21 100644 --- a/features/project/commits/branches.feature +++ b/features/project/commits/branches.feature @@ -23,3 +23,21 @@ Feature: Project Browse branches Given I visit project branches page And I click branch 'improve/awesome' delete link Then I should not see branch 'improve/awesome' + + Scenario: I create a branch with invalid name + Given I visit project branches page + And I click new branch link + When I submit new branch form with invalid name + Then I should see new an error that branch is invalid + + Scenario: I create a branch with invalid reference + Given I visit project branches page + And I click new branch link + When I submit new branch form with invalid reference + Then I should see new an error that ref is invalid + + Scenario: I create a branch that already exists + Given I visit project branches page + And I click new branch link + When I submit new branch form with branch that already exists + Then I should see new an error that branch already exists diff --git a/features/steps/project/browse_branches.rb b/features/steps/project/browse_branches.rb index c00a95a62fd..cfc88bdad22 100644 --- a/features/steps/project/browse_branches.rb +++ b/features/steps/project/browse_branches.rb @@ -38,10 +38,38 @@ class ProjectBrowseBranches < Spinach::FeatureSteps click_button 'Create branch' end + step 'I submit new branch form with invalid name' do + fill_in 'branch_name', with: '1.0 stable' + fill_in 'ref', with: 'master' + click_button 'Create branch' + end + + step 'I submit new branch form with invalid reference' do + fill_in 'branch_name', with: 'foo' + fill_in 'ref', with: 'foo' + click_button 'Create branch' + end + + step 'I submit new branch form with branch that already exists' do + fill_in 'branch_name', with: 'master' + fill_in 'ref', with: 'master' + click_button 'Create branch' + end + step 'I should see new branch created' do - within '.tree-ref-holder' do - page.should have_content 'deploy_keys' - end + page.should have_content 'deploy_keys' + end + + step 'I should see new an error that branch is invalid' do + page.should have_content 'Branch name invalid' + end + + step 'I should see new an error that ref is invalid' do + page.should have_content 'Invalid reference name' + end + + step 'I should see new an error that branch already exists' do + page.should have_content 'Branch already exists' end step "I click branch 'improve/awesome' delete link" do -- cgit v1.2.1 From 392113919adc75ba1537d89a0de8d0641e24d5b8 Mon Sep 17 00:00:00 2001 From: Robert Schilling Date: Sun, 27 Jul 2014 19:56:33 +0200 Subject: Validate tag-names and references in WebUI, API --- features/project/commits/branches.feature | 8 +++--- features/project/commits/tags.feature | 20 ++++++++++++++ features/steps/project/browse_tags.rb | 46 ++++++++++++++++++++++++++++++- 3 files changed, 69 insertions(+), 5 deletions(-) (limited to 'features') diff --git a/features/project/commits/branches.feature b/features/project/commits/branches.feature index 6725a697c21..d124cb7eecd 100644 --- a/features/project/commits/branches.feature +++ b/features/project/commits/branches.feature @@ -15,7 +15,7 @@ Feature: Project Browse branches Scenario: I create a branch Given I visit project branches page And I click new branch link - When I submit new branch form + And I submit new branch form Then I should see new branch created @javascript @@ -27,17 +27,17 @@ Feature: Project Browse branches Scenario: I create a branch with invalid name Given I visit project branches page And I click new branch link - When I submit new branch form with invalid name + And I submit new branch form with invalid name Then I should see new an error that branch is invalid Scenario: I create a branch with invalid reference Given I visit project branches page And I click new branch link - When I submit new branch form with invalid reference + And I submit new branch form with invalid reference Then I should see new an error that ref is invalid Scenario: I create a branch that already exists Given I visit project branches page And I click new branch link - When I submit new branch form with branch that already exists + And I submit new branch form with branch that already exists Then I should see new an error that branch already exists diff --git a/features/project/commits/tags.feature b/features/project/commits/tags.feature index 1ac0f8bfa45..36c7a6492ff 100644 --- a/features/project/commits/tags.feature +++ b/features/project/commits/tags.feature @@ -7,5 +7,25 @@ Feature: Project Browse tags Scenario: I can see all git tags Then I should see "Shop" all tags list + Scenario: I create a tag + And I click new tag link + And I submit new tag form + Then I should see new tag created + + Scenario: I create a tag with invalid name + And I click new tag link + And I submit new tag form with invalid name + Then I should see new an error that tag is invalid + + Scenario: I create a tag with invalid reference + And I click new tag link + And I submit new tag form with invalid reference + Then I should see new an error that tag ref is invalid + + Scenario: I create a tag that already exists + And I click new tag link + And I submit new tag form with tag that already exists + Then I should see new an error that tag already exists + # @wip # Scenario: I can download project by tag diff --git a/features/steps/project/browse_tags.rb b/features/steps/project/browse_tags.rb index 7c679911e00..64c0c284f6c 100644 --- a/features/steps/project/browse_tags.rb +++ b/features/steps/project/browse_tags.rb @@ -3,8 +3,52 @@ class ProjectBrowseTags < Spinach::FeatureSteps include SharedProject include SharedPaths - Then 'I should see "Shop" all tags list' do + step 'I should see "Shop" all tags list' do page.should have_content "Tags" page.should have_content "v1.0.0" end + + step 'I click new tag link' do + click_link 'New tag' + end + + step 'I submit new tag form' do + fill_in 'tag_name', with: 'v7.0' + fill_in 'ref', with: 'master' + click_button 'Create tag' + end + + step 'I submit new tag form with invalid name' do + fill_in 'tag_name', with: 'v 1.0' + fill_in 'ref', with: 'master' + click_button 'Create tag' + end + + step 'I submit new tag form with invalid reference' do + fill_in 'tag_name', with: 'foo' + fill_in 'ref', with: 'foo' + click_button 'Create tag' + end + + step 'I submit new tag form with tag that already exists' do + fill_in 'tag_name', with: 'v1.0.0' + fill_in 'ref', with: 'master' + click_button 'Create tag' + end + + step 'I should see new tag created' do + page.should have_content 'v7.0' + end + + step 'I should see new an error that tag is invalid' do + page.should have_content 'Tag name invalid' + end + + step 'I should see new an error that tag ref is invalid' do + page.should have_content 'Invalid reference name' + end + + step 'I should see new an error that tag already exists' do + page.should have_content 'Tag already exists' + end end -- cgit v1.2.1