Merged new_web action into create_web
This commit is contained in:
parent
16dcdb6e0e
commit
63cf09059b
5 changed files with 27 additions and 26 deletions
|
@ -5,7 +5,7 @@ class AdminController < ApplicationController
|
|||
layout 'default'
|
||||
|
||||
def create_system
|
||||
if wiki.setup?
|
||||
if @wiki.setup?
|
||||
flash[:error] = <<-EOL
|
||||
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/>
|
||||
|
@ -27,11 +27,19 @@ class AdminController < ApplicationController
|
|||
end
|
||||
|
||||
def create_web
|
||||
if @wiki.authenticate(@params['system_password'])
|
||||
@wiki.create_web(@params['name'], @params['address'])
|
||||
redirect_show('HomePage', @params['address'])
|
||||
else
|
||||
redirect_to :action => 'index'
|
||||
if @params['address']
|
||||
# form submitted
|
||||
if @wiki.authenticate(@params['system_password'])
|
||||
@wiki.create_web(@params['name'], @params['address'])
|
||||
redirect_show('HomePage', @params['address'])
|
||||
else
|
||||
redirect_to :action => 'index'
|
||||
end
|
||||
else
|
||||
# no form submitted -> render template
|
||||
if @wiki.system[:password].nil?
|
||||
redirect_to :controller => 'wiki', :action => 'index'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -39,11 +47,6 @@ class AdminController < ApplicationController
|
|||
# to template
|
||||
end
|
||||
|
||||
def new_web
|
||||
redirect_to :action => 'index' if wiki.system['password'].nil?
|
||||
# otherwise, to template
|
||||
end
|
||||
|
||||
def update_web
|
||||
if wiki.authenticate(@params['system_password'])
|
||||
wiki.update_web(
|
||||
|
|
|
@ -93,7 +93,7 @@
|
|||
and
|
||||
<input type="submit" value="Update Web" />
|
||||
<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>
|
||||
</p>
|
||||
|
||||
|
|
|
@ -67,7 +67,6 @@ class DispatchServlet
|
|||
'edit_web' => 'admin',
|
||||
'file' => 'file',
|
||||
'import' => 'file',
|
||||
'new_web' => 'admin',
|
||||
'pic' => 'file',
|
||||
'update_web' => 'admin'
|
||||
}
|
||||
|
|
|
@ -92,6 +92,18 @@ class AdminControllerTest < Test::Unit::TestCase
|
|||
assert_nil @wiki.webs['wiki2']
|
||||
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
|
||||
process 'edit_web', 'web' => 'wiki1'
|
||||
|
@ -100,19 +112,6 @@ class AdminControllerTest < Test::Unit::TestCase
|
|||
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
|
||||
@wiki.system[:password] = 'pswd'
|
||||
|
||||
|
|
Loading…
Reference in a new issue