Commit 3d42567fe2c8dbfb2c9608f2ded82c85a4e22c19

Authored by Gabriela Navarro
Committed by David Silva
1 parent 4f66c14d
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

Refactoring the size of line in different files

Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
test/functional/mpog_software_plugin_controller_test.rb
@@ -16,14 +16,34 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase @@ -16,14 +16,34 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase
16 @environment.add_admin(@admin) 16 @environment.add_admin(@admin)
17 @environment.save 17 @environment.save
18 18
19 - @govPower = GovernmentalPower.create(:name=>"Some Gov Power")  
20 - @govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") 19 + @gov_power = GovernmentalPower.create(:name=>"Some Gov Power")
  20 + @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere")
21 @juridical_nature = JuridicalNature.create(:name => "Autarquia") 21 @juridical_nature = JuridicalNature.create(:name => "Autarquia")
22 @response = ActionController::TestResponse.new 22 @response = ActionController::TestResponse.new
23 23
24 @institution_list = [] 24 @institution_list = []
25 - @institution_list << InstitutionTestHelper.create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", @juridical_nature, @govPower, @govSphere, "12.345.678/9012-45")  
26 - @institution_list << InstitutionTestHelper.create_public_institution("Tribunal Regional da Uniao", "TRU", "BR", "DF", "Brasilia", @juridical_nature, @govPower, @govSphere, "12.345.678/9012-90") 25 + @institution_list << InstitutionTestHelper.create_public_institution(
  26 + "Ministerio Publico da Uniao",
  27 + "MPU",
  28 + "BR",
  29 + "DF",
  30 + "Gama",
  31 + @juridical_nature,
  32 + @gov_power,
  33 + @gov_sphere,
  34 + "12.345.678/9012-45"
  35 + )
  36 + @institution_list << InstitutionTestHelper.create_public_institution(
  37 + "Tribunal Regional da Uniao",
  38 + "TRU",
  39 + "BR",
  40 + "DF",
  41 + "Brasilia",
  42 + @juridical_nature,
  43 + @gov_power,
  44 + @gov_sphere,
  45 + "12.345.678/9012-90"
  46 + )
27 end 47 end
28 48
29 should "Search for institution with acronym" do 49 should "Search for institution with acronym" do
@@ -60,9 +80,16 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase @@ -60,9 +80,16 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase
60 should "create new institution with ajax without acronym" do 80 should "create new institution with ajax without acronym" do
61 @controller.stubs(:verify_recaptcha).returns(true) 81 @controller.stubs(:verify_recaptcha).returns(true)
62 82
63 - fields = InstitutionTestHelper.generate_form_fields "foo bar", "BR", "DF", "Brasilia", "12.234.567/8900-10", "PublicInstitution"  
64 - fields[:institutions][:governmental_power] = @govPower.id  
65 - fields[:institutions][:governmental_sphere] = @govSphere.id 83 + fields = InstitutionTestHelper.generate_form_fields(
  84 + "foo bar",
  85 + "BR",
  86 + "DF",
  87 + "Brasilia",
  88 + "12.234.567/8900-10",
  89 + "PublicInstitution"
  90 + )
  91 + fields[:institutions][:governmental_power] = @gov_power.id
  92 + fields[:institutions][:governmental_sphere] = @gov_sphere.id
66 fields[:institutions][:juridical_nature] = @juridical_nature.id 93 fields[:institutions][:juridical_nature] = @juridical_nature.id
67 94
68 xhr :get, :new_institution, fields 95 xhr :get, :new_institution, fields
@@ -75,9 +102,16 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase @@ -75,9 +102,16 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase
75 should "not create a institution that already exists" do 102 should "not create a institution that already exists" do
76 @controller.stubs(:verify_recaptcha).returns(true) 103 @controller.stubs(:verify_recaptcha).returns(true)
77 104
78 - fields = InstitutionTestHelper.generate_form_fields "Ministerio Publico da Uniao", "BR", "DF", "Brasilia", "12.234.567/8900-10", "PublicInstitution"  
79 - fields[:institutions][:governmental_power] = @govPower.id  
80 - fields[:institutions][:governmental_sphere] = @govSphere.id 105 + fields = InstitutionTestHelper.generate_form_fields(
  106 + "Ministerio Publico da Uniao",
  107 + "BR",
  108 + "DF",
  109 + "Brasilia",
  110 + "12.234.567/8900-10",
  111 + "PublicInstitution"
  112 + )
  113 + fields[:institutions][:governmental_power] = @gov_power.id
  114 + fields[:institutions][:governmental_sphere] = @gov_sphere.id
81 fields[:institutions][:juridical_nature] = @juridical_nature.id 115 fields[:institutions][:juridical_nature] = @juridical_nature.id
82 116
83 xhr :get, :new_institution, fields 117 xhr :get, :new_institution, fields
@@ -90,7 +124,14 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase @@ -90,7 +124,14 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase
90 should "not create a institution without cnpj" do 124 should "not create a institution without cnpj" do
91 @controller.stubs(:verify_recaptcha).returns(true) 125 @controller.stubs(:verify_recaptcha).returns(true)
92 126
93 - fields = InstitutionTestHelper.generate_form_fields "Some Private Institution", "BR", "DF", "Brasilia", "", "PrivateInstitution" 127 + fields = InstitutionTestHelper.generate_form_fields(
  128 + "Some Private Institution",
  129 + "BR",
  130 + "DF",
  131 + "Brasilia",
  132 + "",
  133 + "PrivateInstitution"
  134 + )
94 fields[:institutions][:acronym] = "SPI" 135 fields[:institutions][:acronym] = "SPI"
95 136
96 xhr :get, :new_institution, fields 137 xhr :get, :new_institution, fields
@@ -121,7 +162,14 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase @@ -121,7 +162,14 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase
121 should "Create new institution with method post" do 162 should "Create new institution with method post" do
122 @controller.stubs(:verify_recaptcha).returns(true) 163 @controller.stubs(:verify_recaptcha).returns(true)
123 164
124 - fields = InstitutionTestHelper.generate_form_fields "Some Private Institution", "BR", "DF", "Brasilia", "12.345.567/8900-10", "PrivateInstitution" 165 + fields = InstitutionTestHelper.generate_form_fields(
  166 + "Some Private Institution",
  167 + "BR",
  168 + "DF",
  169 + "Brasilia",
  170 + "12.345.567/8900-10",
  171 + "PrivateInstitution"
  172 + )
125 fields[:institutions][:acronym] = "SPI" 173 fields[:institutions][:acronym] = "SPI"
126 174
127 post :new_institution, fields 175 post :new_institution, fields
@@ -132,7 +180,14 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase @@ -132,7 +180,14 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase
132 should "not create new institution with method post without cnpj" do 180 should "not create new institution with method post without cnpj" do
133 @controller.stubs(:verify_recaptcha).returns(true) 181 @controller.stubs(:verify_recaptcha).returns(true)
134 182
135 - fields = InstitutionTestHelper.generate_form_fields "Some Private Institution", "BR", "DF", "Brasilia", "", "PrivateInstitution" 183 + fields = InstitutionTestHelper.generate_form_fields(
  184 + "Some Private Institution",
  185 + "BR",
  186 + "DF",
  187 + "Brasilia",
  188 + "",
  189 + "PrivateInstitution"
  190 + )
136 fields[:institutions][:acronym] = "SPI" 191 fields[:institutions][:acronym] = "SPI"
137 192
138 post :new_institution, fields 193 post :new_institution, fields
@@ -143,7 +198,14 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase @@ -143,7 +198,14 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase
143 should "Create foreign institution without city, state and cnpj by post" do 198 should "Create foreign institution without city, state and cnpj by post" do
144 @controller.stubs(:verify_recaptcha).returns(true) 199 @controller.stubs(:verify_recaptcha).returns(true)
145 200
146 - fields = InstitutionTestHelper.generate_form_fields "Foreign institution", "AZ", "", "", "", "PrivateInstitution" 201 + fields = InstitutionTestHelper.generate_form_fields(
  202 + "Foreign institution",
  203 + "AZ",
  204 + "",
  205 + "",
  206 + "",
  207 + "PrivateInstitution"
  208 + )
147 fields[:institutions][:acronym] = "FI" 209 fields[:institutions][:acronym] = "FI"
148 210
149 post :new_institution, fields 211 post :new_institution, fields
@@ -154,7 +216,14 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase @@ -154,7 +216,14 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase
154 should "Create foreign institution without city, state and cnpj by ajax" do 216 should "Create foreign institution without city, state and cnpj by ajax" do
155 @controller.stubs(:verify_recaptcha).returns(true) 217 @controller.stubs(:verify_recaptcha).returns(true)
156 218
157 - fields = InstitutionTestHelper.generate_form_fields "Foreign institution", "AZ", "", "", "", "PrivateInstitution" 219 + fields = InstitutionTestHelper.generate_form_fields(
  220 + "Foreign institution",
  221 + "AZ",
  222 + "",
  223 + "",
  224 + "",
  225 + "PrivateInstitution"
  226 + )
158 fields[:institutions][:acronym] = "FI" 227 fields[:institutions][:acronym] = "FI"
159 228
160 xhr :post, :new_institution, fields 229 xhr :post, :new_institution, fields
@@ -170,7 +239,14 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase @@ -170,7 +239,14 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase
170 @environment.add_admin(admin2) 239 @environment.add_admin(admin2)
171 @environment.save 240 @environment.save
172 241
173 - fields = InstitutionTestHelper.generate_form_fields "Private Institution", "BR", "DF", "Brasilia", "12.323.557/8900-10", "PrivateInstitution" 242 + fields = InstitutionTestHelper.generate_form_fields(
  243 + "Private Institution",
  244 + "BR",
  245 + "DF",
  246 + "Brasilia",
  247 + "12.323.557/8900-10",
  248 + "PrivateInstitution"
  249 + )
174 fields[:institutions][:acronym] = "PI" 250 fields[:institutions][:acronym] = "PI"
175 fields[:edit_institution_page] = false 251 fields[:edit_institution_page] = false
176 post :new_institution, fields 252 post :new_institution, fields
test/unit/institution_test.rb
@@ -8,7 +8,17 @@ class InstitutionTest &lt; ActiveSupport::TestCase @@ -8,7 +8,17 @@ class InstitutionTest &lt; ActiveSupport::TestCase
8 @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") 8 @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere")
9 @juridical_nature = JuridicalNature.create(:name => "Autarquia") 9 @juridical_nature = JuridicalNature.create(:name => "Autarquia")
10 10
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(
  12 + "Ministerio Publico da Uniao",
  13 + "MPU",
  14 + "BR",
  15 + "DF",
  16 + "Gama",
  17 + @juridical_nature,
  18 + @gov_power,
  19 + @gov_sphere,
  20 + "11.222.333/4444-55"
  21 + )
12 end 22 end
13 23
14 def teardown 24 def teardown
@@ -24,9 +34,10 @@ class InstitutionTest &lt; ActiveSupport::TestCase @@ -24,9 +34,10 @@ class InstitutionTest &lt; ActiveSupport::TestCase
24 end 34 end
25 35
26 should "not save if institution has invalid type" do 36 should "not save if institution has invalid type" do
  37 + invalid_msg = "Type invalid, only public and private institutions are allowed."
27 @institution.type = "Other type" 38 @institution.type = "Other type"
28 assert !@institution.save, 'Invalid type' 39 assert !@institution.save, 'Invalid type'
29 - assert @institution.errors.full_messages.include? "Type invalid, only public and private institutions are allowed." 40 + assert @institution.errors.full_messages.include? invalid_msg
30 end 41 end
31 42
32 should "not save without country" do 43 should "not save without country" do
test/unit/institutions_block_test.rb
@@ -23,9 +23,23 @@ class InstitutionsBlockTest &lt; ActiveSupport::TestCase @@ -23,9 +23,23 @@ class InstitutionsBlockTest &lt; ActiveSupport::TestCase
23 end 23 end
24 24
25 should 'list institutions' do 25 should 'list institutions' do
26 - user = create_person("Jose_Augusto", "jose_augusto@email.com", "aaaaaaa", "aaaaaaa", "jose_silva@email.com", "DF", "Gama")  
27 -  
28 - institution = create_private_institution "inst name", "IN", "country", "state", "city", "00.111.222/3333-44" 26 + user = create_person("Jose_Augusto",
  27 + "jose_augusto@email.com",
  28 + "aaaaaaa",
  29 + "aaaaaaa",
  30 + "jose_silva@email.com",
  31 + "DF",
  32 + "Gama"
  33 + )
  34 +
  35 + institution = create_private_institution(
  36 + "inst name",
  37 + "IN",
  38 + "country",
  39 + "state",
  40 + "city",
  41 + "00.111.222/3333-44"
  42 + )
29 institution.community.add_member(user) 43 institution.community.add_member(user)
30 44
31 block = InstitutionsBlock.new 45 block = InstitutionsBlock.new
test/unit/mpog_software_plugin_user_test.rb
@@ -13,7 +13,7 @@ class MpogSoftwarePluginUserTest &lt; ActiveSupport::TestCase @@ -13,7 +13,7 @@ class MpogSoftwarePluginUserTest &lt; ActiveSupport::TestCase
13 assert !user.save 13 assert !user.save
14 end 14 end
15 15
16 - should 'not save user whose both email and secondary email have already been used' do 16 + should 'not save user whose email and secondary email have been taken' do
17 user1 = create_default_user 17 user1 = create_default_user
18 user2 = fast_create(User) 18 user2 = fast_create(User)
19 19
@@ -31,7 +31,7 @@ class MpogSoftwarePluginUserTest &lt; ActiveSupport::TestCase @@ -31,7 +31,7 @@ class MpogSoftwarePluginUserTest &lt; ActiveSupport::TestCase
31 assert !user2.save 31 assert !user2.save
32 end 32 end
33 33
34 - should 'not save user whose email has already been used in another users secondary email' do 34 + should 'not save user whose email has been taken another in users secondary email' do
35 user1 = create_default_user 35 user1 = create_default_user
36 user2 = fast_create(User) 36 user2 = fast_create(User)
37 37
@@ -41,7 +41,7 @@ class MpogSoftwarePluginUserTest &lt; ActiveSupport::TestCase @@ -41,7 +41,7 @@ class MpogSoftwarePluginUserTest &lt; ActiveSupport::TestCase
41 assert !user2.save 41 assert !user2.save
42 end 42 end
43 43
44 - should 'not save user whose secondary email has already been used in another users email' do 44 + should 'not save user whose secondary email has been taken used in another users email' do
45 user1 = create_default_user 45 user1 = create_default_user
46 user2 = fast_create(User) 46 user2 = fast_create(User)
47 47
@@ -85,13 +85,14 @@ class MpogSoftwarePluginUserTest &lt; ActiveSupport::TestCase @@ -85,13 +85,14 @@ class MpogSoftwarePluginUserTest &lt; ActiveSupport::TestCase
85 assert user2.save 85 assert user2.save
86 end 86 end
87 should 'return an error if secondary email is governmental and primary is not' do 87 should 'return an error if secondary email is governmental and primary is not' do
  88 + invalid_msg = "The governamental email must be the primary one."
88 user = fast_create(User) 89 user = fast_create(User)
89 90
90 user.email = "test@email.com" 91 user.email = "test@email.com"
91 user.secondary_email = "test@gov.br" 92 user.secondary_email = "test@gov.br"
92 93
93 assert !user.save 94 assert !user.save
94 - assert user.errors.full_messages.include?("The governamental email must be the primary one.") 95 + assert user.errors.full_messages.include?(invalid_msg)
95 end 96 end
96 97
97 should 'have institution if email is governmental' do 98 should 'have institution if email is governmental' do
@@ -105,7 +106,17 @@ class MpogSoftwarePluginUserTest &lt; ActiveSupport::TestCase @@ -105,7 +106,17 @@ class MpogSoftwarePluginUserTest &lt; ActiveSupport::TestCase
105 gov_power = GovernmentalPower.create(:name=>"Some Gov Power") 106 gov_power = GovernmentalPower.create(:name=>"Some Gov Power")
106 gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") 107 gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere")
107 juridical_nature = JuridicalNature.create(:name => "Autarquia") 108 juridical_nature = JuridicalNature.create(:name => "Autarquia")
108 - institution = create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", juridical_nature, gov_power, gov_sphere, "44.555.666/7777-88") 109 + institution = create_public_institution(
  110 + "Ministerio Publico da Uniao",
  111 + "MPU",
  112 + "BR",
  113 + "DF",
  114 + "Gama",
  115 + juridical_nature,
  116 + gov_power,
  117 + gov_sphere,
  118 + "44.555.666/7777-88"
  119 + )
109 institution.save! 120 institution.save!
110 121
111 user.institutions << institution 122 user.institutions << institution
test/unit/operating_system_helper_test.rb
@@ -6,12 +6,14 @@ OperatingSystemName.create(:name=&gt;&quot;CentOS&quot;) @@ -6,12 +6,14 @@ OperatingSystemName.create(:name=&gt;&quot;CentOS&quot;)
6 6
7 class OperatingSystemHelperTest < ActiveSupport::TestCase 7 class OperatingSystemHelperTest < ActiveSupport::TestCase
8 8
9 - include OperatingSystemHelper 9 + include OperatingSystemHelper
10 10
11 - def setup  
12 - @operating_system_objects = [{:operating_system_name_id => "1" ,:version => "2.0"}, 11 + def setup
  12 + @operating_system_objects = [
  13 + {:operating_system_name_id => "1" ,:version => "2.0"},
13 {:operating_system_name_id => "2" ,"version" => "2.1"}, 14 {:operating_system_name_id => "2" ,"version" => "2.1"},
14 - {:operating_system_name_id => "3" ,"version" => "2.2"}] 15 + {:operating_system_name_id => "3" ,"version" => "2.2"}
  16 + ]
15 @operating_system_objects 17 @operating_system_objects
16 end 18 end
17 19
@@ -26,12 +28,14 @@ class OperatingSystemHelperTest &lt; ActiveSupport::TestCase @@ -26,12 +28,14 @@ class OperatingSystemHelperTest &lt; ActiveSupport::TestCase
26 28
27 should "return a list with current OperatingSystems" do 29 should "return a list with current OperatingSystems" do
28 list_compare = [] 30 list_compare = []
29 - assert_equal list_compare.class, OperatingSystemHelper.list_operating_system(@operating_system_objects).class 31 + list_op = OperatingSystemHelper.list_operating_system(@operating_system_objects)
  32 + assert_equal list_compare.class, list_op.class
30 end 33 end
31 34
32 should "have same information from the list passed as parameter" do 35 should "have same information from the list passed as parameter" do
33 list_compare = OperatingSystemHelper.list_operating_system(@operating_system_objects) 36 list_compare = OperatingSystemHelper.list_operating_system(@operating_system_objects)
34 - assert_equal @operating_system_objects.first[:operating_system_name_id], list_compare.first.operating_system_name_id.to_s 37 + first_operating = @operating_system_objects.first[:operating_system_name_id]
  38 + assert_equal first_operating, list_compare.first.operating_system_name_id.to_s
35 end 39 end
36 40
37 should "return a list with the same size of the parameter" do 41 should "return a list with the same size of the parameter" do
@@ -55,7 +59,8 @@ class OperatingSystemHelperTest &lt; ActiveSupport::TestCase @@ -55,7 +59,8 @@ class OperatingSystemHelperTest &lt; ActiveSupport::TestCase
55 software_operating_system.operating_system_name = operating_system 59 software_operating_system.operating_system_name = operating_system
56 60
57 operating_systems << software_operating_system 61 operating_systems << software_operating_system
  62 + op_table = OperatingSystemHelper.operating_system_as_tables(operating_systems)
58 63
59 - assert_not_nil OperatingSystemHelper.operating_system_as_tables(operating_systems).first.call.index(OperatingSystemName.first.name) 64 + assert_not_nil op_table.first.call.index(OperatingSystemName.first.name)
60 end 65 end
61 end 66 end
test/unit/private_institution_test.rb
@@ -4,7 +4,14 @@ require File.dirname(__FILE__) + &#39;/../helpers/plugin_test_helper&#39; @@ -4,7 +4,14 @@ require File.dirname(__FILE__) + &#39;/../helpers/plugin_test_helper&#39;
4 class PrivateInstitutionTest < ActiveSupport::TestCase 4 class PrivateInstitutionTest < ActiveSupport::TestCase
5 include PluginTestHelper 5 include PluginTestHelper
6 def setup 6 def setup
7 - @institution = create_private_institution "Simple Private Institution", "SPI", "BR", "DF", "Gama", "00.000.000/0001-00" 7 + @institution = create_private_institution(
  8 + "Simple Private Institution",
  9 + "SPI",
  10 + "BR",
  11 + "DF",
  12 + "Gama",
  13 + "00.000.000/0001-00"
  14 + )
8 end 15 end
9 16
10 def teardown 17 def teardown
@@ -20,10 +27,18 @@ class PrivateInstitutionTest &lt; ActiveSupport::TestCase @@ -20,10 +27,18 @@ class PrivateInstitutionTest &lt; ActiveSupport::TestCase
20 end 27 end
21 28
22 should "not save with a repeated cnpj" do 29 should "not save with a repeated cnpj" do
  30 + msg = "Cnpj has already been taken"
23 assert @institution.save 31 assert @institution.save
24 - sec_institution = create_private_institution "Another Private Institution", "API", "BR", "DF", "Gama", "00.000.000/0001-00"  
25 -  
26 - assert sec_institution.errors.full_messages.include? "Cnpj has already been taken" 32 + sec_institution = create_private_institution(
  33 + "Another Private Institution",
  34 + "API",
  35 + "BR",
  36 + "DF",
  37 + "Gama",
  38 + "00.000.000/0001-00"
  39 + )
  40 +
  41 + assert sec_institution.errors.full_messages.include? msg
27 end 42 end
28 43
29 should "save without fantasy name" do 44 should "save without fantasy name" do
test/unit/public_institution_test.rb
@@ -8,7 +8,17 @@ class PublicInstitutionTest &lt; ActiveSupport::TestCase @@ -8,7 +8,17 @@ class PublicInstitutionTest &lt; ActiveSupport::TestCase
8 @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") 8 @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere")
9 @juridical_nature = JuridicalNature.create(:name => "Autarquia") 9 @juridical_nature = JuridicalNature.create(:name => "Autarquia")
10 10
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(
  12 + "Ministerio Publico da Uniao",
  13 + "MPU",
  14 + "BR",
  15 + "DF",
  16 + "Gama",
  17 + @juridical_nature,
  18 + @gov_power,
  19 + @gov_sphere,
  20 + "11.222.333/4444-55"
  21 + )
12 end 22 end
13 23
14 def teardown 24 def teardown
@@ -33,23 +43,26 @@ class PublicInstitutionTest &lt; ActiveSupport::TestCase @@ -33,23 +43,26 @@ class PublicInstitutionTest &lt; ActiveSupport::TestCase
33 end 43 end
34 44
35 should "Not save institution without a governmental_power" do 45 should "Not save institution without a governmental_power" do
  46 + invalid_msg = "Governmental power can't be blank"
36 @institution.governmental_power = nil 47 @institution.governmental_power = nil
37 48
38 assert !@institution.save 49 assert !@institution.save
39 - assert @institution.errors.full_messages.include? "Governmental power can't be blank" 50 + assert @institution.errors.full_messages.include? invalid_msg
40 end 51 end
41 52
42 should "Not save institution without a governmental_sphere" do 53 should "Not save institution without a governmental_sphere" do
  54 + invalid_msg = "Governmental sphere can't be blank"
43 @institution.governmental_sphere = nil 55 @institution.governmental_sphere = nil
44 56
45 assert !@institution.save 57 assert !@institution.save
46 - assert @institution.errors.full_messages.include? "Governmental sphere can't be blank" 58 + assert @institution.errors.full_messages.include? invalid_msg
47 end 59 end
48 60
49 should "not save institution without juridical nature" do 61 should "not save institution without juridical nature" do
  62 + invalid_msg = "Juridical nature can't be blank"
50 @institution.juridical_nature = nil 63 @institution.juridical_nature = nil
51 64
52 assert !@institution.save 65 assert !@institution.save
53 - assert @institution.errors.full_messages.include? "Juridical nature can't be blank" 66 + assert @institution.errors.full_messages.include? invalid_msg
54 end 67 end
55 end 68 end
test/unit/search_person_test.rb
@@ -44,7 +44,7 @@ class SearchPersonTest &lt; ActiveSupport::TestCase @@ -44,7 +44,7 @@ class SearchPersonTest &lt; ActiveSupport::TestCase
44 assert_equal 2, people_list.count 44 assert_equal 2, people_list.count
45 end 45 end
46 46
47 - should "Find people with Ma in name and RJ in state and Rio in city and ma in email" do 47 + should "Find people with Ma in name and email and RJ in state and Rio in city" do
48 people_list = Person.search("Ma", "RJ", "Rio", "ma") 48 people_list = Person.search("Ma", "RJ", "Rio", "ma")
49 49
50 assert_equal 1, people_list.count 50 assert_equal 1, people_list.count
test/unit/software_database_test.rb
@@ -3,7 +3,10 @@ require File.dirname(__FILE__) + &#39;/../../../../test/test_helper&#39; @@ -3,7 +3,10 @@ require File.dirname(__FILE__) + &#39;/../../../../test/test_helper&#39;
3 class SoftwareDatabaseTest < ActiveSupport::TestCase 3 class SoftwareDatabaseTest < ActiveSupport::TestCase
4 def setup 4 def setup
5 DatabaseDescription.create!(name: "PostgreSQL") 5 DatabaseDescription.create!(name: "PostgreSQL")
6 - @software_database = SoftwareDatabase.new(:version => "1.0", :operating_system => "Debian") 6 + @software_database = SoftwareDatabase.new(
  7 + :version => "1.0",
  8 + :operating_system => "Debian"
  9 + )
7 @software_database.database_description_id = 1 10 @software_database.database_description_id = 1
8 end 11 end
9 12
@@ -37,7 +40,8 @@ class SoftwareDatabaseTest &lt; ActiveSupport::TestCase @@ -37,7 +40,8 @@ class SoftwareDatabaseTest &lt; ActiveSupport::TestCase
37 end 40 end
38 41
39 should "not save if operating system has more than 20 characters" do 42 should "not save if operating system has more than 20 characters" do
  43 + invalid_msg = "Operating system must have until 20 characters"
40 @software_database.operating_system = "a"*21 44 @software_database.operating_system = "a"*21
41 - assert !@software_database.save, "Operating system must have until 20 characters" 45 + assert !@software_database.save, invalid_msg
42 end 46 end
43 end 47 end
test/unit/software_language_validation.rb
@@ -12,7 +12,7 @@ class SoftwareLanguageValidationTest &lt; ActiveSupport::TestCase @@ -12,7 +12,7 @@ class SoftwareLanguageValidationTest &lt; ActiveSupport::TestCase
12 SoftwareInfo.destroy_all 12 SoftwareInfo.destroy_all
13 end 13 end
14 14
15 - should "Save SoftwareLanguage if version and programming_language are filled" do 15 + should "Save SoftwareLanguage if version and prog_language are filled" do
16 @software_language = create_software_language 16 @software_language = create_software_language
17 assert_equal true, @software_language.save 17 assert_equal true, @software_language.save
18 end 18 end
@@ -31,13 +31,14 @@ class SoftwareLanguageValidationTest &lt; ActiveSupport::TestCase @@ -31,13 +31,14 @@ class SoftwareLanguageValidationTest &lt; ActiveSupport::TestCase
31 31
32 should "Don't save SoftwareLanguage if version is too long" do 32 should "Don't save SoftwareLanguage if version is too long" do
33 @software_language = create_software_language 33 @software_language = create_software_language
34 - @software_language.version = "A too long version to be considered valid as a version" 34 + @software_language.version = "A too long version to be valid as a version"
35 assert_equal true, !@software_language.save 35 assert_equal true, !@software_language.save
36 end 36 end
37 37
38 should "Don't save SoftwareLanguage if operating system is too long" do 38 should "Don't save SoftwareLanguage if operating system is too long" do
  39 + operating_system = "A too long to be valid as a operating system"
39 @software_language = create_software_language 40 @software_language = create_software_language
40 - @software_language.operating_system = "A too long operating system to be considered valid as a operating system" 41 + @software_language.operating_system = operating_system
41 assert_equal true, !@software_language.save 42 assert_equal true, !@software_language.save
42 end 43 end
43 44
test/unit/software_registration_test.rb
@@ -16,14 +16,22 @@ class SoftwareRegistrationTest &lt; ActiveSupport::TestCase @@ -16,14 +16,22 @@ class SoftwareRegistrationTest &lt; ActiveSupport::TestCase
16 should 'include software registration task if is admin' do 16 should 'include software registration task if is admin' do
17 person = create_user('molly').person 17 person = create_user('molly').person
18 @environment.add_admin(person) 18 @environment.add_admin(person)
19 - task = CreateSoftware.create!(:name => "Teste One", :requestor => person,:environment => @environment) 19 + task = CreateSoftware.create!(
  20 + :name => "Teste One",
  21 + :requestor => person,
  22 + :environment => @environment
  23 + )
20 assert_equal [task], Task.to(person).pending 24 assert_equal [task], Task.to(person).pending
21 end 25 end
22 26
23 should 'create software when admin accept software create task' do 27 should 'create software when admin accept software create task' do
24 person = create_user('Pedro').person 28 person = create_user('Pedro').person
25 @environment.add_admin(person) 29 @environment.add_admin(person)
26 - task = CreateSoftware.create!(:name => "Teste Two", :requestor => person,:environment => @environment) 30 + task = CreateSoftware.create!(
  31 + :name => "Teste Two",
  32 + :requestor => person,
  33 + :environment => @environment
  34 + )
27 35
28 software_count = SoftwareInfo.count 36 software_count = SoftwareInfo.count
29 task.finish 37 task.finish