diff --git a/test/functional/mpog_software_plugin_myprofile_controller_test.rb b/test/functional/mpog_software_plugin_myprofile_controller_test.rb index 553842a..d036d82 100644 --- a/test/functional/mpog_software_plugin_myprofile_controller_test.rb +++ b/test/functional/mpog_software_plugin_myprofile_controller_test.rb @@ -1,12 +1,12 @@ require File.dirname(__FILE__) + '/../../../../test/test_helper' require File.dirname(__FILE__) + '/../../controllers/mpog_software_plugin_myprofile_controller' -require File.dirname(__FILE__) + '/software_helper' +require File.dirname(__FILE__) + '/software_test_helper' class MpogSoftwarePluginMyprofileController; def rescue_action(e) raise e end; end class MpogSoftwarePluginMyprofileControllerTest < ActionController::TestCase - include SoftwareHelper + include SoftwareTestHelper def setup @controller = MpogSoftwarePluginMyprofileController.new @request = ActionController::TestRequest.new @@ -22,9 +22,9 @@ class MpogSoftwarePluginMyprofileControllerTest < ActionController::TestCase OperatingSystemName.create(:name=>"Debian") login_as(@person.user.login) - e = Environment.default - e.enable_plugin('MpogSoftwarePlugin') - e.save! + @e = Environment.default + @e.enable_plugin('MpogSoftwarePlugin') + @e.save! end attr_accessor :person, :offer @@ -32,8 +32,9 @@ class MpogSoftwarePluginMyprofileControllerTest < ActionController::TestCase should 'Add offer to admin in new software' do @hash_list = software_fields @software = create_software @hash_list - @software.community.add_admin(@offer.person) - assert_equal @offer.id, Community.last.admins.last.id + @software.community.add_admin(@offer.person) + @software.save + assert_equal @offer.id, @software.community.admins.last.id end should 'search new offers while creating a new software' do @@ -62,52 +63,12 @@ class MpogSoftwarePluginMyprofileControllerTest < ActionController::TestCase should 'create a new software with all fields filled in' do fields = software_fields - software = create_software(fields) - assert software.save - end - -private - - def software_fields - fields = Hash.new - fields_library = Hash.new - fields_language = Hash.new - fields_database = Hash.new - fields_license = Hash.new - fields_operating_system = Hash.new - #Fields for library - fields_library['version'] = 'test' - fields_library['name'] = 'test' - fields_library['license'] = 'test' - #Fields for software language - fields_language['version'] = 'test' - fields_language['programming_language_id'] = ProgrammingLanguage.last.id - fields_language['operating_system'] = 'test' - #Fields for database - fields_database['version'] = 'test' - fields_database['database_description_id'] = DatabaseDescription.last.id - fields_database['operating_system'] = 'test' - #Fields for license info - fields_license['version'] = 'teste' - fields_license['link'] = 'teste' - #Fields for operating system - fields_operating_system['version'] = 'version' - fields_operating_system['operating_system_name_id'] = OperatingSystemName.last.id + 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] + assert @response.success? + end - fields['acronym'] = 'test' - fields['objectives'] = 'test' - fields['features'] = 'test' - fields['operating_platform'] = 'operating_plataform_test' - fields['demonstration_url'] = 'test' - hash_list = [] - hash_list << fields - hash_list << fields_library - hash_list << fields_language - hash_list << fields_database - hash_list << fields_operating_system - hash_list << fields_license - hash_list - end end diff --git a/test/functional/software_helper.rb b/test/functional/software_helper.rb deleted file mode 100644 index 256d636..0000000 --- a/test/functional/software_helper.rb +++ /dev/null @@ -1,80 +0,0 @@ -module SoftwareHelper - - def create_language language_fields - language = SoftwareLanguage.new - - language_fields.each do |k,v| - language[k] = v - end - language.save - language - end - - def create_database database_fields - - database = SoftwareDatabase.new - - database_fields.each do |k,v| - database[k] = v - end - - database.save - database - end - - def create_library library_fields - library = Library.new - - library_fields.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.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_software fields - - software = SoftwareInfo.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] - - software_hash.each do |k,v| - software[k] = v - end - - community = Community.new - community.name = "debian" - 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.license_info = create_license(license_system_hash) - software.libraries << create_library(library_hash) - - software - end -end diff --git a/test/functional/software_test_helper.rb b/test/functional/software_test_helper.rb new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/functional/software_test_helper.rb -- libgit2 0.21.2