Commit 362e45e66737e6554f57bc7c4d163d84b9a5f1a7
1 parent
feedfd2f
Exists in
master
and in
5 other branches
Update functional tests with register institution in mpog_software_plugin_controller_test.rb
(institution_fields) Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>
Showing
2 changed files
with
28 additions
and
31 deletions
Show diff stats
test/functional/account_controller_test.rb
... | ... | @@ -21,7 +21,6 @@ class AccountControllerTest < ActionController::TestCase |
21 | 21 | @institution_list = [] |
22 | 22 | @institution_list << create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", @juridical_nature, @govPower, @govSphere) |
23 | 23 | @institution_list << create_public_institution("Tribunal Regional da Uniao", "TRU", "BR", "DF", "Brasilia", @juridical_nature, @govPower, @govSphere) |
24 | - | |
25 | 24 | @user_info = { |
26 | 25 | :login=>"novo_usuario", |
27 | 26 | :password=>"nova_senha", | ... | ... |
test/functional/mpog_software_plugin_controller_test.rb
... | ... | @@ -16,11 +16,12 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase |
16 | 16 | |
17 | 17 | @govPower = GovernmentalPower.create(:name=>"Some Gov Power") |
18 | 18 | @govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") |
19 | + @juridical_nature = JuridicalNature.create(:name => "Autarquia") | |
19 | 20 | @response = ActionController::TestResponse.new |
20 | 21 | |
21 | 22 | @institution_list = [] |
22 | - @institution_list << create_public_institution("Ministerio Publico da Uniao", "MPU", @govPower, @govSphere) | |
23 | - @institution_list << create_public_institution("Tribunal Regional da Uniao", "TRU", @govPower, @govSphere) | |
23 | + @institution_list << create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", @juridical_nature, @govPower, @govSphere) | |
24 | + @institution_list << create_public_institution("Tribunal Regional da Uniao", "TRU", "BR", "DF", "Brasilia", @juridical_nature, @govPower, @govSphere) | |
24 | 25 | end |
25 | 26 | |
26 | 27 | should "Search for institution with acronym" do |
... | ... | @@ -58,11 +59,14 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase |
58 | 59 | |
59 | 60 | xhr :get, :new_institution, |
60 | 61 | :authenticity_token=>"dsa45a6das52sd", |
61 | - :community=>{:name=>"foo bar"}, | |
62 | - :institution => {:cnpj=>"12.234.567/8900-10", :acronym=>"fb", :type=>"PublicInstitution"}, | |
62 | + :name => "foo bar", | |
63 | + :community=>{:name=>"foo bar", :country => "BR", :state => "DF", :city => "Brasilia"}, | |
63 | 64 | :governmental=>{:power=>@govPower.id, :sphere=>@govSphere.id}, |
65 | + :juridical => {:nature => @juridical_nature.id}, | |
66 | + :institution => {:cnpj=>"12.234.567/8900-10", :acronym=>"fb", :type=>"PublicInstitution"}, | |
64 | 67 | :recaptcha_response_field=>'' |
65 | 68 | |
69 | + | |
66 | 70 | json_response = ActiveSupport::JSON.decode(@response.body) |
67 | 71 | |
68 | 72 | assert json_response["success"] |
... | ... | @@ -73,9 +77,11 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase |
73 | 77 | |
74 | 78 | xhr :get, :new_institution, |
75 | 79 | :authenticity_token=>"dsa45a6das52sd", |
76 | - :community=>{:name=>"Ministerio Publico da Uniao"}, | |
77 | - :institution => {:cnpj=>"12.234.567/8900-10", :acronym=>"fb", :type=>"PublicInstitution"}, | |
80 | + :name => "Ministerio Publico da Uniao", | |
81 | + :community=>{:name=>"Ministerio Publico da Uniao", :country => "BR", :state => "DF", :city => "Brasilia"}, | |
78 | 82 | :governmental=>{:power=>@govPower.id, :sphere=>@govSphere.id}, |
83 | + :juridical => {:nature => @juridical_nature.id}, | |
84 | + :institution => {:cnpj=>"12.234.567/8900-10", :acronym=>"fb", :type=>"PublicInstitution"}, | |
79 | 85 | :recaptcha_response_field=>'' |
80 | 86 | |
81 | 87 | json_response = ActiveSupport::JSON.decode(@response.body) |
... | ... | @@ -83,24 +89,6 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase |
83 | 89 | assert !json_response["success"] |
84 | 90 | end |
85 | 91 | |
86 | - should "set the environment admin as institution community admin" do | |
87 | - @controller.stubs(:verify_recaptcha).returns(true) | |
88 | - | |
89 | - xhr :get, :new_institution, | |
90 | - :authenticity_token=>"dsa45a6das52sd", | |
91 | - :community=>{:name=>"Another instituon community"}, | |
92 | - :institution => {:cnpj=>"10.254.577/8910-12", :acronym=>"aic", :type=>"PublicInstitution"}, | |
93 | - :governmental=>{:power=>@govPower.id, :sphere=>@govSphere.id}, | |
94 | - :recaptcha_response_field=>'' | |
95 | - | |
96 | - json_response = ActiveSupport::JSON.decode(@response.body) | |
97 | - | |
98 | - assert json_response["success"] | |
99 | - | |
100 | - assert Community.last.admins.include?(@environment.admins.first) | |
101 | - assert_equal Community.last.name, "Another instituon community" | |
102 | - end | |
103 | - | |
104 | 92 | should "verify if institution name already exists" do |
105 | 93 | xhr :get, :institution_already_exists, :name=>"Ministerio Publico da Uniao" |
106 | 94 | assert_equal "true", @response.body |
... | ... | @@ -135,9 +123,11 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase |
135 | 123 | |
136 | 124 | xhr :get, :new_institution, |
137 | 125 | :authenticity_token=>"dsa45a6das52sd", |
138 | - :community=>{:name=>"foo bar"}, | |
139 | - :institution => {:cnpj=>"12.234.567/8900-10", :acronym=>"fb", :type=>"PublicInstitution"}, | |
126 | + :name => "foo bar", | |
127 | + :community=>{:name=>"foo bar", :country => "BR", :state => "DF", :city => "Brasilia"}, | |
140 | 128 | :governmental=>{:power=>@govPower.id, :sphere=>@govSphere.id}, |
129 | + :juridical => {:nature => @juridical_nature.id}, | |
130 | + :institution => {:cnpj=>"12.234.567/8900-10", :acronym=>"fb", :type=>"PublicInstitution"}, | |
141 | 131 | :recaptcha_response_field=>'' |
142 | 132 | |
143 | 133 | date = Time.now.day.to_s + "/" + Time.now.month.to_s + "/" + Time.now.year.to_s |
... | ... | @@ -147,15 +137,23 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase |
147 | 137 | |
148 | 138 | private |
149 | 139 | |
150 | - def create_public_institution name, acronym, gov_p, gov_s | |
151 | - institution_community = Community::new :name=>name | |
140 | + def create_public_institution name, acronym, country, state, city, juridical_nature, gov_p, gov_s | |
141 | + institution_community = fast_create(Community) | |
142 | + institution_community.name = name | |
143 | + institution_community.country = country | |
144 | + institution_community.state = state | |
145 | + institution_community.city = city | |
146 | + institution_community.save! | |
147 | + | |
152 | 148 | institution = PublicInstitution.new |
153 | 149 | institution.community = institution_community |
154 | 150 | institution.name = name |
155 | - institution.acronym = acronym | |
151 | + institution.juridical_nature = juridical_nature | |
152 | + institution.acronym = acronym | |
156 | 153 | institution.governmental_power = gov_p |
157 | 154 | institution.governmental_sphere = gov_s |
158 | - institution.save | |
155 | + institution.save! | |
159 | 156 | institution |
160 | 157 | end |
158 | + | |
161 | 159 | end | ... | ... |