Commit d7a9bdd0ceac35946aba922071558cd8d0e4e3ce
Committed by
Gabriela Navarro
1 parent
55dbc944
Exists in
master
and in
79 other branches
Corrections on all unit tests
- Duplicated integration test was removed(institution_helper_test.rb) (correcoes_aderencia) Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Showing
10 changed files
with
117 additions
and
53 deletions
Show diff stats
lib/mpog_software_plugin.rb
@@ -266,13 +266,12 @@ class MpogSoftwarePlugin < Noosfero::Plugin | @@ -266,13 +266,12 @@ class MpogSoftwarePlugin < Noosfero::Plugin | ||
266 | 266 | ||
267 | protected | 267 | protected |
268 | 268 | ||
269 | - | ||
270 | - def create_url_to_edit_profile person | 269 | + def create_url_to_edit_profile person |
271 | new_url = person.public_profile_url | 270 | new_url = person.public_profile_url |
272 | new_url[:controller] = 'profile_editor' | 271 | new_url[:controller] = 'profile_editor' |
273 | new_url[:action] = 'edit' | 272 | new_url[:action] = 'edit' |
274 | new_url | 273 | new_url |
275 | - end | 274 | + end |
276 | 275 | ||
277 | def profile_required_list | 276 | def profile_required_list |
278 | required_list = ["cell_phone","contact_phone","institutions","comercial_phone","country","city","state","organization_website","area_interest","image"] | 277 | required_list = ["cell_phone","contact_phone","institutions","comercial_phone","country","city","state","organization_website","area_interest","image"] |
test/functional/search_controller_test.rb
@@ -85,7 +85,7 @@ class SearchControllerTest < ActionController::TestCase | @@ -85,7 +85,7 @@ class SearchControllerTest < ActionController::TestCase | ||
85 | should "search for software by identifier" do | 85 | should "search for software by identifier" do |
86 | software = create_software("beautiful os") | 86 | software = create_software("beautiful os") |
87 | 87 | ||
88 | - params = {"type"=>"Software", "query"=>"", "name"=>"beautiful-os", "database_description"=>{"id"=>""}, "programming_language"=>{"id"=>""}, "operating_system"=>{"id"=>""}, "controlled_vocabulary"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", "commit"=>"Search"} | 88 | + params = {"type"=>"Software", "query"=>"", "name"=>"beautiful-os", "database_description"=>{"id"=>""}, "programming_language"=>{"id"=>""}, "operating_system"=>{"id"=>""}, "software_categories"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", "commit"=>"Search"} |
89 | get :communities, params | 89 | get :communities, params |
90 | 90 | ||
91 | assert_includes assigns(:searches)[:communities][:results], software.community | 91 | assert_includes assigns(:searches)[:communities][:results], software.community |
@@ -94,7 +94,7 @@ class SearchControllerTest < ActionController::TestCase | @@ -94,7 +94,7 @@ class SearchControllerTest < ActionController::TestCase | ||
94 | should "search for software by name" do | 94 | should "search for software by name" do |
95 | software = create_software("beautiful") | 95 | software = create_software("beautiful") |
96 | 96 | ||
97 | - params = {"type"=>"Software", "query"=>"", "name"=>"beautiful", "database_description"=>{"id"=>""}, "programming_language"=>{"id"=>""}, "operating_system"=>{"id"=>""}, "controlled_vocabulary"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", "commit"=>"Search"} | 97 | + params = {"type"=>"Software", "query"=>"", "name"=>"beautiful", "database_description"=>{"id"=>""}, "programming_language"=>{"id"=>""}, "operating_system"=>{"id"=>""}, "software_categories"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", "commit"=>"Search"} |
98 | get :communities, params | 98 | get :communities, params |
99 | 99 | ||
100 | assert_includes assigns(:searches)[:communities][:results], software.community | 100 | assert_includes assigns(:searches)[:communities][:results], software.community |
@@ -108,7 +108,7 @@ class SearchControllerTest < ActionController::TestCase | @@ -108,7 +108,7 @@ class SearchControllerTest < ActionController::TestCase | ||
108 | 108 | ||
109 | params = {"type"=>"Software", "query"=>"", "name"=>"", | 109 | params = {"type"=>"Software", "query"=>"", "name"=>"", |
110 | "database_description"=>{"id"=>SoftwareDatabase.last.database_description.id}, | 110 | "database_description"=>{"id"=>SoftwareDatabase.last.database_description.id}, |
111 | - "programming_language"=>{"id"=>""}, "operating_system"=>{"id"=>""}, "controlled_vocabulary"=>"", | 111 | + "programming_language"=>{"id"=>""}, "operating_system"=>{"id"=>""}, "software_categories"=>"", |
112 | "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", | 112 | "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", |
113 | "commit"=>"Search"} | 113 | "commit"=>"Search"} |
114 | get :communities, params | 114 | get :communities, params |
@@ -124,7 +124,7 @@ class SearchControllerTest < ActionController::TestCase | @@ -124,7 +124,7 @@ class SearchControllerTest < ActionController::TestCase | ||
124 | 124 | ||
125 | params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | 125 | params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, |
126 | "programming_language"=>{"id"=>SoftwareLanguage.last.programming_language.id}, | 126 | "programming_language"=>{"id"=>SoftwareLanguage.last.programming_language.id}, |
127 | - "operating_system"=>{"id"=>""}, "controlled_vocabulary"=>"", | 127 | + "operating_system"=>{"id"=>""}, "software_categories"=>"", |
128 | "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", | 128 | "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", |
129 | "commit"=>"Search"} | 129 | "commit"=>"Search"} |
130 | get :communities, params | 130 | get :communities, params |
@@ -141,7 +141,7 @@ class SearchControllerTest < ActionController::TestCase | @@ -141,7 +141,7 @@ class SearchControllerTest < ActionController::TestCase | ||
141 | params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | 141 | params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, |
142 | "programming_language"=>{"id"=>""}, | 142 | "programming_language"=>{"id"=>""}, |
143 | "operating_system"=>{"id"=>OperatingSystem.last.id}, | 143 | "operating_system"=>{"id"=>OperatingSystem.last.id}, |
144 | - "controlled_vocabulary"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", | 144 | + "software_categories"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", |
145 | "commit"=>"Search"} | 145 | "commit"=>"Search"} |
146 | get :communities, params | 146 | get :communities, params |
147 | 147 | ||
@@ -150,13 +150,13 @@ class SearchControllerTest < ActionController::TestCase | @@ -150,13 +150,13 @@ class SearchControllerTest < ActionController::TestCase | ||
150 | 150 | ||
151 | should "search for software by controlled vocabulary" do | 151 | should "search for software by controlled vocabulary" do |
152 | software = create_software("beautiful") | 152 | software = create_software("beautiful") |
153 | - software.controlled_vocabulary.habitation = true | ||
154 | - software.controlled_vocabulary.save! | 153 | + software.software_categories.habitation = true |
154 | + software.software_categories.save! | ||
155 | 155 | ||
156 | params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | 156 | params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, |
157 | "programming_language"=>{"id"=>""}, | 157 | "programming_language"=>{"id"=>""}, |
158 | "operating_system"=>{"id"=>""}, | 158 | "operating_system"=>{"id"=>""}, |
159 | - "controlled_vocabulary"=>"habitation", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", | 159 | + "software_categories"=>"habitation", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", |
160 | "commit"=>"Search"} | 160 | "commit"=>"Search"} |
161 | get :communities, params | 161 | get :communities, params |
162 | 162 | ||
@@ -171,7 +171,7 @@ class SearchControllerTest < ActionController::TestCase | @@ -171,7 +171,7 @@ class SearchControllerTest < ActionController::TestCase | ||
171 | params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | 171 | params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, |
172 | "programming_language"=>{"id"=>""}, | 172 | "programming_language"=>{"id"=>""}, |
173 | "operating_system"=>{"id"=>""}, | 173 | "operating_system"=>{"id"=>""}, |
174 | - "controlled_vocabulary"=>"", "license_info"=>{"id"=>LicenseInfo.last.id}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", | 174 | + "software_categories"=>"", "license_info"=>{"id"=>LicenseInfo.last.id}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", |
175 | "commit"=>"Search"} | 175 | "commit"=>"Search"} |
176 | get :communities, params | 176 | get :communities, params |
177 | 177 | ||
@@ -187,7 +187,7 @@ class SearchControllerTest < ActionController::TestCase | @@ -187,7 +187,7 @@ class SearchControllerTest < ActionController::TestCase | ||
187 | params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | 187 | params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, |
188 | "programming_language"=>{"id"=>""}, | 188 | "programming_language"=>{"id"=>""}, |
189 | "operating_system"=>{"id"=>""}, | 189 | "operating_system"=>{"id"=>""}, |
190 | - "controlled_vocabulary"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"true", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", | 190 | + "software_categories"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"true", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", |
191 | "commit"=>"Search"} | 191 | "commit"=>"Search"} |
192 | get :communities, params | 192 | get :communities, params |
193 | 193 | ||
@@ -203,7 +203,7 @@ class SearchControllerTest < ActionController::TestCase | @@ -203,7 +203,7 @@ class SearchControllerTest < ActionController::TestCase | ||
203 | params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | 203 | params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, |
204 | "programming_language"=>{"id"=>""}, | 204 | "programming_language"=>{"id"=>""}, |
205 | "operating_system"=>{"id"=>""}, | 205 | "operating_system"=>{"id"=>""}, |
206 | - "controlled_vocabulary"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"true", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", | 206 | + "software_categories"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"true", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", |
207 | "commit"=>"Search"} | 207 | "commit"=>"Search"} |
208 | get :communities, params | 208 | get :communities, params |
209 | 209 | ||
@@ -219,7 +219,7 @@ class SearchControllerTest < ActionController::TestCase | @@ -219,7 +219,7 @@ class SearchControllerTest < ActionController::TestCase | ||
219 | params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | 219 | params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, |
220 | "programming_language"=>{"id"=>""}, | 220 | "programming_language"=>{"id"=>""}, |
221 | "operating_system"=>{"id"=>""}, | 221 | "operating_system"=>{"id"=>""}, |
222 | - "controlled_vocabulary"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"true", "e_arq"=>"", "internacionalizable"=>"", | 222 | + "software_categories"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"true", "e_arq"=>"", "internacionalizable"=>"", |
223 | "commit"=>"Search"} | 223 | "commit"=>"Search"} |
224 | get :communities, params | 224 | get :communities, params |
225 | 225 | ||
@@ -234,7 +234,7 @@ class SearchControllerTest < ActionController::TestCase | @@ -234,7 +234,7 @@ class SearchControllerTest < ActionController::TestCase | ||
234 | params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | 234 | params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, |
235 | "programming_language"=>{"id"=>""}, | 235 | "programming_language"=>{"id"=>""}, |
236 | "operating_system"=>{"id"=>""}, | 236 | "operating_system"=>{"id"=>""}, |
237 | - "controlled_vocabulary"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"true", "internacionalizable"=>"", | 237 | + "software_categories"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"true", "internacionalizable"=>"", |
238 | "commit"=>"Search"} | 238 | "commit"=>"Search"} |
239 | get :communities, params | 239 | get :communities, params |
240 | 240 | ||
@@ -249,7 +249,7 @@ class SearchControllerTest < ActionController::TestCase | @@ -249,7 +249,7 @@ class SearchControllerTest < ActionController::TestCase | ||
249 | params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | 249 | params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, |
250 | "programming_language"=>{"id"=>""}, | 250 | "programming_language"=>{"id"=>""}, |
251 | "operating_system"=>{"id"=>""}, | 251 | "operating_system"=>{"id"=>""}, |
252 | - "controlled_vocabulary"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"true", | 252 | + "software_categories"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"true", |
253 | "commit"=>"Search"} | 253 | "commit"=>"Search"} |
254 | get :communities, params | 254 | get :communities, params |
255 | 255 | ||
@@ -265,7 +265,7 @@ class SearchControllerTest < ActionController::TestCase | @@ -265,7 +265,7 @@ class SearchControllerTest < ActionController::TestCase | ||
265 | params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | 265 | params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, |
266 | "programming_language"=>{"id"=>""}, | 266 | "programming_language"=>{"id"=>""}, |
267 | "operating_system"=>{"id"=>""}, | 267 | "operating_system"=>{"id"=>""}, |
268 | - "controlled_vocabulary"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"true", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"true", "internacionalizable"=>"", | 268 | + "software_categories"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"true", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"true", "internacionalizable"=>"", |
269 | "commit"=>"Search"} | 269 | "commit"=>"Search"} |
270 | get :communities, params | 270 | get :communities, params |
271 | 271 | ||
@@ -295,16 +295,16 @@ class SearchControllerTest < ActionController::TestCase | @@ -295,16 +295,16 @@ class SearchControllerTest < ActionController::TestCase | ||
295 | software_info.license_info = LicenseInfo.last | 295 | software_info.license_info = LicenseInfo.last |
296 | 296 | ||
297 | 297 | ||
298 | - cv = ControlledVocabulary.new() | ||
299 | - cv.attributes.each do |key| | 298 | + sc = SoftwareCategories.new() |
299 | + sc.attributes.each do |key| | ||
300 | if(key.first == 'id' || key.first == 'software_info_id') | 300 | if(key.first == 'id' || key.first == 'software_info_id') |
301 | next | 301 | next |
302 | end | 302 | end |
303 | - cv.update_attribute(key.first, false) | 303 | + sc.update_attribute(key.first, false) |
304 | end | 304 | end |
305 | - cv.save! | 305 | + sc.save! |
306 | 306 | ||
307 | - software_info.controlled_vocabulary = cv | 307 | + software_info.software_categories = sc |
308 | 308 | ||
309 | software_info.save! | 309 | software_info.save! |
310 | 310 |
test/unit/governmental_power_test.rb
@@ -35,6 +35,11 @@ class GovernmentalPowerTest < ActiveSupport::TestCase | @@ -35,6 +35,11 @@ class GovernmentalPowerTest < ActiveSupport::TestCase | ||
35 | institution.type = type | 35 | institution.type = type |
36 | institution.cnpj = cnpj | 36 | institution.cnpj = cnpj |
37 | 37 | ||
38 | + institution.community = Community.create(:name => "Simple Public Institution") | ||
39 | + institution.community.country = "BR" | ||
40 | + institution.community.state = "DF" | ||
41 | + institution.community.city = "Gama" | ||
42 | + | ||
38 | if type == "PublicInstitution" | 43 | if type == "PublicInstitution" |
39 | institution.governmental_power = GovernmentalPower.first | 44 | institution.governmental_power = GovernmentalPower.first |
40 | institution.governmental_sphere = GovernmentalSphere.first | 45 | institution.governmental_sphere = GovernmentalSphere.first |
test/unit/institution_helper_test.rb
@@ -1,26 +0,0 @@ | @@ -1,26 +0,0 @@ | ||
1 | -require File.dirname(__FILE__) + '/../../../../test/test_helper' | ||
2 | - | ||
3 | -class InstitutionHelperTest < ActiveSupport::TestCase | ||
4 | - | ||
5 | - should "populate public institutions with data from SIORG" do | ||
6 | - Institution.destroy_all | ||
7 | - | ||
8 | - InstitutionHelper.mass_update | ||
9 | - | ||
10 | - assert Institution.count != 0 | ||
11 | - end | ||
12 | - | ||
13 | - should "receive json data from SIORG" do | ||
14 | - data = InstitutionHelper.get_json(2, 1) | ||
15 | - | ||
16 | - assert data["unidades"].count != 0 | ||
17 | - end | ||
18 | - | ||
19 | - should "update Institution's date modification when edit the Institution" do | ||
20 | - institution = Institution.new | ||
21 | - InstitutionHelper.register_institution_modification institution | ||
22 | - date = Time.now.day.to_s + "/" + Time.now.month.to_s + "/" + Time.now.year.to_s | ||
23 | - | ||
24 | - assert_equal date, institution.date_modification | ||
25 | - end | ||
26 | -end |
test/unit/juridical_nature_test.rb
@@ -18,8 +18,26 @@ class JuridicalNatureTest < ActiveSupport::TestCase | @@ -18,8 +18,26 @@ class JuridicalNatureTest < ActiveSupport::TestCase | ||
18 | juridical_nature = JuridicalNature.create(:name => "Autarquia") | 18 | juridical_nature = JuridicalNature.create(:name => "Autarquia") |
19 | create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", juridical_nature, @govPower, @govSphere) | 19 | create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", juridical_nature, @govPower, @govSphere) |
20 | create_public_institution("Tribunal Regional da Uniao", "TRU", "BR", "DF", "Brasilia", juridical_nature, @govPower, @govSphere) | 20 | create_public_institution("Tribunal Regional da Uniao", "TRU", "BR", "DF", "Brasilia", juridical_nature, @govPower, @govSphere) |
21 | - | ||
22 | assert juridical_nature.public_institutions.count == PublicInstitution.count | 21 | assert juridical_nature.public_institutions.count == PublicInstitution.count |
23 | end | 22 | end |
23 | + | ||
24 | + private | ||
25 | + | ||
26 | + def build_institution name, type="PublicInstitution", cnpj=nil | ||
27 | + institution = Institution::new | ||
28 | + institution.name = name | ||
29 | + institution.type = type | ||
30 | + institution.cnpj = cnpj | ||
31 | + | ||
32 | + institution.community = Community.create(:name => "Simple Public Institution") | ||
33 | + institution.community.country = "BR" | ||
34 | + institution.community.state = "DF" | ||
35 | + institution.community.city = "Gama" | ||
36 | + | ||
37 | + if type == "PublicInstitution" | ||
38 | + institution.juridical_nature = JuridicalNature.first | ||
39 | + end | ||
40 | + | ||
41 | + end | ||
24 | 42 | ||
25 | end | 43 | end |
test/unit/mpog_software_plugin_test.rb
@@ -33,4 +33,18 @@ class MpogSoftwarePluginTest < ActiveSupport::TestCase | @@ -33,4 +33,18 @@ class MpogSoftwarePluginTest < ActiveSupport::TestCase | ||
33 | 33 | ||
34 | assert_equal(test_percentege, plugin_percentege) | 34 | assert_equal(test_percentege, plugin_percentege) |
35 | end | 35 | end |
36 | + | ||
37 | + private | ||
38 | + | ||
39 | + def create_user | ||
40 | + user = User.new | ||
41 | + user.login = "login" | ||
42 | + user.email = "user@email.com" | ||
43 | + user.password = "123456" | ||
44 | + user.password_confirmation = "123456" | ||
45 | + user.secondary_email = "user@secondary_email.com" | ||
46 | + user.save | ||
47 | + user.person.save | ||
48 | + user | ||
49 | + end | ||
36 | end | 50 | end |
test/unit/mpog_user_test.rb
@@ -86,10 +86,13 @@ class MpogSoftwarePluginUserTest < ActiveSupport::TestCase | @@ -86,10 +86,13 @@ class MpogSoftwarePluginUserTest < ActiveSupport::TestCase | ||
86 | 86 | ||
87 | user.email = "test@gov.br" | 87 | user.email = "test@gov.br" |
88 | 88 | ||
89 | - user.institution = nil | 89 | + user.institutions = [] |
90 | assert !user.save | 90 | assert !user.save |
91 | 91 | ||
92 | - user.institution = Institution::new(:name=>"Test Other institution") | 92 | + institution = build_institution "Test simple institution" |
93 | + institution.save | ||
94 | + | ||
95 | + user.institutions << institution | ||
93 | assert user.save | 96 | assert user.save |
94 | end | 97 | end |
95 | 98 | ||
@@ -104,4 +107,22 @@ class MpogSoftwarePluginUserTest < ActiveSupport::TestCase | @@ -104,4 +107,22 @@ class MpogSoftwarePluginUserTest < ActiveSupport::TestCase | ||
104 | 107 | ||
105 | return user | 108 | return user |
106 | end | 109 | end |
110 | + | ||
111 | + def build_institution name, type="PublicInstitution", cnpj=nil | ||
112 | + institution = Institution::new | ||
113 | + institution.name = name | ||
114 | + institution.type = type | ||
115 | + institution.cnpj = cnpj | ||
116 | + | ||
117 | + institution.community = Community.create(:name => "Simple Public Institution") | ||
118 | + institution.community.country = "BR" | ||
119 | + institution.community.state = "DF" | ||
120 | + institution.community.city = "Gama" | ||
121 | + | ||
122 | + if type == "PublicInstitution" | ||
123 | + institution.juridical_nature = JuridicalNature.first | ||
124 | + end | ||
125 | + | ||
126 | + institution | ||
127 | + end | ||
107 | end | 128 | end |
test/unit/mpog_validation_test.rb
@@ -6,8 +6,12 @@ class MpogSoftwarePluginValidationTest < ActiveSupport::TestCase | @@ -6,8 +6,12 @@ class MpogSoftwarePluginValidationTest < ActiveSupport::TestCase | ||
6 | 6 | ||
7 | def setup | 7 | def setup |
8 | @plugin = MpogSoftwarePlugin.new | 8 | @plugin = MpogSoftwarePlugin.new |
9 | - @user = create_user 'login', 'test@email.com', '1234', '1234', 'test2@email.com' | ||
10 | 9 | ||
10 | + institution = build_institution("Test institution") | ||
11 | + institution.save | ||
12 | + | ||
13 | + @user = fast_create(User) | ||
14 | + @user.institutions << institution | ||
11 | end | 15 | end |
12 | 16 | ||
13 | def teardown | 17 | def teardown |
@@ -25,4 +29,24 @@ class MpogSoftwarePluginValidationTest < ActiveSupport::TestCase | @@ -25,4 +29,24 @@ class MpogSoftwarePluginValidationTest < ActiveSupport::TestCase | ||
25 | @user.email = "test_email@net.br" | 29 | @user.email = "test_email@net.br" |
26 | assert @user.save | 30 | assert @user.save |
27 | end | 31 | end |
32 | + | ||
33 | + private | ||
34 | + | ||
35 | + def build_institution name, type="PublicInstitution", cnpj=nil | ||
36 | + institution = Institution::new | ||
37 | + institution.name = name | ||
38 | + institution.type = type | ||
39 | + institution.cnpj = cnpj | ||
40 | + | ||
41 | + institution.community = Community.create(:name => "Simple Public Institution") | ||
42 | + institution.community.country = "BR" | ||
43 | + institution.community.state = "DF" | ||
44 | + institution.community.city = "Gama" | ||
45 | + | ||
46 | + if type == "PublicInstitution" | ||
47 | + institution.juridical_nature = JuridicalNature.first | ||
48 | + end | ||
49 | + | ||
50 | + institution | ||
51 | + end | ||
28 | end | 52 | end |
test/unit/software_info_validation_test.rb
@@ -31,6 +31,12 @@ class SoftwareInfoValidationTest < ActiveSupport::TestCase | @@ -31,6 +31,12 @@ class SoftwareInfoValidationTest < ActiveSupport::TestCase | ||
31 | 31 | ||
32 | @software_info.features = "Do a lot of things" | 32 | @software_info.features = "Do a lot of things" |
33 | @software_info.objectives = "All tests should pass !" | 33 | @software_info.objectives = "All tests should pass !" |
34 | + | ||
35 | + software_categories = SoftwareCategories::new | ||
36 | + software_categories.administration = true | ||
37 | + software_categories.save | ||
38 | + | ||
39 | + @software_info.software_categories = software_categories | ||
34 | end | 40 | end |
35 | 41 | ||
36 | should 'Save SoftwareInfo if all fields are filled' do | 42 | should 'Save SoftwareInfo if all fields are filled' do |
@@ -49,6 +55,7 @@ class SoftwareInfoValidationTest < ActiveSupport::TestCase | @@ -49,6 +55,7 @@ class SoftwareInfoValidationTest < ActiveSupport::TestCase | ||
49 | 55 | ||
50 | should "Save SoftwareInfo if acronym is blank" do | 56 | should "Save SoftwareInfo if acronym is blank" do |
51 | @software_info.acronym = "" | 57 | @software_info.acronym = "" |
58 | + | ||
52 | assert_equal true, @software_info.save | 59 | assert_equal true, @software_info.save |
53 | end | 60 | end |
54 | 61 |
test/unit/software_language_validation.rb
@@ -63,6 +63,8 @@ class SoftwareLanguageValidationTest < ActiveSupport::TestCase | @@ -63,6 +63,8 @@ class SoftwareLanguageValidationTest < ActiveSupport::TestCase | ||
63 | software_info.e_ping = true | 63 | software_info.e_ping = true |
64 | software_info.e_arq = true | 64 | software_info.e_arq = true |
65 | software_info.operating_platform = 'GNU/Linux' | 65 | software_info.operating_platform = 'GNU/Linux' |
66 | + software_info.features = "Do a lot of things" | ||
67 | + software_info.objectives = "All tests should pass !" | ||
66 | software_info | 68 | software_info |
67 | end | 69 | end |
68 | 70 |