Skip to content

Commit

Permalink
Merge pull request #122 from zoombody/fixes
Browse files Browse the repository at this point in the history
Fix redirect to home page after open signup
  • Loading branch information
lrbalt committed Nov 30, 2012
2 parents 4d2f25a + c838272 commit 93c6d33
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ def create
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
Expand Down
17 changes: 16 additions & 1 deletion test/integration/stories_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,25 @@ def test_signup_new_user_by_admin
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
Expand Down Expand Up @@ -72,4 +87,4 @@ def new_session_as(user,plainpass)
end
end

end
end

0 comments on commit 93c6d33

Please sign in to comment.