From 92b813daa2697aa4e097a9f083ac719216c9bd4b Mon Sep 17 00:00:00 2001 From: Luciano Date: Tue, 16 Dec 2014 16:38:30 -0200 Subject: [PATCH] Remove dead code --- test/functional/institution_test_helper.rb | 59 ----------------------------------------------------------- test/functional/mpog_software_plugin_myprofile_controller_test.rb | 2 +- test/functional/software_test_helper.rb | 187 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- test/helpers/software_test_helper.rb | 187 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/unit/mpog_person_test.rb | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ test/unit/mpog_software_plugin_test.rb | 45 --------------------------------------------- test/unit/mpog_validation_test.rb | 28 ---------------------------- 7 files changed, 238 insertions(+), 320 deletions(-) delete mode 100644 test/functional/institution_test_helper.rb delete mode 100644 test/functional/software_test_helper.rb create mode 100644 test/helpers/software_test_helper.rb delete mode 100644 test/unit/mpog_software_plugin_test.rb delete mode 100644 test/unit/mpog_validation_test.rb diff --git a/test/functional/institution_test_helper.rb b/test/functional/institution_test_helper.rb deleted file mode 100644 index 0f129e3..0000000 --- a/test/functional/institution_test_helper.rb +++ /dev/null @@ -1,59 +0,0 @@ -module InstitutionTestHelper - - def self.generate_form_fields name, country, state, city, cnpj, type - fields = { - :community => { - :name => name, - :country => country, - :state => state, - :city => city - }, - :institutions => { - :cnpj=> cnpj, - :type => type, - :acronym => "", - :governmental_power => "", - :governmental_sphere => "", - :juridical_nature => "", - :corporate_name => "coporate default" - } - } - fields - end - - def self.create_public_institution name, acronym, country, state, city, juridical_nature, gov_p, gov_s, cnpj - institution = PublicInstitution.new - institution.community = institution_community(name, country, state, city) - institution.name = name - institution.juridical_nature = juridical_nature - institution.acronym = acronym - institution.governmental_power = gov_p - institution.governmental_sphere = gov_s - institution.cnpj = cnpj - institution.corporate_name = "corporate default" - institution.save! - institution - end - - def self.create_private_institution name, acronym, country, state, city, cnpj - institution = PrivateInstitution.new - institution.community = institution_community(name, country, state, city) - institution.name = name - institution.acronym = acronym - institution.cnpj = cnpj - institution.corporate_name = "corporate default" - institution.save! - - institution - end - - def self.institution_community name, country, state, city - institution_community = Community::new - institution_community.name = name - institution_community.country = country - institution_community.state = state - institution_community.city = city - institution_community.save! - institution_community - end -end \ No newline at end of file diff --git a/test/functional/mpog_software_plugin_myprofile_controller_test.rb b/test/functional/mpog_software_plugin_myprofile_controller_test.rb index 0ef1a8d..5bb9989 100644 --- a/test/functional/mpog_software_plugin_myprofile_controller_test.rb +++ b/test/functional/mpog_software_plugin_myprofile_controller_test.rb @@ -1,5 +1,5 @@ require File.dirname(__FILE__) + '/../../../../test/test_helper' -require File.dirname(__FILE__) + '/software_test_helper' +require File.dirname(__FILE__) + '/../helpers/software_test_helper' require File.dirname(__FILE__) + '/../helpers/institution_test_helper' require( File.dirname(__FILE__) + diff --git a/test/functional/software_test_helper.rb b/test/functional/software_test_helper.rb deleted file mode 100644 index 93705c6..0000000 --- a/test/functional/software_test_helper.rb +++ /dev/null @@ -1,187 +0,0 @@ -module SoftwareTestHelper - - def create_language language_fields - language = SoftwareLanguage.new - - language_fields[0].each do |k,v| - language[k] = v - end - language.save! - language - end - - def create_database database_fields - - database = SoftwareDatabase.new - - database_fields[0].each do |k,v| - database[k] = v - end - - database.save! - database - end - - def create_library library_fields - library = Library.new - - library_fields[0].each do |k,v| - library[k] = v - end - library.save! - library - end - - def create_operating_system operating_system_hash - operating_system = OperatingSystem.new - - operating_system_hash[0].each do |k,v| - operating_system[k] = v - end - operating_system.save - operating_system - end - - def create_license license_hash - license_info = LicenseInfo.new - - license_hash.each do |k,v| - license_info[k] = v - end - license_info.save - license_info - end - - def create_categories categories_hash - software_categories = SoftwareCategories.new - - categories_hash.each do |k,v| - software_categories[k] = v - end - software_categories.save - software_categories - end - - def create_software fields - - software = SoftwareInfo.new - community = Community.new - software_hash = fields[2] - license_system_hash = fields[0] - community_hash = fields[1] - - software_hash.each do |k,v| - software[k] = v - end - - community_hash.each do |k,v| - community[k] = v - end - - community.save! - software.community = community - software.license_info_id = license_system_hash - - software.save - software - end - - def software_edit_basic_fields - fields = Hash.new - fields_license = Hash.new - hash_list = [] - - fields['repository_link'] = 'www.github.com/test' - fields['finality'] = 'This is the new finality of the software' - hash_list << fields - - #Fields for license info - fields_license['license_infos_id'] = LicenseInfo.last.id - hash_list << fields_license - - hash_list - end - - def software_edit_specific_fields - fields_library = Hash.new - fields_language = Hash.new - fields_database = Hash.new - fields_operating_system = Hash.new - fields_software = Hash.new - fields_categories = Hash.new - fields_license = Hash.new - - hash_list = [] - list_database = [] - list_language = [] - list_operating_system = [] - list_library = [] - - #Fields for library - fields_library['version'] = 'test' - fields_library['name'] = 'test' - fields_library['license'] = 'test' - list_library << fields_library - list_library << {} - hash_list << list_library - - #Fields for software language - fields_language['version'] = 'test' - fields_language['programming_language_id'] = ProgrammingLanguage.last.id - fields_language['operating_system'] = 'test' - list_language << fields_language - list_language << {} - hash_list << list_language - - #Fields for database - fields_database['version'] = 'test' - fields_database['database_description_id'] = DatabaseDescription.last.id - fields_database['operating_system'] = 'test' - list_database << fields_database - list_database << {} - hash_list << list_database - - #Fields for operating system - fields_operating_system['version'] = 'version' - fields_operating_system['operating_system_name_id'] = OperatingSystemName.last.id - list_operating_system << fields_operating_system - list_operating_system << {} - hash_list << list_operating_system - - #software fields - fields_software['acronym'] = 'test' - fields_software['operating_platform'] = 'Linux' - fields_software['objectives'] = 'This is the objective of the software' - fields_software['features'] = 'This software does nothing' - fields_software['demonstration_url'] = 'www.test.com' - hash_list << fields_software - - #Fields for license - fields_license['license_infos_id'] = LicenseInfo.last.id - hash_list << fields_license - - hash_list - end - - def software_fields - fields = Hash.new - fields_community = Hash.new - fields_license = Hash.new - hash_list = [] - - #Fields for license info - fields_license['version'] = LicenseInfo.last.version - hash_list << fields_license - - #Fields for community - fields_community['name'] = 'Debian' - fields_community['identifier'] = 'debian' - hash_list << fields_community - - #Fields for basic information - fields['finality'] = 'This is the finality of the software' - hash_list << fields - - hash_list - end -end diff --git a/test/helpers/software_test_helper.rb b/test/helpers/software_test_helper.rb new file mode 100644 index 0000000..93705c6 --- /dev/null +++ b/test/helpers/software_test_helper.rb @@ -0,0 +1,187 @@ +module SoftwareTestHelper + + def create_language language_fields + language = SoftwareLanguage.new + + language_fields[0].each do |k,v| + language[k] = v + end + language.save! + language + end + + def create_database database_fields + + database = SoftwareDatabase.new + + database_fields[0].each do |k,v| + database[k] = v + end + + database.save! + database + end + + def create_library library_fields + library = Library.new + + library_fields[0].each do |k,v| + library[k] = v + end + library.save! + library + end + + def create_operating_system operating_system_hash + operating_system = OperatingSystem.new + + operating_system_hash[0].each do |k,v| + operating_system[k] = v + end + operating_system.save + operating_system + end + + def create_license license_hash + license_info = LicenseInfo.new + + license_hash.each do |k,v| + license_info[k] = v + end + license_info.save + license_info + end + + def create_categories categories_hash + software_categories = SoftwareCategories.new + + categories_hash.each do |k,v| + software_categories[k] = v + end + software_categories.save + software_categories + end + + def create_software fields + + software = SoftwareInfo.new + community = Community.new + software_hash = fields[2] + license_system_hash = fields[0] + community_hash = fields[1] + + software_hash.each do |k,v| + software[k] = v + end + + community_hash.each do |k,v| + community[k] = v + end + + community.save! + software.community = community + software.license_info_id = license_system_hash + + software.save + software + end + + def software_edit_basic_fields + fields = Hash.new + fields_license = Hash.new + hash_list = [] + + fields['repository_link'] = 'www.github.com/test' + fields['finality'] = 'This is the new finality of the software' + hash_list << fields + + #Fields for license info + fields_license['license_infos_id'] = LicenseInfo.last.id + hash_list << fields_license + + hash_list + end + + def software_edit_specific_fields + fields_library = Hash.new + fields_language = Hash.new + fields_database = Hash.new + fields_operating_system = Hash.new + fields_software = Hash.new + fields_categories = Hash.new + fields_license = Hash.new + + hash_list = [] + list_database = [] + list_language = [] + list_operating_system = [] + list_library = [] + + #Fields for library + fields_library['version'] = 'test' + fields_library['name'] = 'test' + fields_library['license'] = 'test' + list_library << fields_library + list_library << {} + hash_list << list_library + + #Fields for software language + fields_language['version'] = 'test' + fields_language['programming_language_id'] = ProgrammingLanguage.last.id + fields_language['operating_system'] = 'test' + list_language << fields_language + list_language << {} + hash_list << list_language + + #Fields for database + fields_database['version'] = 'test' + fields_database['database_description_id'] = DatabaseDescription.last.id + fields_database['operating_system'] = 'test' + list_database << fields_database + list_database << {} + hash_list << list_database + + #Fields for operating system + fields_operating_system['version'] = 'version' + fields_operating_system['operating_system_name_id'] = OperatingSystemName.last.id + list_operating_system << fields_operating_system + list_operating_system << {} + hash_list << list_operating_system + + #software fields + fields_software['acronym'] = 'test' + fields_software['operating_platform'] = 'Linux' + fields_software['objectives'] = 'This is the objective of the software' + fields_software['features'] = 'This software does nothing' + fields_software['demonstration_url'] = 'www.test.com' + hash_list << fields_software + + #Fields for license + fields_license['license_infos_id'] = LicenseInfo.last.id + hash_list << fields_license + + hash_list + end + + def software_fields + fields = Hash.new + fields_community = Hash.new + fields_license = Hash.new + hash_list = [] + + #Fields for license info + fields_license['version'] = LicenseInfo.last.version + hash_list << fields_license + + #Fields for community + fields_community['name'] = 'Debian' + fields_community['identifier'] = 'debian' + hash_list << fields_community + + #Fields for basic information + fields['finality'] = 'This is the finality of the software' + hash_list << fields + + hash_list + end +end diff --git a/test/unit/mpog_person_test.rb b/test/unit/mpog_person_test.rb index ae4c5cb..a692a45 100644 --- a/test/unit/mpog_person_test.rb +++ b/test/unit/mpog_person_test.rb @@ -1,8 +1,41 @@ # encoding: utf-8 require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' class MpogSoftwarePluginPersonTest < ActiveSupport::TestCase + include PluginTestHelper + + def setup + @plugin = MpogSoftwarePlugin.new + + @user = fast_create(User) + @person = create_person( + "My Name", + "user@email.com", + "123456", + "123456", + "user@secondary_email.com", + "Any State", + "Some City" + ) + end + + def teardown + @plugin = nil + end + + should 'be a noosfero plugin' do + assert_kind_of Noosfero::Plugin, @plugin + end + + + should 'return true when the email has not gov.br,jus.br,leg.br or mp.br' do + @user.secondary_email = "test_email@com.br" + @user.email = "test_email@net.br" + assert @user.save + end + should 'save person with a valid full name' do p = Person::new :name=>"S1mpl3 0f N4m3", :identifier=>"simple-name" p.user = fast_create(:user) @@ -29,4 +62,21 @@ class MpogSoftwarePluginPersonTest < ActiveSupport::TestCase assert !p.save , _("Name Should begin with a capital letter and no special characters") end + + should 'calculate the percentege of person incomplete fields' do + @person.cell_phone = "76888919" + @person.contact_phone = "987654321" + + assert_equal(67, @plugin.calc_percentage_registration(@person)) + + @person.comercial_phone = "11223344" + @person.country = "I dont know" + @person.state = "I dont know" + @person.city = "I dont know" + @person.organization_website = "www.whatever.com" + @person.image = Image::new :uploaded_data=>fixture_file_upload('/files/rails.png', 'image/png') + @person.save + + assert_equal(100, @plugin.calc_percentage_registration(@person)) + end end \ No newline at end of file diff --git a/test/unit/mpog_software_plugin_test.rb b/test/unit/mpog_software_plugin_test.rb deleted file mode 100644 index 4041e1c..0000000 --- a/test/unit/mpog_software_plugin_test.rb +++ /dev/null @@ -1,45 +0,0 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' -require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' - -class MpogSoftwarePluginTest < ActiveSupport::TestCase - include PluginTestHelper - - def setup - @plugin = MpogSoftwarePlugin.new - @person = create_person( - "My Name", - "user@email.com", - "123456", - "123456", - "user@secondary_email.com", - "Any State", - "Some City" - ) - end - - def teardown - @person.destroy - end - - - should 'be a noosfero plugin' do - assert_kind_of Noosfero::Plugin, @plugin - end - - should 'calculate the percentege of person incomplete fields' do - @person.cell_phone = "76888919" - @person.contact_phone = "987654321" - - assert_equal(67, @plugin.calc_percentage_registration(@person)) - - @person.comercial_phone = "11223344" - @person.country = "I dont know" - @person.state = "I dont know" - @person.city = "I dont know" - @person.organization_website = "www.whatever.com" - @person.image = Image::new :uploaded_data=>fixture_file_upload('/files/rails.png', 'image/png') - @person.save - - assert_equal(100, @plugin.calc_percentage_registration(@person)) - end -end diff --git a/test/unit/mpog_validation_test.rb b/test/unit/mpog_validation_test.rb deleted file mode 100644 index 0f6b675..0000000 --- a/test/unit/mpog_validation_test.rb +++ /dev/null @@ -1,28 +0,0 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' -require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' - -class MpogSoftwarePluginValidationTest < ActiveSupport::TestCase - include PluginTestHelper - - def setup - @plugin = MpogSoftwarePlugin.new - - @user = fast_create(User) - end - - def teardown - @plugin = nil - @user = nil - end - - should 'be a noosfero plugin' do - assert_kind_of Noosfero::Plugin, @plugin - end - - - should 'return true when the email has not gov.br,jus.br,leg.br or mp.br' do - @user.secondary_email = "test_email@com.br" - @user.email = "test_email@net.br" - assert @user.save - end -end -- libgit2 0.21.2