Commit 3a116bc3520e84015d805d1565ff9aca80117977

Authored by Luciano Prestes
1 parent fc1161f0
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

Implement functional tests for Institution date_modification

Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com>
Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
lib/institution_helper.rb
... ... @@ -49,6 +49,7 @@ module InstitutionHelper
49 49  
50 50 def self.register_institution_modification institution
51 51 institution.date_modification = current_date
  52 + institution.save!
52 53 end
53 54  
54 55 protected
... ...
lib/mpog_software_plugin.rb
... ... @@ -245,9 +245,9 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
245 245 end
246 246  
247 247 def institution_transaction
  248 + InstitutionHelper.register_institution_modification context.profile.institution
248 249 if context.params.has_key?(:governmental_power)
249 250 context.profile.institution.governmental_power_id = context.params[:governmental_power]
250   - InstitutionHelper.register_institution_modification context.profile.institution
251 251 context.profile.institution.save!
252 252 end
253 253  
... ...
test/functional/mpog_software_plugin_controller_test.rb
... ... @@ -3,7 +3,6 @@ require File.dirname(__FILE__) + &#39;/../../controllers/mpog_software_plugin_contro
3 3  
4 4 class MpogSoftwarePluginController; def rescue_action(e) raise e end; end
5 5  
6   -
7 6 class MpogSoftwarePluginControllerTest < ActionController::TestCase
8 7  
9 8 def setup
... ... @@ -110,7 +109,6 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase
110 109 assert_equal "false", @response.body
111 110 end
112 111  
113   -
114 112 should "response as XML to export softwares" do
115 113 get :download, :format => 'xml'
116 114 assert_equal 'text/xml', @response.content_type
... ... @@ -132,6 +130,20 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase
132 130 assert_equal "false", @response.body
133 131 end
134 132  
  133 + should "update institution date_modification in your creation" do
  134 + @controller.stubs(:verify_recaptcha).returns(true)
  135 +
  136 + xhr :get, :new_institution,
  137 + :authenticity_token=>"dsa45a6das52sd",
  138 + :community=>{:name=>"foo bar"},
  139 + :institution => {:cnpj=>"12.234.567/8900-10", :acronym=>"fb", :type=>"PublicInstitution"},
  140 + :governmental=>{:power=>@govPower.id, :sphere=>@govSphere.id},
  141 + :recaptcha_response_field=>''
  142 +
  143 + date = Time.now.day.to_s + "/" + Time.now.month.to_s + "/" + Time.now.year.to_s
  144 + assert_equal date, Institution.last.date_modification
  145 + end
  146 +
135 147  
136 148 private
137 149  
... ...
test/functional/profile_editor_controller_test.rb 0 → 100644
... ... @@ -0,0 +1,54 @@
  1 +require File.dirname(__FILE__) + '/../../../../test/test_helper'
  2 +require File.dirname(__FILE__) + '/../../../../app/controllers/my_profile/profile_editor_controller'
  3 +
  4 +class ProfileEditorController; def rescue_action(e) raise e end; end
  5 +
  6 +class ProfileEditorControllerTest < ActionController::TestCase
  7 +
  8 + def setup
  9 + @controller = ProfileEditorController.new
  10 + @request = ActionController::TestRequest.new
  11 + @response = ActionController::TestResponse.new
  12 + @profile = create_user('default_user').person
  13 + Environment.default.affiliate(@profile, [Environment::Roles.admin(Environment.default.id)] + Profile::Roles.all_roles(Environment.default.id))
  14 + @environment = Environment.default
  15 + @environment.enabled_plugins = ['MpogSoftwarePlugin']
  16 +
  17 + @govPower = GovernmentalPower.create(:name=>"Some Gov Power")
  18 + @govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere")
  19 +
  20 + admin = create_user("adminuser").person
  21 + admin.stubs(:has_permission?).returns("true")
  22 + login_as('adminuser')
  23 +
  24 + @environment.add_admin(admin)
  25 + @environment.save
  26 + end
  27 +
  28 + should "update institution date_modification in your creation" do
  29 + institution = create_public_institution("Ministerio Publico da Uniao", "MPU", @govPower, @govSphere)
  30 + institution.date_modification = "Invalid Date"
  31 +
  32 + post :edit, :profile => Institution.last.community.identifier, :profile_data => {:name => "Ministerio da Saude"}, :institution => institution
  33 +
  34 + date = Time.now.day.to_s + "/" + Time.now.month.to_s + "/" + Time.now.year.to_s
  35 + assert_equal date, Institution.last.date_modification
  36 + end
  37 +
  38 + private
  39 +
  40 + def create_public_institution name, acronym, gov_p, gov_s
  41 + institution_community = fast_create(Community)
  42 + institution_community.name = name
  43 +
  44 + institution = PublicInstitution.new
  45 + institution.community = institution_community
  46 + institution.name = name
  47 + institution.acronym = acronym
  48 + institution.governmental_power = gov_p
  49 + institution.governmental_sphere = gov_s
  50 + institution.save!
  51 + institution
  52 + end
  53 +
  54 +end
0 55 \ No newline at end of file
... ...