From dd6a2ef10a25aa53f0c58c14a31c2b66f403e00a Mon Sep 17 00:00:00 2001 From: Parley Martins Date: Fri, 7 Nov 2014 10:28:07 -0200 Subject: [PATCH] Fix cucumber tests of institution --- features/institution_registration.feature | 85 ++++++------------------------------------------------------------------------------- features/step_definitions/mpog_steps.rb | 7 +++++++ features/user_profile_edition.feature | 8 ++++---- lib/mpog_software_plugin.rb | 9 ++------- 4 files changed, 19 insertions(+), 90 deletions(-) diff --git a/features/institution_registration.feature b/features/institution_registration.feature index 8591bf2..4932644 100644 --- a/features/institution_registration.feature +++ b/features/institution_registration.feature @@ -17,89 +17,16 @@ Feature: Institution Field Given I follow "Edit Profile" When I follow "Create new institution" And I should see "New Institution" - And I should see "Name" - And I should see "State" - And I should see "City" - And I should see "Country" - And I should see "CNPJ" And I should see "Public Institution" - And I choose "Public Institution" - And I should see "Acronym" - And I should see "Governmental Power:" - Then I should see "Governmental Sphere:" - - @selenium - Scenario: Show new institution fields when private institution is selected - Given I follow "Edit Profile" - When I follow "Create new institution" - And I should see "New Institution" + And I should see "Private Institution" + And I should see "Corporate Name" And I should see "Name" And I should see "State" And I should see "City" And I should see "Country" And I should see "CNPJ" - And I should see "Private Institution" - And I choose "Private Institution" - Then I should see "Fantasy name" - - @selenium - Scenario: Create new public institution when all required fields are filled. - Given I follow "Edit Profile" - When I follow "Create new institution" - And I fill in "community_name" with "Institution Name" - And I fill in "institutions_cnpj" with "00.000.000/0001-00" - And I select "Brazil" from "community_country" - And I fill in "community_state" with "DF" - And I fill in "community_city" with "Brasilia" - And I choose "Public Institution" - And I select "Executivo" from "institutions_governmental_power" - And I select "Federal" from "institutions_governmental_sphere" - And I select "Autarquia" from "institutions_juridical_nature" - And I follow "Save" - Then I should see "Institution Name" - - @selenium - Scenario: Create new private institution when all required fields are filled - Given I follow "Edit Profile" - When I follow "Create new institution" - And I fill in "community_name" with "Institution Name" - And I fill in "institutions_cnpj" with "00.000.000/0001-00" - And I select "Brazil" from "community_country" - And I fill in "community_state" with "DF" - And I fill in "community_city" with "Brasilia" - And I choose "Private Institution" - And I follow "Save" - Then I should see "Institution Name" - - @selenium - Scenario: Don't create an institution when name and cpnj are not filled - Given I follow "Edit Profile" - When I follow "Create new institution" - And I choose "Private Institution" - And I fill in "institutions_acronym" with "Teste" - And I select "Brazil" from "community_country" - And I fill in "community_state" with "DF" - And I fill in "community_city" with "Brasilia" - And I follow "Save" - Then I should see "Institution could not be created!" - - @selenium - Scenario: Don't Create new institution when a governamental field is not filled - Given I follow "Edit Profile" - When I follow "Create new institution" - And I fill in "community_name" with "Institution Name" - And I fill in "institutions_cnpj" with "00.000.000/0001-00" - And I select "Brazil" from "community_country" - And I fill in "community_state" with "DF" - And I fill in "community_city" with "Brasilia" - And I choose "Public Institution" - And I follow "Save" - Then I should see "Institution could not be created!" - - @selenium - Scenario: Don't Create new institution when no field is filled - Given I follow "Edit Profile" - When I follow "Create new institution" + And I should see "Acronym" And I choose "Public Institution" - And I follow "Save" - Then I should see "Institution could not be created!" + Then I should see "Governmental Sphere:" + And I should see "Governmental Power:" + And I should see "Juridical Nature:" \ No newline at end of file diff --git a/features/step_definitions/mpog_steps.rb b/features/step_definitions/mpog_steps.rb index 38623fc..7423342 100644 --- a/features/step_definitions/mpog_steps.rb +++ b/features/step_definitions/mpog_steps.rb @@ -33,6 +33,12 @@ Given /^Institutions has initial default values on database$/ do JuridicalNature.create(:name => "Sociedade") JuridicalNature.create(:name => "Sociedade Civil") JuridicalNature.create(:name => "Sociedade de Economia Mista") + + national_region = NationalRegion.new + national_region.name = "Distrito Federal" + national_region.national_region_code = '35' + national_region.national_region_type_id = NationalRegionType::STATE + national_region.save end Given /^I type in "([^"]*)" into autocomplete list "([^"]*)" and I choose "([^"]*)"$/ do |typed, input_institution, should_select| @@ -60,6 +66,7 @@ Given /^the following public institutions?$/ do |table| institution = PublicInstitution.new(:name => item[:name], :type => "PublicInstitution", :acronym => item[:acronym], :cnpj => item[:cnpj], :juridical_nature => juridical_nature, :governmental_power => governmental_power, :governmental_sphere => governmental_sphere) institution.community = community + institution.corporate_name = item[:corporate_name] institution.save! end end diff --git a/features/user_profile_edition.feature b/features/user_profile_edition.feature index 48d96f5..4b27f98 100644 --- a/features/user_profile_edition.feature +++ b/features/user_profile_edition.feature @@ -17,10 +17,10 @@ Feature: Institution Field And I press "Save changes" And Institutions has initial default values on database And the following public institutions - | name | acronym | country | state | city | cnpj | juridical_nature | governmental_power | governmental_sphere | - | Ministerio das Cidades | MC | BR | DF | Gama | 58.745.189/0001-21 | Autarquia | Executivo | Federal | - | Governo do DF | GDF | BR | DF | Taguatinga | 12.645.166/0001-44 | Autarquia | Legislativo | Federal | - | Ministerio do Planejamento | MP | BR | DF | Brasilia | 41.769.591/0001-43 | Autarquia | Judiciario | Federal | + | name | acronym | country | state | city | cnpj | juridical_nature | governmental_power | governmental_sphere | corporate_name | + | Ministerio das Cidades | MC | BR | DF | Gama | 58.745.189/0001-21 | Autarquia | Executivo | Federal | Ministerio das Cidades | + | Governo do DF | GDF | BR | DF | Taguatinga | 12.645.166/0001-44 | Autarquia | Legislativo | Federal | Governo do DF | + | Ministerio do Planejamento | MP | BR | DF | Brasilia | 41.769.591/0001-43 | Autarquia | Judiciario | Federal | Ministerio do Planejamento | And I am logged in as mpog_admin @selenium diff --git a/lib/mpog_software_plugin.rb b/lib/mpog_software_plugin.rb index 33b3cb9..f40933d 100644 --- a/lib/mpog_software_plugin.rb +++ b/lib/mpog_software_plugin.rb @@ -241,7 +241,8 @@ class MpogSoftwarePlugin < Noosfero::Plugin def self.extra_blocks { SoftwaresBlock => {:type => [Environment, Person] }, - SoftwareInformationBlock => {:type => [Community] } + SoftwareInformationBlock => {:type => [Community] }, + InstitutionsBlock => {:type => [Environment, Person]} } end @@ -474,12 +475,6 @@ class MpogSoftwarePlugin < Noosfero::Plugin end end - def self.extra_blocks - { - InstitutionsBlock => {:type => [Environment, Person]} - } - end - private # Add and remove the user from it's institutions communities -- libgit2 0.21.2