From 7e2d4d40698c26777839ffd8879ace1d0766bcdf Mon Sep 17 00:00:00 2001 From: Gabriela Navarro Date: Thu, 16 Oct 2014 14:11:25 +0000 Subject: [PATCH] Tests for edit software --- test/functional/mpog_software_plugin_myprofile_controller_test.rb | 21 ++++++++++++++++++--- test/functional/software_test_helper.rb | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------- 2 files changed, 90 insertions(+), 36 deletions(-) diff --git a/test/functional/mpog_software_plugin_myprofile_controller_test.rb b/test/functional/mpog_software_plugin_myprofile_controller_test.rb index d8a8a06..d119673 100644 --- a/test/functional/mpog_software_plugin_myprofile_controller_test.rb +++ b/test/functional/mpog_software_plugin_myprofile_controller_test.rb @@ -63,13 +63,28 @@ class MpogSoftwarePluginMyprofileControllerTest < ActionController::TestCase should 'create a new software with all fields filled in' do fields = software_fields - post :new_software, :profile => person.identifier, :community => fields[6], :license_info => fields[5], - :software_info => fields[0], :library => fields[1], :database => fields[3], - :language => fields[2], :operating_system=> fields[4],:software_categories => fields[7] + post :new_software, :profile => person.identifier, :community => fields[1], :license_info => fields[0], + :software_info => fields[2] assert_equal SoftwareInfo.last.community.name, "Debian" end + should 'edit a new software adding basic information' do + fields_software = software_fields + fields = software_edit_basic_fields + software = create_software fields_software + post :edit_software, :profile => software.community.identifier, :license => fields[1], :software => fields[0], :library => {}, :operating_system => {}, :language => {}, :database => {} + assert_equal SoftwareInfo.last.repository_link, "www.github.com/test" + end + + should 'edit a new software adding specific information' do + fields_software = software_fields + fields = software_edit_specific_fields + software = create_software fields_software + post :edit_software, :profile => software.community.identifier, :library => fields[0], :language => fields[1], + :database => fields[2], :operating_system => fields[3], :software => fields[4], :software_categories => fields[5], :license => fields[6] + assert_equal SoftwareInfo.last.acronym, "test" + end end diff --git a/test/functional/software_test_helper.rb b/test/functional/software_test_helper.rb index 3b58f93..0378aef 100644 --- a/test/functional/software_test_helper.rb +++ b/test/functional/software_test_helper.rb @@ -66,14 +66,14 @@ module SoftwareTestHelper software = SoftwareInfo.new community = Community.new - software_hash = fields[0] - library_hash = fields[1] - language_hash = fields[2] - database_hash = fields[3] - operating_system_hash = fields[4] - license_system_hash = fields[5] - community_hash = fields[6] - categories_hash = fields[7] + software_hash = fields[2] + #library_hash = fields[1] + #language_hash = fields[2] + #database_hash = fields[3] + #operating_system_hash = fields[4] + license_system_hash = fields[0] + community_hash = fields[1] + #categories_hash = fields[7] software_hash.each do |k,v| software[k] = v @@ -85,25 +85,43 @@ module SoftwareTestHelper community.save! software.community = community - software.software_databases << create_database(database_hash) - software.software_languages << create_language(language_hash) - software.operating_systems << create_operating_system(operating_system_hash) + #software.software_databases << create_database(database_hash) + #software.software_languages << create_language(language_hash) + #software.operating_systems << create_operating_system(operating_system_hash) software.license_info_id = license_system_hash - software.libraries << create_library(library_hash) - software.software_categories = create_categories(categories_hash) + #software.libraries << create_library(library_hash) + #software.software_categories = create_categories(categories_hash) + software.save software end - def software_fields - + 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_community = Hash.new + fields_software = Hash.new + fields_categories = Hash.new fields_license = Hash.new + + hash_list = [] list_database = [] list_language = [] list_operating_system = [] @@ -115,36 +133,39 @@ module SoftwareTestHelper 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 << {} - #Fields for license info - fields_license['version'] = LicenseInfo.last.version + 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 << {} - #Fields for community - fields_community['name'] = 'Debian' - fields_community['identifier'] = 'debian' + hash_list << list_operating_system - fields['acronym'] = 'test' - fields['objectives'] = 'test' - fields['features'] = 'test' - fields['operating_platform'] = 'operating_platform_test' - fields['demonstration_url'] = 'test' + #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' + hash_list << fields_software - fields_categories = {} + #Fields for software categories fields_categories["administration"] = true fields_categories["agriculture"] = "1" fields_categories["business_and_services"] = "1" @@ -167,16 +188,34 @@ module SoftwareTestHelper fields_categories["work"] = "1" fields_categories["transportation"] = "1" fields_categories["urbanism"] = "1" + hash_list << fields_categories + + #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 = [] - hash_list << fields - hash_list << list_library - hash_list << list_language - hash_list << list_database - hash_list << list_operating_system + + #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 - hash_list << fields_categories + + #Fields for basic information + fields['finality'] = 'This is the finality of the software' + hash_list << fields + hash_list end end -- libgit2 0.21.2