Merged new_web action into create_web

This commit is contained in:
Alexey Verkhovsky 2005-01-28 03:44:36 +00:00
parent 16dcdb6e0e
commit 63cf09059b
5 changed files with 27 additions and 26 deletions

View file

@ -5,7 +5,7 @@ class AdminController < ApplicationController
layout 'default' layout 'default'
def create_system def create_system
if wiki.setup? if @wiki.setup?
flash[:error] = <<-EOL flash[:error] = <<-EOL
Wiki has already been created in '#{@wiki.storage_path}'. Shut down Instiki and delete Wiki has already been created in '#{@wiki.storage_path}'. Shut down Instiki and delete
this directory if you want to recreate it from scratch.<br/><br/> this directory if you want to recreate it from scratch.<br/><br/>
@ -27,23 +27,26 @@ class AdminController < ApplicationController
end end
def create_web def create_web
if @params['address']
# form submitted
if @wiki.authenticate(@params['system_password']) if @wiki.authenticate(@params['system_password'])
@wiki.create_web(@params['name'], @params['address']) @wiki.create_web(@params['name'], @params['address'])
redirect_show('HomePage', @params['address']) redirect_show('HomePage', @params['address'])
else else
redirect_to :action => 'index' redirect_to :action => 'index'
end end
else
# no form submitted -> render template
if @wiki.system[:password].nil?
redirect_to :controller => 'wiki', :action => 'index'
end
end
end end
def edit_web def edit_web
# to template # to template
end end
def new_web
redirect_to :action => 'index' if wiki.system['password'].nil?
# otherwise, to template
end
def update_web def update_web
if wiki.authenticate(@params['system_password']) if wiki.authenticate(@params['system_password'])
wiki.update_web( wiki.update_web(

View file

@ -93,7 +93,7 @@
and and
<input type="submit" value="Update Web" /> <input type="submit" value="Update Web" />
<br/><br/> <br/><br/>
...or forget changes and <a href="/new_web/">create a new web</a> ...or forget changes and <a href="/create_web/">create a new web</a>
</small> </small>
</p> </p>

View file

@ -67,7 +67,6 @@ class DispatchServlet
'edit_web' => 'admin', 'edit_web' => 'admin',
'file' => 'file', 'file' => 'file',
'import' => 'file', 'import' => 'file',
'new_web' => 'admin',
'pic' => 'file', 'pic' => 'file',
'update_web' => 'admin' 'update_web' => 'admin'
} }

View file

@ -92,6 +92,18 @@ class AdminControllerTest < Test::Unit::TestCase
assert_nil @wiki.webs['wiki2'] assert_nil @wiki.webs['wiki2']
end end
def test_create_web_no_form_submitted
@wiki.system[:password] = 'pswd'
process 'create_web'
assert_success
end
def test_create_web_no_form_submitted_and_no_password_set
@wiki.system[:password] = nil
process 'create_web'
assert_redirected_to :action => 'index'
end
def test_edit_web def test_edit_web
process 'edit_web', 'web' => 'wiki1' process 'edit_web', 'web' => 'wiki1'
@ -100,19 +112,6 @@ class AdminControllerTest < Test::Unit::TestCase
end end
def test_new_web
@wiki.system['password'] = 'pswd'
process 'new_web'
assert_success
end
def test_new_web_no_password_set
@wiki.system['password'] = nil
process 'new_web'
assert_redirected_to :action => 'index'
end
def test_update_web def test_update_web
@wiki.system[:password] = 'pswd' @wiki.system[:password] = 'pswd'