From 7e2ba029df2c91e49a1d31cbc9667f826d80c300 Mon Sep 17 00:00:00 2001 From: Daniela Feitosa Date: Fri, 16 May 2014 20:53:02 +0000 Subject: [PATCH] Fixed broken and removed unused tests --- app/controllers/public/account_controller.rb | 6 +++--- test/functional/profile_controller_test.rb | 27 ++++++++++++--------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb index 41d73ef..4c1120d 100644 --- a/app/controllers/public/account_controller.rb +++ b/app/controllers/public/account_controller.rb @@ -36,7 +36,7 @@ class AccountController < ApplicationController self.current_user ||= User.authenticate(params[:user][:login], params[:user][:password], environment) if params[:user] if logged_in? - join_community(self.current_user) + check_join_in_community(self.current_user) if params[:remember_me] == "1" self.current_user.remember_me cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at } @@ -104,7 +104,7 @@ class AccountController < ApplicationController end if @user.activated? self.current_user = @user - join_community(@user) + check_join_in_community(@user) go_to_signup_initial_page else @register_pending = true @@ -453,7 +453,7 @@ class AccountController < ApplicationController end end - def join_community(user) + def check_join_in_community(user) profile_to_join = session[:join] unless profile_to_join.blank? environment.profiles.find_by_identifier(profile_to_join).add_member(user.person) diff --git a/test/functional/profile_controller_test.rb b/test/functional/profile_controller_test.rb index e0f9d58..bfa901e 100644 --- a/test/functional/profile_controller_test.rb +++ b/test/functional/profile_controller_test.rb @@ -477,17 +477,23 @@ class ProfileControllerTest < ActionController::TestCase assert_equal "/profile/#{community.identifier}", @request.session[:previous_location] end - should 'redirect to location before login after join community' do + should 'redirect to login after user not logged asks to join a community' do community = Community.create!(:name => 'my test community') - @request.expects(:referer).returns("/profile/#{community.identifier}/to_go") - login_as(profile.identifier) + get :join_not_logged, :profile => community.identifier - post :join_not_logged, :profile => community.identifier + assert_equal community.identifier, @request.session[:join] + assert_redirected_to :controller => :account, :action => :login + end - assert_redirected_to "/profile/#{community.identifier}/to_go" + should 'redirect to join after user logged asks to join_not_logged a community' do + community = Community.create!(:name => 'my test community') + + login_as(profile.identifier) + get :join_not_logged, :profile => community.identifier - assert_nil @request.session[:previous_location] + assert_equal community.identifier, @request.session[:join] + assert_redirected_to :controller => :profile, :action => :join end should 'show number of published events in index' do @@ -1272,15 +1278,6 @@ class ProfileControllerTest < ActionController::TestCase assert_tag :tag => 'div', :content => /#{instance_eval(&plugin2.profile_tabs[:content])}/, :attributes => {:id => /#{plugin2.profile_tabs[:id]}/} end - should 'redirect to profile page when try to request join_not_logged via GET method' do - community = Community.create!(:name => 'my test community') - login_as(profile.identifier) - get :join_not_logged, :profile => community.identifier - assert_nothing_raised do - assert_redirected_to community.url - end - end - should 'check different profile from the domain profile' do default = Environment.default default.domains.create!(:name => 'environment.com') -- libgit2 0.21.2