Removed deprecation errors for rails 1.2.3. Corrected test case failures as a result of updated features and functionality

This commit is contained in:
Matt MacGillivray 2007-05-07 22:46:00 +00:00
parent 322a09274f
commit 36b86a9d41
21 changed files with 174 additions and 159 deletions

View file

@ -13,12 +13,12 @@ class AdminController < ApplicationController
"\n\n" +
"(WARNING: this will destroy content of your current wiki)."
redirect_home(@wiki.webs.keys.first)
elsif @params['web_name']
elsif params['web_name']
# form submitted -> create a wiki
@wiki.setup(@params['password'], @params['web_name'], @params['web_address'])
flash[:info] = "Your new wiki '#{@params['web_name']}' is created!\n" +
@wiki.setup(params['password'], params['web_name'], params['web_address'])
flash[:info] = "Your new wiki '#{params['web_name']}' is created!\n" +
"Please edit its home page and press Submit when finished."
redirect_to :web => @params['web_address'], :controller => 'wiki', :action => 'new',
redirect_to :web => params['web_address'], :controller => 'wiki', :action => 'new',
:id => 'HomePage'
else
# no form submitted -> go to template
@ -26,13 +26,13 @@ class AdminController < ApplicationController
end
def create_web
if @params['address']
if params['address']
# form submitted
if @wiki.authenticate(@params['system_password'])
if @wiki.authenticate(params['system_password'])
begin
@wiki.create_web(@params['name'], @params['address'])
flash[:info] = "New web '#{@params['name']}' successfully created."
redirect_to :web => @params['address'], :controller => 'wiki', :action => 'new',
@wiki.create_web(params['name'], params['address'])
flash[:info] = "New web '#{params['name']}' successfully created."
redirect_to :web => params['address'], :controller => 'wiki', :action => 'new',
:id => 'HomePage'
rescue Instiki::ValidationError => e
@error = e.message
@ -47,25 +47,25 @@ class AdminController < ApplicationController
end
def edit_web
system_password = @params['system_password']
system_password = params['system_password']
if system_password
# form submitted
if wiki.authenticate(system_password)
begin
wiki.edit_web(
@web.address, @params['address'], @params['name'],
@params['markup'].intern,
@params['color'], @params['additional_style'],
@params['safe_mode'] ? true : false,
@params['password'].empty? ? nil : @params['password'],
@params['published'] ? true : false,
@params['brackets_only'] ? true : false,
@params['count_pages'] ? true : false,
@params['allow_uploads'] ? true : false,
@params['max_upload_size']
@web.address, params['address'], params['name'],
params['markup'].intern,
params['color'], params['additional_style'],
params['safe_mode'] ? true : false,
params['password'].empty? ? nil : params['password'],
params['published'] ? true : false,
params['brackets_only'] ? true : false,
params['count_pages'] ? true : false,
params['allow_uploads'] ? true : false,
params['max_upload_size']
)
flash[:info] = "Web '#{@params['address']}' was successfully updated"
redirect_home(@params['address'])
flash[:info] = "Web '#{params['address']}' was successfully updated"
redirect_home(params['address'])
rescue Instiki::ValidationError => e
logger.warn e.message
@error = e.message
@ -81,12 +81,12 @@ class AdminController < ApplicationController
end
def remove_orphaned_pages
if wiki.authenticate(@params['system_password_orphaned'])
if wiki.authenticate(params['system_password_orphaned'])
wiki.remove_orphaned_pages(@web_name)
flash[:info] = 'Orphaned pages removed'
redirect_to :controller => 'wiki', :web => @web_name, :action => 'list'
else
flash[:error] = password_error(@params['system_password_orphaned'])
flash[:error] = password_error(params['system_password_orphaned'])
redirect_to :controller => 'admin', :web => @web_name, :action => 'edit_web'
end
end

View file

@ -29,8 +29,8 @@ class ApplicationController < ActionController::Base
end
def connect_to_model
@action_name = @params['action'] || 'index'
@web_name = @params['web']
@action_name = params['action'] || 'index'
@web_name = params['web']
@wiki = wiki
@author = cookies['author'] || 'AnonymousCoward'
if @web_name
@ -105,11 +105,11 @@ class ApplicationController < ActionController::Base
end
def remember_location
if @request.method == :get and
@response.headers['Status'] == '200 OK' and not
if request.method == :get and
response.headers['Status'] == '200 OK' and not
%w(locked save back file pic import).include?(action_name)
@session[:return_to] = @request.request_uri
logger.debug "Session ##{session.object_id}: remembered URL '#{@session[:return_to]}'"
session[:return_to] = request.request_uri
logger.debug "Session ##{session.object_id}: remembered URL '#{session[:return_to]}'"
end
end
@ -125,8 +125,8 @@ class ApplicationController < ActionController::Base
def return_to_last_remembered
# Forget the redirect location
redirect_target, @session[:return_to] = @session[:return_to], nil
tried_home, @session[:tried_home] = @session[:tried_home], false
redirect_target, session[:return_to] = session[:return_to], nil
tried_home, session[:tried_home] = session[:tried_home], false
# then try to redirect to it
if redirect_target.nil?
@ -145,9 +145,9 @@ class ApplicationController < ActionController::Base
def set_content_type_header
if %w(rss_with_content rss_with_headlines).include?(action_name)
@response.headers['Content-Type'] = 'text/xml; charset=UTF-8'
response.headers['Content-Type'] = 'text/xml; charset=UTF-8'
else
@response.headers['Content-Type'] = 'text/html; charset=UTF-8'
response.headers['Content-Type'] = 'text/html; charset=UTF-8'
end
end
@ -185,7 +185,7 @@ class ApplicationController < ActionController::Base
@web.nil? or
@web.password.nil? or
cookies[CGI.escape(@web_name)] == @web.password or
password_check(@params['password'])
password_check(params['password'])
end
end

View file

@ -10,9 +10,9 @@ class FileController < ApplicationController
def file
@file_name = params['id']
if @params['file']
if params['file']
# form supplied
new_file = @web.wiki_files.create(@params['file'])
new_file = @web.wiki_files.create(params['file'])
if new_file.valid?
flash[:info] = "File '#{@file_name}' successfully uploaded"
return_to_last_remembered
@ -38,10 +38,10 @@ class FileController < ApplicationController
end
def import
if @params['file']
if params['file']
@problems = []
import_file_name = "#{@web.address}-import-#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}.zip"
import_from_archive(@params['file'].path)
import_from_archive(params['file'].path)
if @problems.empty?
flash[:info] = 'Import successfully finished'
else
@ -57,7 +57,7 @@ class FileController < ApplicationController
protected
def check_allow_uploads
render(:status => 404, :text => "Web #{@params['web'].inspect} not found") and return false unless @web
render(:status => 404, :text => "Web #{params['web'].inspect} not found") and return false unless @web
if @web.allow_uploads?
return true
else

View file

@ -26,10 +26,10 @@ class WikiController < ApplicationController
# Outside a single web --------------------------------------------------------
def authenticate
if password_check(@params['password'])
if password_check(params['password'])
redirect_home
else
flash[:info] = password_error(@params['password'])
flash[:info] = password_error(params['password'])
redirect_to :action => 'login', :web => @web_name
end
end
@ -144,7 +144,7 @@ class WikiController < ApplicationController
end
def search
@query = @params['query']
@query = params['query']
@title_results = @web.select { |page| page.name =~ /#{@query}/i }.sort
@results = @web.select { |page| page.content =~ /#{@query}/i }.sort
all_pages_found = (@results + @title_results).uniq
@ -163,7 +163,7 @@ class WikiController < ApplicationController
def edit
if @page.nil?
redirect_home
elsif @page.locked?(Time.now) and not @params['break_lock']
elsif @page.locked?(Time.now) and not params['break_lock']
redirect_to :web => @web_name, :action => 'locked', :id => @page_name
else
@page.lock(Time.now, @author)
@ -214,7 +214,7 @@ class WikiController < ApplicationController
def revision
get_page_and_revision
@show_diff = (@params[:mode] == 'diff')
@show_diff = (params[:mode] == 'diff')
@renderer = PageRenderer.new(@revision)
end
@ -225,25 +225,25 @@ class WikiController < ApplicationController
def save
render(:status => 404, :text => 'Undefined page name') and return if @page_name.nil?
author_name = @params['author']
author_name = params['author']
author_name = 'AnonymousCoward' if author_name =~ /^\s*$/
cookies['author'] = { :value => author_name, :expires => Time.utc(2030) }
begin
filter_spam(@params['content'])
filter_spam(params['content'])
if @page
wiki.revise_page(@web_name, @page_name, @params['content'], Time.now,
wiki.revise_page(@web_name, @page_name, params['content'], Time.now,
Author.new(author_name, remote_ip), PageRenderer.new)
@page.unlock
else
wiki.write_page(@web_name, @page_name, @params['content'], Time.now,
wiki.write_page(@web_name, @page_name, params['content'], Time.now,
Author.new(author_name, remote_ip), PageRenderer.new)
end
redirect_to_page @page_name
rescue => e
flash[:error] = e
logger.error e
flash[:content] = @params['content']
flash[:content] = params['content']
if @page
@page.unlock
redirect_to :action => 'edit', :web => @web_name, :id => @page_name
@ -257,7 +257,7 @@ class WikiController < ApplicationController
if @page
begin
@renderer = PageRenderer.new(@page.revisions.last)
@show_diff = (@params[:mode] == 'diff')
@show_diff = (params[:mode] == 'diff')
render_action 'page'
# TODO this rescue should differentiate between errors due to rendering and errors in
# the application itself (for application errors, it's better not to rescue the error at all)
@ -286,7 +286,7 @@ class WikiController < ApplicationController
protected
def load_page
@page_name = @params['id']
@page_name = params['id']
@page = @wiki.read_page(@web_name, @page_name) if @page_name
end
@ -339,8 +339,8 @@ class WikiController < ApplicationController
end
def get_page_and_revision
if @params['rev']
@revision_number = @params['rev'].to_i
if params['rev']
@revision_number = params['rev'].to_i
else
@revision_number = @page.revisions.length
end
@ -349,7 +349,7 @@ class WikiController < ApplicationController
def parse_category
@categories = WikiReference.list_categories.sort
@category = @params['category']
@category = params['category']
if @category
@set_name = "category '#{@category}'"
pages = WikiReference.pages_in_category(@category).sort.map { |page_name| @web.page(page_name) }
@ -362,19 +362,19 @@ class WikiController < ApplicationController
end
def parse_rss_params
if @params.include? 'limit'
limit = @params['limit'].to_i rescue nil
if params.include? 'limit'
limit = params['limit'].to_i rescue nil
limit = nil if limit == 0
else
limit = 15
end
start_date = Time.local(*ParseDate::parsedate(@params['start'])) rescue nil
end_date = Time.local(*ParseDate::parsedate(@params['end'])) rescue nil
start_date = Time.local(*ParseDate::parsedate(params['start'])) rescue nil
end_date = Time.local(*ParseDate::parsedate(params['end'])) rescue nil
[ limit, start_date, end_date ]
end
def remote_ip
ip = @request.remote_ip
ip = request.remote_ip
logger.info(ip)
ip
end