From 7ae224f5c294de48fade4e9067b938a606e25118 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 7 Dec 2008 16:16:01 +0000 Subject: [PATCH] Rails 2.2 deprecations git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/work@2113 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- rails-2.2/app/controllers/settings_controller.rb | 2 +- rails-2.2/app/helpers/application_helper.rb | 8 ++++---- rails-2.2/app/helpers/messages_helper.rb | 2 +- rails-2.2/app/helpers/projects_helper.rb | 4 ++-- rails-2.2/app/helpers/sort_helper.rb | 4 ++-- rails-2.2/app/models/mailer.rb | 9 ++------- rails-2.2/app/models/user.rb | 2 +- rails-2.2/app/views/common/_calendar.rhtml | 2 +- rails-2.2/app/views/common/feed.atom.rxml | 6 +++--- rails-2.2/app/views/documents/_document.rhtml | 2 +- rails-2.2/app/views/my/account.rhtml | 2 +- .../views/repositories/_dir_list_content.rhtml | 2 +- rails-2.2/app/views/search/index.rhtml | 2 +- rails-2.2/app/views/timelog/_list.rhtml | 2 +- rails-2.2/config/initializers/10-patches.rb | 15 --------------- .../lib/redmine/wiki_formatting/textile/helper.rb | 6 ++++-- rails-2.2/test/unit/mailer_test.rb | 12 ++++++------ rails-2.2/test/unit/project_test.rb | 3 ++- .../dispatcher/action_controller_dispatcher.rb | 2 +- .../plugins/classic_pagination/lib/pagination.rb | 4 ++-- 20 files changed, 37 insertions(+), 54 deletions(-) diff --git a/rails-2.2/app/controllers/settings_controller.rb b/rails-2.2/app/controllers/settings_controller.rb index 99f7bcf08..331f5b5b1 100644 --- a/rails-2.2/app/controllers/settings_controller.rb +++ b/rails-2.2/app/controllers/settings_controller.rb @@ -41,7 +41,7 @@ class SettingsController < ApplicationController @deliveries = ActionMailer::Base.perform_deliveries @guessed_host_and_path = request.host_with_port - @guessed_host_and_path << ('/'+ request.relative_url_root.gsub(%r{^\/}, '')) unless request.relative_url_root.blank? + @guessed_host_and_path << ('/'+ self.class.relative_url_root.gsub(%r{^\/}, '')) unless self.class.relative_url_root.blank? end def plugin diff --git a/rails-2.2/app/helpers/application_helper.rb b/rails-2.2/app/helpers/application_helper.rb index 248704609..2fd263e50 100644 --- a/rails-2.2/app/helpers/application_helper.rb +++ b/rails-2.2/app/helpers/application_helper.rb @@ -372,7 +372,7 @@ module ApplicationHelper if project && (changeset = project.changesets.find_by_revision(oid)) link = link_to("r#{oid}", {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => oid}, :class => 'changeset', - :title => truncate_single_line(changeset.comments, 100)) + :title => truncate_single_line(changeset.comments, :length => 100)) end elsif sep == '#' oid = oid.to_i @@ -381,7 +381,7 @@ module ApplicationHelper if issue = Issue.find_by_id(oid, :include => [:project, :status], :conditions => Project.visible_by(User.current)) link = link_to("##{oid}", {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid}, :class => (issue.closed? ? 'issue closed' : 'issue'), - :title => "#{truncate(issue.subject, 100)} (#{issue.status.name})") + :title => "#{truncate(issue.subject, :length => 100)} (#{issue.status.name})") link = content_tag('del', link) if issue.closed? end when 'document' @@ -396,7 +396,7 @@ module ApplicationHelper end when 'message' if message = Message.find_by_id(oid, :include => [:parent, {:board => :project}], :conditions => Project.visible_by(User.current)) - link = link_to h(truncate(message.subject, 60)), {:only_path => only_path, + link = link_to h(truncate(message.subject, :length => 60)), {:only_path => only_path, :controller => 'messages', :action => 'show', :board_id => message.board, @@ -423,7 +423,7 @@ module ApplicationHelper if project && (changeset = project.changesets.find(:first, :conditions => ["scmid LIKE ?", "#{name}%"])) link = link_to h("#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.revision}, :class => 'changeset', - :title => truncate_single_line(changeset.comments, 100) + :title => truncate_single_line(changeset.comments, :length => 100) end when 'source', 'export' if project && project.repository diff --git a/rails-2.2/app/helpers/messages_helper.rb b/rails-2.2/app/helpers/messages_helper.rb index bf23275c3..034d1ad31 100644 --- a/rails-2.2/app/helpers/messages_helper.rb +++ b/rails-2.2/app/helpers/messages_helper.rb @@ -19,7 +19,7 @@ module MessagesHelper def link_to_message(message) return '' unless message - link_to h(truncate(message.subject, 60)), :controller => 'messages', + link_to h(truncate(message.subject, :length => 60)), :controller => 'messages', :action => 'show', :board_id => message.board_id, :id => message.root, diff --git a/rails-2.2/app/helpers/projects_helper.rb b/rails-2.2/app/helpers/projects_helper.rb index cd2e743fe..c759ee5f7 100644 --- a/rails-2.2/app/helpers/projects_helper.rb +++ b/rails-2.2/app/helpers/projects_helper.rb @@ -22,7 +22,7 @@ module ProjectsHelper end def format_activity_title(text) - h(truncate_single_line(text, 100)) + h(truncate_single_line(text, :length => 100)) end def format_activity_day(date) @@ -30,7 +30,7 @@ module ProjectsHelper end def format_activity_description(text) - h(truncate(text.to_s, 250).gsub(%r{<(pre|code)>.*$}m, '...')) + h(truncate(text.to_s, :length => 250).gsub(%r{<(pre|code)>.*$}m, '...')) end def project_settings_tabs diff --git a/rails-2.2/app/helpers/sort_helper.rb b/rails-2.2/app/helpers/sort_helper.rb index 9ca5c11bd..704361529 100644 --- a/rails-2.2/app/helpers/sort_helper.rb +++ b/rails-2.2/app/helpers/sort_helper.rb @@ -106,7 +106,7 @@ module SortHelper icon = nil order = default_order end - caption = titleize(Inflector::humanize(column)) unless caption + caption = titleize(ActiveSupport::Inflector::humanize(column)) unless caption sort_options = { :sort_key => column, :sort_order => order } # don't reuse params if filters are present @@ -139,7 +139,7 @@ module SortHelper # # def sort_header_tag(column, options = {}) - caption = options.delete(:caption) || titleize(Inflector::humanize(column)) + caption = options.delete(:caption) || titleize(ActiveSupport::Inflector::humanize(column)) default_order = options.delete(:default_order) || 'asc' options[:title]= l(:label_sort_by, "\"#{caption}\"") unless options[:title] content_tag('th', sort_link(column, caption, default_order), options) diff --git a/rails-2.2/app/models/mailer.rb b/rails-2.2/app/models/mailer.rb index 397807d16..5f883b22b 100644 --- a/rails-2.2/app/models/mailer.rb +++ b/rails-2.2/app/models/mailer.rb @@ -186,7 +186,7 @@ class Mailer < ActionMailer::Base # URL options h = Setting.host_name - h = h.to_s.gsub(%r{\/.*$}, '') unless ActionController::AbstractRequest.relative_url_root.blank? + h = h.to_s.gsub(%r{\/.*$}, '') unless ActionController::Base.relative_url_root.blank? default_url_options[:host] = h default_url_options[:protocol] = Setting.protocol @@ -220,7 +220,7 @@ class Mailer < ActionMailer::Base # Renders a message with the corresponding layout def render_message(method_name, body) - layout = method_name.match(%r{text\.html\.(rhtml|rxml)}) ? 'layout.text.html.rhtml' : 'layout.text.plain.rhtml' + layout = method_name.to_s.match(%r{text\.html\.(rhtml|rxml)}) ? 'layout.text.html.rhtml' : 'layout.text.plain.rhtml' body[:content_for_layout] = render(:file => method_name, :body => body) ActionView::Base.new(template_root, body, self).render(:file => "mailer/#{layout}", :use_full_path => true) end @@ -239,9 +239,4 @@ class Mailer < ActionMailer::Base end return value end - - # Makes partial rendering work with Rails 1.2 (retro-compatibility) - def self.controller_path - '' - end unless respond_to?('controller_path') end diff --git a/rails-2.2/app/models/user.rb b/rails-2.2/app/models/user.rb index 72c550b82..0fe60571a 100644 --- a/rails-2.2/app/models/user.rb +++ b/rails-2.2/app/models/user.rb @@ -153,7 +153,7 @@ class User < ActiveRecord::Base end def time_zone - @time_zone ||= (self.pref.time_zone.blank? ? nil : TimeZone[self.pref.time_zone]) + @time_zone ||= (self.pref.time_zone.blank? ? nil : ActiveSupport::TimeZone[self.pref.time_zone]) end def wants_comments_in_reverse_order? diff --git a/rails-2.2/app/views/common/_calendar.rhtml b/rails-2.2/app/views/common/_calendar.rhtml index 1095cd501..6ac9ddce6 100644 --- a/rails-2.2/app/views/common/_calendar.rhtml +++ b/rails-2.2/app/views/common/_calendar.rhtml @@ -20,7 +20,7 @@ while day <= calendar.enddt %> image_tag('arrow_to.png') end %> <%= h("#{i.project} -") unless @project && @project == i.project %> - <%= link_to_issue i %>: <%= h(truncate(i.subject, 30)) %> + <%= link_to_issue i %>: <%= h(truncate(i.subject, :length => 30)) %> <%= render_issue_tooltip i %> <% else %> diff --git a/rails-2.2/app/views/common/feed.atom.rxml b/rails-2.2/app/views/common/feed.atom.rxml index 8d07cf208..811140152 100644 --- a/rails-2.2/app/views/common/feed.atom.rxml +++ b/rails-2.2/app/views/common/feed.atom.rxml @@ -1,6 +1,6 @@ xml.instruct! xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do - xml.title truncate_single_line(@title, 100) + xml.title truncate_single_line(@title, :length => 100) xml.link "rel" => "self", "href" => url_for(params.merge({:format => nil, :only_path => false})) xml.link "rel" => "alternate", "href" => url_for(:controller => 'welcome', :only_path => false) xml.id url_for(:controller => 'welcome', :only_path => false) @@ -11,9 +11,9 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do xml.entry do url = url_for(item.event_url(:only_path => false)) if @project - xml.title truncate_single_line(item.event_title, 100) + xml.title truncate_single_line(item.event_title, :length => 100) else - xml.title truncate_single_line("#{item.project} - #{item.event_title}", 100) + xml.title truncate_single_line("#{item.project} - #{item.event_title}", :length => 100) end xml.link "rel" => "alternate", "href" => url xml.id url diff --git a/rails-2.2/app/views/documents/_document.rhtml b/rails-2.2/app/views/documents/_document.rhtml index ddfdb9eec..47b450000 100644 --- a/rails-2.2/app/views/documents/_document.rhtml +++ b/rails-2.2/app/views/documents/_document.rhtml @@ -1,3 +1,3 @@

<%= link_to h(document.title), :controller => 'documents', :action => 'show', :id => document %>
-<% unless document.description.blank? %><%=h(truncate(document.description, 250)) %>
<% end %> +<% unless document.description.blank? %><%=h(truncate(document.description, :length => 250)) %>
<% end %> <%= format_time(document.created_on) %>

\ No newline at end of file diff --git a/rails-2.2/app/views/my/account.rhtml b/rails-2.2/app/views/my/account.rhtml index 20210c99a..f4b726f96 100644 --- a/rails-2.2/app/views/my/account.rhtml +++ b/rails-2.2/app/views/my/account.rhtml @@ -38,7 +38,7 @@
<% fields_for :pref, @user.pref, :builder => TabularFormBuilder, :lang => current_language do |pref_fields| %>

<%= pref_fields.check_box :hide_mail %>

-

<%= pref_fields.select :time_zone, TimeZone.all.collect {|z| [ z.to_s, z.name ]}, :include_blank => true %>

+

<%= pref_fields.select :time_zone, ActiveSupport::TimeZone.all.collect {|z| [ z.to_s, z.name ]}, :include_blank => true %>

<%= pref_fields.select :comments_sorting, [[l(:label_chronological_order), 'asc'], [l(:label_reverse_chronological_order), 'desc']] %>

<% end %>
diff --git a/rails-2.2/app/views/repositories/_dir_list_content.rhtml b/rails-2.2/app/views/repositories/_dir_list_content.rhtml index 12ee44dbf..3fad7c02c 100644 --- a/rails-2.2/app/views/repositories/_dir_list_content.rhtml +++ b/rails-2.2/app/views/repositories/_dir_list_content.rhtml @@ -19,6 +19,6 @@ <%= link_to(format_revision(entry.lastrev.name), :action => 'revision', :id => @project, :rev => entry.lastrev.identifier) if entry.lastrev && entry.lastrev.identifier %> <%= distance_of_time_in_words(entry.lastrev.time, Time.now) if entry.lastrev && entry.lastrev.time %> <%= changeset.nil? ? h(entry.lastrev.author.to_s.split('<').first) : changeset.author if entry.lastrev %> -<%=h truncate(changeset.comments, 50) unless changeset.nil? %> +<%=h truncate(changeset.comments, :length => 50) unless changeset.nil? %> <% end %> diff --git a/rails-2.2/app/views/search/index.rhtml b/rails-2.2/app/views/search/index.rhtml index cb5b70a4c..128937288 100644 --- a/rails-2.2/app/views/search/index.rhtml +++ b/rails-2.2/app/views/search/index.rhtml @@ -26,7 +26,7 @@

<%= l(:label_result_plural) %> (<%= @results_by_type.values.sum %>)

<% @results.each do |e| %> -
<%= content_tag('span', h(e.project), :class => 'project') unless @project == e.project %> <%= link_to highlight_tokens(truncate(e.event_title, 255), @tokens), e.event_url %>
+
<%= content_tag('span', h(e.project), :class => 'project') unless @project == e.project %> <%= link_to highlight_tokens(truncate(e.event_title, :length => 255), @tokens), e.event_url %>
<%= highlight_tokens(e.event_description, @tokens) %> <%= format_time(e.event_datetime) %>
<% end %> diff --git a/rails-2.2/app/views/timelog/_list.rhtml b/rails-2.2/app/views/timelog/_list.rhtml index 8aebd75de..6510b8ecb 100644 --- a/rails-2.2/app/views/timelog/_list.rhtml +++ b/rails-2.2/app/views/timelog/_list.rhtml @@ -20,7 +20,7 @@ <%=h entry.project %> <% if entry.issue -%> -<%= link_to_issue entry.issue %>: <%= h(truncate(entry.issue.subject, 50)) -%> +<%= link_to_issue entry.issue %>: <%= h(truncate(entry.issue.subject, :length => 50)) -%> <% end -%> <%=h entry.comments %> diff --git a/rails-2.2/config/initializers/10-patches.rb b/rails-2.2/config/initializers/10-patches.rb index fcc091997..24c803f19 100644 --- a/rails-2.2/config/initializers/10-patches.rb +++ b/rails-2.2/config/initializers/10-patches.rb @@ -1,17 +1,2 @@ -ActiveRecord::Errors.default_error_messages = { - :inclusion => "activerecord_error_inclusion", - :exclusion => "activerecord_error_exclusion", - :invalid => "activerecord_error_invalid", - :confirmation => "activerecord_error_confirmation", - :accepted => "activerecord_error_accepted", - :empty => "activerecord_error_empty", - :blank => "activerecord_error_blank", - :too_long => "activerecord_error_too_long", - :too_short => "activerecord_error_too_short", - :wrong_length => "activerecord_error_wrong_length", - :taken => "activerecord_error_taken", - :not_a_number => "activerecord_error_not_a_number" -} - ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "#{html_tag}" } diff --git a/rails-2.2/lib/redmine/wiki_formatting/textile/helper.rb b/rails-2.2/lib/redmine/wiki_formatting/textile/helper.rb index af021f990..52b6278b4 100644 --- a/rails-2.2/lib/redmine/wiki_formatting/textile/helper.rb +++ b/rails-2.2/lib/redmine/wiki_formatting/textile/helper.rb @@ -20,9 +20,11 @@ module Redmine module Textile module Helper def wikitoolbar_for(field_id) + # TODO: do not hardcode this path + help_path = '/wiki_syntax/help.html' help_link = l(:setting_text_formatting) + ': ' + - link_to(l(:label_help), compute_public_path('wiki_syntax', 'help', 'html'), - :onclick => "window.open(\"#{ compute_public_path('wiki_syntax', 'help', 'html') }\", \"\", \"resizable=yes, location=no, width=300, height=640, menubar=no, status=no, scrollbars=yes\"); return false;") + link_to(l(:label_help), help_path, + :onclick => "window.open(\"#{ help_path }\", \"\", \"resizable=yes, location=no, width=300, height=640, menubar=no, status=no, scrollbars=yes\"); return false;") javascript_include_tag('jstoolbar/jstoolbar') + javascript_include_tag('jstoolbar/textile') + diff --git a/rails-2.2/test/unit/mailer_test.rb b/rails-2.2/test/unit/mailer_test.rb index 1fd43af5d..ef47c65df 100644 --- a/rails-2.2/test/unit/mailer_test.rb +++ b/rails-2.2/test/unit/mailer_test.rb @@ -40,11 +40,11 @@ class MailerTest < Test::Unit::TestCase end def test_generated_links_with_prefix - relative_url_root = ActionController::AbstractRequest.relative_url_root + relative_url_root = ActionController::Base.relative_url_root ActionMailer::Base.deliveries.clear Setting.host_name = 'mydomain.foo/rdm' Setting.protocol = 'http' - ActionController::AbstractRequest.relative_url_root = '/rdm' + ActionController::Base.relative_url_root = '/rdm' journal = Journal.find(2) assert Mailer.deliver_issue_edit(journal) @@ -60,15 +60,15 @@ class MailerTest < Test::Unit::TestCase assert mail.body.include?('r2') ensure # restore it - ActionController::AbstractRequest.relative_url_root = relative_url_root + ActionController::Base.relative_url_root = relative_url_root end def test_generated_links_with_prefix_and_no_relative_url_root - relative_url_root = ActionController::AbstractRequest.relative_url_root + relative_url_root = ActionController::Base.relative_url_root ActionMailer::Base.deliveries.clear Setting.host_name = 'mydomain.foo/rdm' Setting.protocol = 'http' - ActionController::AbstractRequest.relative_url_root = nil + ActionController::Base.relative_url_root = nil journal = Journal.find(2) assert Mailer.deliver_issue_edit(journal) @@ -84,7 +84,7 @@ class MailerTest < Test::Unit::TestCase assert mail.body.include?('r2') ensure # restore it - ActionController::AbstractRequest.relative_url_root = relative_url_root + ActionController::Base.relative_url_root = relative_url_root end def test_plain_text_mail diff --git a/rails-2.2/test/unit/project_test.rb b/rails-2.2/test/unit/project_test.rb index 6e32c02e7..8d71f0846 100644 --- a/rails-2.2/test/unit/project_test.rb +++ b/rails-2.2/test/unit/project_test.rb @@ -122,7 +122,8 @@ class ProjectTest < Test::Unit::TestCase child = parent.children.find(3) assert_equal [1, 2], parent.tracker_ids - assert_equal [2, 3], child.tracker_ids + # TODO: child.tracker_ids breaks with Rails 2.2.2 + assert_equal [2, 3], child.trackers.collect(&:id) assert_kind_of Tracker, parent.rolled_up_trackers.first assert_equal Tracker.find(1), parent.rolled_up_trackers.first diff --git a/rails-2.2/vendor/plugins/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb b/rails-2.2/vendor/plugins/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb index f9995197a..3f8c6bb43 100644 --- a/rails-2.2/vendor/plugins/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb +++ b/rails-2.2/vendor/plugins/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb @@ -165,7 +165,7 @@ module ActionWebService # :nodoc: private def base_uri host = request.host_with_port - relative_url_root = request.relative_url_root + relative_url_root = ActionController::Base.relative_url_root scheme = request.ssl? ? 'https' : 'http' '%s://%s%s/%s/' % [scheme, host, relative_url_root, self.class.controller_path] end diff --git a/rails-2.2/vendor/plugins/classic_pagination/lib/pagination.rb b/rails-2.2/vendor/plugins/classic_pagination/lib/pagination.rb index b6e9cf4bc..6a3e1a97b 100644 --- a/rails-2.2/vendor/plugins/classic_pagination/lib/pagination.rb +++ b/rails-2.2/vendor/plugins/classic_pagination/lib/pagination.rb @@ -97,8 +97,8 @@ module ActionController "Unknown options: #{unknown_option_keys.join(', ')}" unless unknown_option_keys.empty? - options[:singular_name] ||= Inflector.singularize(collection_id.to_s) - options[:class_name] ||= Inflector.camelize(options[:singular_name]) + options[:singular_name] ||= ActiveSupport::Inflector.singularize(collection_id.to_s) + options[:class_name] ||= ActiveSupport::Inflector.camelize(options[:singular_name]) end # Returns a paginator and a collection of Active Record model instances