Commit 92b813daa2697aa4e097a9f083ac719216c9bd4b
Committed by
David Silva
1 parent
2e318144
Exists in
master
and in
79 other branches
Remove dead code
Signed-off-by: Gabriela Navarro <navarro1703@gmail.com> Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
Showing
7 changed files
with
238 additions
and
320 deletions
Show diff stats
test/functional/institution_test_helper.rb
@@ -1,59 +0,0 @@ | @@ -1,59 +0,0 @@ | ||
1 | -module InstitutionTestHelper | ||
2 | - | ||
3 | - def self.generate_form_fields name, country, state, city, cnpj, type | ||
4 | - fields = { | ||
5 | - :community => { | ||
6 | - :name => name, | ||
7 | - :country => country, | ||
8 | - :state => state, | ||
9 | - :city => city | ||
10 | - }, | ||
11 | - :institutions => { | ||
12 | - :cnpj=> cnpj, | ||
13 | - :type => type, | ||
14 | - :acronym => "", | ||
15 | - :governmental_power => "", | ||
16 | - :governmental_sphere => "", | ||
17 | - :juridical_nature => "", | ||
18 | - :corporate_name => "coporate default" | ||
19 | - } | ||
20 | - } | ||
21 | - fields | ||
22 | - end | ||
23 | - | ||
24 | - def self.create_public_institution name, acronym, country, state, city, juridical_nature, gov_p, gov_s, cnpj | ||
25 | - institution = PublicInstitution.new | ||
26 | - institution.community = institution_community(name, country, state, city) | ||
27 | - institution.name = name | ||
28 | - institution.juridical_nature = juridical_nature | ||
29 | - institution.acronym = acronym | ||
30 | - institution.governmental_power = gov_p | ||
31 | - institution.governmental_sphere = gov_s | ||
32 | - institution.cnpj = cnpj | ||
33 | - institution.corporate_name = "corporate default" | ||
34 | - institution.save! | ||
35 | - institution | ||
36 | - end | ||
37 | - | ||
38 | - def self.create_private_institution name, acronym, country, state, city, cnpj | ||
39 | - institution = PrivateInstitution.new | ||
40 | - institution.community = institution_community(name, country, state, city) | ||
41 | - institution.name = name | ||
42 | - institution.acronym = acronym | ||
43 | - institution.cnpj = cnpj | ||
44 | - institution.corporate_name = "corporate default" | ||
45 | - institution.save! | ||
46 | - | ||
47 | - institution | ||
48 | - end | ||
49 | - | ||
50 | - def self.institution_community name, country, state, city | ||
51 | - institution_community = Community::new | ||
52 | - institution_community.name = name | ||
53 | - institution_community.country = country | ||
54 | - institution_community.state = state | ||
55 | - institution_community.city = city | ||
56 | - institution_community.save! | ||
57 | - institution_community | ||
58 | - end | ||
59 | -end | ||
60 | \ No newline at end of file | 0 | \ No newline at end of file |
test/functional/mpog_software_plugin_myprofile_controller_test.rb
1 | require File.dirname(__FILE__) + '/../../../../test/test_helper' | 1 | require File.dirname(__FILE__) + '/../../../../test/test_helper' |
2 | -require File.dirname(__FILE__) + '/software_test_helper' | 2 | +require File.dirname(__FILE__) + '/../helpers/software_test_helper' |
3 | require File.dirname(__FILE__) + '/../helpers/institution_test_helper' | 3 | require File.dirname(__FILE__) + '/../helpers/institution_test_helper' |
4 | require( | 4 | require( |
5 | File.dirname(__FILE__) + | 5 | File.dirname(__FILE__) + |
test/functional/software_test_helper.rb
@@ -1,187 +0,0 @@ | @@ -1,187 +0,0 @@ | ||
1 | -module SoftwareTestHelper | ||
2 | - | ||
3 | - def create_language language_fields | ||
4 | - language = SoftwareLanguage.new | ||
5 | - | ||
6 | - language_fields[0].each do |k,v| | ||
7 | - language[k] = v | ||
8 | - end | ||
9 | - language.save! | ||
10 | - language | ||
11 | - end | ||
12 | - | ||
13 | - def create_database database_fields | ||
14 | - | ||
15 | - database = SoftwareDatabase.new | ||
16 | - | ||
17 | - database_fields[0].each do |k,v| | ||
18 | - database[k] = v | ||
19 | - end | ||
20 | - | ||
21 | - database.save! | ||
22 | - database | ||
23 | - end | ||
24 | - | ||
25 | - def create_library library_fields | ||
26 | - library = Library.new | ||
27 | - | ||
28 | - library_fields[0].each do |k,v| | ||
29 | - library[k] = v | ||
30 | - end | ||
31 | - library.save! | ||
32 | - library | ||
33 | - end | ||
34 | - | ||
35 | - def create_operating_system operating_system_hash | ||
36 | - operating_system = OperatingSystem.new | ||
37 | - | ||
38 | - operating_system_hash[0].each do |k,v| | ||
39 | - operating_system[k] = v | ||
40 | - end | ||
41 | - operating_system.save | ||
42 | - operating_system | ||
43 | - end | ||
44 | - | ||
45 | - def create_license license_hash | ||
46 | - license_info = LicenseInfo.new | ||
47 | - | ||
48 | - license_hash.each do |k,v| | ||
49 | - license_info[k] = v | ||
50 | - end | ||
51 | - license_info.save | ||
52 | - license_info | ||
53 | - end | ||
54 | - | ||
55 | - def create_categories categories_hash | ||
56 | - software_categories = SoftwareCategories.new | ||
57 | - | ||
58 | - categories_hash.each do |k,v| | ||
59 | - software_categories[k] = v | ||
60 | - end | ||
61 | - software_categories.save | ||
62 | - software_categories | ||
63 | - end | ||
64 | - | ||
65 | - def create_software fields | ||
66 | - | ||
67 | - software = SoftwareInfo.new | ||
68 | - community = Community.new | ||
69 | - software_hash = fields[2] | ||
70 | - license_system_hash = fields[0] | ||
71 | - community_hash = fields[1] | ||
72 | - | ||
73 | - software_hash.each do |k,v| | ||
74 | - software[k] = v | ||
75 | - end | ||
76 | - | ||
77 | - community_hash.each do |k,v| | ||
78 | - community[k] = v | ||
79 | - end | ||
80 | - | ||
81 | - community.save! | ||
82 | - software.community = community | ||
83 | - software.license_info_id = license_system_hash | ||
84 | - | ||
85 | - software.save | ||
86 | - software | ||
87 | - end | ||
88 | - | ||
89 | - def software_edit_basic_fields | ||
90 | - fields = Hash.new | ||
91 | - fields_license = Hash.new | ||
92 | - hash_list = [] | ||
93 | - | ||
94 | - fields['repository_link'] = 'www.github.com/test' | ||
95 | - fields['finality'] = 'This is the new finality of the software' | ||
96 | - hash_list << fields | ||
97 | - | ||
98 | - #Fields for license info | ||
99 | - fields_license['license_infos_id'] = LicenseInfo.last.id | ||
100 | - hash_list << fields_license | ||
101 | - | ||
102 | - hash_list | ||
103 | - end | ||
104 | - | ||
105 | - def software_edit_specific_fields | ||
106 | - fields_library = Hash.new | ||
107 | - fields_language = Hash.new | ||
108 | - fields_database = Hash.new | ||
109 | - fields_operating_system = Hash.new | ||
110 | - fields_software = Hash.new | ||
111 | - fields_categories = Hash.new | ||
112 | - fields_license = Hash.new | ||
113 | - | ||
114 | - hash_list = [] | ||
115 | - list_database = [] | ||
116 | - list_language = [] | ||
117 | - list_operating_system = [] | ||
118 | - list_library = [] | ||
119 | - | ||
120 | - #Fields for library | ||
121 | - fields_library['version'] = 'test' | ||
122 | - fields_library['name'] = 'test' | ||
123 | - fields_library['license'] = 'test' | ||
124 | - list_library << fields_library | ||
125 | - list_library << {} | ||
126 | - hash_list << list_library | ||
127 | - | ||
128 | - #Fields for software language | ||
129 | - fields_language['version'] = 'test' | ||
130 | - fields_language['programming_language_id'] = ProgrammingLanguage.last.id | ||
131 | - fields_language['operating_system'] = 'test' | ||
132 | - list_language << fields_language | ||
133 | - list_language << {} | ||
134 | - hash_list << list_language | ||
135 | - | ||
136 | - #Fields for database | ||
137 | - fields_database['version'] = 'test' | ||
138 | - fields_database['database_description_id'] = DatabaseDescription.last.id | ||
139 | - fields_database['operating_system'] = 'test' | ||
140 | - list_database << fields_database | ||
141 | - list_database << {} | ||
142 | - hash_list << list_database | ||
143 | - | ||
144 | - #Fields for operating system | ||
145 | - fields_operating_system['version'] = 'version' | ||
146 | - fields_operating_system['operating_system_name_id'] = OperatingSystemName.last.id | ||
147 | - list_operating_system << fields_operating_system | ||
148 | - list_operating_system << {} | ||
149 | - hash_list << list_operating_system | ||
150 | - | ||
151 | - #software fields | ||
152 | - fields_software['acronym'] = 'test' | ||
153 | - fields_software['operating_platform'] = 'Linux' | ||
154 | - fields_software['objectives'] = 'This is the objective of the software' | ||
155 | - fields_software['features'] = 'This software does nothing' | ||
156 | - fields_software['demonstration_url'] = 'www.test.com' | ||
157 | - hash_list << fields_software | ||
158 | - | ||
159 | - #Fields for license | ||
160 | - fields_license['license_infos_id'] = LicenseInfo.last.id | ||
161 | - hash_list << fields_license | ||
162 | - | ||
163 | - hash_list | ||
164 | - end | ||
165 | - | ||
166 | - def software_fields | ||
167 | - fields = Hash.new | ||
168 | - fields_community = Hash.new | ||
169 | - fields_license = Hash.new | ||
170 | - hash_list = [] | ||
171 | - | ||
172 | - #Fields for license info | ||
173 | - fields_license['version'] = LicenseInfo.last.version | ||
174 | - hash_list << fields_license | ||
175 | - | ||
176 | - #Fields for community | ||
177 | - fields_community['name'] = 'Debian' | ||
178 | - fields_community['identifier'] = 'debian' | ||
179 | - hash_list << fields_community | ||
180 | - | ||
181 | - #Fields for basic information | ||
182 | - fields['finality'] = 'This is the finality of the software' | ||
183 | - hash_list << fields | ||
184 | - | ||
185 | - hash_list | ||
186 | - end | ||
187 | -end |
@@ -0,0 +1,187 @@ | @@ -0,0 +1,187 @@ | ||
1 | +module SoftwareTestHelper | ||
2 | + | ||
3 | + def create_language language_fields | ||
4 | + language = SoftwareLanguage.new | ||
5 | + | ||
6 | + language_fields[0].each do |k,v| | ||
7 | + language[k] = v | ||
8 | + end | ||
9 | + language.save! | ||
10 | + language | ||
11 | + end | ||
12 | + | ||
13 | + def create_database database_fields | ||
14 | + | ||
15 | + database = SoftwareDatabase.new | ||
16 | + | ||
17 | + database_fields[0].each do |k,v| | ||
18 | + database[k] = v | ||
19 | + end | ||
20 | + | ||
21 | + database.save! | ||
22 | + database | ||
23 | + end | ||
24 | + | ||
25 | + def create_library library_fields | ||
26 | + library = Library.new | ||
27 | + | ||
28 | + library_fields[0].each do |k,v| | ||
29 | + library[k] = v | ||
30 | + end | ||
31 | + library.save! | ||
32 | + library | ||
33 | + end | ||
34 | + | ||
35 | + def create_operating_system operating_system_hash | ||
36 | + operating_system = OperatingSystem.new | ||
37 | + | ||
38 | + operating_system_hash[0].each do |k,v| | ||
39 | + operating_system[k] = v | ||
40 | + end | ||
41 | + operating_system.save | ||
42 | + operating_system | ||
43 | + end | ||
44 | + | ||
45 | + def create_license license_hash | ||
46 | + license_info = LicenseInfo.new | ||
47 | + | ||
48 | + license_hash.each do |k,v| | ||
49 | + license_info[k] = v | ||
50 | + end | ||
51 | + license_info.save | ||
52 | + license_info | ||
53 | + end | ||
54 | + | ||
55 | + def create_categories categories_hash | ||
56 | + software_categories = SoftwareCategories.new | ||
57 | + | ||
58 | + categories_hash.each do |k,v| | ||
59 | + software_categories[k] = v | ||
60 | + end | ||
61 | + software_categories.save | ||
62 | + software_categories | ||
63 | + end | ||
64 | + | ||
65 | + def create_software fields | ||
66 | + | ||
67 | + software = SoftwareInfo.new | ||
68 | + community = Community.new | ||
69 | + software_hash = fields[2] | ||
70 | + license_system_hash = fields[0] | ||
71 | + community_hash = fields[1] | ||
72 | + | ||
73 | + software_hash.each do |k,v| | ||
74 | + software[k] = v | ||
75 | + end | ||
76 | + | ||
77 | + community_hash.each do |k,v| | ||
78 | + community[k] = v | ||
79 | + end | ||
80 | + | ||
81 | + community.save! | ||
82 | + software.community = community | ||
83 | + software.license_info_id = license_system_hash | ||
84 | + | ||
85 | + software.save | ||
86 | + software | ||
87 | + end | ||
88 | + | ||
89 | + def software_edit_basic_fields | ||
90 | + fields = Hash.new | ||
91 | + fields_license = Hash.new | ||
92 | + hash_list = [] | ||
93 | + | ||
94 | + fields['repository_link'] = 'www.github.com/test' | ||
95 | + fields['finality'] = 'This is the new finality of the software' | ||
96 | + hash_list << fields | ||
97 | + | ||
98 | + #Fields for license info | ||
99 | + fields_license['license_infos_id'] = LicenseInfo.last.id | ||
100 | + hash_list << fields_license | ||
101 | + | ||
102 | + hash_list | ||
103 | + end | ||
104 | + | ||
105 | + def software_edit_specific_fields | ||
106 | + fields_library = Hash.new | ||
107 | + fields_language = Hash.new | ||
108 | + fields_database = Hash.new | ||
109 | + fields_operating_system = Hash.new | ||
110 | + fields_software = Hash.new | ||
111 | + fields_categories = Hash.new | ||
112 | + fields_license = Hash.new | ||
113 | + | ||
114 | + hash_list = [] | ||
115 | + list_database = [] | ||
116 | + list_language = [] | ||
117 | + list_operating_system = [] | ||
118 | + list_library = [] | ||
119 | + | ||
120 | + #Fields for library | ||
121 | + fields_library['version'] = 'test' | ||
122 | + fields_library['name'] = 'test' | ||
123 | + fields_library['license'] = 'test' | ||
124 | + list_library << fields_library | ||
125 | + list_library << {} | ||
126 | + hash_list << list_library | ||
127 | + | ||
128 | + #Fields for software language | ||
129 | + fields_language['version'] = 'test' | ||
130 | + fields_language['programming_language_id'] = ProgrammingLanguage.last.id | ||
131 | + fields_language['operating_system'] = 'test' | ||
132 | + list_language << fields_language | ||
133 | + list_language << {} | ||
134 | + hash_list << list_language | ||
135 | + | ||
136 | + #Fields for database | ||
137 | + fields_database['version'] = 'test' | ||
138 | + fields_database['database_description_id'] = DatabaseDescription.last.id | ||
139 | + fields_database['operating_system'] = 'test' | ||
140 | + list_database << fields_database | ||
141 | + list_database << {} | ||
142 | + hash_list << list_database | ||
143 | + | ||
144 | + #Fields for operating system | ||
145 | + fields_operating_system['version'] = 'version' | ||
146 | + fields_operating_system['operating_system_name_id'] = OperatingSystemName.last.id | ||
147 | + list_operating_system << fields_operating_system | ||
148 | + list_operating_system << {} | ||
149 | + hash_list << list_operating_system | ||
150 | + | ||
151 | + #software fields | ||
152 | + fields_software['acronym'] = 'test' | ||
153 | + fields_software['operating_platform'] = 'Linux' | ||
154 | + fields_software['objectives'] = 'This is the objective of the software' | ||
155 | + fields_software['features'] = 'This software does nothing' | ||
156 | + fields_software['demonstration_url'] = 'www.test.com' | ||
157 | + hash_list << fields_software | ||
158 | + | ||
159 | + #Fields for license | ||
160 | + fields_license['license_infos_id'] = LicenseInfo.last.id | ||
161 | + hash_list << fields_license | ||
162 | + | ||
163 | + hash_list | ||
164 | + end | ||
165 | + | ||
166 | + def software_fields | ||
167 | + fields = Hash.new | ||
168 | + fields_community = Hash.new | ||
169 | + fields_license = Hash.new | ||
170 | + hash_list = [] | ||
171 | + | ||
172 | + #Fields for license info | ||
173 | + fields_license['version'] = LicenseInfo.last.version | ||
174 | + hash_list << fields_license | ||
175 | + | ||
176 | + #Fields for community | ||
177 | + fields_community['name'] = 'Debian' | ||
178 | + fields_community['identifier'] = 'debian' | ||
179 | + hash_list << fields_community | ||
180 | + | ||
181 | + #Fields for basic information | ||
182 | + fields['finality'] = 'This is the finality of the software' | ||
183 | + hash_list << fields | ||
184 | + | ||
185 | + hash_list | ||
186 | + end | ||
187 | +end |
test/unit/mpog_person_test.rb
1 | # encoding: utf-8 | 1 | # encoding: utf-8 |
2 | 2 | ||
3 | require File.dirname(__FILE__) + '/../../../../test/test_helper' | 3 | require File.dirname(__FILE__) + '/../../../../test/test_helper' |
4 | +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' | ||
4 | 5 | ||
5 | class MpogSoftwarePluginPersonTest < ActiveSupport::TestCase | 6 | class MpogSoftwarePluginPersonTest < ActiveSupport::TestCase |
7 | + include PluginTestHelper | ||
8 | + | ||
9 | + def setup | ||
10 | + @plugin = MpogSoftwarePlugin.new | ||
11 | + | ||
12 | + @user = fast_create(User) | ||
13 | + @person = create_person( | ||
14 | + "My Name", | ||
15 | + "user@email.com", | ||
16 | + "123456", | ||
17 | + "123456", | ||
18 | + "user@secondary_email.com", | ||
19 | + "Any State", | ||
20 | + "Some City" | ||
21 | + ) | ||
22 | + end | ||
23 | + | ||
24 | + def teardown | ||
25 | + @plugin = nil | ||
26 | + end | ||
27 | + | ||
28 | + should 'be a noosfero plugin' do | ||
29 | + assert_kind_of Noosfero::Plugin, @plugin | ||
30 | + end | ||
31 | + | ||
32 | + | ||
33 | + should 'return true when the email has not gov.br,jus.br,leg.br or mp.br' do | ||
34 | + @user.secondary_email = "test_email@com.br" | ||
35 | + @user.email = "test_email@net.br" | ||
36 | + assert @user.save | ||
37 | + end | ||
38 | + | ||
6 | should 'save person with a valid full name' do | 39 | should 'save person with a valid full name' do |
7 | p = Person::new :name=>"S1mpl3 0f N4m3", :identifier=>"simple-name" | 40 | p = Person::new :name=>"S1mpl3 0f N4m3", :identifier=>"simple-name" |
8 | p.user = fast_create(:user) | 41 | p.user = fast_create(:user) |
@@ -29,4 +62,21 @@ class MpogSoftwarePluginPersonTest < ActiveSupport::TestCase | @@ -29,4 +62,21 @@ class MpogSoftwarePluginPersonTest < ActiveSupport::TestCase | ||
29 | 62 | ||
30 | assert !p.save , _("Name Should begin with a capital letter and no special characters") | 63 | assert !p.save , _("Name Should begin with a capital letter and no special characters") |
31 | end | 64 | end |
65 | + | ||
66 | + should 'calculate the percentege of person incomplete fields' do | ||
67 | + @person.cell_phone = "76888919" | ||
68 | + @person.contact_phone = "987654321" | ||
69 | + | ||
70 | + assert_equal(67, @plugin.calc_percentage_registration(@person)) | ||
71 | + | ||
72 | + @person.comercial_phone = "11223344" | ||
73 | + @person.country = "I dont know" | ||
74 | + @person.state = "I dont know" | ||
75 | + @person.city = "I dont know" | ||
76 | + @person.organization_website = "www.whatever.com" | ||
77 | + @person.image = Image::new :uploaded_data=>fixture_file_upload('/files/rails.png', 'image/png') | ||
78 | + @person.save | ||
79 | + | ||
80 | + assert_equal(100, @plugin.calc_percentage_registration(@person)) | ||
81 | + end | ||
32 | end | 82 | end |
33 | \ No newline at end of file | 83 | \ No newline at end of file |
test/unit/mpog_software_plugin_test.rb
@@ -1,45 +0,0 @@ | @@ -1,45 +0,0 @@ | ||
1 | -require File.dirname(__FILE__) + '/../../../../test/test_helper' | ||
2 | -require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' | ||
3 | - | ||
4 | -class MpogSoftwarePluginTest < ActiveSupport::TestCase | ||
5 | - include PluginTestHelper | ||
6 | - | ||
7 | - def setup | ||
8 | - @plugin = MpogSoftwarePlugin.new | ||
9 | - @person = create_person( | ||
10 | - "My Name", | ||
11 | - "user@email.com", | ||
12 | - "123456", | ||
13 | - "123456", | ||
14 | - "user@secondary_email.com", | ||
15 | - "Any State", | ||
16 | - "Some City" | ||
17 | - ) | ||
18 | - end | ||
19 | - | ||
20 | - def teardown | ||
21 | - @person.destroy | ||
22 | - end | ||
23 | - | ||
24 | - | ||
25 | - should 'be a noosfero plugin' do | ||
26 | - assert_kind_of Noosfero::Plugin, @plugin | ||
27 | - end | ||
28 | - | ||
29 | - should 'calculate the percentege of person incomplete fields' do | ||
30 | - @person.cell_phone = "76888919" | ||
31 | - @person.contact_phone = "987654321" | ||
32 | - | ||
33 | - assert_equal(67, @plugin.calc_percentage_registration(@person)) | ||
34 | - | ||
35 | - @person.comercial_phone = "11223344" | ||
36 | - @person.country = "I dont know" | ||
37 | - @person.state = "I dont know" | ||
38 | - @person.city = "I dont know" | ||
39 | - @person.organization_website = "www.whatever.com" | ||
40 | - @person.image = Image::new :uploaded_data=>fixture_file_upload('/files/rails.png', 'image/png') | ||
41 | - @person.save | ||
42 | - | ||
43 | - assert_equal(100, @plugin.calc_percentage_registration(@person)) | ||
44 | - end | ||
45 | -end |
test/unit/mpog_validation_test.rb
@@ -1,28 +0,0 @@ | @@ -1,28 +0,0 @@ | ||
1 | -require File.dirname(__FILE__) + '/../../../../test/test_helper' | ||
2 | -require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' | ||
3 | - | ||
4 | -class MpogSoftwarePluginValidationTest < ActiveSupport::TestCase | ||
5 | - include PluginTestHelper | ||
6 | - | ||
7 | - def setup | ||
8 | - @plugin = MpogSoftwarePlugin.new | ||
9 | - | ||
10 | - @user = fast_create(User) | ||
11 | - end | ||
12 | - | ||
13 | - def teardown | ||
14 | - @plugin = nil | ||
15 | - @user = nil | ||
16 | - end | ||
17 | - | ||
18 | - should 'be a noosfero plugin' do | ||
19 | - assert_kind_of Noosfero::Plugin, @plugin | ||
20 | - end | ||
21 | - | ||
22 | - | ||
23 | - should 'return true when the email has not gov.br,jus.br,leg.br or mp.br' do | ||
24 | - @user.secondary_email = "test_email@com.br" | ||
25 | - @user.email = "test_email@net.br" | ||
26 | - assert @user.save | ||
27 | - end | ||
28 | -end |