diff --git a/test/unit/communities_block_test.rb b/test/unit/communities_block_test.rb index 48a14fc..c5be634 100644 --- a/test/unit/communities_block_test.rb +++ b/test/unit/communities_block_test.rb @@ -25,6 +25,16 @@ class CommunitiesBlockTest < ActiveSupport::TestCase @comminities_block.expects(:owner).at_least_once.returns(@person) end + def teardown + GovernmentalPower.destroy_all + GovernmentalSphere.destroy_all + JuridicalNature.destroy_all + CommunitiesBlock.destroy_all + @person = nil + @institution = nil + @community = nil + @software_info = nil + end should "not have community of software or institution in block" do assert_equal 1, @comminities_block.profile_list.count end diff --git a/test/unit/database_helper_test.rb b/test/unit/database_helper_test.rb index 326f6b9..7bc6f44 100644 --- a/test/unit/database_helper_test.rb +++ b/test/unit/database_helper_test.rb @@ -6,11 +6,11 @@ class DatabaseHelperTest < ActiveSupport::TestCase def setup dd1 = DatabaseDescription.create(:name => "Oracle") - dd2 = DatabaseDescription.create(:name => "MySQL") + dd2 = DatabaseDescription.create!(:name => "MySQL") @database_objects = [ {:database_description_id => dd1.id.to_s ,:version => "2.0", :operating_system => "debian"}, - {:database_description_id => dd2.id.to_s ,:version => "2.1", :operating_system => "debian"}, + {:database_description_id => dd2.id.to_s ,:version => "2.1", :operating_system => "debian"} ] end @@ -64,7 +64,7 @@ class DatabaseHelperTest < ActiveSupport::TestCase should "remove invalid tables from the list" do @database_objects.push({ :database_description_id => "I'm not a valid id", - :version => "2.0", + :version => "2.5", :operating_system => "debian" }) diff --git a/test/unit/institution_test.rb b/test/unit/institution_test.rb index a4ef1b1..db3b149 100644 --- a/test/unit/institution_test.rb +++ b/test/unit/institution_test.rb @@ -11,6 +11,12 @@ class InstitutionTest < ActiveSupport::TestCase @institution = create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", @juridical_nature, @gov_power, @gov_sphere, "11.222.333/4444-55") end + def teardown + GovernmentalPower.destroy_all + GovernmentalSphere.destroy_all + JuridicalNature.destroy_all + @institution = nil + end should "not save institutions without name" do @institution.name = nil assert !@institution.save diff --git a/test/unit/operating_system_helper_test.rb b/test/unit/operating_system_helper_test.rb index c34b279..5fc4092 100644 --- a/test/unit/operating_system_helper_test.rb +++ b/test/unit/operating_system_helper_test.rb @@ -16,7 +16,7 @@ class OperatingSystemHelperTest < ActiveSupport::TestCase end def teardown - @database_objects = nil + @operating_system_objects = nil end should "return an empty list" do @@ -44,7 +44,7 @@ class OperatingSystemHelperTest < ActiveSupport::TestCase assert_equal false,OperatingSystemHelper.valid_list_operating_system?(list_compare) end - should "return a html text with operating system" do + should "return a html text with operating system" do operating_systems = [] operating_system = OperatingSystemName.new @@ -57,5 +57,5 @@ class OperatingSystemHelperTest < ActiveSupport::TestCase operating_systems << software_operating_system assert_not_nil OperatingSystemHelper.operating_system_as_tables(operating_systems).first.call.index(OperatingSystemName.first.name) - end + end end diff --git a/test/unit/operating_system_validation_test.rb b/test/unit/operating_system_validation_test.rb index 11058fa..19996ac 100644 --- a/test/unit/operating_system_validation_test.rb +++ b/test/unit/operating_system_validation_test.rb @@ -9,6 +9,10 @@ class OperatingSystemValidationTest < ActiveSupport::TestCase @operating_system end + def teardown + @operating_system.destroy + end + should "save OperatingSystem if all fields are filled" do assert @operating_system.save end diff --git a/test/unit/private_institution_test.rb b/test/unit/private_institution_test.rb index 073ac9e..03a1d0d 100644 --- a/test/unit/private_institution_test.rb +++ b/test/unit/private_institution_test.rb @@ -7,6 +7,11 @@ class PrivateInstitutionTest < ActiveSupport::TestCase @institution = create_private_institution "Simple Private Institution", "SPI", "BR", "DF", "Gama", "00.000.000/0001-00" end + def teardown + @institution = nil + Institution.destroy_all + end + should "not save without a cnpj" do @institution.cnpj = nil diff --git a/test/unit/public_institution_test.rb b/test/unit/public_institution_test.rb index 940959e..b3be359 100644 --- a/test/unit/public_institution_test.rb +++ b/test/unit/public_institution_test.rb @@ -11,6 +11,17 @@ class PublicInstitutionTest < ActiveSupport::TestCase @institution = create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", @juridical_nature, @gov_power, @gov_sphere, "11.222.333/4444-55") end + def teardown + GovernmentalPower.destroy_all + GovernmentalSphere.destroy_all + JuridicalNature.destroy_all + Institution.destroy_all + @gov_power = nil + @gov_sphere = nil + @juridical_nature = nil + @institution = nil + end + should "not save without a cnpj" do @institution.cnpj = nil assert !@institution.save diff --git a/test/unit/search_person_test.rb b/test/unit/search_person_test.rb index 502e5be..de20568 100644 --- a/test/unit/search_person_test.rb +++ b/test/unit/search_person_test.rb @@ -10,6 +10,10 @@ class SearchPersonTest < ActiveSupport::TestCase create_person("Joao_da_silva_costa_cunha", "joao_da_silva_costa_cunha@email.com", "aaaaaaa", "aaaaaaa", "joao_cunha@email.com" ,"RJ", "Rio de Janeiro") end + def teardown + Person.destroy_all + end + should "Find people with Jo in name" do people_list = Person.search("Jo") @@ -46,4 +50,4 @@ class SearchPersonTest < ActiveSupport::TestCase assert_equal 1, people_list.count end -end \ No newline at end of file +end diff --git a/test/unit/software_categories_test.rb b/test/unit/software_categories_test.rb index 8ecd009..e1fd93c 100644 --- a/test/unit/software_categories_test.rb +++ b/test/unit/software_categories_test.rb @@ -44,6 +44,11 @@ class SoftwareCategoriesTest < ActiveSupport::TestCase def teardown SoftwareDatabase.destroy_all DatabaseDescription.destroy_all + ProgrammingLanguage.destroy_all + SoftwareLanguage.destroy_all + OperatingSystem.destroy_all + SoftwareCategories.destroy_all + SoftwareInfo.destroy_all end should "save software correctly with SoftwareCategories filds" do diff --git a/test/unit/software_database_test.rb b/test/unit/software_database_test.rb index ddd0014..c70bbd0 100644 --- a/test/unit/software_database_test.rb +++ b/test/unit/software_database_test.rb @@ -1,9 +1,8 @@ require File.dirname(__FILE__) + '/../../../../test/test_helper' class SoftwareDatabaseTest < ActiveSupport::TestCase - DatabaseDescription.create!(name: "MySQL") - def setup + DatabaseDescription.create!(name: "PostgreSQL") @software_database = SoftwareDatabase.new(:version => "1.0", :operating_system => "Debian") @software_database.database_description_id = 1 end diff --git a/test/unit/software_info_validation_test.rb b/test/unit/software_info_validation_test.rb index 2ddcb11..7b8ab08 100644 --- a/test/unit/software_info_validation_test.rb +++ b/test/unit/software_info_validation_test.rb @@ -39,6 +39,17 @@ class SoftwareInfoValidationTest < ActiveSupport::TestCase @software_info.software_categories = software_categories end + def teardown + ProgrammingLanguage.destroy_all + SoftwareLanguage.destroy_all + DatabaseDescription.destroy_all + SoftwareDatabase.destroy_all + OperatingSystem.destroy_all + OperatingSystemName.destroy_all + SoftwareInfo.destroy_all + SoftwareCategories.destroy_all + end + should 'Save SoftwareInfo if all fields are filled' do assert_equal true, @software_info.save end diff --git a/test/unit/software_language_validation.rb b/test/unit/software_language_validation.rb index ee5290c..605094c 100644 --- a/test/unit/software_language_validation.rb +++ b/test/unit/software_language_validation.rb @@ -7,6 +7,11 @@ class SoftwareLanguageValidationTest < ActiveSupport::TestCase @software_info.save end + def teardown + @software_info = nil + SoftwareInfo.destroy_all + end + should "Save SoftwareLanguage if version and programming_language are filled" do @software_language = create_software_language assert_equal true, @software_language.save diff --git a/test/unit/software_license_info_test.rb b/test/unit/software_license_info_test.rb index 01964bb..b4a686d 100644 --- a/test/unit/software_license_info_test.rb +++ b/test/unit/software_license_info_test.rb @@ -2,24 +2,22 @@ require File.dirname(__FILE__) + '/../../../../test/test_helper' class SoftwareDatabaseTest < ActiveSupport::TestCase - # def setup - # software_license_info = LicenseInfo.new(:version => "1.0", :link => "www.gpl2.com") - # end + def setup + @software_license_info = LicenseInfo.create!(:version => "1.0", :link => "www.gpl2.com") + end should "save if all informations are filled" do - software_license_info = LicenseInfo.new(:version => "1.0", :link => "www.gpl2.com") - assert software_license_info.save, "License Info should have been saved" + puts @software_license_info.inspect + assert @software_license_info.save!, "License Info should have been saved" end should "not save if license info version is empty" do - software_license_info = LicenseInfo.new(:version => "1.0", :link => "www.gpl2.com") - software_license_info.version = nil - assert !software_license_info.save, "Version can't be blank" + @software_license_info.version = nil + assert !@software_license_info.save, "Version can't be blank" end should "save if link is empty" do - software_license_info = LicenseInfo.new(:version => "1.0", :link => "www.gpl2.com") - software_license_info.link = nil - assert software_license_info.save, "License info should have been saved" + @software_license_info.link = nil + assert @oftware_license_info.save, "License info should have been saved" end -end \ No newline at end of file +end -- libgit2 0.21.2