mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
parent
4d2f25ab20
commit
c838272622
2 changed files with 18 additions and 2 deletions
|
|
@ -99,13 +99,14 @@ class UsersController < ApplicationController
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
signup_by_admin = true if (@user && @user.is_admin?)
|
||||||
first_user_signing_up = User.no_users_yet?
|
first_user_signing_up = User.no_users_yet?
|
||||||
user.is_admin = true if first_user_signing_up
|
user.is_admin = true if first_user_signing_up
|
||||||
if user.save
|
if user.save
|
||||||
@user = User.authenticate(user.login, params['user']['password'])
|
@user = User.authenticate(user.login, params['user']['password'])
|
||||||
@user.create_preference({:locale => I18n.locale})
|
@user.create_preference({:locale => I18n.locale})
|
||||||
@user.save
|
@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)
|
notify :notice, t('users.signup_successful', :username => @user.login)
|
||||||
redirect_back_or_home
|
redirect_back_or_home
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,25 @@ class StoriesTest < ActionController::IntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_signup_new_user_by_nonadmin
|
def test_signup_new_user_by_nonadmin
|
||||||
|
SITE_CONFIG['open_signups'] = false
|
||||||
other_user = new_session_as(:other_user,"sesame")
|
other_user = new_session_as(:other_user,"sesame")
|
||||||
other_user.goes_to_signup_as_nonadmin
|
other_user.goes_to_signup_as_nonadmin
|
||||||
end
|
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
|
private
|
||||||
|
|
||||||
module CustomAssertions
|
module CustomAssertions
|
||||||
|
|
@ -72,4 +87,4 @@ class StoriesTest < ActionController::IntegrationTest
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue