Commit c36f36abd33cc5c1ff5a7fac9f81858f98476ac1
1 parent
079b2651
Exists in
colab
and in
4 other branches
Acceptance tests for repository edition
Also fixed a bug on the RepositoriesController for the case qhere some data is invalid
Showing
4 changed files
with
64 additions
and
1 deletions
Show diff stats
app/controllers/repositories_controller.rb
| ... | ... | @@ -58,6 +58,9 @@ class RepositoriesController < ApplicationController |
| 58 | 58 | format.html { redirect_to(project_repository_path(params[:project_id], @repository.id), notice: 'Repository was successfully updated.') } |
| 59 | 59 | format.json { head :no_content } |
| 60 | 60 | else |
| 61 | + @project_id = params[:project_id] | |
| 62 | + @repository_types = Repository.repository_types | |
| 63 | + | |
| 61 | 64 | format.html { render action: 'edit' } |
| 62 | 65 | format.json { render json: @repository.errors, status: :unprocessable_entity } |
| 63 | 66 | end | ... | ... |
| ... | ... | @@ -0,0 +1,51 @@ |
| 1 | +Feature: Repository Edit | |
| 2 | + In Order to be able to update my repositories info | |
| 3 | + As a regular user | |
| 4 | + I should be able to edit my repositories | |
| 5 | + | |
| 6 | + @kalibro_restart | |
| 7 | + Scenario: editing a repository successfully | |
| 8 | + Given I am a regular user | |
| 9 | + And I am signed in | |
| 10 | + And I own a sample project | |
| 11 | + And I have a sample configuration with native metrics | |
| 12 | + And I have a sample repository within the sample project named "QtCalculator" | |
| 13 | + And I start to process that repository | |
| 14 | + And I wait up for a ready processing | |
| 15 | + And I am at repository edit page | |
| 16 | + Then the field "Name" should be filled with "QtCalculator" | |
| 17 | + And the field "Type" should be filled with "SUBVERSION" | |
| 18 | + And the field "Address" should be filled with "svn://svn.code.sf.net/p/qt-calculator/code/trunk" | |
| 19 | + When I fill the Name field with "MedSquare" | |
| 20 | + And I set the select field "Type" as "GIT" | |
| 21 | + And I fill the Address field with "git://git.code.sf.net/p/medsquare/git" | |
| 22 | + And I press the Save button | |
| 23 | + Then I should see "MedSquare" | |
| 24 | + And I should see "git://git.code.sf.net/p/medsquare/git" | |
| 25 | + | |
| 26 | + @kalibro_restart | |
| 27 | + Scenario: editing a repository with blank fields | |
| 28 | + Given I am a regular user | |
| 29 | + And I am signed in | |
| 30 | + And I own a sample project | |
| 31 | + And I have a sample configuration with native metrics | |
| 32 | + And I have a sample repository within the sample project named "QtCalculator" | |
| 33 | + And I am at repository edit page | |
| 34 | + When I fill the Name field with " " | |
| 35 | + And I fill the Address field with " " | |
| 36 | + And I press the Save button | |
| 37 | + Then I should see "Name can't be blank" | |
| 38 | + And I should see "Address can't be blank" | |
| 39 | + | |
| 40 | + @kalibro_restart | |
| 41 | + Scenario: editing a repository with already taken name | |
| 42 | + Given I am a regular user | |
| 43 | + And I am signed in | |
| 44 | + And I own a sample project | |
| 45 | + And I have a sample configuration with native metrics | |
| 46 | + And I have a sample repository within the sample project named "MedSquare" | |
| 47 | + And I have a sample repository within the sample project named "QtCalculator" | |
| 48 | + And I am at repository edit page | |
| 49 | + When I fill the Name field with "MedSquare" | |
| 50 | + And I press the Save button | |
| 51 | + Then I should see "There's already" | ... | ... |
features/step_definitions/repository_steps.rb
| ... | ... | @@ -35,6 +35,10 @@ Given(/^I am at the New Repository page$/) do |
| 35 | 35 | visit new_project_repository_path(@project.id) |
| 36 | 36 | end |
| 37 | 37 | |
| 38 | +Given(/^I am at repository edit page$/) do | |
| 39 | + visit edit_project_repository_path(@repository.project_id, @repository.id) | |
| 40 | +end | |
| 41 | + | |
| 38 | 42 | When(/^I set the select field "(.+)" as "(.+)"$/) do |field, text| |
| 39 | 43 | select text, from: field |
| 40 | 44 | end |
| ... | ... | @@ -45,4 +49,8 @@ end |
| 45 | 49 | |
| 46 | 50 | Then(/^I should see the sample repository name$/) do |
| 47 | 51 | page.should have_content(@repository.name) |
| 48 | -end | |
| 49 | 52 | \ No newline at end of file |
| 53 | +end | |
| 54 | + | |
| 55 | +Then(/^the field "(.*?)" should be filled with "(.*?)"$/) do |field, value| | |
| 56 | + page.find_field(field).value.should eq(value) | |
| 57 | +end | ... | ... |
spec/controllers/repositories_controller_spec.rb
| ... | ... | @@ -210,6 +210,7 @@ describe RepositoriesController do |
| 210 | 210 | before :each do |
| 211 | 211 | Repository.expects(:find).at_least_once.with(repository.id).returns(repository) |
| 212 | 212 | Repository.any_instance.expects(:update).with(repository_params).returns(false) |
| 213 | + Repository.expects(:repository_types).returns([]) | |
| 213 | 214 | |
| 214 | 215 | post :update, project_id: project.id.to_s, :id => repository.id, :repository => repository_params |
| 215 | 216 | end | ... | ... |