From 133f6fa99157db9f52c8bad9b302029785c75d39 Mon Sep 17 00:00:00 2001 From: Gabriela Navarro Date: Thu, 11 Dec 2014 18:26:43 +0000 Subject: [PATCH] Removing software categories model and related files --- lib/software_categories.rb | 25 ------------------------- lib/software_categories_helper.rb | 15 --------------- test/functional/mpog_software_plugin_myprofile_controller_test.rb | 4 ++-- test/functional/software_test_helper.rb | 35 ----------------------------------- test/unit/software_categories_test.rb | 71 ----------------------------------------------------------------------- 5 files changed, 2 insertions(+), 148 deletions(-) delete mode 100644 lib/software_categories.rb delete mode 100644 lib/software_categories_helper.rb delete mode 100644 test/unit/software_categories_test.rb diff --git a/lib/software_categories.rb b/lib/software_categories.rb deleted file mode 100644 index e7206f9..0000000 --- a/lib/software_categories.rb +++ /dev/null @@ -1,25 +0,0 @@ -class SoftwareCategories < ActiveRecord::Base - attr_accessible :administration , :agriculture , :business_and_services , :communication , - :culture , :national_defense , :economy_and_finances , :education , - :energy , :sports , :habitation , :industry , :environment , - :research_and_development , :social_security , :social_protection , - :international_relations , :sanitation , :health , - :security_public_order , :work , :transportation , :urbanism - - belongs_to :software_info - - validate :verify_blank_fields - - def verify_blank_fields - ignore_list = ["id", "software_info_id"] - - fields = self.attribute_names - ignore_list - - one_is_filled = false - fields.each do |field| - one_is_filled = true if self[field] == true - end - - self.errors.add(:base, _("At last one category must be checked")) unless one_is_filled - end -end \ No newline at end of file diff --git a/lib/software_categories_helper.rb b/lib/software_categories_helper.rb deleted file mode 100644 index 4540847..0000000 --- a/lib/software_categories_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -module SoftwareCategoriesHelper - - def self.get_categories_as_options - categories = ["".html_safe] - value = 1 - - SoftwareCategories.attribute_names.each do |attribute| - if attribute.to_s != "id" && attribute.to_s != "software_info_id" then - categories << "".html_safe - value+=1 - end - end - categories - end -end diff --git a/test/functional/mpog_software_plugin_myprofile_controller_test.rb b/test/functional/mpog_software_plugin_myprofile_controller_test.rb index a5aae0f..66a0988 100644 --- a/test/functional/mpog_software_plugin_myprofile_controller_test.rb +++ b/test/functional/mpog_software_plugin_myprofile_controller_test.rb @@ -87,7 +87,7 @@ class MpogSoftwarePluginMyprofileControllerTest < ActionController::TestCase 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] + :database => fields[2], :operating_system => fields[3], :software => fields[4], :license => fields[5] assert_equal SoftwareInfo.last.acronym, "test" end @@ -98,7 +98,7 @@ class MpogSoftwarePluginMyprofileControllerTest < ActionController::TestCase fields[4]['public_software'] = true 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] + :database => fields[2], :operating_system => fields[3], :software => fields[4], :license => fields[5] assert_equal true, SoftwareInfo.last.public_software? end diff --git a/test/functional/software_test_helper.rb b/test/functional/software_test_helper.rb index 5181f24..93705c6 100644 --- a/test/functional/software_test_helper.rb +++ b/test/functional/software_test_helper.rb @@ -67,13 +67,8 @@ module SoftwareTestHelper software = SoftwareInfo.new community = Community.new 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,12 +80,7 @@ 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.license_info_id = license_system_hash - #software.libraries << create_library(library_hash) - #software.software_categories = create_categories(categories_hash) software.save software @@ -166,31 +156,6 @@ module SoftwareTestHelper fields_software['demonstration_url'] = 'www.test.com' hash_list << fields_software - #Fields for software categories - fields_categories["administration"] = true - fields_categories["agriculture"] = "1" - fields_categories["business_and_services"] = "1" - fields_categories["communication"] = "1" - fields_categories["culture"] = "1" - fields_categories["national_defense"] = "1" - fields_categories["economy_and_finances"] = "1" - fields_categories["education"] = "1" - fields_categories["energy"] = "1" - fields_categories["sports"] = "1" - fields_categories["habitation"] = "1" - fields_categories["industry"] = "1" - fields_categories["environment"] = "1" - fields_categories["research_and_development"] = "1" - fields_categories["social_security"] = "1" - fields_categories["social_protection"] = "1" - fields_categories["sanitation"] = "1" - fields_categories["health"] = "1" - fields_categories["security_public_order"] = "1" - 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 diff --git a/test/unit/software_categories_test.rb b/test/unit/software_categories_test.rb deleted file mode 100644 index e1fd93c..0000000 --- a/test/unit/software_categories_test.rb +++ /dev/null @@ -1,71 +0,0 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' - -class SoftwareCategoriesTest < ActiveSupport::TestCase - - def setup - @community = fast_create(Community, :identifier => 'new-software', :name => 'New Software') - - @language = ProgrammingLanguage.new(:name => 'C++') - @language.save - @software_language = SoftwareLanguage.new(:version => '1', :operating_system => 'os') - @software_language.programming_language = @language - @software_language.save - - @database = DatabaseDescription.new(:name => 'Oracle') - @database.save - @software_database = SoftwareDatabase.new(:version => '2', :operating_system => 'os2') - @software_database.database_description = @database - @software_database.save - - @operating_system_name = OperatingSystemName.new(:name => 'Debian') - @operating_system_name.save - @operating_system = OperatingSystem.new(:version => '1.0') - @operating_system.operating_system_name = @operating_system_name - @operating_system.save - - @software_info = SoftwareInfo.new(:acronym => "SFTW", :e_mag => true,:icp_brasil => true,:intern => true,:e_ping => true, - :e_arq => true, :operating_platform => true, :objectives => "", :features => "") - @software_info.software_languages << @software_language - @software_info.software_databases << @software_database - @software_info.operating_systems << @operating_system - - @software_info.features = "Do a lot of things" - @software_info.objectives = "All tests should pass !" - - @software_categories = SoftwareCategories.new(:administration => true, :agriculture => true, :business_and_services => true, :communication => true, - :culture => true, :national_defense => true, :economy_and_finances => true, :education => true, - :energy => true, :sports => false , :habitation => true, :industry => true, :environment => true, - :research_and_development => true, :social_security => false , :social_protection => true, - :international_relations => true, :sanitation => true, :health => false, - :security_public_order => true, :work => true, :transportation => true, :urbanism => true) - @software_info.software_categories = @software_categories - end - - def teardown - SoftwareDatabase.destroy_all - DatabaseDescription.destroy_all - ProgrammingLanguage.destroy_all - SoftwareLanguage.destroy_all - OperatingSystem.destroy_all - SoftwareCategories.destroy_all - SoftwareInfo.destroy_all - end - - should "save software correctly with SoftwareCategories filds" do - assert @software_info.save - end - - should "set in software_info a reference to software_categories" do - @software_info.save - @software_categories.save - assert_equal SoftwareInfo.last.software_categories, SoftwareCategories.last - end - - should "return a valid value from database" do - @software_info.save - @software_categories.save - software_info = SoftwareInfo.find(@software_info.id) - software_categories = SoftwareCategories.find(software_info.software_categories) - assert_equal true, software_categories.education - end -end -- libgit2 0.21.2