From a49aca64264c38d9a34747590ad1e33d4e9a0e26 Mon Sep 17 00:00:00 2001 From: Alessandro Palmeira + Daniel Alves + Diego Araújo + Guilherme Rojas Date: Thu, 28 Feb 2013 17:49:20 -0300 Subject: [PATCH] [Mezuro] More acceptance tests for repository feature. --- features/step_definitions/mezuro_steps.rb | 24 +++++++++++++++++++----- plugins/mezuro/features/repository.feature | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 96 insertions(+), 17 deletions(-) diff --git a/features/step_definitions/mezuro_steps.rb b/features/step_definitions/mezuro_steps.rb index ca02ed3..af02743 100644 --- a/features/step_definitions/mezuro_steps.rb +++ b/features/step_definitions/mezuro_steps.rb @@ -60,11 +60,16 @@ Then /^I should see "([^"]*)" in the "([^"]*)" select$/ do |content, labeltext| find_field(labeltext).value.strip.should == content #strip because have empty spaces around some options end -Then /^I shoud see "([^"]*)" in the process period select field$/ do |content| +Then /^I should see "([^"]*)" in the process period select field$/ do |content| selected = MezuroPlugin::Helpers::ContentViewerHelper.periodicity_options.select { |option| option.first == content }.first assert_equal selected.last, find_field("repository_process_period").value.to_i end +Then /^I should see "([^"]*)" in the repository configuration select field$/ do |content| + selected = Kalibro::Configuration.all.select { |option| option.name == content }.first + assert_equal selected.id, find_field("repository_configuration_id").value.to_i +end + Then /^I should not see "([^"]*)" button$/ do |button_name| find_button(button_name).should be_nil end @@ -91,7 +96,7 @@ When /^I have a Mezuro (project|reading group|configuration|repository) with the puts Kalibro::Project.all.last.id item.merge(:configuration_id => Kalibro::Configuration.all.last.id) result = Kalibro::Repository.new(item) - raise (result.save Kalibro::Project.all.last.id).inspect + result.save Kalibro::Project.all.last.id else result.save! end @@ -113,8 +118,8 @@ When /^I fill the fields with the new following data$/ do |fields| end end -When /^I have a Mezuro metric configuration with previous created configuration and reading group/ do - Kalibro::MetricConfiguration.create({ +When /^I have a Mezuro metric configuration with previous created configuration and reading group$/ do + Kalibro::MetricConfiguration.create({ :code => 'amloc1', :metric => {:name => 'Total Coupling Factor', :compound => "false", :scope => 'SOFTWARE', :language => ['JAVA']}, :base_tool_name => "Analizo", @@ -122,5 +127,14 @@ When /^I have a Mezuro metric configuration with previous created configuration :aggregation_form => 'AVERAGE', :reading_group_id => Kalibro::ReadingGroup.all.last.id, :configuration_id => Kalibro::Configuration.all.last.id - }) + }) +end + +When /^I follow the (edit|remove) link for "([^"]*)" repository$/ do |action,repository_name| + project_id = Kalibro::Project.all.last.id + repositories = Kalibro::Repository.repositories_of project_id + repository_id = repositories.select {|option| option.name == repository_name}.first.id + elements = all('a', :text => action.capitalize) + action_link = elements.select {|element| (/repository_id=#{repository_id}/ =~ element[:href]) }.first + action_link.click end diff --git a/plugins/mezuro/features/repository.feature b/plugins/mezuro/features/repository.feature index 34a18f4..6740d75 100644 --- a/plugins/mezuro/features/repository.feature +++ b/plugins/mezuro/features/repository.feature @@ -81,7 +81,7 @@ Feature: Repository And I press "Add" Then I should see "Address does not match type GIT chosen." inside an alert - @selenium + @selenium-teste Scenario: I want to add a repository with valid attributes Given I follow "Add Repository" When I fill the fields with the new following data @@ -100,9 +100,10 @@ Feature: Repository And I should see "GIT" And I should see "https://github.com/user/project.git" And I should see "Sample Configuration" + And I should see "Status" #FIXME: create the step given I have repository... - @selenium + @selenium-teste Scenario: I want to see the repository edit form Given I follow "Add Repository" And I fill the fields with the new following data @@ -122,11 +123,11 @@ Feature: Repository And I should see "Not Periodically" in the process period select field And I should see "GIT" in the "repository_type" select And I should see "https://github.com/user/project.git" in the "repository_address" input - And I should see "Sample Configuration" in the "repository_configuration_id" select + And I should see "Sample Configuration" in the repository configuration select field #FIXME: create the step given I have repository... @selenium - Scenario: I want to see the repository edit form + Scenario: I edit a Mezuro project with valid attributes Given I follow "Add Repository" And I fill the fields with the new following data | repository_name | My Name | @@ -139,14 +140,23 @@ Feature: Repository And I press "Add" And I am on article "Sample Project" When I follow "Edit" - Then I should see "My Name" in the "repository_name" input - And I should see "My Description" in the "repository_description" input - And I should see "ISC License (ISC)" in the "repository_license" select - And I should see "Not Periodically" in the process period select field - And I should see "GIT" in the "repository_type" select - And I should see "https://github.com/user/project.git" in the "repository_address" input - And I should see "2" in the "repository_configuration_id" select - + And I fill the fields with the new following data + | repository_name | Another Name | + | repository_description | Another Description | + | repository_license | Apple Public Source License (APSL-2.0) | + | repository_process_period | Weekly | + | repository_type | SUBVERSION | + | repository_address | https://project.svn.sourceforge.net/svnroot/project | + | repository_configuration_id | Sample Configuration | + And I press "Add" + Then I should see "Another Name" + And I should see "Another Description" + And I should see "Apple Public Source License (APSL-2.0)" + And I should see "Weekly" + And I should see "SUBVERSION" + And I should see "https://project.svn.sourceforge.net/svnroot/project" + And I should see "Sample Configuration" + #FIXME: create the step given I have repository... @selenium Scenario: I try to edit a Mezuro project leaving empty its title @@ -184,4 +194,59 @@ Feature: Repository When I erase the "repository_address" field And I press "Add" Then I should see "Please fill all fields marked with (*)." inside an alert + + #FIXME: create the step given I have repository... + @selenium + Scenario: I try to edit a repository with an existing repository name + Given I follow "Add Repository" + And I fill the fields with the new following data + | repository_name | My Name | + | repository_description | My Description | + | repository_license | ISC License (ISC) | + | repository_process_period | Not Periodically | + | repository_type | GIT | + | repository_address | https://github.com/user/project.git | + | repository_configuration_id | Sample Configuration | + And I press "Add" + And I am on article "Sample Project" + And I follow "Add Repository" + And I fill the fields with the new following data + | repository_name | Another Name | + | repository_description | Another Description | + | repository_license | Apple Public Source License (APSL-2.0) | + | repository_process_period | Weekly | + | repository_type | SUBVERSION | + | repository_address | https://project.svn.sourceforge.net/svnroot/project | + | repository_configuration_id | Sample Configuration | + And I press "Add" + And I am on article "Sample Project" + When I follow the edit link for "My Name" repository + And I fill the fields with the new following data + | repository_name | Another Name | + | repository_description | Another Description | + | repository_license | Apple Public Source License (APSL-2.0) | + | repository_process_period | Weekly | + | repository_type | SUBVERSION | + | repository_address | https://project.svn.sourceforge.net/svnroot/project | + | repository_configuration_id | Sample Configuration | + And I press "Add" + #Then I should see "Slug The title (article name) is already being used by another article, please use another title." + #FIXME fix this validation + + #FIXME: Need to define permissions? + @selenium + Scenario: I delete a Mezuro repository + Given I follow "Add Repository" + And I fill the fields with the new following data + | repository_name | My Name | + | repository_description | My Description | + | repository_license | ISC License (ISC) | + | repository_process_period | Not Periodically | + | repository_type | GIT | + | repository_address | https://github.com/user/project.git | + | repository_configuration_id | Sample Configuration | + And I press "Add" + And I am on article "Sample Project" + When I follow the remove link for "My Name" repository + And I should not see "My Name" -- libgit2 0.21.2