From d4f22713a9757f84c194cd8aca8f7587bbcb6f67 Mon Sep 17 00:00:00 2001 From: Daniela Feitosa Date: Mon, 19 May 2014 14:55:12 +0000 Subject: [PATCH] Added back method and tests removed on merge --- app/controllers/public/account_controller.rb | 6 +++--- test/functional/profile_controller_test.rb | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb index ce51dae..b91be44 100644 --- a/app/controllers/public/account_controller.rb +++ b/app/controllers/public/account_controller.rb @@ -37,7 +37,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 } @@ -105,7 +105,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 @@ -455,7 +455,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 95655d7..fa0af57 100644 --- a/test/functional/profile_controller_test.rb +++ b/test/functional/profile_controller_test.rb @@ -477,6 +477,25 @@ class ProfileControllerTest < ActionController::TestCase assert_equal "/profile/#{community.identifier}", @request.session[:previous_location] end + should 'redirect to login after user not logged asks to join a community' do + community = Community.create!(:name => 'my test community') + + get :join_not_logged, :profile => community.identifier + + assert_equal community.identifier, @request.session[:join] + assert_redirected_to :controller => :account, :action => :login + end + + 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_equal community.identifier, @request.session[:join] + assert_redirected_to :controller => :profile, :action => :join + end + should 'show number of published events in index' do profile.articles << Event.new(:name => 'Published event', :start_date => Date.today) profile.articles << Event.new(:name => 'Unpublished event', :start_date => Date.today, :published => false) -- libgit2 0.21.2