gov_user_plugin_myprofile_controller.rb
2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
require File.dirname(__FILE__) + '/../../../../test/test_helper'
require File.dirname(__FILE__) + '/../helpers/institution_test_helper'
require(
File.dirname(__FILE__) +
'/../../controllers/gov_user_plugin_myprofile_controller'
)
class GovUserPluginMyprofileController; def rescue_action(e) raise e end;
end
class GovUserPluginMyprofileControllerTest < ActionController::TestCase
def setup
@controller = GovUserPluginMyprofileController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@person = create_user('person').person
@offer = create_user('Angela Silva')
@offer_1 = create_user('Ana de Souza')
@offer_2 = create_user('Angelo Roberto')
login_as(@person.user_login)
@environment = Environment.default
@environment.enable_plugin('GovUserPlugin')
@environment.save!
end
should "user edit its community institution" do
govPower = GovernmentalPower.create(:name=>"Some Gov Power")
govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere")
juridical_nature = JuridicalNature.create(:name => "Autarquia")
institution = InstitutionTestHelper.create_public_institution(
"Ministerio Publico da Uniao",
"MPU",
"BR",
"DF",
"Gama",
juridical_nature,
govPower,
govSphere,
"12.345.678/9012-45"
)
identifier = institution.community.identifier
fields = InstitutionTestHelper.generate_form_fields(
"institution new name",
"BR",
"DF",
"Gama",
"12.345.678/9012-45",
"PrivateInstitution"
)
post(
:edit_institution,
:profile=>institution.community.identifier,
:community=>fields[:community],
:institutions=>fields[:institutions]
)
institution = Community[identifier].institution
assert_not_equal "Ministerio Publico da Uniao", institution.community.name
end
should "not user edit its community institution with wrong values" do
govPower = GovernmentalPower.create(:name=>"Some Gov Power")
govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere")
juridical_nature = JuridicalNature.create(:name => "Autarquia")
institution = InstitutionTestHelper.create_public_institution(
"Ministerio Publico da Uniao",
"MPU",
"BR",
"DF",
"Gama",
juridical_nature,
govPower,
govSphere,
"12.345.678/9012-45"
)
identifier = institution.community.identifier
fields = InstitutionTestHelper.generate_form_fields(
"",
"BR",
"DF",
"Gama",
"6465465465",
"PrivateInstitution"
)
post(
:edit_institution,
:profile=>institution.community.identifier,
:community=>fields[:community],
:institutions=>fields[:institutions]
)
institution = Community[identifier].institution
assert_equal "Ministerio Publico da Uniao", institution.community.name
assert_equal "12.345.678/9012-45", institution.cnpj
end
end