Commit c559daa02bfd879f71b9c414521a90ab916c6d3e

Authored by Fabio Teixeira
1 parent 0a1a80ef

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,7 +6,17 @@ class AccountController; def rescue_action(e) raise e end; end
6 class AccountControllerTest < ActionController::TestCase 6 class AccountControllerTest < ActionController::TestCase
7 7
8 def setup 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 @response = ActionController::TestResponse.new 18 @response = ActionController::TestResponse.new
  19 +
10 @institution_list = [] 20 @institution_list = []
11 @institution_list << create_institution("Ministerio Publico da Uniao", "MPU") 21 @institution_list << create_institution("Ministerio Publico da Uniao", "MPU")
12 @institution_list << create_institution("Tribunal Regional da Uniao", "TRU") 22 @institution_list << create_institution("Tribunal Regional da Uniao", "TRU")
@@ -25,6 +35,8 @@ class AccountControllerTest &lt; ActionController::TestCase @@ -25,6 +35,8 @@ class AccountControllerTest &lt; ActionController::TestCase
25 :name=>"Um novo usuario", 35 :name=>"Um novo usuario",
26 :area_interest=>"uma area ai" 36 :area_interest=>"uma area ai"
27 } 37 }
  38 +
  39 + disable_signup_bot_check
28 end 40 end
29 41
30 should "Create a user without gov email and institution" do 42 should "Create a user without gov email and institution" do
@@ -55,13 +67,27 @@ class AccountControllerTest &lt; ActionController::TestCase @@ -55,13 +67,27 @@ class AccountControllerTest &lt; ActionController::TestCase
55 assert !assigns(:user).save 67 assert !assigns(:user).save
56 end 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 private 81 private
59 82
60 def create_institution name, acronym 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 institution.name = name 87 institution.name = name
63 institution.acronym = acronym 88 institution.acronym = acronym
64 - institution.type = "PublicInstitution" 89 + institution.governmental_power = @govPower
  90 + institution.governmental_sphere = @govSphere
65 institution.save 91 institution.save
66 institution 92 institution
67 end 93 end
@@ -85,4 +111,9 @@ class AccountControllerTest &lt; ActionController::TestCase @@ -85,4 +111,9 @@ class AccountControllerTest &lt; ActionController::TestCase
85 user["profile_data"] = profile_data 111 user["profile_data"] = profile_data
86 user 112 user
87 end 113 end
  114 +
  115 + def disable_signup_bot_check(environment = Environment.default)
  116 + environment.min_signup_delay = 0
  117 + environment.save!
  118 + end
88 end 119 end
89 \ No newline at end of file 120 \ No newline at end of file