1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-03-12 04:03:08 +00:00

Rails 2.2 deprecations

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/work@2113 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2008-12-07 16:16:01 +00:00
parent 859c89ccb6
commit 7ae224f5c2
20 changed files with 37 additions and 54 deletions

View File

@ -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

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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
# </th>
#
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)

View File

@ -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

View File

@ -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?

View File

@ -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)) %>
<span class="tip"><%= render_issue_tooltip i %></span>
</div>
<% else %>

View File

@ -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

View File

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

View File

@ -38,7 +38,7 @@
<div class="box tabular">
<% fields_for :pref, @user.pref, :builder => TabularFormBuilder, :lang => current_language do |pref_fields| %>
<p><%= pref_fields.check_box :hide_mail %></p>
<p><%= pref_fields.select :time_zone, TimeZone.all.collect {|z| [ z.to_s, z.name ]}, :include_blank => true %></p>
<p><%= pref_fields.select :time_zone, ActiveSupport::TimeZone.all.collect {|z| [ z.to_s, z.name ]}, :include_blank => true %></p>
<p><%= pref_fields.select :comments_sorting, [[l(:label_chronological_order), 'asc'], [l(:label_reverse_chronological_order), 'desc']] %></p>
<% end %>
</div>

View File

@ -19,6 +19,6 @@
<td class="revision"><%= link_to(format_revision(entry.lastrev.name), :action => 'revision', :id => @project, :rev => entry.lastrev.identifier) if entry.lastrev && entry.lastrev.identifier %></td>
<td class="age"><%= distance_of_time_in_words(entry.lastrev.time, Time.now) if entry.lastrev && entry.lastrev.time %></td>
<td class="author"><%= changeset.nil? ? h(entry.lastrev.author.to_s.split('<').first) : changeset.author if entry.lastrev %></td>
<td class="comments"><%=h truncate(changeset.comments, 50) unless changeset.nil? %></td>
<td class="comments"><%=h truncate(changeset.comments, :length => 50) unless changeset.nil? %></td>
</tr>
<% end %>

View File

@ -26,7 +26,7 @@
<h3><%= l(:label_result_plural) %> (<%= @results_by_type.values.sum %>)</h3>
<dl id="search-results">
<% @results.each do |e| %>
<dt class="<%= e.event_type %>"><%= 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 %></dt>
<dt class="<%= e.event_type %>"><%= 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 %></dt>
<dd><span class="description"><%= highlight_tokens(e.event_description, @tokens) %></span>
<span class="author"><%= format_time(e.event_datetime) %></span></dd>
<% end %>

View File

@ -20,7 +20,7 @@
<td class="project"><%=h entry.project %></td>
<td class="subject">
<% 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 -%>
</td>
<td class="comments"><%=h entry.comments %></td>

View File

@ -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}" }

View File

@ -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') +

View File

@ -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?('<a href="http://mydomain.foo/rdm/repositories/revision/ecookbook/2" class="changeset" title="This commit fixes #1, #2 and references #1 &amp; #3">r2</a>')
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?('<a href="http://mydomain.foo/rdm/repositories/revision/ecookbook/2" class="changeset" title="This commit fixes #1, #2 and references #1 &amp; #3">r2</a>')
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

View File

@ -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

View File

@ -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

View File

@ -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