Commit 723fb3b9db99be4e0b65a72694d803c8d9ae32ae
1 parent
5255150f
Exists in
master
and in
5 other branches
fix_institution: Fix some unit tests, add teardown
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com> Signed-off-by: Parley Martins <parley@outlook.com>
Showing
13 changed files
with
79 additions
and
21 deletions
Show diff stats
test/unit/communities_block_test.rb
| @@ -25,6 +25,16 @@ class CommunitiesBlockTest < ActiveSupport::TestCase | @@ -25,6 +25,16 @@ class CommunitiesBlockTest < ActiveSupport::TestCase | ||
| 25 | @comminities_block.expects(:owner).at_least_once.returns(@person) | 25 | @comminities_block.expects(:owner).at_least_once.returns(@person) |
| 26 | end | 26 | end |
| 27 | 27 | ||
| 28 | + def teardown | ||
| 29 | + GovernmentalPower.destroy_all | ||
| 30 | + GovernmentalSphere.destroy_all | ||
| 31 | + JuridicalNature.destroy_all | ||
| 32 | + CommunitiesBlock.destroy_all | ||
| 33 | + @person = nil | ||
| 34 | + @institution = nil | ||
| 35 | + @community = nil | ||
| 36 | + @software_info = nil | ||
| 37 | + end | ||
| 28 | should "not have community of software or institution in block" do | 38 | should "not have community of software or institution in block" do |
| 29 | assert_equal 1, @comminities_block.profile_list.count | 39 | assert_equal 1, @comminities_block.profile_list.count |
| 30 | end | 40 | end |
test/unit/database_helper_test.rb
| @@ -6,11 +6,11 @@ class DatabaseHelperTest < ActiveSupport::TestCase | @@ -6,11 +6,11 @@ class DatabaseHelperTest < ActiveSupport::TestCase | ||
| 6 | 6 | ||
| 7 | def setup | 7 | def setup |
| 8 | dd1 = DatabaseDescription.create(:name => "Oracle") | 8 | dd1 = DatabaseDescription.create(:name => "Oracle") |
| 9 | - dd2 = DatabaseDescription.create(:name => "MySQL") | 9 | + dd2 = DatabaseDescription.create!(:name => "MySQL") |
| 10 | 10 | ||
| 11 | @database_objects = [ | 11 | @database_objects = [ |
| 12 | {:database_description_id => dd1.id.to_s ,:version => "2.0", :operating_system => "debian"}, | 12 | {:database_description_id => dd1.id.to_s ,:version => "2.0", :operating_system => "debian"}, |
| 13 | - {:database_description_id => dd2.id.to_s ,:version => "2.1", :operating_system => "debian"}, | 13 | + {:database_description_id => dd2.id.to_s ,:version => "2.1", :operating_system => "debian"} |
| 14 | ] | 14 | ] |
| 15 | end | 15 | end |
| 16 | 16 | ||
| @@ -64,7 +64,7 @@ class DatabaseHelperTest < ActiveSupport::TestCase | @@ -64,7 +64,7 @@ class DatabaseHelperTest < ActiveSupport::TestCase | ||
| 64 | should "remove invalid tables from the list" do | 64 | should "remove invalid tables from the list" do |
| 65 | @database_objects.push({ | 65 | @database_objects.push({ |
| 66 | :database_description_id => "I'm not a valid id", | 66 | :database_description_id => "I'm not a valid id", |
| 67 | - :version => "2.0", | 67 | + :version => "2.5", |
| 68 | :operating_system => "debian" | 68 | :operating_system => "debian" |
| 69 | }) | 69 | }) |
| 70 | 70 |
test/unit/institution_test.rb
| @@ -11,6 +11,12 @@ class InstitutionTest < ActiveSupport::TestCase | @@ -11,6 +11,12 @@ class InstitutionTest < ActiveSupport::TestCase | ||
| 11 | @institution = create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", @juridical_nature, @gov_power, @gov_sphere, "11.222.333/4444-55") | 11 | @institution = create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", @juridical_nature, @gov_power, @gov_sphere, "11.222.333/4444-55") |
| 12 | end | 12 | end |
| 13 | 13 | ||
| 14 | + def teardown | ||
| 15 | + GovernmentalPower.destroy_all | ||
| 16 | + GovernmentalSphere.destroy_all | ||
| 17 | + JuridicalNature.destroy_all | ||
| 18 | + @institution = nil | ||
| 19 | + end | ||
| 14 | should "not save institutions without name" do | 20 | should "not save institutions without name" do |
| 15 | @institution.name = nil | 21 | @institution.name = nil |
| 16 | assert !@institution.save | 22 | assert !@institution.save |
test/unit/operating_system_helper_test.rb
| @@ -16,7 +16,7 @@ class OperatingSystemHelperTest < ActiveSupport::TestCase | @@ -16,7 +16,7 @@ class OperatingSystemHelperTest < ActiveSupport::TestCase | ||
| 16 | end | 16 | end |
| 17 | 17 | ||
| 18 | def teardown | 18 | def teardown |
| 19 | - @database_objects = nil | 19 | + @operating_system_objects = nil |
| 20 | end | 20 | end |
| 21 | 21 | ||
| 22 | should "return an empty list" do | 22 | should "return an empty list" do |
| @@ -44,7 +44,7 @@ class OperatingSystemHelperTest < ActiveSupport::TestCase | @@ -44,7 +44,7 @@ class OperatingSystemHelperTest < ActiveSupport::TestCase | ||
| 44 | assert_equal false,OperatingSystemHelper.valid_list_operating_system?(list_compare) | 44 | assert_equal false,OperatingSystemHelper.valid_list_operating_system?(list_compare) |
| 45 | end | 45 | end |
| 46 | 46 | ||
| 47 | - should "return a html text with operating system" do | 47 | + should "return a html text with operating system" do |
| 48 | operating_systems = [] | 48 | operating_systems = [] |
| 49 | 49 | ||
| 50 | operating_system = OperatingSystemName.new | 50 | operating_system = OperatingSystemName.new |
| @@ -57,5 +57,5 @@ class OperatingSystemHelperTest < ActiveSupport::TestCase | @@ -57,5 +57,5 @@ class OperatingSystemHelperTest < ActiveSupport::TestCase | ||
| 57 | operating_systems << software_operating_system | 57 | operating_systems << software_operating_system |
| 58 | 58 | ||
| 59 | assert_not_nil OperatingSystemHelper.operating_system_as_tables(operating_systems).first.call.index(OperatingSystemName.first.name) | 59 | assert_not_nil OperatingSystemHelper.operating_system_as_tables(operating_systems).first.call.index(OperatingSystemName.first.name) |
| 60 | - end | 60 | + end |
| 61 | end | 61 | end |
test/unit/operating_system_validation_test.rb
| @@ -9,6 +9,10 @@ class OperatingSystemValidationTest < ActiveSupport::TestCase | @@ -9,6 +9,10 @@ class OperatingSystemValidationTest < ActiveSupport::TestCase | ||
| 9 | @operating_system | 9 | @operating_system |
| 10 | end | 10 | end |
| 11 | 11 | ||
| 12 | + def teardown | ||
| 13 | + @operating_system.destroy | ||
| 14 | + end | ||
| 15 | + | ||
| 12 | should "save OperatingSystem if all fields are filled" do | 16 | should "save OperatingSystem if all fields are filled" do |
| 13 | assert @operating_system.save | 17 | assert @operating_system.save |
| 14 | end | 18 | end |
test/unit/private_institution_test.rb
| @@ -7,6 +7,11 @@ class PrivateInstitutionTest < ActiveSupport::TestCase | @@ -7,6 +7,11 @@ class PrivateInstitutionTest < ActiveSupport::TestCase | ||
| 7 | @institution = create_private_institution "Simple Private Institution", "SPI", "BR", "DF", "Gama", "00.000.000/0001-00" | 7 | @institution = create_private_institution "Simple Private Institution", "SPI", "BR", "DF", "Gama", "00.000.000/0001-00" |
| 8 | end | 8 | end |
| 9 | 9 | ||
| 10 | + def teardown | ||
| 11 | + @institution = nil | ||
| 12 | + Institution.destroy_all | ||
| 13 | + end | ||
| 14 | + | ||
| 10 | should "not save without a cnpj" do | 15 | should "not save without a cnpj" do |
| 11 | @institution.cnpj = nil | 16 | @institution.cnpj = nil |
| 12 | 17 |
test/unit/public_institution_test.rb
| @@ -11,6 +11,17 @@ class PublicInstitutionTest < ActiveSupport::TestCase | @@ -11,6 +11,17 @@ class PublicInstitutionTest < ActiveSupport::TestCase | ||
| 11 | @institution = create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", @juridical_nature, @gov_power, @gov_sphere, "11.222.333/4444-55") | 11 | @institution = create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", @juridical_nature, @gov_power, @gov_sphere, "11.222.333/4444-55") |
| 12 | end | 12 | end |
| 13 | 13 | ||
| 14 | + def teardown | ||
| 15 | + GovernmentalPower.destroy_all | ||
| 16 | + GovernmentalSphere.destroy_all | ||
| 17 | + JuridicalNature.destroy_all | ||
| 18 | + Institution.destroy_all | ||
| 19 | + @gov_power = nil | ||
| 20 | + @gov_sphere = nil | ||
| 21 | + @juridical_nature = nil | ||
| 22 | + @institution = nil | ||
| 23 | + end | ||
| 24 | + | ||
| 14 | should "not save without a cnpj" do | 25 | should "not save without a cnpj" do |
| 15 | @institution.cnpj = nil | 26 | @institution.cnpj = nil |
| 16 | assert !@institution.save | 27 | assert !@institution.save |
test/unit/search_person_test.rb
| @@ -10,6 +10,10 @@ class SearchPersonTest < ActiveSupport::TestCase | @@ -10,6 +10,10 @@ class SearchPersonTest < ActiveSupport::TestCase | ||
| 10 | create_person("Joao_da_silva_costa_cunha", "joao_da_silva_costa_cunha@email.com", "aaaaaaa", "aaaaaaa", "joao_cunha@email.com" ,"RJ", "Rio de Janeiro") | 10 | create_person("Joao_da_silva_costa_cunha", "joao_da_silva_costa_cunha@email.com", "aaaaaaa", "aaaaaaa", "joao_cunha@email.com" ,"RJ", "Rio de Janeiro") |
| 11 | end | 11 | end |
| 12 | 12 | ||
| 13 | + def teardown | ||
| 14 | + Person.destroy_all | ||
| 15 | + end | ||
| 16 | + | ||
| 13 | should "Find people with Jo in name" do | 17 | should "Find people with Jo in name" do |
| 14 | people_list = Person.search("Jo") | 18 | people_list = Person.search("Jo") |
| 15 | 19 | ||
| @@ -46,4 +50,4 @@ class SearchPersonTest < ActiveSupport::TestCase | @@ -46,4 +50,4 @@ class SearchPersonTest < ActiveSupport::TestCase | ||
| 46 | assert_equal 1, people_list.count | 50 | assert_equal 1, people_list.count |
| 47 | end | 51 | end |
| 48 | 52 | ||
| 49 | -end | ||
| 50 | \ No newline at end of file | 53 | \ No newline at end of file |
| 54 | +end |
test/unit/software_categories_test.rb
| @@ -44,6 +44,11 @@ class SoftwareCategoriesTest < ActiveSupport::TestCase | @@ -44,6 +44,11 @@ class SoftwareCategoriesTest < ActiveSupport::TestCase | ||
| 44 | def teardown | 44 | def teardown |
| 45 | SoftwareDatabase.destroy_all | 45 | SoftwareDatabase.destroy_all |
| 46 | DatabaseDescription.destroy_all | 46 | DatabaseDescription.destroy_all |
| 47 | + ProgrammingLanguage.destroy_all | ||
| 48 | + SoftwareLanguage.destroy_all | ||
| 49 | + OperatingSystem.destroy_all | ||
| 50 | + SoftwareCategories.destroy_all | ||
| 51 | + SoftwareInfo.destroy_all | ||
| 47 | end | 52 | end |
| 48 | 53 | ||
| 49 | should "save software correctly with SoftwareCategories filds" do | 54 | should "save software correctly with SoftwareCategories filds" do |
test/unit/software_database_test.rb
| 1 | require File.dirname(__FILE__) + '/../../../../test/test_helper' | 1 | require File.dirname(__FILE__) + '/../../../../test/test_helper' |
| 2 | 2 | ||
| 3 | class SoftwareDatabaseTest < ActiveSupport::TestCase | 3 | class SoftwareDatabaseTest < ActiveSupport::TestCase |
| 4 | - DatabaseDescription.create!(name: "MySQL") | ||
| 5 | - | ||
| 6 | def setup | 4 | def setup |
| 5 | + DatabaseDescription.create!(name: "PostgreSQL") | ||
| 7 | @software_database = SoftwareDatabase.new(:version => "1.0", :operating_system => "Debian") | 6 | @software_database = SoftwareDatabase.new(:version => "1.0", :operating_system => "Debian") |
| 8 | @software_database.database_description_id = 1 | 7 | @software_database.database_description_id = 1 |
| 9 | end | 8 | end |
test/unit/software_info_validation_test.rb
| @@ -39,6 +39,17 @@ class SoftwareInfoValidationTest < ActiveSupport::TestCase | @@ -39,6 +39,17 @@ class SoftwareInfoValidationTest < ActiveSupport::TestCase | ||
| 39 | @software_info.software_categories = software_categories | 39 | @software_info.software_categories = software_categories |
| 40 | end | 40 | end |
| 41 | 41 | ||
| 42 | + def teardown | ||
| 43 | + ProgrammingLanguage.destroy_all | ||
| 44 | + SoftwareLanguage.destroy_all | ||
| 45 | + DatabaseDescription.destroy_all | ||
| 46 | + SoftwareDatabase.destroy_all | ||
| 47 | + OperatingSystem.destroy_all | ||
| 48 | + OperatingSystemName.destroy_all | ||
| 49 | + SoftwareInfo.destroy_all | ||
| 50 | + SoftwareCategories.destroy_all | ||
| 51 | + end | ||
| 52 | + | ||
| 42 | should 'Save SoftwareInfo if all fields are filled' do | 53 | should 'Save SoftwareInfo if all fields are filled' do |
| 43 | assert_equal true, @software_info.save | 54 | assert_equal true, @software_info.save |
| 44 | end | 55 | end |
test/unit/software_language_validation.rb
| @@ -7,6 +7,11 @@ class SoftwareLanguageValidationTest < ActiveSupport::TestCase | @@ -7,6 +7,11 @@ class SoftwareLanguageValidationTest < ActiveSupport::TestCase | ||
| 7 | @software_info.save | 7 | @software_info.save |
| 8 | end | 8 | end |
| 9 | 9 | ||
| 10 | + def teardown | ||
| 11 | + @software_info = nil | ||
| 12 | + SoftwareInfo.destroy_all | ||
| 13 | + end | ||
| 14 | + | ||
| 10 | should "Save SoftwareLanguage if version and programming_language are filled" do | 15 | should "Save SoftwareLanguage if version and programming_language are filled" do |
| 11 | @software_language = create_software_language | 16 | @software_language = create_software_language |
| 12 | assert_equal true, @software_language.save | 17 | assert_equal true, @software_language.save |
test/unit/software_license_info_test.rb
| @@ -2,24 +2,22 @@ require File.dirname(__FILE__) + '/../../../../test/test_helper' | @@ -2,24 +2,22 @@ require File.dirname(__FILE__) + '/../../../../test/test_helper' | ||
| 2 | 2 | ||
| 3 | class SoftwareDatabaseTest < ActiveSupport::TestCase | 3 | class SoftwareDatabaseTest < ActiveSupport::TestCase |
| 4 | 4 | ||
| 5 | - # def setup | ||
| 6 | - # software_license_info = LicenseInfo.new(:version => "1.0", :link => "www.gpl2.com") | ||
| 7 | - # end | 5 | + def setup |
| 6 | + @software_license_info = LicenseInfo.create!(:version => "1.0", :link => "www.gpl2.com") | ||
| 7 | + end | ||
| 8 | 8 | ||
| 9 | should "save if all informations are filled" do | 9 | should "save if all informations are filled" do |
| 10 | - software_license_info = LicenseInfo.new(:version => "1.0", :link => "www.gpl2.com") | ||
| 11 | - assert software_license_info.save, "License Info should have been saved" | 10 | + puts @software_license_info.inspect |
| 11 | + assert @software_license_info.save!, "License Info should have been saved" | ||
| 12 | end | 12 | end |
| 13 | 13 | ||
| 14 | should "not save if license info version is empty" do | 14 | should "not save if license info version is empty" do |
| 15 | - software_license_info = LicenseInfo.new(:version => "1.0", :link => "www.gpl2.com") | ||
| 16 | - software_license_info.version = nil | ||
| 17 | - assert !software_license_info.save, "Version can't be blank" | 15 | + @software_license_info.version = nil |
| 16 | + assert !@software_license_info.save, "Version can't be blank" | ||
| 18 | end | 17 | end |
| 19 | 18 | ||
| 20 | should "save if link is empty" do | 19 | should "save if link is empty" do |
| 21 | - software_license_info = LicenseInfo.new(:version => "1.0", :link => "www.gpl2.com") | ||
| 22 | - software_license_info.link = nil | ||
| 23 | - assert software_license_info.save, "License info should have been saved" | 20 | + @software_license_info.link = nil |
| 21 | + assert @oftware_license_info.save, "License info should have been saved" | ||
| 24 | end | 22 | end |
| 25 | -end | ||
| 26 | \ No newline at end of file | 23 | \ No newline at end of file |
| 24 | +end |