Commit e25098386c3c0299edec78308a06970c5ca15838
1 parent
7495e3aa
Exists in
master
and in
5 other branches
institution_fields: Create tests for sisp field.
Showing
2 changed files
with
69 additions
and
0 deletions
Show diff stats
| @@ -0,0 +1,68 @@ | @@ -0,0 +1,68 @@ | ||
| 1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | ||
| 2 | +require File.dirname(__FILE__) + '/../../controllers/mpog_software_plugin_controller' | ||
| 3 | + | ||
| 4 | + | ||
| 5 | +class InstitutionEditorTest < ActionController::TestCase | ||
| 6 | + | ||
| 7 | + def setup | ||
| 8 | + @controller = ProfileEditorController.new | ||
| 9 | + @request = ActionController::TestRequest.new | ||
| 10 | + @response = ActionController::TestResponse.new | ||
| 11 | + | ||
| 12 | + @environment = Environment.default | ||
| 13 | + @environment.enabled_plugins = ['MpogSoftwarePlugin'] | ||
| 14 | + @environment.save | ||
| 15 | + | ||
| 16 | + @govPower = GovernmentalPower.create(:name=>"Some Gov Power") | ||
| 17 | + @govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") | ||
| 18 | + @juridical_nature = JuridicalNature.create(:name => "Autarquia") | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + @institution_list = [] | ||
| 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) | ||
| 24 | + end | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + should ' enable edition of sisp field for enviroment admin' do | ||
| 28 | + admin = create_user("adminuser").person | ||
| 29 | + admin.stubs(:has_permission?).returns("true") | ||
| 30 | + login_as('adminuser') | ||
| 31 | + @environment.add_admin(admin) | ||
| 32 | + get :edit, :profile => @institution_list[0].community.identifier, :id => @institution_list[0].community.id | ||
| 33 | + assert_tag :tag => 'span', :descendant => {:tag => "input", :attributes => { :type => 'radio', :name => "institution[sisp]"}} | ||
| 34 | + end | ||
| 35 | + | ||
| 36 | + should 'enable only visulization of sisp field for institution admin' do | ||
| 37 | + ze = create_user("ze").person | ||
| 38 | + login_as('ze') | ||
| 39 | + @institution_list[0].community.add_admin(ze) | ||
| 40 | + get :edit, :profile => @institution_list[0].community.identifier, :id => @institution_list[0].community.id | ||
| 41 | + assert_tag :tag => 'span', :descendant => {:tag => "label", :attributes => {:for => "SISP"}} | ||
| 42 | + end | ||
| 43 | + | ||
| 44 | + | ||
| 45 | + private | ||
| 46 | + | ||
| 47 | + def create_public_institution name, acronym, country, state, city, juridical_nature, gov_p, gov_s | ||
| 48 | + institution_community = fast_create(Community) | ||
| 49 | + institution_community.name = name | ||
| 50 | + institution_community.country = country | ||
| 51 | + institution_community.state = state | ||
| 52 | + institution_community.city = city | ||
| 53 | + institution_community.save! | ||
| 54 | + | ||
| 55 | + institution = PublicInstitution.new | ||
| 56 | + institution.community = institution_community | ||
| 57 | + institution.name = name | ||
| 58 | + institution.juridical_nature = juridical_nature | ||
| 59 | + institution.sisp = false | ||
| 60 | + institution.acronym = acronym | ||
| 61 | + institution.governmental_power = gov_p | ||
| 62 | + institution.governmental_sphere = gov_s | ||
| 63 | + institution.save! | ||
| 64 | + | ||
| 65 | + institution | ||
| 66 | + end | ||
| 67 | + | ||
| 68 | +end |
views/institution_editor_extras.html.erb
| @@ -38,6 +38,7 @@ | @@ -38,6 +38,7 @@ | ||
| 38 | 38 | ||
| 39 | <span class= 'public-institutions-fields'> | 39 | <span class= 'public-institutions-fields'> |
| 40 | <div class="formfieldline"> | 40 | <div class="formfieldline"> |
| 41 | + | ||
| 41 | <% if @show_sisp_field %> | 42 | <% if @show_sisp_field %> |
| 42 | <%= _("SISP?") %> | 43 | <%= _("SISP?") %> |
| 43 | <%= labelled_radio_button(_('Yes'), 'institution[sisp]', 'true', context.profile.institution.sisp)%> | 44 | <%= labelled_radio_button(_('Yes'), 'institution[sisp]', 'true', context.profile.institution.sisp)%> |