Commit 723fb3b9db99be4e0b65a72694d803c8d9ae32ae
1 parent
5255150f
Exists in
master
and in
79 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 | 25 | @comminities_block.expects(:owner).at_least_once.returns(@person) |
26 | 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 | 38 | should "not have community of software or institution in block" do |
29 | 39 | assert_equal 1, @comminities_block.profile_list.count |
30 | 40 | end | ... | ... |
test/unit/database_helper_test.rb
... | ... | @@ -6,11 +6,11 @@ class DatabaseHelperTest < ActiveSupport::TestCase |
6 | 6 | |
7 | 7 | def setup |
8 | 8 | dd1 = DatabaseDescription.create(:name => "Oracle") |
9 | - dd2 = DatabaseDescription.create(:name => "MySQL") | |
9 | + dd2 = DatabaseDescription.create!(:name => "MySQL") | |
10 | 10 | |
11 | 11 | @database_objects = [ |
12 | 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 | 15 | end |
16 | 16 | |
... | ... | @@ -64,7 +64,7 @@ class DatabaseHelperTest < ActiveSupport::TestCase |
64 | 64 | should "remove invalid tables from the list" do |
65 | 65 | @database_objects.push({ |
66 | 66 | :database_description_id => "I'm not a valid id", |
67 | - :version => "2.0", | |
67 | + :version => "2.5", | |
68 | 68 | :operating_system => "debian" |
69 | 69 | }) |
70 | 70 | ... | ... |
test/unit/institution_test.rb
... | ... | @@ -11,6 +11,12 @@ class InstitutionTest < ActiveSupport::TestCase |
11 | 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 | 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 | 20 | should "not save institutions without name" do |
15 | 21 | @institution.name = nil |
16 | 22 | assert !@institution.save | ... | ... |
test/unit/operating_system_helper_test.rb
... | ... | @@ -16,7 +16,7 @@ class OperatingSystemHelperTest < ActiveSupport::TestCase |
16 | 16 | end |
17 | 17 | |
18 | 18 | def teardown |
19 | - @database_objects = nil | |
19 | + @operating_system_objects = nil | |
20 | 20 | end |
21 | 21 | |
22 | 22 | should "return an empty list" do |
... | ... | @@ -44,7 +44,7 @@ class OperatingSystemHelperTest < ActiveSupport::TestCase |
44 | 44 | assert_equal false,OperatingSystemHelper.valid_list_operating_system?(list_compare) |
45 | 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 | 48 | operating_systems = [] |
49 | 49 | |
50 | 50 | operating_system = OperatingSystemName.new |
... | ... | @@ -57,5 +57,5 @@ class OperatingSystemHelperTest < ActiveSupport::TestCase |
57 | 57 | operating_systems << software_operating_system |
58 | 58 | |
59 | 59 | assert_not_nil OperatingSystemHelper.operating_system_as_tables(operating_systems).first.call.index(OperatingSystemName.first.name) |
60 | - end | |
60 | + end | |
61 | 61 | end | ... | ... |
test/unit/operating_system_validation_test.rb
... | ... | @@ -9,6 +9,10 @@ class OperatingSystemValidationTest < ActiveSupport::TestCase |
9 | 9 | @operating_system |
10 | 10 | end |
11 | 11 | |
12 | + def teardown | |
13 | + @operating_system.destroy | |
14 | + end | |
15 | + | |
12 | 16 | should "save OperatingSystem if all fields are filled" do |
13 | 17 | assert @operating_system.save |
14 | 18 | end | ... | ... |
test/unit/private_institution_test.rb
... | ... | @@ -7,6 +7,11 @@ class PrivateInstitutionTest < ActiveSupport::TestCase |
7 | 7 | @institution = create_private_institution "Simple Private Institution", "SPI", "BR", "DF", "Gama", "00.000.000/0001-00" |
8 | 8 | end |
9 | 9 | |
10 | + def teardown | |
11 | + @institution = nil | |
12 | + Institution.destroy_all | |
13 | + end | |
14 | + | |
10 | 15 | should "not save without a cnpj" do |
11 | 16 | @institution.cnpj = nil |
12 | 17 | ... | ... |
test/unit/public_institution_test.rb
... | ... | @@ -11,6 +11,17 @@ class PublicInstitutionTest < ActiveSupport::TestCase |
11 | 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 | 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 | 25 | should "not save without a cnpj" do |
15 | 26 | @institution.cnpj = nil |
16 | 27 | assert !@institution.save | ... | ... |
test/unit/search_person_test.rb
... | ... | @@ -10,6 +10,10 @@ class SearchPersonTest < ActiveSupport::TestCase |
10 | 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 | 11 | end |
12 | 12 | |
13 | + def teardown | |
14 | + Person.destroy_all | |
15 | + end | |
16 | + | |
13 | 17 | should "Find people with Jo in name" do |
14 | 18 | people_list = Person.search("Jo") |
15 | 19 | |
... | ... | @@ -46,4 +50,4 @@ class SearchPersonTest < ActiveSupport::TestCase |
46 | 50 | assert_equal 1, people_list.count |
47 | 51 | end |
48 | 52 | |
49 | -end | |
50 | 53 | \ No newline at end of file |
54 | +end | ... | ... |
test/unit/software_categories_test.rb
... | ... | @@ -44,6 +44,11 @@ class SoftwareCategoriesTest < ActiveSupport::TestCase |
44 | 44 | def teardown |
45 | 45 | SoftwareDatabase.destroy_all |
46 | 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 | 52 | end |
48 | 53 | |
49 | 54 | should "save software correctly with SoftwareCategories filds" do | ... | ... |
test/unit/software_database_test.rb
1 | 1 | require File.dirname(__FILE__) + '/../../../../test/test_helper' |
2 | 2 | |
3 | 3 | class SoftwareDatabaseTest < ActiveSupport::TestCase |
4 | - DatabaseDescription.create!(name: "MySQL") | |
5 | - | |
6 | 4 | def setup |
5 | + DatabaseDescription.create!(name: "PostgreSQL") | |
7 | 6 | @software_database = SoftwareDatabase.new(:version => "1.0", :operating_system => "Debian") |
8 | 7 | @software_database.database_description_id = 1 |
9 | 8 | end | ... | ... |
test/unit/software_info_validation_test.rb
... | ... | @@ -39,6 +39,17 @@ class SoftwareInfoValidationTest < ActiveSupport::TestCase |
39 | 39 | @software_info.software_categories = software_categories |
40 | 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 | 53 | should 'Save SoftwareInfo if all fields are filled' do |
43 | 54 | assert_equal true, @software_info.save |
44 | 55 | end | ... | ... |
test/unit/software_language_validation.rb
... | ... | @@ -7,6 +7,11 @@ class SoftwareLanguageValidationTest < ActiveSupport::TestCase |
7 | 7 | @software_info.save |
8 | 8 | end |
9 | 9 | |
10 | + def teardown | |
11 | + @software_info = nil | |
12 | + SoftwareInfo.destroy_all | |
13 | + end | |
14 | + | |
10 | 15 | should "Save SoftwareLanguage if version and programming_language are filled" do |
11 | 16 | @software_language = create_software_language |
12 | 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 | 2 | |
3 | 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 | 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 | 12 | end |
13 | 13 | |
14 | 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 | 17 | end |
19 | 18 | |
20 | 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 | 22 | end |
25 | -end | |
26 | 23 | \ No newline at end of file |
24 | +end | ... | ... |