diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index cc6e5799..d15581b1 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -99,13 +99,14 @@ class UsersController < ApplicationController return end + signup_by_admin = true if (@user && @user.is_admin?) first_user_signing_up = User.no_users_yet? user.is_admin = true if first_user_signing_up if user.save @user = User.authenticate(user.login, params['user']['password']) @user.create_preference({:locale => I18n.locale}) @user.save - session['user_id'] = @user.id if first_user_signing_up + session['user_id'] = @user.id unless signup_by_admin notify :notice, t('users.signup_successful', :username => @user.login) redirect_back_or_home end diff --git a/test/integration/stories_test.rb b/test/integration/stories_test.rb index 4a9ce419..3d37f29f 100644 --- a/test/integration/stories_test.rb +++ b/test/integration/stories_test.rb @@ -14,10 +14,25 @@ class StoriesTest < ActionController::IntegrationTest end def test_signup_new_user_by_nonadmin + SITE_CONFIG['open_signups'] = false other_user = new_session_as(:other_user,"sesame") other_user.goes_to_signup_as_nonadmin end + def test_open_signup_new_user + SITE_CONFIG['open_signups'] = true + get "/signup" + assert_response :success + assert_template "users/new" + post "/users", :user => {:login => "newbie", + :password => "newbiepass", + :password_confirmation => "newbiepass"} + assert_response :redirect + follow_redirect! + assert_response :success + assert_template "todos/index" + end + private module CustomAssertions @@ -72,4 +87,4 @@ class StoriesTest < ActionController::IntegrationTest end end -end \ No newline at end of file +end