Commit c559daa02bfd879f71b9c414521a90ab916c6d3e

Authored by Fabio Teixeira
1 parent 0a1a80ef
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

Funcional test, user become a member of its institution community on registration

(add_user_to_institution_community)

Signed-off-by: Arthur Del Esposte <arthurmde@yahoo.com.br>
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Showing 1 changed file with 33 additions and 2 deletions   Show diff stats
test/functional/account_controller_test.rb
... ... @@ -6,7 +6,17 @@ class AccountController; def rescue_action(e) raise e end; end
6 6 class AccountControllerTest < ActionController::TestCase
7 7  
8 8 def setup
  9 + environment = Environment.default
  10 + environment.enabled_plugins = ['MpogSoftwarePlugin']
  11 + environment.save
  12 +
  13 + @govPower = GovernmentalPower.create(:name=>"Some Gov Power")
  14 + @govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere")
  15 +
  16 + @controller = AccountController.new
  17 + @request = ActionController::TestRequest.new
9 18 @response = ActionController::TestResponse.new
  19 +
10 20 @institution_list = []
11 21 @institution_list << create_institution("Ministerio Publico da Uniao", "MPU")
12 22 @institution_list << create_institution("Tribunal Regional da Uniao", "TRU")
... ... @@ -25,6 +35,8 @@ class AccountControllerTest &lt; ActionController::TestCase
25 35 :name=>"Um novo usuario",
26 36 :area_interest=>"uma area ai"
27 37 }
  38 +
  39 + disable_signup_bot_check
28 40 end
29 41  
30 42 should "Create a user without gov email and institution" do
... ... @@ -55,13 +67,27 @@ class AccountControllerTest &lt; ActionController::TestCase
55 67 assert !assigns(:user).save
56 68 end
57 69  
  70 + should "user become a member of its institution community on registration" do
  71 + post :signup, :user => @user_info, :profile_data => @profile_data_info
  72 +
  73 + last_user = User.last
  74 + last_community = Community.last
  75 +
  76 + assert_equal @user_info[:secondary_email], last_user.secondary_email
  77 + assert_equal true, last_community.members.include?(last_user.person)
  78 + assert_response :success
  79 + end
  80 +
58 81 private
59 82  
60 83 def create_institution name, acronym
61   - institution = Institution.new
  84 + institution_community = Community::create :name=>name
  85 + institution = PublicInstitution.new
  86 + institution.community = institution_community
62 87 institution.name = name
63 88 institution.acronym = acronym
64   - institution.type = "PublicInstitution"
  89 + institution.governmental_power = @govPower
  90 + institution.governmental_sphere = @govSphere
65 91 institution.save
66 92 institution
67 93 end
... ... @@ -85,4 +111,9 @@ class AccountControllerTest &lt; ActionController::TestCase
85 111 user["profile_data"] = profile_data
86 112 user
87 113 end
  114 +
  115 + def disable_signup_bot_check(environment = Environment.default)
  116 + environment.min_signup_delay = 0
  117 + environment.save!
  118 + end
88 119 end
89 120 \ No newline at end of file
... ...