Commit 7e2ba029df2c91e49a1d31cbc9667f826d80c300

Authored by Daniela Feitosa
1 parent a99b94fa

Fixed broken and removed unused tests

(ActionItem3096)
app/controllers/public/account_controller.rb
@@ -36,7 +36,7 @@ class AccountController < ApplicationController @@ -36,7 +36,7 @@ class AccountController < ApplicationController
36 self.current_user ||= User.authenticate(params[:user][:login], params[:user][:password], environment) if params[:user] 36 self.current_user ||= User.authenticate(params[:user][:login], params[:user][:password], environment) if params[:user]
37 37
38 if logged_in? 38 if logged_in?
39 - join_community(self.current_user) 39 + check_join_in_community(self.current_user)
40 if params[:remember_me] == "1" 40 if params[:remember_me] == "1"
41 self.current_user.remember_me 41 self.current_user.remember_me
42 cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at } 42 cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at }
@@ -104,7 +104,7 @@ class AccountController < ApplicationController @@ -104,7 +104,7 @@ class AccountController < ApplicationController
104 end 104 end
105 if @user.activated? 105 if @user.activated?
106 self.current_user = @user 106 self.current_user = @user
107 - join_community(@user) 107 + check_join_in_community(@user)
108 go_to_signup_initial_page 108 go_to_signup_initial_page
109 else 109 else
110 @register_pending = true 110 @register_pending = true
@@ -453,7 +453,7 @@ class AccountController < ApplicationController @@ -453,7 +453,7 @@ class AccountController < ApplicationController
453 end 453 end
454 end 454 end
455 455
456 - def join_community(user) 456 + def check_join_in_community(user)
457 profile_to_join = session[:join] 457 profile_to_join = session[:join]
458 unless profile_to_join.blank? 458 unless profile_to_join.blank?
459 environment.profiles.find_by_identifier(profile_to_join).add_member(user.person) 459 environment.profiles.find_by_identifier(profile_to_join).add_member(user.person)
test/functional/profile_controller_test.rb
@@ -477,17 +477,23 @@ class ProfileControllerTest < ActionController::TestCase @@ -477,17 +477,23 @@ class ProfileControllerTest < ActionController::TestCase
477 assert_equal "/profile/#{community.identifier}", @request.session[:previous_location] 477 assert_equal "/profile/#{community.identifier}", @request.session[:previous_location]
478 end 478 end
479 479
480 - should 'redirect to location before login after join community' do 480 + should 'redirect to login after user not logged asks to join a community' do
481 community = Community.create!(:name => 'my test community') 481 community = Community.create!(:name => 'my test community')
482 482
483 - @request.expects(:referer).returns("/profile/#{community.identifier}/to_go")  
484 - login_as(profile.identifier) 483 + get :join_not_logged, :profile => community.identifier
485 484
486 - post :join_not_logged, :profile => community.identifier 485 + assert_equal community.identifier, @request.session[:join]
  486 + assert_redirected_to :controller => :account, :action => :login
  487 + end
487 488
488 - assert_redirected_to "/profile/#{community.identifier}/to_go" 489 + should 'redirect to join after user logged asks to join_not_logged a community' do
  490 + community = Community.create!(:name => 'my test community')
  491 +
  492 + login_as(profile.identifier)
  493 + get :join_not_logged, :profile => community.identifier
489 494
490 - assert_nil @request.session[:previous_location] 495 + assert_equal community.identifier, @request.session[:join]
  496 + assert_redirected_to :controller => :profile, :action => :join
491 end 497 end
492 498
493 should 'show number of published events in index' do 499 should 'show number of published events in index' do
@@ -1272,15 +1278,6 @@ class ProfileControllerTest < ActionController::TestCase @@ -1272,15 +1278,6 @@ class ProfileControllerTest < ActionController::TestCase
1272 assert_tag :tag => 'div', :content => /#{instance_eval(&plugin2.profile_tabs[:content])}/, :attributes => {:id => /#{plugin2.profile_tabs[:id]}/} 1278 assert_tag :tag => 'div', :content => /#{instance_eval(&plugin2.profile_tabs[:content])}/, :attributes => {:id => /#{plugin2.profile_tabs[:id]}/}
1273 end 1279 end
1274 1280
1275 - should 'redirect to profile page when try to request join_not_logged via GET method' do  
1276 - community = Community.create!(:name => 'my test community')  
1277 - login_as(profile.identifier)  
1278 - get :join_not_logged, :profile => community.identifier  
1279 - assert_nothing_raised do  
1280 - assert_redirected_to community.url  
1281 - end  
1282 - end  
1283 -  
1284 should 'check different profile from the domain profile' do 1281 should 'check different profile from the domain profile' do
1285 default = Environment.default 1282 default = Environment.default
1286 default.domains.create!(:name => 'environment.com') 1283 default.domains.create!(:name => 'environment.com')