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,7 +21,6 @@ class AccountControllerTest < ActionController::TestCase | ||
| 21 | @institution_list = [] | 21 | @institution_list = [] |
| 22 | @institution_list << create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", @juridical_nature, @govPower, @govSphere) | 22 | @institution_list << create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", @juridical_nature, @govPower, @govSphere) |
| 23 | @institution_list << create_public_institution("Tribunal Regional da Uniao", "TRU", "BR", "DF", "Brasilia", @juridical_nature, @govPower, @govSphere) | 23 | @institution_list << create_public_institution("Tribunal Regional da Uniao", "TRU", "BR", "DF", "Brasilia", @juridical_nature, @govPower, @govSphere) |
| 24 | - | ||
| 25 | @user_info = { | 24 | @user_info = { |
| 26 | :login=>"novo_usuario", | 25 | :login=>"novo_usuario", |
| 27 | :password=>"nova_senha", | 26 | :password=>"nova_senha", |
test/functional/mpog_software_plugin_controller_test.rb
| @@ -16,11 +16,12 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase | @@ -16,11 +16,12 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase | ||
| 16 | 16 | ||
| 17 | @govPower = GovernmentalPower.create(:name=>"Some Gov Power") | 17 | @govPower = GovernmentalPower.create(:name=>"Some Gov Power") |
| 18 | @govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") | 18 | @govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") |
| 19 | + @juridical_nature = JuridicalNature.create(:name => "Autarquia") | ||
| 19 | @response = ActionController::TestResponse.new | 20 | @response = ActionController::TestResponse.new |
| 20 | 21 | ||
| 21 | @institution_list = [] | 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 | end | 25 | end |
| 25 | 26 | ||
| 26 | should "Search for institution with acronym" do | 27 | should "Search for institution with acronym" do |
| @@ -58,11 +59,14 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase | @@ -58,11 +59,14 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase | ||
| 58 | 59 | ||
| 59 | xhr :get, :new_institution, | 60 | xhr :get, :new_institution, |
| 60 | :authenticity_token=>"dsa45a6das52sd", | 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 | :governmental=>{:power=>@govPower.id, :sphere=>@govSphere.id}, | 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 | :recaptcha_response_field=>'' | 67 | :recaptcha_response_field=>'' |
| 65 | 68 | ||
| 69 | + | ||
| 66 | json_response = ActiveSupport::JSON.decode(@response.body) | 70 | json_response = ActiveSupport::JSON.decode(@response.body) |
| 67 | 71 | ||
| 68 | assert json_response["success"] | 72 | assert json_response["success"] |
| @@ -73,9 +77,11 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase | @@ -73,9 +77,11 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase | ||
| 73 | 77 | ||
| 74 | xhr :get, :new_institution, | 78 | xhr :get, :new_institution, |
| 75 | :authenticity_token=>"dsa45a6das52sd", | 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 | :governmental=>{:power=>@govPower.id, :sphere=>@govSphere.id}, | 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 | :recaptcha_response_field=>'' | 85 | :recaptcha_response_field=>'' |
| 80 | 86 | ||
| 81 | json_response = ActiveSupport::JSON.decode(@response.body) | 87 | json_response = ActiveSupport::JSON.decode(@response.body) |
| @@ -83,24 +89,6 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase | @@ -83,24 +89,6 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase | ||
| 83 | assert !json_response["success"] | 89 | assert !json_response["success"] |
| 84 | end | 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 | should "verify if institution name already exists" do | 92 | should "verify if institution name already exists" do |
| 105 | xhr :get, :institution_already_exists, :name=>"Ministerio Publico da Uniao" | 93 | xhr :get, :institution_already_exists, :name=>"Ministerio Publico da Uniao" |
| 106 | assert_equal "true", @response.body | 94 | assert_equal "true", @response.body |
| @@ -135,9 +123,11 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase | @@ -135,9 +123,11 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase | ||
| 135 | 123 | ||
| 136 | xhr :get, :new_institution, | 124 | xhr :get, :new_institution, |
| 137 | :authenticity_token=>"dsa45a6das52sd", | 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 | :governmental=>{:power=>@govPower.id, :sphere=>@govSphere.id}, | 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 | :recaptcha_response_field=>'' | 131 | :recaptcha_response_field=>'' |
| 142 | 132 | ||
| 143 | date = Time.now.day.to_s + "/" + Time.now.month.to_s + "/" + Time.now.year.to_s | 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,15 +137,23 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase | ||
| 147 | 137 | ||
| 148 | private | 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 | institution = PublicInstitution.new | 148 | institution = PublicInstitution.new |
| 153 | institution.community = institution_community | 149 | institution.community = institution_community |
| 154 | institution.name = name | 150 | institution.name = name |
| 155 | - institution.acronym = acronym | 151 | + institution.juridical_nature = juridical_nature |
| 152 | + institution.acronym = acronym | ||
| 156 | institution.governmental_power = gov_p | 153 | institution.governmental_power = gov_p |
| 157 | institution.governmental_sphere = gov_s | 154 | institution.governmental_sphere = gov_s |
| 158 | - institution.save | 155 | + institution.save! |
| 159 | institution | 156 | institution |
| 160 | end | 157 | end |
| 158 | + | ||
| 161 | end | 159 | end |