From c407fc2463e98bc3aabef372410e58dc5617962f Mon Sep 17 00:00:00 2001 From: lukemelia Date: Fri, 29 Dec 2006 17:48:47 +0000 Subject: [PATCH] On first run, tracks now automatically redirects to signup page to create the admin user. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@383 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/controllers/login_controller.rb | 6 +++++- tracks/test/functional/login_controller_test.rb | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tracks/app/controllers/login_controller.rb b/tracks/app/controllers/login_controller.rb index 6b001d98..fb16be66 100644 --- a/tracks/app/controllers/login_controller.rb +++ b/tracks/app/controllers/login_controller.rb @@ -21,7 +21,11 @@ class LoginController < ApplicationController else @login = params['user_login'] notify :warning, "Login unsuccessful" - end + end + when :get + if User.no_users_yet? + redirect_to :action => 'signup' + end end end diff --git a/tracks/test/functional/login_controller_test.rb b/tracks/test/functional/login_controller_test.rb index 4204de8e..b698385a 100644 --- a/tracks/test/functional/login_controller_test.rb +++ b/tracks/test/functional/login_controller_test.rb @@ -38,7 +38,6 @@ class LoginControllerTest < Test::Unit::TestCase assert_equal("http://#{@request.host}/bogus/location", @response.redirect_url) end - def test_login_with_valid_standard_user user = login('jane','sesame', 'off') assert_equal user.id, @response.session['user_id'] @@ -48,6 +47,12 @@ class LoginControllerTest < Test::Unit::TestCase assert_redirected_to :controller => 'todo', :action => 'index' end + def test_login_with_no_users_redirects_to_signup + User.delete_all + get :login + assert_redirected_to :controller => 'login', :action => 'signup' + end + def test_logout user = login('admin','abracadabra', 'on') get :logout