diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 27aba499fdfe8e4eacd1d15bc4a926ddc8584585..92635e90dd226372225fdbd504c8d4ffbeb48e1d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -106,10 +106,17 @@ class ApplicationController < ActionController::Base end def after_sign_in_path_for(resource) - stored_location_for(:user) || (current_user.getting_started? ? getting_started_path : root_path) + stored_location_for(:user) || current_user_redirect_path end def max_time params[:max_time] ? Time.at(params[:max_time].to_i) : Time.now + 1 end + + private + + def current_user_redirect_path + return person_path(current_user.person) if current_user.beta? + current_user.getting_started? ? getting_started_path : root_path + end end diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 66cd6fa3b26b6ce6f47152df4a0d993f86163247..d22361d01ed67488528900863f915a9e2b56285e 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -32,17 +32,5 @@ describe ApplicationController do response.headers['X-Git-Revision'].should == '02395' end end - #this context is commented out because the code to do it gets applied at environment load. - #context 'without git info' do - # before do - # AppConfig.config_vars.delete(:git_update) - # AppConfig.config_vars.delete(:git_revision) - # end - # it 'does not set the headers if there is no git info' do - # get :index - # response.headers.keys.should_not include('X-Git-Update') - # response.headers.keys.should_not include('X-Git-Revision') - # end - #end end end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 160d7269aa04f7f9a157751aececed9603f56f6b..9a2d2725552d15fb4358816a8f91622acaf8cf87 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -251,5 +251,27 @@ describe UsersController do response.should be_success end end + + # This logic lives in application controller + describe "#after_sign_in_path_for" do + before do + @controller.stub(:current_user).and_return(eve) + end + + context 'getting started true on user' do + before do + eve.update_attribute(:getting_started, true) + end + + it "redirects to getting started if the user has getting started set to true" do + @controller.after_sign_in_path_for(eve).should == getting_started_path + end + + it "does not redirect to getting started if the user is beta" do + Role.add_beta(eve.person) + @controller.after_sign_in_path_for(eve).should == person_path(eve.person) + end + end + end end