Commit 133f6fa99157db9f52c8bad9b302029785c75d39

Authored by Gabriela Navarro
Committed by David Silva
1 parent da809018

Removing software categories model and related files

Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
lib/software_categories.rb
... ... @@ -1,25 +0,0 @@
1   -class SoftwareCategories < ActiveRecord::Base
2   - attr_accessible :administration , :agriculture , :business_and_services , :communication ,
3   - :culture , :national_defense , :economy_and_finances , :education ,
4   - :energy , :sports , :habitation , :industry , :environment ,
5   - :research_and_development , :social_security , :social_protection ,
6   - :international_relations , :sanitation , :health ,
7   - :security_public_order , :work , :transportation , :urbanism
8   -
9   - belongs_to :software_info
10   -
11   - validate :verify_blank_fields
12   -
13   - def verify_blank_fields
14   - ignore_list = ["id", "software_info_id"]
15   -
16   - fields = self.attribute_names - ignore_list
17   -
18   - one_is_filled = false
19   - fields.each do |field|
20   - one_is_filled = true if self[field] == true
21   - end
22   -
23   - self.errors.add(:base, _("At last one category must be checked")) unless one_is_filled
24   - end
25   -end
26 0 \ No newline at end of file
lib/software_categories_helper.rb
... ... @@ -1,15 +0,0 @@
1   -module SoftwareCategoriesHelper
2   -
3   - def self.get_categories_as_options
4   - categories = ["<option value = #{""} >Any</option>".html_safe]
5   - value = 1
6   -
7   - SoftwareCategories.attribute_names.each do |attribute|
8   - if attribute.to_s != "id" && attribute.to_s != "software_info_id" then
9   - categories << "<option value = #{attribute} >#{attribute.titleize}</option>".html_safe
10   - value+=1
11   - end
12   - end
13   - categories
14   - end
15   -end
test/functional/mpog_software_plugin_myprofile_controller_test.rb
... ... @@ -87,7 +87,7 @@ class MpogSoftwarePluginMyprofileControllerTest &lt; ActionController::TestCase
87 87  
88 88 software = create_software fields_software
89 89 post :edit_software, :profile => software.community.identifier, :library => fields[0], :language => fields[1],
90   - :database => fields[2], :operating_system => fields[3], :software => fields[4], :software_categories => fields[5], :license => fields[6]
  90 + :database => fields[2], :operating_system => fields[3], :software => fields[4], :license => fields[5]
91 91 assert_equal SoftwareInfo.last.acronym, "test"
92 92 end
93 93  
... ... @@ -98,7 +98,7 @@ class MpogSoftwarePluginMyprofileControllerTest &lt; ActionController::TestCase
98 98 fields[4]['public_software'] = true
99 99 software = create_software fields_software
100 100 post :edit_software, :profile => software.community.identifier, :library => fields[0], :language => fields[1],
101   - :database => fields[2], :operating_system => fields[3], :software => fields[4], :software_categories => fields[5], :license => fields[6]
  101 + :database => fields[2], :operating_system => fields[3], :software => fields[4], :license => fields[5]
102 102 assert_equal true, SoftwareInfo.last.public_software?
103 103 end
104 104  
... ...
test/functional/software_test_helper.rb
... ... @@ -67,13 +67,8 @@ module SoftwareTestHelper
67 67 software = SoftwareInfo.new
68 68 community = Community.new
69 69 software_hash = fields[2]
70   - #library_hash = fields[1]
71   - #language_hash = fields[2]
72   - #database_hash = fields[3]
73   - #operating_system_hash = fields[4]
74 70 license_system_hash = fields[0]
75 71 community_hash = fields[1]
76   - #categories_hash = fields[7]
77 72  
78 73 software_hash.each do |k,v|
79 74 software[k] = v
... ... @@ -85,12 +80,7 @@ module SoftwareTestHelper
85 80  
86 81 community.save!
87 82 software.community = community
88   - #software.software_databases << create_database(database_hash)
89   - #software.software_languages << create_language(language_hash)
90   - #software.operating_systems << create_operating_system(operating_system_hash)
91 83 software.license_info_id = license_system_hash
92   - #software.libraries << create_library(library_hash)
93   - #software.software_categories = create_categories(categories_hash)
94 84  
95 85 software.save
96 86 software
... ... @@ -166,31 +156,6 @@ module SoftwareTestHelper
166 156 fields_software['demonstration_url'] = 'www.test.com'
167 157 hash_list << fields_software
168 158  
169   - #Fields for software categories
170   - fields_categories["administration"] = true
171   - fields_categories["agriculture"] = "1"
172   - fields_categories["business_and_services"] = "1"
173   - fields_categories["communication"] = "1"
174   - fields_categories["culture"] = "1"
175   - fields_categories["national_defense"] = "1"
176   - fields_categories["economy_and_finances"] = "1"
177   - fields_categories["education"] = "1"
178   - fields_categories["energy"] = "1"
179   - fields_categories["sports"] = "1"
180   - fields_categories["habitation"] = "1"
181   - fields_categories["industry"] = "1"
182   - fields_categories["environment"] = "1"
183   - fields_categories["research_and_development"] = "1"
184   - fields_categories["social_security"] = "1"
185   - fields_categories["social_protection"] = "1"
186   - fields_categories["sanitation"] = "1"
187   - fields_categories["health"] = "1"
188   - fields_categories["security_public_order"] = "1"
189   - fields_categories["work"] = "1"
190   - fields_categories["transportation"] = "1"
191   - fields_categories["urbanism"] = "1"
192   - hash_list << fields_categories
193   -
194 159 #Fields for license
195 160 fields_license['license_infos_id'] = LicenseInfo.last.id
196 161 hash_list << fields_license
... ...
test/unit/software_categories_test.rb
... ... @@ -1,71 +0,0 @@
1   -require File.dirname(__FILE__) + '/../../../../test/test_helper'
2   -
3   -class SoftwareCategoriesTest < ActiveSupport::TestCase
4   -
5   - def setup
6   - @community = fast_create(Community, :identifier => 'new-software', :name => 'New Software')
7   -
8   - @language = ProgrammingLanguage.new(:name => 'C++')
9   - @language.save
10   - @software_language = SoftwareLanguage.new(:version => '1', :operating_system => 'os')
11   - @software_language.programming_language = @language
12   - @software_language.save
13   -
14   - @database = DatabaseDescription.new(:name => 'Oracle')
15   - @database.save
16   - @software_database = SoftwareDatabase.new(:version => '2', :operating_system => 'os2')
17   - @software_database.database_description = @database
18   - @software_database.save
19   -
20   - @operating_system_name = OperatingSystemName.new(:name => 'Debian')
21   - @operating_system_name.save
22   - @operating_system = OperatingSystem.new(:version => '1.0')
23   - @operating_system.operating_system_name = @operating_system_name
24   - @operating_system.save
25   -
26   - @software_info = SoftwareInfo.new(:acronym => "SFTW", :e_mag => true,:icp_brasil => true,:intern => true,:e_ping => true,
27   - :e_arq => true, :operating_platform => true, :objectives => "", :features => "")
28   - @software_info.software_languages << @software_language
29   - @software_info.software_databases << @software_database
30   - @software_info.operating_systems << @operating_system
31   -
32   - @software_info.features = "Do a lot of things"
33   - @software_info.objectives = "All tests should pass !"
34   -
35   - @software_categories = SoftwareCategories.new(:administration => true, :agriculture => true, :business_and_services => true, :communication => true,
36   - :culture => true, :national_defense => true, :economy_and_finances => true, :education => true,
37   - :energy => true, :sports => false , :habitation => true, :industry => true, :environment => true,
38   - :research_and_development => true, :social_security => false , :social_protection => true,
39   - :international_relations => true, :sanitation => true, :health => false,
40   - :security_public_order => true, :work => true, :transportation => true, :urbanism => true)
41   - @software_info.software_categories = @software_categories
42   - end
43   -
44   - def teardown
45   - SoftwareDatabase.destroy_all
46   - DatabaseDescription.destroy_all
47   - ProgrammingLanguage.destroy_all
48   - SoftwareLanguage.destroy_all
49   - OperatingSystem.destroy_all
50   - SoftwareCategories.destroy_all
51   - SoftwareInfo.destroy_all
52   - end
53   -
54   - should "save software correctly with SoftwareCategories filds" do
55   - assert @software_info.save
56   - end
57   -
58   - should "set in software_info a reference to software_categories" do
59   - @software_info.save
60   - @software_categories.save
61   - assert_equal SoftwareInfo.last.software_categories, SoftwareCategories.last
62   - end
63   -
64   - should "return a valid value from database" do
65   - @software_info.save
66   - @software_categories.save
67   - software_info = SoftwareInfo.find(@software_info.id)
68   - software_categories = SoftwareCategories.find(software_info.software_categories)
69   - assert_equal true, software_categories.education
70   - end
71   -end