diff --git a/test/functional/mpog_software_plugin_controller_test.rb b/test/functional/mpog_software_plugin_controller_test.rb index 4366e9e..690c181 100644 --- a/test/functional/mpog_software_plugin_controller_test.rb +++ b/test/functional/mpog_software_plugin_controller_test.rb @@ -16,14 +16,34 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase @environment.add_admin(@admin) @environment.save - @govPower = GovernmentalPower.create(:name=>"Some Gov Power") - @govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") + @gov_power = GovernmentalPower.create(:name=>"Some Gov Power") + @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") @juridical_nature = JuridicalNature.create(:name => "Autarquia") @response = ActionController::TestResponse.new @institution_list = [] - @institution_list << InstitutionTestHelper.create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", @juridical_nature, @govPower, @govSphere, "12.345.678/9012-45") - @institution_list << InstitutionTestHelper.create_public_institution("Tribunal Regional da Uniao", "TRU", "BR", "DF", "Brasilia", @juridical_nature, @govPower, @govSphere, "12.345.678/9012-90") + @institution_list << InstitutionTestHelper.create_public_institution( + "Ministerio Publico da Uniao", + "MPU", + "BR", + "DF", + "Gama", + @juridical_nature, + @gov_power, + @gov_sphere, + "12.345.678/9012-45" + ) + @institution_list << InstitutionTestHelper.create_public_institution( + "Tribunal Regional da Uniao", + "TRU", + "BR", + "DF", + "Brasilia", + @juridical_nature, + @gov_power, + @gov_sphere, + "12.345.678/9012-90" + ) end should "Search for institution with acronym" do @@ -60,9 +80,16 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase should "create new institution with ajax without acronym" do @controller.stubs(:verify_recaptcha).returns(true) - fields = InstitutionTestHelper.generate_form_fields "foo bar", "BR", "DF", "Brasilia", "12.234.567/8900-10", "PublicInstitution" - fields[:institutions][:governmental_power] = @govPower.id - fields[:institutions][:governmental_sphere] = @govSphere.id + fields = InstitutionTestHelper.generate_form_fields( + "foo bar", + "BR", + "DF", + "Brasilia", + "12.234.567/8900-10", + "PublicInstitution" + ) + fields[:institutions][:governmental_power] = @gov_power.id + fields[:institutions][:governmental_sphere] = @gov_sphere.id fields[:institutions][:juridical_nature] = @juridical_nature.id xhr :get, :new_institution, fields @@ -75,9 +102,16 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase should "not create a institution that already exists" do @controller.stubs(:verify_recaptcha).returns(true) - fields = InstitutionTestHelper.generate_form_fields "Ministerio Publico da Uniao", "BR", "DF", "Brasilia", "12.234.567/8900-10", "PublicInstitution" - fields[:institutions][:governmental_power] = @govPower.id - fields[:institutions][:governmental_sphere] = @govSphere.id + fields = InstitutionTestHelper.generate_form_fields( + "Ministerio Publico da Uniao", + "BR", + "DF", + "Brasilia", + "12.234.567/8900-10", + "PublicInstitution" + ) + fields[:institutions][:governmental_power] = @gov_power.id + fields[:institutions][:governmental_sphere] = @gov_sphere.id fields[:institutions][:juridical_nature] = @juridical_nature.id xhr :get, :new_institution, fields @@ -90,7 +124,14 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase should "not create a institution without cnpj" do @controller.stubs(:verify_recaptcha).returns(true) - fields = InstitutionTestHelper.generate_form_fields "Some Private Institution", "BR", "DF", "Brasilia", "", "PrivateInstitution" + fields = InstitutionTestHelper.generate_form_fields( + "Some Private Institution", + "BR", + "DF", + "Brasilia", + "", + "PrivateInstitution" + ) fields[:institutions][:acronym] = "SPI" xhr :get, :new_institution, fields @@ -121,7 +162,14 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase should "Create new institution with method post" do @controller.stubs(:verify_recaptcha).returns(true) - fields = InstitutionTestHelper.generate_form_fields "Some Private Institution", "BR", "DF", "Brasilia", "12.345.567/8900-10", "PrivateInstitution" + fields = InstitutionTestHelper.generate_form_fields( + "Some Private Institution", + "BR", + "DF", + "Brasilia", + "12.345.567/8900-10", + "PrivateInstitution" + ) fields[:institutions][:acronym] = "SPI" post :new_institution, fields @@ -132,7 +180,14 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase should "not create new institution with method post without cnpj" do @controller.stubs(:verify_recaptcha).returns(true) - fields = InstitutionTestHelper.generate_form_fields "Some Private Institution", "BR", "DF", "Brasilia", "", "PrivateInstitution" + fields = InstitutionTestHelper.generate_form_fields( + "Some Private Institution", + "BR", + "DF", + "Brasilia", + "", + "PrivateInstitution" + ) fields[:institutions][:acronym] = "SPI" post :new_institution, fields @@ -143,7 +198,14 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase should "Create foreign institution without city, state and cnpj by post" do @controller.stubs(:verify_recaptcha).returns(true) - fields = InstitutionTestHelper.generate_form_fields "Foreign institution", "AZ", "", "", "", "PrivateInstitution" + fields = InstitutionTestHelper.generate_form_fields( + "Foreign institution", + "AZ", + "", + "", + "", + "PrivateInstitution" + ) fields[:institutions][:acronym] = "FI" post :new_institution, fields @@ -154,7 +216,14 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase should "Create foreign institution without city, state and cnpj by ajax" do @controller.stubs(:verify_recaptcha).returns(true) - fields = InstitutionTestHelper.generate_form_fields "Foreign institution", "AZ", "", "", "", "PrivateInstitution" + fields = InstitutionTestHelper.generate_form_fields( + "Foreign institution", + "AZ", + "", + "", + "", + "PrivateInstitution" + ) fields[:institutions][:acronym] = "FI" xhr :post, :new_institution, fields @@ -170,7 +239,14 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase @environment.add_admin(admin2) @environment.save - fields = InstitutionTestHelper.generate_form_fields "Private Institution", "BR", "DF", "Brasilia", "12.323.557/8900-10", "PrivateInstitution" + fields = InstitutionTestHelper.generate_form_fields( + "Private Institution", + "BR", + "DF", + "Brasilia", + "12.323.557/8900-10", + "PrivateInstitution" + ) fields[:institutions][:acronym] = "PI" fields[:edit_institution_page] = false post :new_institution, fields diff --git a/test/unit/institution_test.rb b/test/unit/institution_test.rb index c471333..cda237c 100644 --- a/test/unit/institution_test.rb +++ b/test/unit/institution_test.rb @@ -8,7 +8,17 @@ class InstitutionTest < ActiveSupport::TestCase @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") @juridical_nature = JuridicalNature.create(:name => "Autarquia") - @institution = create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", @juridical_nature, @gov_power, @gov_sphere, "11.222.333/4444-55") + @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 @@ -24,9 +34,10 @@ class InstitutionTest < ActiveSupport::TestCase end should "not save if institution has invalid type" do + invalid_msg = "Type invalid, only public and private institutions are allowed." @institution.type = "Other type" assert !@institution.save, 'Invalid type' - assert @institution.errors.full_messages.include? "Type invalid, only public and private institutions are allowed." + assert @institution.errors.full_messages.include? invalid_msg end should "not save without country" do diff --git a/test/unit/institutions_block_test.rb b/test/unit/institutions_block_test.rb index 90147b1..37ceb71 100644 --- a/test/unit/institutions_block_test.rb +++ b/test/unit/institutions_block_test.rb @@ -23,9 +23,23 @@ class InstitutionsBlockTest < ActiveSupport::TestCase end should 'list institutions' do - user = create_person("Jose_Augusto", "jose_augusto@email.com", "aaaaaaa", "aaaaaaa", "jose_silva@email.com", "DF", "Gama") - - institution = create_private_institution "inst name", "IN", "country", "state", "city", "00.111.222/3333-44" + user = create_person("Jose_Augusto", + "jose_augusto@email.com", + "aaaaaaa", + "aaaaaaa", + "jose_silva@email.com", + "DF", + "Gama" + ) + + institution = create_private_institution( + "inst name", + "IN", + "country", + "state", + "city", + "00.111.222/3333-44" + ) institution.community.add_member(user) block = InstitutionsBlock.new diff --git a/test/unit/mpog_software_plugin_user_test.rb b/test/unit/mpog_software_plugin_user_test.rb index ef978f0..16f8e54 100644 --- a/test/unit/mpog_software_plugin_user_test.rb +++ b/test/unit/mpog_software_plugin_user_test.rb @@ -13,7 +13,7 @@ class MpogSoftwarePluginUserTest < ActiveSupport::TestCase assert !user.save end - should 'not save user whose both email and secondary email have already been used' do + should 'not save user whose email and secondary email have been taken' do user1 = create_default_user user2 = fast_create(User) @@ -31,7 +31,7 @@ class MpogSoftwarePluginUserTest < ActiveSupport::TestCase assert !user2.save end - should 'not save user whose email has already been used in another users secondary email' do + should 'not save user whose email has been taken another in users secondary email' do user1 = create_default_user user2 = fast_create(User) @@ -41,7 +41,7 @@ class MpogSoftwarePluginUserTest < ActiveSupport::TestCase assert !user2.save end - should 'not save user whose secondary email has already been used in another users email' do + should 'not save user whose secondary email has been taken used in another users email' do user1 = create_default_user user2 = fast_create(User) @@ -85,13 +85,14 @@ class MpogSoftwarePluginUserTest < ActiveSupport::TestCase assert user2.save end should 'return an error if secondary email is governmental and primary is not' do + invalid_msg = "The governamental email must be the primary one." user = fast_create(User) user.email = "test@email.com" user.secondary_email = "test@gov.br" assert !user.save - assert user.errors.full_messages.include?("The governamental email must be the primary one.") + assert user.errors.full_messages.include?(invalid_msg) end should 'have institution if email is governmental' do @@ -105,7 +106,17 @@ class MpogSoftwarePluginUserTest < ActiveSupport::TestCase gov_power = GovernmentalPower.create(:name=>"Some Gov Power") gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") juridical_nature = JuridicalNature.create(:name => "Autarquia") - institution = create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", juridical_nature, gov_power, gov_sphere, "44.555.666/7777-88") + institution = create_public_institution( + "Ministerio Publico da Uniao", + "MPU", + "BR", + "DF", + "Gama", + juridical_nature, + gov_power, + gov_sphere, + "44.555.666/7777-88" + ) institution.save! user.institutions << institution diff --git a/test/unit/operating_system_helper_test.rb b/test/unit/operating_system_helper_test.rb index 5fc4092..93c6b27 100644 --- a/test/unit/operating_system_helper_test.rb +++ b/test/unit/operating_system_helper_test.rb @@ -6,12 +6,14 @@ OperatingSystemName.create(:name=>"CentOS") class OperatingSystemHelperTest < ActiveSupport::TestCase - include OperatingSystemHelper + include OperatingSystemHelper - def setup - @operating_system_objects = [{:operating_system_name_id => "1" ,:version => "2.0"}, + def setup + @operating_system_objects = [ + {:operating_system_name_id => "1" ,:version => "2.0"}, {:operating_system_name_id => "2" ,"version" => "2.1"}, - {:operating_system_name_id => "3" ,"version" => "2.2"}] + {:operating_system_name_id => "3" ,"version" => "2.2"} + ] @operating_system_objects end @@ -26,12 +28,14 @@ class OperatingSystemHelperTest < ActiveSupport::TestCase should "return a list with current OperatingSystems" do list_compare = [] - assert_equal list_compare.class, OperatingSystemHelper.list_operating_system(@operating_system_objects).class + list_op = OperatingSystemHelper.list_operating_system(@operating_system_objects) + assert_equal list_compare.class, list_op.class end should "have same information from the list passed as parameter" do list_compare = OperatingSystemHelper.list_operating_system(@operating_system_objects) - assert_equal @operating_system_objects.first[:operating_system_name_id], list_compare.first.operating_system_name_id.to_s + first_operating = @operating_system_objects.first[:operating_system_name_id] + assert_equal first_operating, list_compare.first.operating_system_name_id.to_s end should "return a list with the same size of the parameter" do @@ -55,7 +59,8 @@ class OperatingSystemHelperTest < ActiveSupport::TestCase software_operating_system.operating_system_name = operating_system operating_systems << software_operating_system + op_table = OperatingSystemHelper.operating_system_as_tables(operating_systems) - assert_not_nil OperatingSystemHelper.operating_system_as_tables(operating_systems).first.call.index(OperatingSystemName.first.name) + assert_not_nil op_table.first.call.index(OperatingSystemName.first.name) end end diff --git a/test/unit/private_institution_test.rb b/test/unit/private_institution_test.rb index 7d287db..e0fad37 100644 --- a/test/unit/private_institution_test.rb +++ b/test/unit/private_institution_test.rb @@ -4,7 +4,14 @@ require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' class PrivateInstitutionTest < ActiveSupport::TestCase include PluginTestHelper def setup - @institution = create_private_institution "Simple Private Institution", "SPI", "BR", "DF", "Gama", "00.000.000/0001-00" + @institution = create_private_institution( + "Simple Private Institution", + "SPI", + "BR", + "DF", + "Gama", + "00.000.000/0001-00" + ) end def teardown @@ -20,10 +27,18 @@ class PrivateInstitutionTest < ActiveSupport::TestCase end should "not save with a repeated cnpj" do + msg = "Cnpj has already been taken" assert @institution.save - sec_institution = create_private_institution "Another Private Institution", "API", "BR", "DF", "Gama", "00.000.000/0001-00" - - assert sec_institution.errors.full_messages.include? "Cnpj has already been taken" + sec_institution = create_private_institution( + "Another Private Institution", + "API", + "BR", + "DF", + "Gama", + "00.000.000/0001-00" + ) + + assert sec_institution.errors.full_messages.include? msg end should "save without fantasy name" do diff --git a/test/unit/public_institution_test.rb b/test/unit/public_institution_test.rb index c2acc8a..1976d0f 100644 --- a/test/unit/public_institution_test.rb +++ b/test/unit/public_institution_test.rb @@ -8,7 +8,17 @@ class PublicInstitutionTest < ActiveSupport::TestCase @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") @juridical_nature = JuridicalNature.create(:name => "Autarquia") - @institution = create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", @juridical_nature, @gov_power, @gov_sphere, "11.222.333/4444-55") + @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 @@ -33,23 +43,26 @@ class PublicInstitutionTest < ActiveSupport::TestCase end should "Not save institution without a governmental_power" do + invalid_msg = "Governmental power can't be blank" @institution.governmental_power = nil assert !@institution.save - assert @institution.errors.full_messages.include? "Governmental power can't be blank" + assert @institution.errors.full_messages.include? invalid_msg end should "Not save institution without a governmental_sphere" do + invalid_msg = "Governmental sphere can't be blank" @institution.governmental_sphere = nil assert !@institution.save - assert @institution.errors.full_messages.include? "Governmental sphere can't be blank" + assert @institution.errors.full_messages.include? invalid_msg end should "not save institution without juridical nature" do + invalid_msg = "Juridical nature can't be blank" @institution.juridical_nature = nil assert !@institution.save - assert @institution.errors.full_messages.include? "Juridical nature can't be blank" + assert @institution.errors.full_messages.include? invalid_msg end end diff --git a/test/unit/search_person_test.rb b/test/unit/search_person_test.rb index 8cdd6af..0f12abc 100644 --- a/test/unit/search_person_test.rb +++ b/test/unit/search_person_test.rb @@ -44,7 +44,7 @@ class SearchPersonTest < ActiveSupport::TestCase assert_equal 2, people_list.count end - should "Find people with Ma in name and RJ in state and Rio in city and ma in email" do + should "Find people with Ma in name and email and RJ in state and Rio in city" do people_list = Person.search("Ma", "RJ", "Rio", "ma") assert_equal 1, people_list.count diff --git a/test/unit/software_database_test.rb b/test/unit/software_database_test.rb index fa6d3fa..b6386d6 100644 --- a/test/unit/software_database_test.rb +++ b/test/unit/software_database_test.rb @@ -3,7 +3,10 @@ require File.dirname(__FILE__) + '/../../../../test/test_helper' class SoftwareDatabaseTest < ActiveSupport::TestCase def setup DatabaseDescription.create!(name: "PostgreSQL") - @software_database = SoftwareDatabase.new(:version => "1.0", :operating_system => "Debian") + @software_database = SoftwareDatabase.new( + :version => "1.0", + :operating_system => "Debian" + ) @software_database.database_description_id = 1 end @@ -37,7 +40,8 @@ class SoftwareDatabaseTest < ActiveSupport::TestCase end should "not save if operating system has more than 20 characters" do + invalid_msg = "Operating system must have until 20 characters" @software_database.operating_system = "a"*21 - assert !@software_database.save, "Operating system must have until 20 characters" + assert !@software_database.save, invalid_msg end end diff --git a/test/unit/software_language_validation.rb b/test/unit/software_language_validation.rb index 5a6cf72..f2e3ddf 100644 --- a/test/unit/software_language_validation.rb +++ b/test/unit/software_language_validation.rb @@ -12,7 +12,7 @@ class SoftwareLanguageValidationTest < ActiveSupport::TestCase SoftwareInfo.destroy_all end - should "Save SoftwareLanguage if version and programming_language are filled" do + should "Save SoftwareLanguage if version and prog_language are filled" do @software_language = create_software_language assert_equal true, @software_language.save end @@ -31,13 +31,14 @@ class SoftwareLanguageValidationTest < ActiveSupport::TestCase should "Don't save SoftwareLanguage if version is too long" do @software_language = create_software_language - @software_language.version = "A too long version to be considered valid as a version" + @software_language.version = "A too long version to be valid as a version" assert_equal true, !@software_language.save end should "Don't save SoftwareLanguage if operating system is too long" do + operating_system = "A too long to be valid as a operating system" @software_language = create_software_language - @software_language.operating_system = "A too long operating system to be considered valid as a operating system" + @software_language.operating_system = operating_system assert_equal true, !@software_language.save end diff --git a/test/unit/software_registration_test.rb b/test/unit/software_registration_test.rb index b6b111a..3f89ac0 100644 --- a/test/unit/software_registration_test.rb +++ b/test/unit/software_registration_test.rb @@ -16,14 +16,22 @@ class SoftwareRegistrationTest < ActiveSupport::TestCase should 'include software registration task if is admin' do person = create_user('molly').person @environment.add_admin(person) - task = CreateSoftware.create!(:name => "Teste One", :requestor => person,:environment => @environment) + task = CreateSoftware.create!( + :name => "Teste One", + :requestor => person, + :environment => @environment + ) assert_equal [task], Task.to(person).pending end should 'create software when admin accept software create task' do person = create_user('Pedro').person @environment.add_admin(person) - task = CreateSoftware.create!(:name => "Teste Two", :requestor => person,:environment => @environment) + task = CreateSoftware.create!( + :name => "Teste Two", + :requestor => person, + :environment => @environment + ) software_count = SoftwareInfo.count task.finish -- libgit2 0.21.2