Commit d4f22713a9757f84c194cd8aca8f7587bbcb6f67
1 parent
a8302165
Exists in
master
and in
27 other branches
Added back method and tests removed on merge
(ActionItem3096)
Showing
2 changed files
with
22 additions
and
3 deletions
Show diff stats
app/controllers/public/account_controller.rb
| ... | ... | @@ -37,7 +37,7 @@ class AccountController < ApplicationController |
| 37 | 37 | self.current_user ||= User.authenticate(params[:user][:login], params[:user][:password], environment) if params[:user] |
| 38 | 38 | |
| 39 | 39 | if logged_in? |
| 40 | - join_community(self.current_user) | |
| 40 | + check_join_in_community(self.current_user) | |
| 41 | 41 | if params[:remember_me] == "1" |
| 42 | 42 | self.current_user.remember_me |
| 43 | 43 | cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at } |
| ... | ... | @@ -105,7 +105,7 @@ class AccountController < ApplicationController |
| 105 | 105 | end |
| 106 | 106 | if @user.activated? |
| 107 | 107 | self.current_user = @user |
| 108 | - join_community(@user) | |
| 108 | + check_join_in_community(@user) | |
| 109 | 109 | go_to_signup_initial_page |
| 110 | 110 | else |
| 111 | 111 | @register_pending = true |
| ... | ... | @@ -455,7 +455,7 @@ class AccountController < ApplicationController |
| 455 | 455 | end |
| 456 | 456 | end |
| 457 | 457 | |
| 458 | - def join_community(user) | |
| 458 | + def check_join_in_community(user) | |
| 459 | 459 | profile_to_join = session[:join] |
| 460 | 460 | unless profile_to_join.blank? |
| 461 | 461 | environment.profiles.find_by_identifier(profile_to_join).add_member(user.person) | ... | ... |
test/functional/profile_controller_test.rb
| ... | ... | @@ -477,6 +477,25 @@ class ProfileControllerTest < ActionController::TestCase |
| 477 | 477 | assert_equal "/profile/#{community.identifier}", @request.session[:previous_location] |
| 478 | 478 | end |
| 479 | 479 | |
| 480 | + should 'redirect to login after user not logged asks to join a community' do | |
| 481 | + community = Community.create!(:name => 'my test community') | |
| 482 | + | |
| 483 | + get :join_not_logged, :profile => community.identifier | |
| 484 | + | |
| 485 | + assert_equal community.identifier, @request.session[:join] | |
| 486 | + assert_redirected_to :controller => :account, :action => :login | |
| 487 | + end | |
| 488 | + | |
| 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 | |
| 494 | + | |
| 495 | + assert_equal community.identifier, @request.session[:join] | |
| 496 | + assert_redirected_to :controller => :profile, :action => :join | |
| 497 | + end | |
| 498 | + | |
| 480 | 499 | should 'show number of published events in index' do |
| 481 | 500 | profile.articles << Event.new(:name => 'Published event', :start_date => Date.today) |
| 482 | 501 | profile.articles << Event.new(:name => 'Unpublished event', :start_date => Date.today, :published => false) | ... | ... |